]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/stress/inline-llint-with-switch.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / inline-llint-with-switch.js
CommitLineData
81345200
A
1function 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
19function bar(p) {
20 if (p)
21 return foo(effectful42() - 42);
22 else
23 return 42;
24}
25
26noInline(bar);
27
28function 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.
35for (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.
39for (var i = 0; i < 10000; ++i)
40 test(false);
41
42// And finally test the switch statement.
43test(true);