]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/inline-llint-with-switch.js
84b7b6bdfbac989c0ed005dd95b57bb649638ff9
[apple/javascriptcore.git] / tests / stress / inline-llint-with-switch.js
1 function foo(i) {
2 switch (i) {
3 case 0:
4 case 1:
5 case 2:
6 case 3:
7 case 4:
8 case 5:
9 case 6:
10 case 7:
11 case 8:
12 case 9:
13 return 42;
14 default:
15 return "error";
16 }
17 }
18
19 function bar(p) {
20 if (p)
21 return foo(effectful42() - 42);
22 else
23 return 42;
24 }
25
26 noInline(bar);
27
28 function test(p) {
29 var result = bar(p);
30 if (result != 42)
31 throw "Error: bad result: " + result;
32 }
33
34 // Make sure that the call to foo() looks like it has happened.
35 for (var i = 0; i < 2; ++i)
36 test(true);
37
38 // Warm up bar and cause inlining, but make sure that foo() doesn't get DFG'd.
39 for (var i = 0; i < 10000; ++i)
40 test(false);
41
42 // And finally test the switch statement.
43 test(true);