]> git.saurik.com Git - apple/javascriptcore.git/blame - 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
CommitLineData
ed1e77d3
A
1function blah(args) {
2 var array = [];
3 for (var i = 0; i < args.length; ++i)
4 array.push(args[i]);
5 return array;
6}
7
8function 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
16function bar(array) {
17 return foo.apply(this, array);
18}
19
20noInline(blah);
21noInline(bar);
22
23function 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
32function test(array) {
33 var actual = bar(array);
34 checkEqual(actual, array);
35}
36
37for (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}