]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/get-argument-by-val-safe-in-inlined-varargs-call-out-of-bounds.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / get-argument-by-val-safe-in-inlined-varargs-call-out-of-bounds.js
1 var gi;
2
3 function foo() {
4 if (!effectful42())
5 arguments = "hello";
6 return arguments[gi];
7 }
8
9 function bar(array, i) {
10 gi = i;
11 return foo.apply(this, array);
12 }
13
14 noInline(bar);
15
16 var bigArray = [];
17 for (var i = 0; i < 50; ++i)
18 bigArray.push(42);
19
20 for (var i = 0; i < 10000; ++i) {
21 var mi = i % 50;
22 var result = bar(bigArray, mi);
23 if (result !== 42)
24 throw "Bad result in first loop: " + result + "; expected: " + 42;
25 }
26
27
28 for (var i = 0; i < 10000; ++i) {
29 var mi = i % 100;
30 var result = bar([42], mi);
31 var expected = mi ? void 0 : 42;
32 if (result !== expected)
33 throw "Bad result in second loop: " + result + "; expected: " + expected;
34 }
35