]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/stress/load-varargs-then-inlined-call-exit-in-foo.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / load-varargs-then-inlined-call-exit-in-foo.js
CommitLineData
ed1e77d3
A
1function 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
8function bar(array) {
9 return foo.apply(this, array);
10}
11
12noInline(bar);
13
14function 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
27function 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.
35var array = [];
36array.push(42);
37array.push(42.5);
38
39for (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
46test([1.5, 2.5, 3.5]);