]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/test-spec-misc.js
7d7150542dff108397bf1f927448f98d7aea4ea4
[apple/javascriptcore.git] / tests / stress / test-spec-misc.js
1 var a = [ "String", false, 42 ];
2 var count = 0;
3
4 function getX(fromDFG) {
5 if (fromDFG)
6 return 42;
7 return false;
8 }
9
10 noInline(getX);
11
12 function foo(index) {
13 var result = false;
14 var x = getX(DFGTrue());
15
16 x * 2;
17
18 var y = a[index % a.length];
19 result = y === x;
20 count += 1;
21 return result;
22 }
23
24 noInline(foo);
25
26 var loopCount = 10000;
27
28 function bar() {
29 var result;
30
31 for (var i = 0; i < loopCount - 1; i++)
32 result = foo(i)
33
34 result = foo(0);
35
36 return result;
37 }
38
39 var result = bar();
40 if (result != false)
41 throw "Error: bad result expected false: " + result;
42 if (count != loopCount)
43 throw "Error: bad count, expected: " + loopCount + ", got: " + count;