]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/get-my-argument-by-val-creates-arguments.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / get-my-argument-by-val-creates-arguments.js
1 function blah(args) {
2 var array = [];
3 for (var i = 0; i < args.length; ++i)
4 array.push(args[i]);
5 return array;
6 }
7
8 function foo() {
9 // Force creation of arguments by doing out-of-bounds access.
10 var tmp = arguments[42];
11
12 // Use the created arguments object.
13 return blah(arguments);
14 }
15
16 function bar(array) {
17 return foo.apply(this, array);
18 }
19
20 noInline(blah);
21 noInline(bar);
22
23 function checkEqual(a, b) {
24 if (a.length != b.length)
25 throw "Error: length mismatch: " + a + " versus " + b;
26 for (var i = a.length; i--;) {
27 if (a[i] != b[i])
28 throw "Error: mismatch at i = " + i + ": " + a + " versus " + b;
29 }
30 }
31
32 function test(array) {
33 var actual = bar(array);
34 checkEqual(actual, array);
35 }
36
37 for (var i = 0; i < 10000; ++i) {
38 var array = [];
39 for (var j = 0; j < i % 6; ++j)
40 array.push(j);
41 test(array);
42 }