]>
Commit | Line | Data |
---|---|---|
81345200 A |
1 | function foo(a, i) { |
2 | return [a[i + 0], a[i + 1], a[i + 2], a[i + 3], a[i + 4], a[i + 5], a[i + 6], a[i + 7]]; | |
3 | } | |
4 | ||
5 | noInline(foo); | |
6 | ||
7 | function arraycmp(a, b) { | |
8 | if (a.length != b.length) | |
9 | return false; | |
10 | for (var i = 0; i < a.length; ++i) { | |
11 | if (a[i] != b[i]) | |
12 | return false; | |
13 | } | |
14 | return true; | |
15 | } | |
16 | ||
17 | for (var i = 0; i < 100000; ++i) { | |
18 | var array = []; | |
19 | var offset = i & 3; | |
20 | for (var j = 0; j < offset; ++j) | |
21 | array.push(42); | |
22 | var result = foo(array.concat([1, 2, 3, 4, 5, 6, 7, 8]), offset); | |
23 | if (!arraycmp(result, [1, 2, 3, 4, 5, 6, 7, 8])) | |
24 | throw "Error: bad result (1..8): " + result; | |
25 | } | |
26 | ||
27 | var result = foo([1, 2, 3, 4, 5, 6, 7], 0); | |
28 | if (!arraycmp(result, [1, 2, 3, 4, 5, 6, 7, void 0])) | |
29 | throw "Error: bad result (1..7): " + result; | |
30 | var result = foo([1, 2, 3, 4, 5, 6], 0); | |
31 | if (!arraycmp(result, [1, 2, 3, 4, 5, 6, void 0, void 0])) | |
32 | throw "Error: bad result (1..6): " + result; | |
33 | var result = foo([1, 2, 3, 4, 5], 0); | |
34 | if (!arraycmp(result, [1, 2, 3, 4, 5, void 0, void 0, void 0])) | |
35 | throw "Error: bad result (1..5): " + result; | |
36 | var result = foo([1, 2, 3, 4], 0); | |
37 | if (!arraycmp(result, [1, 2, 3, 4, void 0, void 0, void 0, void 0])) | |
38 | throw "Error: bad result (1..4): " + result; | |
39 | var result = foo([1, 2, 3], 0); | |
40 | if (!arraycmp(result, [1, 2, 3, void 0, void 0, void 0, void 0, void 0])) | |
41 | throw "Error: bad result (1..3): " + result; | |
42 | var result = foo([1, 2], 0); | |
43 | if (!arraycmp(result, [1, 2, void 0, void 0, void 0, void 0, void 0, void 0])) | |
44 | throw "Error: bad result (1..2): " + result; | |
45 | var result = foo([1], 0); | |
46 | if (!arraycmp(result, [1, void 0, void 0, void 0, void 0, void 0, void 0, void 0])) | |
47 | throw "Error: bad result (1..1): " + result; | |
48 | var result = foo([], 0); | |
49 | if (!arraycmp(result, [void 0, void 0, void 0, void 0, void 0, void 0, void 0, void 0])) | |
50 | throw "Error: bad result (1..1): " + result; |