|
1 |
|
2 // test local/arg liveness analysis in presence of many locals |
|
3 |
|
4 function foo(a, b, c) { |
|
5 var x = 0, y = 0, z = 0; |
|
6 if (a < b) { |
|
7 x = a + 0; |
|
8 y = b + 0; |
|
9 z = c + 0; |
|
10 } else { |
|
11 x = a; |
|
12 y = b; |
|
13 z = c; |
|
14 } |
|
15 return x + y + z; |
|
16 } |
|
17 assertEq(foo(1, 2, 3), 6); |
|
18 |
|
19 // restore liveness correctly before switch statements |
|
20 |
|
21 function foo(a, b, c) { |
|
22 var x = 0, y = 0, z = 0; |
|
23 if (a < b) { |
|
24 x = a + 0; |
|
25 y = b + 0; |
|
26 z = c + 0; |
|
27 } else { |
|
28 switch (c) { |
|
29 case 1: |
|
30 case 2: |
|
31 case 3: |
|
32 case 4: |
|
33 case 5: return 0; |
|
34 } |
|
35 x = 0; |
|
36 y = 0; |
|
37 z = 0; |
|
38 } |
|
39 return x + y + z; |
|
40 } |
|
41 assertEq(foo(1, 2, 3), 6); |