OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 function Module() { | 5 function Module() { |
6 "use asm"; | 6 "use asm"; |
7 | 7 |
8 function if0() { | 8 function if0() { |
9 if (0) return 11; | 9 if (0) return 11; |
10 return 12; | 10 return 12; |
11 } | 11 } |
12 | 12 |
13 function if1() { | 13 function if1() { |
14 if (1) return 13; | 14 if (1) return 13; |
15 return 14; | 15 return 14; |
16 } | 16 } |
17 | 17 |
18 function if2() { | 18 function if2() { |
19 if (0) return 15; | 19 if (0) return 15; |
20 else return 16; | 20 else return 16; |
| 21 return 0; // needed for validation |
21 } | 22 } |
22 | 23 |
23 function if3() { | 24 function if3() { |
24 if (1) return 17; | 25 if (1) return 17; |
25 else return 18; | 26 else return 18; |
| 27 return 0; // needed for validation |
26 } | 28 } |
27 | 29 |
28 function if4() { | 30 function if4() { |
29 return 1 ? 19 : 20; | 31 return (1 ? 19 : 20) | 0; |
30 } | 32 } |
31 | 33 |
32 function if5() { | 34 function if5() { |
33 return 0 ? 21 : 22; | 35 return (0 ? 21 : 22) | 0; |
34 } | 36 } |
35 | 37 |
36 function if6() { | 38 function if6() { |
37 var x = 0 ? 23 : 24; | 39 var x = 0; |
38 return x; | 40 x = 0 ? 23 : 24; |
| 41 return x | 0; |
39 } | 42 } |
40 | 43 |
41 function if7() { | 44 function if7() { |
42 if (0) { var x = 0 ? 25 : 26; } | 45 var x = 0; |
43 else { var x = 0 ? 27 : 28; } | 46 if (0) { |
44 return x; | 47 x = 0 ? 25 : 26; |
| 48 } else { |
| 49 x = 0 ? 27 : 28; |
| 50 } |
| 51 return x | 0; |
45 } | 52 } |
46 | 53 |
47 function if8() { | 54 function if8() { |
| 55 var x = 0; |
48 if (0) { | 56 if (0) { |
49 if (0) { var x = 0 ? 29 : 30; } | 57 if (0) { |
50 else { var x = 0 ? 31 : 32; } | 58 x = 0 ? 29 : 30; |
| 59 } else { |
| 60 x = 0 ? 31 : 32; |
| 61 } |
51 } else { | 62 } else { |
52 if (0) { var x = 0 ? 33 : 34; } | 63 if (0) { |
53 else { var x = 0 ? 35 : 36; } | 64 x = 0 ? 33 : 34; |
| 65 } else { |
| 66 x = 0 ? 35 : 36; |
| 67 } |
54 } | 68 } |
55 return x; | 69 return x | 0; |
56 } | 70 } |
57 | 71 |
58 return {if0: if0, if1: if1, if2: if2, if3: if3, if4: if4, if5: if5, if6: if6,
if7: if7, if8: if8 }; | 72 return {if0: if0, if1: if1, if2: if2, if3: if3, if4: if4, if5: if5, if6: if6,
if7: if7, if8: if8 }; |
59 } | 73 } |
60 | 74 |
61 var m = Module(); | 75 var m = Module(); |
62 assertEquals(12, m.if0()); | 76 assertEquals(12, m.if0()); |
63 assertEquals(13, m.if1()); | 77 assertEquals(13, m.if1()); |
64 assertEquals(16, m.if2()); | 78 assertEquals(16, m.if2()); |
65 assertEquals(17, m.if3()); | 79 assertEquals(17, m.if3()); |
66 assertEquals(19, m.if4()); | 80 assertEquals(19, m.if4()); |
67 assertEquals(22, m.if5()); | 81 assertEquals(22, m.if5()); |
68 assertEquals(24, m.if6()); | 82 assertEquals(24, m.if6()); |
69 assertEquals(28, m.if7()); | 83 assertEquals(28, m.if7()); |
70 assertEquals(36, m.if8()); | 84 assertEquals(36, m.if8()); |
71 | 85 |
72 | 86 |
73 function Spec(a,b,c) { | 87 function Spec0(stdlib, foreign, heap) { |
74 "use asm"; | 88 "use asm"; |
75 | 89 |
76 var xx = a | 0; | 90 var xx = foreign.a | 0; |
77 var yy = b | 0; | 91 var yy = foreign.b | 0; |
78 var zz = c | 0; | 92 var zz = foreign.c | 0; |
79 | 93 |
80 function f() { | 94 function f() { |
| 95 var x = 0; |
81 if (xx) { | 96 if (xx) { |
82 if (yy) { var x = zz ? 29 : 30; } | 97 if (yy) { |
83 else { var x = zz ? 31 : 32; } | 98 x = zz ? 29 : 30; |
| 99 } else { |
| 100 x = zz ? 31 : 32; |
| 101 } |
84 } else { | 102 } else { |
85 if (yy) { var x = zz ? 33 : 34; } | 103 if (yy) { |
86 else { var x = zz ? 35 : 36; } | 104 x = zz ? 33 : 34; |
| 105 } else { |
| 106 x = zz ? 35 : 36; |
| 107 } |
87 } | 108 } |
88 return x; | 109 return x | 0; |
89 } | 110 } |
90 return {f: f}; | 111 return {f: f}; |
91 } | 112 } |
| 113 var Spec = (a, b, c) => Spec0(this, {a: a, b: b, c: c}); |
92 | 114 |
93 assertEquals(36, Spec(0,0,0).f()); | 115 assertEquals(36, Spec(0,0,0).f()); |
94 assertEquals(35, Spec(0,0,1).f()); | 116 assertEquals(35, Spec(0,0,1).f()); |
95 assertEquals(34, Spec(0,1,0).f()); | 117 assertEquals(34, Spec(0,1,0).f()); |
96 assertEquals(33, Spec(0,1,1).f()); | 118 assertEquals(33, Spec(0,1,1).f()); |
97 assertEquals(32, Spec(1,0,0).f()); | 119 assertEquals(32, Spec(1,0,0).f()); |
98 assertEquals(31, Spec(1,0,1).f()); | 120 assertEquals(31, Spec(1,0,1).f()); |
99 assertEquals(30, Spec(1,1,0).f()); | 121 assertEquals(30, Spec(1,1,0).f()); |
100 assertEquals(29, Spec(1,1,1).f()); | 122 assertEquals(29, Spec(1,1,1).f()); |
OLD | NEW |