]>
Commit | Line | Data |
---|---|---|
ed1e77d3 A |
1 | function foo(a, b) { |
2 | var array = []; | |
3 | for (var i = 0; i < arguments.length; ++i) | |
4 | array.push(arguments[i] + 1); | |
5 | return {a:a, b:b, c:array}; | |
6 | } | |
7 | ||
8 | function bar(array) { | |
9 | return foo.apply(this, array); | |
10 | } | |
11 | ||
12 | noInline(bar); | |
13 | ||
14 | function checkEqual(a, b) { | |
15 | if (a.a != b.a) | |
16 | throw "Error: bad value of a: " + a.a + " versus " + b.a; | |
17 | if (a.b != b.b) | |
18 | throw "Error: bad value of b: " + a.b + " versus " + b.b; | |
19 | if (a.c.length != b.c.length) | |
20 | throw "Error: bad value of c, length mismatch: " + a.c + " versus " + b.c; | |
21 | for (var i = a.c.length; i--;) { | |
22 | if (a.c[i] != b.c[i]) | |
23 | throw "Error: bad value of c, mismatch at i = " + i + ": " + a.c + " versus " + b.c; | |
24 | } | |
25 | } | |
26 | ||
27 | function test(array) { | |
28 | var expected = {a:array[0], b:array[1], c:array.map(function(value) { return value + 1 })}; | |
29 | var actual = bar(array); | |
30 | checkEqual(actual, expected); | |
31 | } | |
32 | ||
33 | // This is pretty dumb. We need to first make sure that the VM is prepared for double arrays being | |
34 | // created. | |
35 | var array = []; | |
36 | array.push(42); | |
37 | array.push(42.5); | |
38 | ||
39 | for (var i = 0; i < 10000; ++i) { | |
40 | var array = []; | |
41 | for (var j = 0; j < i % 6; ++j) | |
42 | array.push(j); | |
43 | test(array); | |
44 | } | |
45 | ||
46 | test([1.5, 2.5, 3.5]); |