Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 function intLength (a, l) {
2 var res = 0;
3 for (var i = 0; i < l; i++)
4 res += a.length;
5 return res / l;
6 }
8 function valueLength (a, l) {
9 var res = 0;
10 for (var i = 0; i < l; i++)
11 res += a.length;
12 return res / l;
13 }
15 var denseArray = [0,1,2,3,4,5,6,7,8,9];
16 var typedArray = new Uint8Array(10);
17 var hugeArray = new Array(4294967295);
18 var fakeArray1 = { length: 10 };
19 var fakeArray2 = { length: 10.5 };
21 // Check the interpreter result and play with TI type objects.
22 assertEq(intLength(denseArray, 10), 10);
23 assertEq(intLength(typedArray, 10), 10);
24 // assertEq(intLength(fakeArray1, 10), 10);
26 assertEq(valueLength(denseArray, 10), 10);
27 assertEq(valueLength(typedArray, 10), 10);
28 assertEq(valueLength(hugeArray , 10), 4294967295);
29 assertEq(valueLength(fakeArray2, 10), 10.5);
31 // Heat up to compile (either JM / Ion)
32 assertEq(intLength(denseArray, 100), 10);
33 assertEq(valueLength(denseArray, 100), 10);
35 // No bailout should occur during any of the following checks:
37 // Check get-property length IC with dense array.
38 assertEq(intLength(denseArray, 1), 10);
39 assertEq(valueLength(denseArray, 1), 10);
41 // Check get-property length IC with typed array.
42 assertEq(intLength(typedArray, 1), 10);
43 assertEq(valueLength(typedArray, 1), 10);
45 // Check length which do not fit on non-double value.
46 assertEq(valueLength(hugeArray, 1), 4294967295);
48 // Check object length property.
49 assertEq(intLength(fakeArray1, 1), 10);
50 assertEq(valueLength(fakeArray2, 1), 10.5);
52 // Cause invalidation of intLength by returning a double.
53 assertEq(intLength(hugeArray, 1), 4294967295);
54 assertEq(intLength(fakeArray2, 1), 10.5);