Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: test/cctest/wasm/test-run-wasm.cc

Issue 1970543003: [formatting] Remove all double blank lines in WASM code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/wasm/wasm-result.cc ('k') | test/cctest/wasm/test-run-wasm-js.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 #include <stdint.h> 5 #include <stdint.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "src/base/platform/elapsed-timer.h" 9 #include "src/base/platform/elapsed-timer.h"
10 10
(...skipping 16 matching lines...) Expand all
27 #define RET_I8(x) kExprI8Const, x, kExprReturn, 1 27 #define RET_I8(x) kExprI8Const, x, kExprReturn, 1
28 28
29 TEST(Run_WasmInt8Const) { 29 TEST(Run_WasmInt8Const) {
30 WasmRunner<int32_t> r; 30 WasmRunner<int32_t> r;
31 const byte kExpectedValue = 121; 31 const byte kExpectedValue = 121;
32 // return(kExpectedValue) 32 // return(kExpectedValue)
33 BUILD(r, WASM_I8(kExpectedValue)); 33 BUILD(r, WASM_I8(kExpectedValue));
34 CHECK_EQ(kExpectedValue, r.Call()); 34 CHECK_EQ(kExpectedValue, r.Call());
35 } 35 }
36 36
37
38 TEST(Run_WasmInt8Const_fallthru1) { 37 TEST(Run_WasmInt8Const_fallthru1) {
39 WasmRunner<int32_t> r; 38 WasmRunner<int32_t> r;
40 const byte kExpectedValue = 122; 39 const byte kExpectedValue = 122;
41 // kExpectedValue 40 // kExpectedValue
42 BUILD(r, WASM_I8(kExpectedValue)); 41 BUILD(r, WASM_I8(kExpectedValue));
43 CHECK_EQ(kExpectedValue, r.Call()); 42 CHECK_EQ(kExpectedValue, r.Call());
44 } 43 }
45 44
46
47 TEST(Run_WasmInt8Const_fallthru2) { 45 TEST(Run_WasmInt8Const_fallthru2) {
48 WasmRunner<int32_t> r; 46 WasmRunner<int32_t> r;
49 const byte kExpectedValue = 123; 47 const byte kExpectedValue = 123;
50 // -99 kExpectedValue 48 // -99 kExpectedValue
51 BUILD(r, WASM_I8(-99), WASM_I8(kExpectedValue)); 49 BUILD(r, WASM_I8(-99), WASM_I8(kExpectedValue));
52 CHECK_EQ(kExpectedValue, r.Call()); 50 CHECK_EQ(kExpectedValue, r.Call());
53 } 51 }
54 52
55
56 TEST(Run_WasmInt8Const_all) { 53 TEST(Run_WasmInt8Const_all) {
57 for (int value = -128; value <= 127; value++) { 54 for (int value = -128; value <= 127; value++) {
58 WasmRunner<int32_t> r; 55 WasmRunner<int32_t> r;
59 // return(value) 56 // return(value)
60 BUILD(r, WASM_I8(value)); 57 BUILD(r, WASM_I8(value));
61 int32_t result = r.Call(); 58 int32_t result = r.Call();
62 CHECK_EQ(value, result); 59 CHECK_EQ(value, result);
63 } 60 }
64 } 61 }
65 62
66
67 TEST(Run_WasmInt32Const) { 63 TEST(Run_WasmInt32Const) {
68 WasmRunner<int32_t> r; 64 WasmRunner<int32_t> r;
69 const int32_t kExpectedValue = 0x11223344; 65 const int32_t kExpectedValue = 0x11223344;
70 // return(kExpectedValue) 66 // return(kExpectedValue)
71 BUILD(r, WASM_I32V_5(kExpectedValue)); 67 BUILD(r, WASM_I32V_5(kExpectedValue));
72 CHECK_EQ(kExpectedValue, r.Call()); 68 CHECK_EQ(kExpectedValue, r.Call());
73 } 69 }
74 70
75
76 TEST(Run_WasmInt32Const_many) { 71 TEST(Run_WasmInt32Const_many) {
77 FOR_INT32_INPUTS(i) { 72 FOR_INT32_INPUTS(i) {
78 WasmRunner<int32_t> r; 73 WasmRunner<int32_t> r;
79 const int32_t kExpectedValue = *i; 74 const int32_t kExpectedValue = *i;
80 // return(kExpectedValue) 75 // return(kExpectedValue)
81 BUILD(r, WASM_I32V(kExpectedValue)); 76 BUILD(r, WASM_I32V(kExpectedValue));
82 CHECK_EQ(kExpectedValue, r.Call()); 77 CHECK_EQ(kExpectedValue, r.Call());
83 } 78 }
84 } 79 }
85 80
86
87 TEST(Run_WasmMemorySize) { 81 TEST(Run_WasmMemorySize) {
88 TestingModule module; 82 TestingModule module;
89 WasmRunner<int32_t> r(&module); 83 WasmRunner<int32_t> r(&module);
90 module.AddMemory(1024); 84 module.AddMemory(1024);
91 BUILD(r, kExprMemorySize); 85 BUILD(r, kExprMemorySize);
92 CHECK_EQ(1024, r.Call()); 86 CHECK_EQ(1024, r.Call());
93 } 87 }
94 88
95
96 TEST(Run_WasmInt32Param0) { 89 TEST(Run_WasmInt32Param0) {
97 WasmRunner<int32_t> r(MachineType::Int32()); 90 WasmRunner<int32_t> r(MachineType::Int32());
98 // return(local[0]) 91 // return(local[0])
99 BUILD(r, WASM_GET_LOCAL(0)); 92 BUILD(r, WASM_GET_LOCAL(0));
100 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } 93 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
101 } 94 }
102 95
103
104 TEST(Run_WasmInt32Param0_fallthru) { 96 TEST(Run_WasmInt32Param0_fallthru) {
105 WasmRunner<int32_t> r(MachineType::Int32()); 97 WasmRunner<int32_t> r(MachineType::Int32());
106 // local[0] 98 // local[0]
107 BUILD(r, WASM_GET_LOCAL(0)); 99 BUILD(r, WASM_GET_LOCAL(0));
108 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } 100 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
109 } 101 }
110 102
111
112 TEST(Run_WasmInt32Param1) { 103 TEST(Run_WasmInt32Param1) {
113 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); 104 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32());
114 // local[1] 105 // local[1]
115 BUILD(r, WASM_GET_LOCAL(1)); 106 BUILD(r, WASM_GET_LOCAL(1));
116 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(-111, *i)); } 107 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(-111, *i)); }
117 } 108 }
118 109
119
120 TEST(Run_WasmInt32Add) { 110 TEST(Run_WasmInt32Add) {
121 WasmRunner<int32_t> r; 111 WasmRunner<int32_t> r;
122 // 11 + 44 112 // 11 + 44
123 BUILD(r, WASM_I32_ADD(WASM_I8(11), WASM_I8(44))); 113 BUILD(r, WASM_I32_ADD(WASM_I8(11), WASM_I8(44)));
124 CHECK_EQ(55, r.Call()); 114 CHECK_EQ(55, r.Call());
125 } 115 }
126 116
127
128 TEST(Run_WasmInt32Add_P) { 117 TEST(Run_WasmInt32Add_P) {
129 WasmRunner<int32_t> r(MachineType::Int32()); 118 WasmRunner<int32_t> r(MachineType::Int32());
130 // p0 + 13 119 // p0 + 13
131 BUILD(r, WASM_I32_ADD(WASM_I8(13), WASM_GET_LOCAL(0))); 120 BUILD(r, WASM_I32_ADD(WASM_I8(13), WASM_GET_LOCAL(0)));
132 FOR_INT32_INPUTS(i) { CHECK_EQ(*i + 13, r.Call(*i)); } 121 FOR_INT32_INPUTS(i) { CHECK_EQ(*i + 13, r.Call(*i)); }
133 } 122 }
134 123
135
136 TEST(Run_WasmInt32Add_P_fallthru) { 124 TEST(Run_WasmInt32Add_P_fallthru) {
137 WasmRunner<int32_t> r(MachineType::Int32()); 125 WasmRunner<int32_t> r(MachineType::Int32());
138 // p0 + 13 126 // p0 + 13
139 BUILD(r, WASM_I32_ADD(WASM_I8(13), WASM_GET_LOCAL(0))); 127 BUILD(r, WASM_I32_ADD(WASM_I8(13), WASM_GET_LOCAL(0)));
140 FOR_INT32_INPUTS(i) { CHECK_EQ(*i + 13, r.Call(*i)); } 128 FOR_INT32_INPUTS(i) { CHECK_EQ(*i + 13, r.Call(*i)); }
141 } 129 }
142 130
143
144 TEST(Run_WasmInt32Add_P2) { 131 TEST(Run_WasmInt32Add_P2) {
145 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); 132 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32());
146 // p0 + p1 133 // p0 + p1
147 BUILD(r, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 134 BUILD(r, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
148 FOR_INT32_INPUTS(i) { 135 FOR_INT32_INPUTS(i) {
149 FOR_INT32_INPUTS(j) { 136 FOR_INT32_INPUTS(j) {
150 int32_t expected = static_cast<int32_t>(static_cast<uint32_t>(*i) + 137 int32_t expected = static_cast<int32_t>(static_cast<uint32_t>(*i) +
151 static_cast<uint32_t>(*j)); 138 static_cast<uint32_t>(*j));
152 CHECK_EQ(expected, r.Call(*i, *j)); 139 CHECK_EQ(expected, r.Call(*i, *j));
153 } 140 }
154 } 141 }
155 } 142 }
156 143
157
158 TEST(Run_WasmFloat32Add) { 144 TEST(Run_WasmFloat32Add) {
159 WasmRunner<int32_t> r; 145 WasmRunner<int32_t> r;
160 // int(11.5f + 44.5f) 146 // int(11.5f + 44.5f)
161 BUILD(r, 147 BUILD(r,
162 WASM_I32_SCONVERT_F32(WASM_F32_ADD(WASM_F32(11.5f), WASM_F32(44.5f)))); 148 WASM_I32_SCONVERT_F32(WASM_F32_ADD(WASM_F32(11.5f), WASM_F32(44.5f))));
163 CHECK_EQ(56, r.Call()); 149 CHECK_EQ(56, r.Call());
164 } 150 }
165 151
166
167 TEST(Run_WasmFloat64Add) { 152 TEST(Run_WasmFloat64Add) {
168 WasmRunner<int32_t> r; 153 WasmRunner<int32_t> r;
169 // return int(13.5d + 43.5d) 154 // return int(13.5d + 43.5d)
170 BUILD(r, WASM_I32_SCONVERT_F64(WASM_F64_ADD(WASM_F64(13.5), WASM_F64(43.5)))); 155 BUILD(r, WASM_I32_SCONVERT_F64(WASM_F64_ADD(WASM_F64(13.5), WASM_F64(43.5))));
171 CHECK_EQ(57, r.Call()); 156 CHECK_EQ(57, r.Call());
172 } 157 }
173 158
174
175 void TestInt32Binop(WasmOpcode opcode, int32_t expected, int32_t a, int32_t b) { 159 void TestInt32Binop(WasmOpcode opcode, int32_t expected, int32_t a, int32_t b) {
176 { 160 {
177 WasmRunner<int32_t> r; 161 WasmRunner<int32_t> r;
178 // K op K 162 // K op K
179 BUILD(r, WASM_BINOP(opcode, WASM_I32V(a), WASM_I32V(b))); 163 BUILD(r, WASM_BINOP(opcode, WASM_I32V(a), WASM_I32V(b)));
180 CHECK_EQ(expected, r.Call()); 164 CHECK_EQ(expected, r.Call());
181 } 165 }
182 { 166 {
183 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); 167 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32());
184 // a op b 168 // a op b
(...skipping 27 matching lines...) Expand all
212 TestInt32Binop(kExprI32LeS, 0, -2, -3); 196 TestInt32Binop(kExprI32LeS, 0, -2, -3);
213 TestInt32Binop(kExprI32LtU, 1, 0, -6); 197 TestInt32Binop(kExprI32LtU, 1, 0, -6);
214 TestInt32Binop(kExprI32LeU, 1, 98978, 0xF0000000); 198 TestInt32Binop(kExprI32LeU, 1, 98978, 0xF0000000);
215 199
216 TestInt32Binop(kExprI32GtS, 1, 4, -4); 200 TestInt32Binop(kExprI32GtS, 1, 4, -4);
217 TestInt32Binop(kExprI32GeS, 0, -3, -2); 201 TestInt32Binop(kExprI32GeS, 0, -3, -2);
218 TestInt32Binop(kExprI32GtU, 1, -6, 0); 202 TestInt32Binop(kExprI32GtU, 1, -6, 0);
219 TestInt32Binop(kExprI32GeU, 1, 0xF0000000, 98978); 203 TestInt32Binop(kExprI32GeU, 1, 0xF0000000, 98978);
220 } 204 }
221 205
222
223 void TestInt32Unop(WasmOpcode opcode, int32_t expected, int32_t a) { 206 void TestInt32Unop(WasmOpcode opcode, int32_t expected, int32_t a) {
224 { 207 {
225 WasmRunner<int32_t> r; 208 WasmRunner<int32_t> r;
226 // return op K 209 // return op K
227 BUILD(r, WASM_UNOP(opcode, WASM_I32V(a))); 210 BUILD(r, WASM_UNOP(opcode, WASM_I32V(a)));
228 CHECK_EQ(expected, r.Call()); 211 CHECK_EQ(expected, r.Call());
229 } 212 }
230 { 213 {
231 WasmRunner<int32_t> r(MachineType::Int32()); 214 WasmRunner<int32_t> r(MachineType::Int32());
232 // return op a 215 // return op a
233 BUILD(r, WASM_UNOP(opcode, WASM_GET_LOCAL(0))); 216 BUILD(r, WASM_UNOP(opcode, WASM_GET_LOCAL(0)));
234 CHECK_EQ(expected, r.Call(a)); 217 CHECK_EQ(expected, r.Call(a));
235 } 218 }
236 } 219 }
237 220
238
239 TEST(Run_WasmInt32Clz) { 221 TEST(Run_WasmInt32Clz) {
240 TestInt32Unop(kExprI32Clz, 0, 0x80001000); 222 TestInt32Unop(kExprI32Clz, 0, 0x80001000);
241 TestInt32Unop(kExprI32Clz, 1, 0x40000500); 223 TestInt32Unop(kExprI32Clz, 1, 0x40000500);
242 TestInt32Unop(kExprI32Clz, 2, 0x20000300); 224 TestInt32Unop(kExprI32Clz, 2, 0x20000300);
243 TestInt32Unop(kExprI32Clz, 3, 0x10000003); 225 TestInt32Unop(kExprI32Clz, 3, 0x10000003);
244 TestInt32Unop(kExprI32Clz, 4, 0x08050000); 226 TestInt32Unop(kExprI32Clz, 4, 0x08050000);
245 TestInt32Unop(kExprI32Clz, 5, 0x04006000); 227 TestInt32Unop(kExprI32Clz, 5, 0x04006000);
246 TestInt32Unop(kExprI32Clz, 6, 0x02000000); 228 TestInt32Unop(kExprI32Clz, 6, 0x02000000);
247 TestInt32Unop(kExprI32Clz, 7, 0x010000a0); 229 TestInt32Unop(kExprI32Clz, 7, 0x010000a0);
248 TestInt32Unop(kExprI32Clz, 8, 0x00800c00); 230 TestInt32Unop(kExprI32Clz, 8, 0x00800c00);
(...skipping 16 matching lines...) Expand all
265 TestInt32Unop(kExprI32Clz, 25, 0x00000041); 247 TestInt32Unop(kExprI32Clz, 25, 0x00000041);
266 TestInt32Unop(kExprI32Clz, 26, 0x00000022); 248 TestInt32Unop(kExprI32Clz, 26, 0x00000022);
267 TestInt32Unop(kExprI32Clz, 27, 0x00000013); 249 TestInt32Unop(kExprI32Clz, 27, 0x00000013);
268 TestInt32Unop(kExprI32Clz, 28, 0x00000008); 250 TestInt32Unop(kExprI32Clz, 28, 0x00000008);
269 TestInt32Unop(kExprI32Clz, 29, 0x00000004); 251 TestInt32Unop(kExprI32Clz, 29, 0x00000004);
270 TestInt32Unop(kExprI32Clz, 30, 0x00000002); 252 TestInt32Unop(kExprI32Clz, 30, 0x00000002);
271 TestInt32Unop(kExprI32Clz, 31, 0x00000001); 253 TestInt32Unop(kExprI32Clz, 31, 0x00000001);
272 TestInt32Unop(kExprI32Clz, 32, 0x00000000); 254 TestInt32Unop(kExprI32Clz, 32, 0x00000000);
273 } 255 }
274 256
275
276 TEST(Run_WasmInt32Ctz) { 257 TEST(Run_WasmInt32Ctz) {
277 TestInt32Unop(kExprI32Ctz, 32, 0x00000000); 258 TestInt32Unop(kExprI32Ctz, 32, 0x00000000);
278 TestInt32Unop(kExprI32Ctz, 31, 0x80000000); 259 TestInt32Unop(kExprI32Ctz, 31, 0x80000000);
279 TestInt32Unop(kExprI32Ctz, 30, 0x40000000); 260 TestInt32Unop(kExprI32Ctz, 30, 0x40000000);
280 TestInt32Unop(kExprI32Ctz, 29, 0x20000000); 261 TestInt32Unop(kExprI32Ctz, 29, 0x20000000);
281 TestInt32Unop(kExprI32Ctz, 28, 0x10000000); 262 TestInt32Unop(kExprI32Ctz, 28, 0x10000000);
282 TestInt32Unop(kExprI32Ctz, 27, 0xa8000000); 263 TestInt32Unop(kExprI32Ctz, 27, 0xa8000000);
283 TestInt32Unop(kExprI32Ctz, 26, 0xf4000000); 264 TestInt32Unop(kExprI32Ctz, 26, 0xf4000000);
284 TestInt32Unop(kExprI32Ctz, 25, 0x62000000); 265 TestInt32Unop(kExprI32Ctz, 25, 0x62000000);
285 TestInt32Unop(kExprI32Ctz, 24, 0x91000000); 266 TestInt32Unop(kExprI32Ctz, 24, 0x91000000);
(...skipping 16 matching lines...) Expand all
302 TestInt32Unop(kExprI32Ctz, 7, 0xdfbec580); 283 TestInt32Unop(kExprI32Ctz, 7, 0xdfbec580);
303 TestInt32Unop(kExprI32Ctz, 6, 0x27a9db40); 284 TestInt32Unop(kExprI32Ctz, 6, 0x27a9db40);
304 TestInt32Unop(kExprI32Ctz, 5, 0xde3bcb20); 285 TestInt32Unop(kExprI32Ctz, 5, 0xde3bcb20);
305 TestInt32Unop(kExprI32Ctz, 4, 0xd7e8a610); 286 TestInt32Unop(kExprI32Ctz, 4, 0xd7e8a610);
306 TestInt32Unop(kExprI32Ctz, 3, 0x9afdbc88); 287 TestInt32Unop(kExprI32Ctz, 3, 0x9afdbc88);
307 TestInt32Unop(kExprI32Ctz, 2, 0x9afdbc84); 288 TestInt32Unop(kExprI32Ctz, 2, 0x9afdbc84);
308 TestInt32Unop(kExprI32Ctz, 1, 0x9afdbc82); 289 TestInt32Unop(kExprI32Ctz, 1, 0x9afdbc82);
309 TestInt32Unop(kExprI32Ctz, 0, 0x9afdbc81); 290 TestInt32Unop(kExprI32Ctz, 0, 0x9afdbc81);
310 } 291 }
311 292
312
313 TEST(Run_WasmInt32Popcnt) { 293 TEST(Run_WasmInt32Popcnt) {
314 TestInt32Unop(kExprI32Popcnt, 32, 0xffffffff); 294 TestInt32Unop(kExprI32Popcnt, 32, 0xffffffff);
315 TestInt32Unop(kExprI32Popcnt, 0, 0x00000000); 295 TestInt32Unop(kExprI32Popcnt, 0, 0x00000000);
316 TestInt32Unop(kExprI32Popcnt, 1, 0x00008000); 296 TestInt32Unop(kExprI32Popcnt, 1, 0x00008000);
317 TestInt32Unop(kExprI32Popcnt, 13, 0x12345678); 297 TestInt32Unop(kExprI32Popcnt, 13, 0x12345678);
318 TestInt32Unop(kExprI32Popcnt, 19, 0xfedcba09); 298 TestInt32Unop(kExprI32Popcnt, 19, 0xfedcba09);
319 } 299 }
320 300
321 TEST(Run_WasmI32Eqz) { 301 TEST(Run_WasmI32Eqz) {
322 TestInt32Unop(kExprI32Eqz, 0, 1); 302 TestInt32Unop(kExprI32Eqz, 0, 1);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); 346 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32());
367 BUILD(r, WASM_I32_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 347 BUILD(r, WASM_I32_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
368 const int32_t kMin = std::numeric_limits<int32_t>::min(); 348 const int32_t kMin = std::numeric_limits<int32_t>::min();
369 CHECK_EQ(0, r.Call(0, 100)); 349 CHECK_EQ(0, r.Call(0, 100));
370 CHECK_TRAP(r.Call(100, 0)); 350 CHECK_TRAP(r.Call(100, 0));
371 CHECK_TRAP(r.Call(-1001, 0)); 351 CHECK_TRAP(r.Call(-1001, 0));
372 CHECK_TRAP(r.Call(kMin, -1)); 352 CHECK_TRAP(r.Call(kMin, -1));
373 CHECK_TRAP(r.Call(kMin, 0)); 353 CHECK_TRAP(r.Call(kMin, 0));
374 } 354 }
375 355
376
377 TEST(Run_WASM_Int32RemS_trap) { 356 TEST(Run_WASM_Int32RemS_trap) {
378 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); 357 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32());
379 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 358 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
380 const int32_t kMin = std::numeric_limits<int32_t>::min(); 359 const int32_t kMin = std::numeric_limits<int32_t>::min();
381 CHECK_EQ(33, r.Call(133, 100)); 360 CHECK_EQ(33, r.Call(133, 100));
382 CHECK_EQ(0, r.Call(kMin, -1)); 361 CHECK_EQ(0, r.Call(kMin, -1));
383 CHECK_TRAP(r.Call(100, 0)); 362 CHECK_TRAP(r.Call(100, 0));
384 CHECK_TRAP(r.Call(-1001, 0)); 363 CHECK_TRAP(r.Call(-1001, 0));
385 CHECK_TRAP(r.Call(kMin, 0)); 364 CHECK_TRAP(r.Call(kMin, 0));
386 } 365 }
387 366
388
389 TEST(Run_WASM_Int32DivU_trap) { 367 TEST(Run_WASM_Int32DivU_trap) {
390 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); 368 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32());
391 BUILD(r, WASM_I32_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 369 BUILD(r, WASM_I32_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
392 const int32_t kMin = std::numeric_limits<int32_t>::min(); 370 const int32_t kMin = std::numeric_limits<int32_t>::min();
393 CHECK_EQ(0, r.Call(0, 100)); 371 CHECK_EQ(0, r.Call(0, 100));
394 CHECK_EQ(0, r.Call(kMin, -1)); 372 CHECK_EQ(0, r.Call(kMin, -1));
395 CHECK_TRAP(r.Call(100, 0)); 373 CHECK_TRAP(r.Call(100, 0));
396 CHECK_TRAP(r.Call(-1001, 0)); 374 CHECK_TRAP(r.Call(-1001, 0));
397 CHECK_TRAP(r.Call(kMin, 0)); 375 CHECK_TRAP(r.Call(kMin, 0));
398 } 376 }
399 377
400
401 TEST(Run_WASM_Int32RemU_trap) { 378 TEST(Run_WASM_Int32RemU_trap) {
402 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); 379 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32());
403 BUILD(r, WASM_I32_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 380 BUILD(r, WASM_I32_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
404 CHECK_EQ(17, r.Call(217, 100)); 381 CHECK_EQ(17, r.Call(217, 100));
405 const int32_t kMin = std::numeric_limits<int32_t>::min(); 382 const int32_t kMin = std::numeric_limits<int32_t>::min();
406 CHECK_TRAP(r.Call(100, 0)); 383 CHECK_TRAP(r.Call(100, 0));
407 CHECK_TRAP(r.Call(-1001, 0)); 384 CHECK_TRAP(r.Call(-1001, 0));
408 CHECK_TRAP(r.Call(kMin, 0)); 385 CHECK_TRAP(r.Call(kMin, 0));
409 CHECK_EQ(kMin, r.Call(kMin, -1)); 386 CHECK_EQ(kMin, r.Call(kMin, -1));
410 } 387 }
411 388
412 TEST(Run_WASM_Int32DivS_byzero_const) { 389 TEST(Run_WASM_Int32DivS_byzero_const) {
413 for (int8_t denom = -2; denom < 8; denom++) { 390 for (int8_t denom = -2; denom < 8; denom++) {
414 WasmRunner<int32_t> r(MachineType::Int32()); 391 WasmRunner<int32_t> r(MachineType::Int32());
415 BUILD(r, WASM_I32_DIVS(WASM_GET_LOCAL(0), WASM_I8(denom))); 392 BUILD(r, WASM_I32_DIVS(WASM_GET_LOCAL(0), WASM_I8(denom)));
416 for (int32_t val = -7; val < 8; val++) { 393 for (int32_t val = -7; val < 8; val++) {
417 if (denom == 0) { 394 if (denom == 0) {
418 CHECK_TRAP(r.Call(val)); 395 CHECK_TRAP(r.Call(val));
419 } else { 396 } else {
420 CHECK_EQ(val / denom, r.Call(val)); 397 CHECK_EQ(val / denom, r.Call(val));
421 } 398 }
422 } 399 }
423 } 400 }
424 } 401 }
425 402
426
427 TEST(Run_WASM_Int32DivU_byzero_const) { 403 TEST(Run_WASM_Int32DivU_byzero_const) {
428 for (uint32_t denom = 0xfffffffe; denom < 8; denom++) { 404 for (uint32_t denom = 0xfffffffe; denom < 8; denom++) {
429 WasmRunner<uint32_t> r(MachineType::Uint32()); 405 WasmRunner<uint32_t> r(MachineType::Uint32());
430 BUILD(r, WASM_I32_DIVU(WASM_GET_LOCAL(0), WASM_I32V_1(denom))); 406 BUILD(r, WASM_I32_DIVU(WASM_GET_LOCAL(0), WASM_I32V_1(denom)));
431 407
432 for (uint32_t val = 0xfffffff0; val < 8; val++) { 408 for (uint32_t val = 0xfffffff0; val < 8; val++) {
433 if (denom == 0) { 409 if (denom == 0) {
434 CHECK_TRAP(r.Call(val)); 410 CHECK_TRAP(r.Call(val));
435 } else { 411 } else {
436 CHECK_EQ(val / denom, r.Call(val)); 412 CHECK_EQ(val / denom, r.Call(val));
437 } 413 }
438 } 414 }
439 } 415 }
440 } 416 }
441 417
442
443 TEST(Run_WASM_Int32DivS_trap_effect) { 418 TEST(Run_WASM_Int32DivS_trap_effect) {
444 TestingModule module; 419 TestingModule module;
445 module.AddMemoryElems<int32_t>(8); 420 module.AddMemoryElems<int32_t>(8);
446 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32()); 421 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32());
447 422
448 BUILD(r, 423 BUILD(r,
449 WASM_IF_ELSE(WASM_GET_LOCAL(0), 424 WASM_IF_ELSE(WASM_GET_LOCAL(0),
450 WASM_I32_DIVS(WASM_STORE_MEM(MachineType::Int8(), 425 WASM_I32_DIVS(WASM_STORE_MEM(MachineType::Int8(),
451 WASM_ZERO, WASM_GET_LOCAL(0)), 426 WASM_ZERO, WASM_GET_LOCAL(0)),
452 WASM_GET_LOCAL(1)), 427 WASM_GET_LOCAL(1)),
(...skipping 14 matching lines...) Expand all
467 CHECK_EQ(expected, r.Call()); 442 CHECK_EQ(expected, r.Call());
468 } 443 }
469 { 444 {
470 WasmRunner<int32_t> r(MachineType::Float32(), MachineType::Float32()); 445 WasmRunner<int32_t> r(MachineType::Float32(), MachineType::Float32());
471 // return a op b 446 // return a op b
472 BUILD(r, WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 447 BUILD(r, WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
473 CHECK_EQ(expected, r.Call(a, b)); 448 CHECK_EQ(expected, r.Call(a, b));
474 } 449 }
475 } 450 }
476 451
477
478 void TestFloat32BinopWithConvert(WasmOpcode opcode, int32_t expected, float a, 452 void TestFloat32BinopWithConvert(WasmOpcode opcode, int32_t expected, float a,
479 float b) { 453 float b) {
480 { 454 {
481 WasmRunner<int32_t> r; 455 WasmRunner<int32_t> r;
482 // return int(K op K) 456 // return int(K op K)
483 BUILD(r, 457 BUILD(r,
484 WASM_I32_SCONVERT_F32(WASM_BINOP(opcode, WASM_F32(a), WASM_F32(b)))); 458 WASM_I32_SCONVERT_F32(WASM_BINOP(opcode, WASM_F32(a), WASM_F32(b))));
485 CHECK_EQ(expected, r.Call()); 459 CHECK_EQ(expected, r.Call());
486 } 460 }
487 { 461 {
488 WasmRunner<int32_t> r(MachineType::Float32(), MachineType::Float32()); 462 WasmRunner<int32_t> r(MachineType::Float32(), MachineType::Float32());
489 // return int(a op b) 463 // return int(a op b)
490 BUILD(r, WASM_I32_SCONVERT_F32( 464 BUILD(r, WASM_I32_SCONVERT_F32(
491 WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); 465 WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))));
492 CHECK_EQ(expected, r.Call(a, b)); 466 CHECK_EQ(expected, r.Call(a, b));
493 } 467 }
494 } 468 }
495 469
496
497 void TestFloat32UnopWithConvert(WasmOpcode opcode, int32_t expected, float a) { 470 void TestFloat32UnopWithConvert(WasmOpcode opcode, int32_t expected, float a) {
498 { 471 {
499 WasmRunner<int32_t> r; 472 WasmRunner<int32_t> r;
500 // return int(op(K)) 473 // return int(op(K))
501 BUILD(r, WASM_I32_SCONVERT_F32(WASM_UNOP(opcode, WASM_F32(a)))); 474 BUILD(r, WASM_I32_SCONVERT_F32(WASM_UNOP(opcode, WASM_F32(a))));
502 CHECK_EQ(expected, r.Call()); 475 CHECK_EQ(expected, r.Call());
503 } 476 }
504 { 477 {
505 WasmRunner<int32_t> r(MachineType::Float32()); 478 WasmRunner<int32_t> r(MachineType::Float32());
506 // return int(op(a)) 479 // return int(op(a))
507 BUILD(r, WASM_I32_SCONVERT_F32(WASM_UNOP(opcode, WASM_GET_LOCAL(0)))); 480 BUILD(r, WASM_I32_SCONVERT_F32(WASM_UNOP(opcode, WASM_GET_LOCAL(0))));
508 CHECK_EQ(expected, r.Call(a)); 481 CHECK_EQ(expected, r.Call(a));
509 } 482 }
510 } 483 }
511 484
512
513 void TestFloat64Binop(WasmOpcode opcode, int32_t expected, double a, double b) { 485 void TestFloat64Binop(WasmOpcode opcode, int32_t expected, double a, double b) {
514 { 486 {
515 WasmRunner<int32_t> r; 487 WasmRunner<int32_t> r;
516 // return K op K 488 // return K op K
517 BUILD(r, WASM_BINOP(opcode, WASM_F64(a), WASM_F64(b))); 489 BUILD(r, WASM_BINOP(opcode, WASM_F64(a), WASM_F64(b)));
518 CHECK_EQ(expected, r.Call()); 490 CHECK_EQ(expected, r.Call());
519 } 491 }
520 { 492 {
521 WasmRunner<int32_t> r(MachineType::Float64(), MachineType::Float64()); 493 WasmRunner<int32_t> r(MachineType::Float64(), MachineType::Float64());
522 // return a op b 494 // return a op b
523 BUILD(r, WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 495 BUILD(r, WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
524 CHECK_EQ(expected, r.Call(a, b)); 496 CHECK_EQ(expected, r.Call(a, b));
525 } 497 }
526 } 498 }
527 499
528
529 void TestFloat64BinopWithConvert(WasmOpcode opcode, int32_t expected, double a, 500 void TestFloat64BinopWithConvert(WasmOpcode opcode, int32_t expected, double a,
530 double b) { 501 double b) {
531 { 502 {
532 WasmRunner<int32_t> r; 503 WasmRunner<int32_t> r;
533 // return int(K op K) 504 // return int(K op K)
534 BUILD(r, 505 BUILD(r,
535 WASM_I32_SCONVERT_F64(WASM_BINOP(opcode, WASM_F64(a), WASM_F64(b)))); 506 WASM_I32_SCONVERT_F64(WASM_BINOP(opcode, WASM_F64(a), WASM_F64(b))));
536 CHECK_EQ(expected, r.Call()); 507 CHECK_EQ(expected, r.Call());
537 } 508 }
538 { 509 {
539 WasmRunner<int32_t> r(MachineType::Float64(), MachineType::Float64()); 510 WasmRunner<int32_t> r(MachineType::Float64(), MachineType::Float64());
540 BUILD(r, WASM_I32_SCONVERT_F64( 511 BUILD(r, WASM_I32_SCONVERT_F64(
541 WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); 512 WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))));
542 CHECK_EQ(expected, r.Call(a, b)); 513 CHECK_EQ(expected, r.Call(a, b));
543 } 514 }
544 } 515 }
545 516
546
547 void TestFloat64UnopWithConvert(WasmOpcode opcode, int32_t expected, double a) { 517 void TestFloat64UnopWithConvert(WasmOpcode opcode, int32_t expected, double a) {
548 { 518 {
549 WasmRunner<int32_t> r; 519 WasmRunner<int32_t> r;
550 // return int(op(K)) 520 // return int(op(K))
551 BUILD(r, WASM_I32_SCONVERT_F64(WASM_UNOP(opcode, WASM_F64(a)))); 521 BUILD(r, WASM_I32_SCONVERT_F64(WASM_UNOP(opcode, WASM_F64(a))));
552 CHECK_EQ(expected, r.Call()); 522 CHECK_EQ(expected, r.Call());
553 } 523 }
554 { 524 {
555 WasmRunner<int32_t> r(MachineType::Float64()); 525 WasmRunner<int32_t> r(MachineType::Float64());
556 // return int(op(a)) 526 // return int(op(a))
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 TEST(Run_WasmFloat32Neg) { 574 TEST(Run_WasmFloat32Neg) {
605 WasmRunner<float> r(MachineType::Float32()); 575 WasmRunner<float> r(MachineType::Float32());
606 BUILD(r, WASM_F32_NEG(WASM_GET_LOCAL(0))); 576 BUILD(r, WASM_F32_NEG(WASM_GET_LOCAL(0)));
607 577
608 FOR_FLOAT32_INPUTS(i) { 578 FOR_FLOAT32_INPUTS(i) {
609 CHECK_EQ(0x80000000, 579 CHECK_EQ(0x80000000,
610 bit_cast<uint32_t>(*i) ^ bit_cast<uint32_t>(r.Call(*i))); 580 bit_cast<uint32_t>(*i) ^ bit_cast<uint32_t>(r.Call(*i)));
611 } 581 }
612 } 582 }
613 583
614
615 TEST(Run_WasmFloat64Neg) { 584 TEST(Run_WasmFloat64Neg) {
616 WasmRunner<double> r(MachineType::Float64()); 585 WasmRunner<double> r(MachineType::Float64());
617 BUILD(r, WASM_F64_NEG(WASM_GET_LOCAL(0))); 586 BUILD(r, WASM_F64_NEG(WASM_GET_LOCAL(0)));
618 587
619 FOR_FLOAT64_INPUTS(i) { 588 FOR_FLOAT64_INPUTS(i) {
620 CHECK_EQ(0x8000000000000000, 589 CHECK_EQ(0x8000000000000000,
621 bit_cast<uint64_t>(*i) ^ bit_cast<uint64_t>(r.Call(*i))); 590 bit_cast<uint64_t>(*i) ^ bit_cast<uint64_t>(r.Call(*i)));
622 } 591 }
623 } 592 }
624 593
625
626 TEST(Run_Wasm_IfElse_P) { 594 TEST(Run_Wasm_IfElse_P) {
627 WasmRunner<int32_t> r(MachineType::Int32()); 595 WasmRunner<int32_t> r(MachineType::Int32());
628 // if (p0) return 11; else return 22; 596 // if (p0) return 11; else return 22;
629 BUILD(r, WASM_IF_ELSE(WASM_GET_LOCAL(0), // -- 597 BUILD(r, WASM_IF_ELSE(WASM_GET_LOCAL(0), // --
630 WASM_I8(11), // -- 598 WASM_I8(11), // --
631 WASM_I8(22))); // -- 599 WASM_I8(22))); // --
632 FOR_INT32_INPUTS(i) { 600 FOR_INT32_INPUTS(i) {
633 int32_t expected = *i ? 11 : 22; 601 int32_t expected = *i ? 11 : 22;
634 CHECK_EQ(expected, r.Call(*i)); 602 CHECK_EQ(expected, r.Call(*i));
635 } 603 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 651
684 TEST(Run_Wasm_IfElse_Unreachable1) { 652 TEST(Run_Wasm_IfElse_Unreachable1) {
685 WasmRunner<int32_t> r; 653 WasmRunner<int32_t> r;
686 // if (0) unreachable; else return 22; 654 // if (0) unreachable; else return 22;
687 BUILD(r, WASM_IF_ELSE(WASM_ZERO, // -- 655 BUILD(r, WASM_IF_ELSE(WASM_ZERO, // --
688 WASM_UNREACHABLE, // -- 656 WASM_UNREACHABLE, // --
689 WASM_I8(27))); // -- 657 WASM_I8(27))); // --
690 CHECK_EQ(27, r.Call()); 658 CHECK_EQ(27, r.Call());
691 } 659 }
692 660
693
694 TEST(Run_Wasm_Return12) { 661 TEST(Run_Wasm_Return12) {
695 WasmRunner<int32_t> r; 662 WasmRunner<int32_t> r;
696 663
697 BUILD(r, RET_I8(12)); 664 BUILD(r, RET_I8(12));
698 CHECK_EQ(12, r.Call()); 665 CHECK_EQ(12, r.Call());
699 } 666 }
700 667
701
702 TEST(Run_Wasm_Return17) { 668 TEST(Run_Wasm_Return17) {
703 WasmRunner<int32_t> r; 669 WasmRunner<int32_t> r;
704 670
705 BUILD(r, B1(RET_I8(17))); 671 BUILD(r, B1(RET_I8(17)));
706 CHECK_EQ(17, r.Call()); 672 CHECK_EQ(17, r.Call());
707 } 673 }
708 674
709
710 TEST(Run_Wasm_Return_I32) { 675 TEST(Run_Wasm_Return_I32) {
711 WasmRunner<int32_t> r(MachineType::Int32()); 676 WasmRunner<int32_t> r(MachineType::Int32());
712 677
713 BUILD(r, RET(WASM_GET_LOCAL(0))); 678 BUILD(r, RET(WASM_GET_LOCAL(0)));
714 679
715 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } 680 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); }
716 } 681 }
717 682
718
719 TEST(Run_Wasm_Return_F32) { 683 TEST(Run_Wasm_Return_F32) {
720 WasmRunner<float> r(MachineType::Float32()); 684 WasmRunner<float> r(MachineType::Float32());
721 685
722 BUILD(r, RET(WASM_GET_LOCAL(0))); 686 BUILD(r, RET(WASM_GET_LOCAL(0)));
723 687
724 FOR_FLOAT32_INPUTS(i) { 688 FOR_FLOAT32_INPUTS(i) {
725 float expect = *i; 689 float expect = *i;
726 float result = r.Call(expect); 690 float result = r.Call(expect);
727 if (std::isnan(expect)) { 691 if (std::isnan(expect)) {
728 CHECK(std::isnan(result)); 692 CHECK(std::isnan(result));
729 } else { 693 } else {
730 CHECK_EQ(expect, result); 694 CHECK_EQ(expect, result);
731 } 695 }
732 } 696 }
733 } 697 }
734 698
735
736 TEST(Run_Wasm_Return_F64) { 699 TEST(Run_Wasm_Return_F64) {
737 WasmRunner<double> r(MachineType::Float64()); 700 WasmRunner<double> r(MachineType::Float64());
738 701
739 BUILD(r, RET(WASM_GET_LOCAL(0))); 702 BUILD(r, RET(WASM_GET_LOCAL(0)));
740 703
741 FOR_FLOAT64_INPUTS(i) { 704 FOR_FLOAT64_INPUTS(i) {
742 double expect = *i; 705 double expect = *i;
743 double result = r.Call(expect); 706 double result = r.Call(expect);
744 if (std::isnan(expect)) { 707 if (std::isnan(expect)) {
745 CHECK(std::isnan(result)); 708 CHECK(std::isnan(result));
746 } else { 709 } else {
747 CHECK_EQ(expect, result); 710 CHECK_EQ(expect, result);
748 } 711 }
749 } 712 }
750 } 713 }
751 714
752
753 TEST(Run_Wasm_Select) { 715 TEST(Run_Wasm_Select) {
754 WasmRunner<int32_t> r(MachineType::Int32()); 716 WasmRunner<int32_t> r(MachineType::Int32());
755 // return select(11, 22, a); 717 // return select(11, 22, a);
756 BUILD(r, WASM_SELECT(WASM_I8(11), WASM_I8(22), WASM_GET_LOCAL(0))); 718 BUILD(r, WASM_SELECT(WASM_I8(11), WASM_I8(22), WASM_GET_LOCAL(0)));
757 FOR_INT32_INPUTS(i) { 719 FOR_INT32_INPUTS(i) {
758 int32_t expected = *i ? 11 : 22; 720 int32_t expected = *i ? 11 : 22;
759 CHECK_EQ(expected, r.Call(*i)); 721 CHECK_EQ(expected, r.Call(*i));
760 } 722 }
761 } 723 }
762 724
763
764 TEST(Run_Wasm_Select_strict1) { 725 TEST(Run_Wasm_Select_strict1) {
765 WasmRunner<int32_t> r(MachineType::Int32()); 726 WasmRunner<int32_t> r(MachineType::Int32());
766 // select(a=0, a=1, a=2); return a 727 // select(a=0, a=1, a=2); return a
767 BUILD(r, B2(WASM_SELECT(WASM_SET_LOCAL(0, WASM_I8(0)), 728 BUILD(r, B2(WASM_SELECT(WASM_SET_LOCAL(0, WASM_I8(0)),
768 WASM_SET_LOCAL(0, WASM_I8(1)), 729 WASM_SET_LOCAL(0, WASM_I8(1)),
769 WASM_SET_LOCAL(0, WASM_I8(2))), 730 WASM_SET_LOCAL(0, WASM_I8(2))),
770 WASM_GET_LOCAL(0))); 731 WASM_GET_LOCAL(0)));
771 FOR_INT32_INPUTS(i) { CHECK_EQ(2, r.Call(*i)); } 732 FOR_INT32_INPUTS(i) { CHECK_EQ(2, r.Call(*i)); }
772 } 733 }
773 734
774
775 TEST(Run_Wasm_Select_strict2) { 735 TEST(Run_Wasm_Select_strict2) {
776 WasmRunner<int32_t> r(MachineType::Int32()); 736 WasmRunner<int32_t> r(MachineType::Int32());
777 r.AllocateLocal(kAstI32); 737 r.AllocateLocal(kAstI32);
778 r.AllocateLocal(kAstI32); 738 r.AllocateLocal(kAstI32);
779 // select(b=5, c=6, a) 739 // select(b=5, c=6, a)
780 BUILD(r, WASM_SELECT(WASM_SET_LOCAL(1, WASM_I8(5)), 740 BUILD(r, WASM_SELECT(WASM_SET_LOCAL(1, WASM_I8(5)),
781 WASM_SET_LOCAL(2, WASM_I8(6)), WASM_GET_LOCAL(0))); 741 WASM_SET_LOCAL(2, WASM_I8(6)), WASM_GET_LOCAL(0)));
782 FOR_INT32_INPUTS(i) { 742 FOR_INT32_INPUTS(i) {
783 int32_t expected = *i ? 5 : 6; 743 int32_t expected = *i ? 5 : 6;
784 CHECK_EQ(expected, r.Call(*i)); 744 CHECK_EQ(expected, r.Call(*i));
785 } 745 }
786 } 746 }
787 747
788 TEST(Run_Wasm_Select_strict3) { 748 TEST(Run_Wasm_Select_strict3) {
789 WasmRunner<int32_t> r(MachineType::Int32()); 749 WasmRunner<int32_t> r(MachineType::Int32());
790 r.AllocateLocal(kAstI32); 750 r.AllocateLocal(kAstI32);
791 r.AllocateLocal(kAstI32); 751 r.AllocateLocal(kAstI32);
792 // select(b=5, c=6, a=b) 752 // select(b=5, c=6, a=b)
793 BUILD(r, WASM_SELECT(WASM_SET_LOCAL(1, WASM_I8(5)), 753 BUILD(r, WASM_SELECT(WASM_SET_LOCAL(1, WASM_I8(5)),
794 WASM_SET_LOCAL(2, WASM_I8(6)), 754 WASM_SET_LOCAL(2, WASM_I8(6)),
795 WASM_SET_LOCAL(0, WASM_GET_LOCAL(1)))); 755 WASM_SET_LOCAL(0, WASM_GET_LOCAL(1))));
796 FOR_INT32_INPUTS(i) { 756 FOR_INT32_INPUTS(i) {
797 int32_t expected = 5; 757 int32_t expected = 5;
798 CHECK_EQ(expected, r.Call(*i)); 758 CHECK_EQ(expected, r.Call(*i));
799 } 759 }
800 } 760 }
801 761
802
803 TEST(Run_Wasm_BrIf_strict) { 762 TEST(Run_Wasm_BrIf_strict) {
804 WasmRunner<int32_t> r(MachineType::Int32()); 763 WasmRunner<int32_t> r(MachineType::Int32());
805 BUILD( 764 BUILD(
806 r, 765 r,
807 B2(B1(WASM_BRV_IF(0, WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_I8(99)))), 766 B2(B1(WASM_BRV_IF(0, WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_I8(99)))),
808 WASM_GET_LOCAL(0))); 767 WASM_GET_LOCAL(0)));
809 768
810 FOR_INT32_INPUTS(i) { CHECK_EQ(99, r.Call(*i)); } 769 FOR_INT32_INPUTS(i) { CHECK_EQ(99, r.Call(*i)); }
811 } 770 }
812 771
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 BUILD(r, WASM_I32_REINTERPRET_F32( 940 BUILD(r, WASM_I32_REINTERPRET_F32(
982 WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO))); 941 WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO)));
983 942
984 FOR_INT32_INPUTS(i) { 943 FOR_INT32_INPUTS(i) {
985 int32_t expected = *i; 944 int32_t expected = *i;
986 memory[0] = expected; 945 memory[0] = expected;
987 CHECK_EQ(expected, r.Call()); 946 CHECK_EQ(expected, r.Call());
988 } 947 }
989 } 948 }
990 949
991
992 TEST(Run_Wasm_I32ReinterpretF32) { 950 TEST(Run_Wasm_I32ReinterpretF32) {
993 TestingModule module; 951 TestingModule module;
994 int32_t* memory = module.AddMemoryElems<int32_t>(8); 952 int32_t* memory = module.AddMemoryElems<int32_t>(8);
995 WasmRunner<int32_t> r(&module, MachineType::Int32()); 953 WasmRunner<int32_t> r(&module, MachineType::Int32());
996 954
997 BUILD(r, WASM_BLOCK( 955 BUILD(r, WASM_BLOCK(
998 2, WASM_STORE_MEM(MachineType::Float32(), WASM_ZERO, 956 2, WASM_STORE_MEM(MachineType::Float32(), WASM_ZERO,
999 WASM_F32_REINTERPRET_I32(WASM_GET_LOCAL(0))), 957 WASM_F32_REINTERPRET_I32(WASM_GET_LOCAL(0))),
1000 WASM_I8(107))); 958 WASM_I8(107)));
1001 959
1002 FOR_INT32_INPUTS(i) { 960 FOR_INT32_INPUTS(i) {
1003 int32_t expected = *i; 961 int32_t expected = *i;
1004 CHECK_EQ(107, r.Call(expected)); 962 CHECK_EQ(107, r.Call(expected));
1005 CHECK_EQ(expected, memory[0]); 963 CHECK_EQ(expected, memory[0]);
1006 } 964 }
1007 } 965 }
1008 966
1009
1010 TEST(Run_Wasm_ReturnStore) { 967 TEST(Run_Wasm_ReturnStore) {
1011 TestingModule module; 968 TestingModule module;
1012 int32_t* memory = module.AddMemoryElems<int32_t>(8); 969 int32_t* memory = module.AddMemoryElems<int32_t>(8);
1013 WasmRunner<int32_t> r(&module); 970 WasmRunner<int32_t> r(&module);
1014 971
1015 BUILD(r, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO, 972 BUILD(r, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO,
1016 WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO))); 973 WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)));
1017 974
1018 FOR_INT32_INPUTS(i) { 975 FOR_INT32_INPUTS(i) {
1019 int32_t expected = *i; 976 int32_t expected = *i;
1020 memory[0] = expected; 977 memory[0] = expected;
1021 CHECK_EQ(expected, r.Call()); 978 CHECK_EQ(expected, r.Call());
1022 } 979 }
1023 } 980 }
1024 981
1025
1026 TEST(Run_Wasm_VoidReturn1) { 982 TEST(Run_Wasm_VoidReturn1) {
1027 // We use a wrapper function because WasmRunner<void> does not exist. 983 // We use a wrapper function because WasmRunner<void> does not exist.
1028 984
1029 // Build the test function. 985 // Build the test function.
1030 TestSignatures sigs; 986 TestSignatures sigs;
1031 TestingModule module; 987 TestingModule module;
1032 WasmFunctionCompiler t(sigs.v_v(), &module); 988 WasmFunctionCompiler t(sigs.v_v(), &module);
1033 BUILD(t, kExprNop); 989 BUILD(t, kExprNop);
1034 uint32_t index = t.CompileAndAdd(); 990 uint32_t index = t.CompileAndAdd();
1035 991
1036 const int32_t kExpected = -414444; 992 const int32_t kExpected = -414444;
1037 // Build the calling function. 993 // Build the calling function.
1038 WasmRunner<int32_t> r(&module); 994 WasmRunner<int32_t> r(&module);
1039 BUILD(r, B2(WASM_CALL_FUNCTION0(index), WASM_I32V_3(kExpected))); 995 BUILD(r, B2(WASM_CALL_FUNCTION0(index), WASM_I32V_3(kExpected)));
1040 996
1041 int32_t result = r.Call(); 997 int32_t result = r.Call();
1042 CHECK_EQ(kExpected, result); 998 CHECK_EQ(kExpected, result);
1043 } 999 }
1044 1000
1045
1046 TEST(Run_Wasm_VoidReturn2) { 1001 TEST(Run_Wasm_VoidReturn2) {
1047 // We use a wrapper function because WasmRunner<void> does not exist. 1002 // We use a wrapper function because WasmRunner<void> does not exist.
1048 // Build the test function. 1003 // Build the test function.
1049 TestSignatures sigs; 1004 TestSignatures sigs;
1050 TestingModule module; 1005 TestingModule module;
1051 WasmFunctionCompiler t(sigs.v_v(), &module); 1006 WasmFunctionCompiler t(sigs.v_v(), &module);
1052 BUILD(t, WASM_RETURN0); 1007 BUILD(t, WASM_RETURN0);
1053 uint32_t index = t.CompileAndAdd(); 1008 uint32_t index = t.CompileAndAdd();
1054 1009
1055 const int32_t kExpected = -414444; 1010 const int32_t kExpected = -414444;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 1085
1131 TEST(Run_Wasm_Block_BrIf_P) { 1086 TEST(Run_Wasm_Block_BrIf_P) {
1132 WasmRunner<int32_t> r(MachineType::Int32()); 1087 WasmRunner<int32_t> r(MachineType::Int32());
1133 BUILD(r, B2(WASM_BRV_IF(0, WASM_I8(51), WASM_GET_LOCAL(0)), WASM_I8(52))); 1088 BUILD(r, B2(WASM_BRV_IF(0, WASM_I8(51), WASM_GET_LOCAL(0)), WASM_I8(52)));
1134 FOR_INT32_INPUTS(i) { 1089 FOR_INT32_INPUTS(i) {
1135 int32_t expected = *i ? 51 : 52; 1090 int32_t expected = *i ? 51 : 52;
1136 CHECK_EQ(expected, r.Call(*i)); 1091 CHECK_EQ(expected, r.Call(*i));
1137 } 1092 }
1138 } 1093 }
1139 1094
1140
1141 TEST(Run_Wasm_Block_IfElse_P_assign) { 1095 TEST(Run_Wasm_Block_IfElse_P_assign) {
1142 WasmRunner<int32_t> r(MachineType::Int32()); 1096 WasmRunner<int32_t> r(MachineType::Int32());
1143 // { if (p0) p0 = 71; else p0 = 72; return p0; } 1097 // { if (p0) p0 = 71; else p0 = 72; return p0; }
1144 BUILD(r, B2( // -- 1098 BUILD(r, B2( // --
1145 WASM_IF_ELSE(WASM_GET_LOCAL(0), // -- 1099 WASM_IF_ELSE(WASM_GET_LOCAL(0), // --
1146 WASM_SET_LOCAL(0, WASM_I8(71)), // -- 1100 WASM_SET_LOCAL(0, WASM_I8(71)), // --
1147 WASM_SET_LOCAL(0, WASM_I8(72))), // -- 1101 WASM_SET_LOCAL(0, WASM_I8(72))), // --
1148 WASM_GET_LOCAL(0))); 1102 WASM_GET_LOCAL(0)));
1149 FOR_INT32_INPUTS(i) { 1103 FOR_INT32_INPUTS(i) {
1150 int32_t expected = *i ? 71 : 72; 1104 int32_t expected = *i ? 71 : 72;
1151 CHECK_EQ(expected, r.Call(*i)); 1105 CHECK_EQ(expected, r.Call(*i));
1152 } 1106 }
1153 } 1107 }
1154 1108
1155
1156 TEST(Run_Wasm_Block_IfElse_P_return) { 1109 TEST(Run_Wasm_Block_IfElse_P_return) {
1157 WasmRunner<int32_t> r(MachineType::Int32()); 1110 WasmRunner<int32_t> r(MachineType::Int32());
1158 // if (p0) return 81; else return 82; 1111 // if (p0) return 81; else return 82;
1159 BUILD(r, // -- 1112 BUILD(r, // --
1160 WASM_IF_ELSE(WASM_GET_LOCAL(0), // -- 1113 WASM_IF_ELSE(WASM_GET_LOCAL(0), // --
1161 RET_I8(81), // -- 1114 RET_I8(81), // --
1162 RET_I8(82))); // -- 1115 RET_I8(82))); // --
1163 FOR_INT32_INPUTS(i) { 1116 FOR_INT32_INPUTS(i) {
1164 int32_t expected = *i ? 81 : 82; 1117 int32_t expected = *i ? 81 : 82;
1165 CHECK_EQ(expected, r.Call(*i)); 1118 CHECK_EQ(expected, r.Call(*i));
1166 } 1119 }
1167 } 1120 }
1168 1121
1169
1170 TEST(Run_Wasm_Block_If_P_assign) { 1122 TEST(Run_Wasm_Block_If_P_assign) {
1171 WasmRunner<int32_t> r(MachineType::Int32()); 1123 WasmRunner<int32_t> r(MachineType::Int32());
1172 // { if (p0) p0 = 61; p0; } 1124 // { if (p0) p0 = 61; p0; }
1173 BUILD(r, WASM_BLOCK( 1125 BUILD(r, WASM_BLOCK(
1174 2, WASM_IF(WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_I8(61))), 1126 2, WASM_IF(WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_I8(61))),
1175 WASM_GET_LOCAL(0))); 1127 WASM_GET_LOCAL(0)));
1176 FOR_INT32_INPUTS(i) { 1128 FOR_INT32_INPUTS(i) {
1177 int32_t expected = *i ? 61 : *i; 1129 int32_t expected = *i ? 61 : *i;
1178 CHECK_EQ(expected, r.Call(*i)); 1130 CHECK_EQ(expected, r.Call(*i));
1179 } 1131 }
1180 } 1132 }
1181 1133
1182
1183 TEST(Run_Wasm_DanglingAssign) { 1134 TEST(Run_Wasm_DanglingAssign) {
1184 WasmRunner<int32_t> r(MachineType::Int32()); 1135 WasmRunner<int32_t> r(MachineType::Int32());
1185 // { return 0; p0 = 0; } 1136 // { return 0; p0 = 0; }
1186 BUILD(r, B2(RET_I8(99), WASM_SET_LOCAL(0, WASM_ZERO))); 1137 BUILD(r, B2(RET_I8(99), WASM_SET_LOCAL(0, WASM_ZERO)));
1187 CHECK_EQ(99, r.Call(1)); 1138 CHECK_EQ(99, r.Call(1));
1188 } 1139 }
1189 1140
1190
1191 TEST(Run_Wasm_ExprIf_P) { 1141 TEST(Run_Wasm_ExprIf_P) {
1192 WasmRunner<int32_t> r(MachineType::Int32()); 1142 WasmRunner<int32_t> r(MachineType::Int32());
1193 // p0 ? 11 : 22; 1143 // p0 ? 11 : 22;
1194 BUILD(r, WASM_IF_ELSE(WASM_GET_LOCAL(0), // -- 1144 BUILD(r, WASM_IF_ELSE(WASM_GET_LOCAL(0), // --
1195 WASM_I8(11), // -- 1145 WASM_I8(11), // --
1196 WASM_I8(22))); // -- 1146 WASM_I8(22))); // --
1197 FOR_INT32_INPUTS(i) { 1147 FOR_INT32_INPUTS(i) {
1198 int32_t expected = *i ? 11 : 22; 1148 int32_t expected = *i ? 11 : 22;
1199 CHECK_EQ(expected, r.Call(*i)); 1149 CHECK_EQ(expected, r.Call(*i));
1200 } 1150 }
1201 } 1151 }
1202 1152
1203
1204 TEST(Run_Wasm_ExprIf_P_fallthru) { 1153 TEST(Run_Wasm_ExprIf_P_fallthru) {
1205 WasmRunner<int32_t> r(MachineType::Int32()); 1154 WasmRunner<int32_t> r(MachineType::Int32());
1206 // p0 ? 11 : 22; 1155 // p0 ? 11 : 22;
1207 BUILD(r, WASM_IF_ELSE(WASM_GET_LOCAL(0), // -- 1156 BUILD(r, WASM_IF_ELSE(WASM_GET_LOCAL(0), // --
1208 WASM_I8(11), // -- 1157 WASM_I8(11), // --
1209 WASM_I8(22))); // -- 1158 WASM_I8(22))); // --
1210 FOR_INT32_INPUTS(i) { 1159 FOR_INT32_INPUTS(i) {
1211 int32_t expected = *i ? 11 : 22; 1160 int32_t expected = *i ? 11 : 22;
1212 CHECK_EQ(expected, r.Call(*i)); 1161 CHECK_EQ(expected, r.Call(*i));
1213 } 1162 }
1214 } 1163 }
1215 1164
1216
1217 TEST(Run_Wasm_CountDown) { 1165 TEST(Run_Wasm_CountDown) {
1218 WasmRunner<int32_t> r(MachineType::Int32()); 1166 WasmRunner<int32_t> r(MachineType::Int32());
1219 BUILD(r, 1167 BUILD(r,
1220 WASM_BLOCK( 1168 WASM_BLOCK(
1221 2, WASM_LOOP( 1169 2, WASM_LOOP(
1222 1, WASM_IF(WASM_GET_LOCAL(0), 1170 1, WASM_IF(WASM_GET_LOCAL(0),
1223 WASM_BRV(1, WASM_SET_LOCAL( 1171 WASM_BRV(1, WASM_SET_LOCAL(
1224 0, WASM_I32_SUB(WASM_GET_LOCAL(0), 1172 0, WASM_I32_SUB(WASM_GET_LOCAL(0),
1225 WASM_I8(1)))))), 1173 WASM_I8(1)))))),
1226 WASM_GET_LOCAL(0))); 1174 WASM_GET_LOCAL(0)));
1227 CHECK_EQ(0, r.Call(1)); 1175 CHECK_EQ(0, r.Call(1));
1228 CHECK_EQ(0, r.Call(10)); 1176 CHECK_EQ(0, r.Call(10));
1229 CHECK_EQ(0, r.Call(100)); 1177 CHECK_EQ(0, r.Call(100));
1230 } 1178 }
1231 1179
1232
1233 TEST(Run_Wasm_CountDown_fallthru) { 1180 TEST(Run_Wasm_CountDown_fallthru) {
1234 WasmRunner<int32_t> r(MachineType::Int32()); 1181 WasmRunner<int32_t> r(MachineType::Int32());
1235 BUILD(r, 1182 BUILD(r,
1236 WASM_BLOCK( 1183 WASM_BLOCK(
1237 2, WASM_LOOP(3, WASM_IF(WASM_NOT(WASM_GET_LOCAL(0)), WASM_BREAK(1)), 1184 2, WASM_LOOP(3, WASM_IF(WASM_NOT(WASM_GET_LOCAL(0)), WASM_BREAK(1)),
1238 WASM_SET_LOCAL( 1185 WASM_SET_LOCAL(
1239 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(1))), 1186 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(1))),
1240 WASM_CONTINUE(0)), 1187 WASM_CONTINUE(0)),
1241 WASM_GET_LOCAL(0))); 1188 WASM_GET_LOCAL(0)));
1242 CHECK_EQ(0, r.Call(1)); 1189 CHECK_EQ(0, r.Call(1));
1243 CHECK_EQ(0, r.Call(10)); 1190 CHECK_EQ(0, r.Call(10));
1244 CHECK_EQ(0, r.Call(100)); 1191 CHECK_EQ(0, r.Call(100));
1245 } 1192 }
1246 1193
1247
1248 TEST(Run_Wasm_WhileCountDown) { 1194 TEST(Run_Wasm_WhileCountDown) {
1249 WasmRunner<int32_t> r(MachineType::Int32()); 1195 WasmRunner<int32_t> r(MachineType::Int32());
1250 BUILD(r, WASM_BLOCK( 1196 BUILD(r, WASM_BLOCK(
1251 2, WASM_WHILE(WASM_GET_LOCAL(0), 1197 2, WASM_WHILE(WASM_GET_LOCAL(0),
1252 WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), 1198 WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0),
1253 WASM_I8(1)))), 1199 WASM_I8(1)))),
1254 WASM_GET_LOCAL(0))); 1200 WASM_GET_LOCAL(0)));
1255 CHECK_EQ(0, r.Call(1)); 1201 CHECK_EQ(0, r.Call(1));
1256 CHECK_EQ(0, r.Call(10)); 1202 CHECK_EQ(0, r.Call(10));
1257 CHECK_EQ(0, r.Call(100)); 1203 CHECK_EQ(0, r.Call(100));
1258 } 1204 }
1259 1205
1260
1261 TEST(Run_Wasm_Loop_if_break1) { 1206 TEST(Run_Wasm_Loop_if_break1) {
1262 WasmRunner<int32_t> r(MachineType::Int32()); 1207 WasmRunner<int32_t> r(MachineType::Int32());
1263 BUILD(r, B2(WASM_LOOP(2, WASM_IF(WASM_GET_LOCAL(0), WASM_BREAK(1)), 1208 BUILD(r, B2(WASM_LOOP(2, WASM_IF(WASM_GET_LOCAL(0), WASM_BREAK(1)),
1264 WASM_SET_LOCAL(0, WASM_I8(99))), 1209 WASM_SET_LOCAL(0, WASM_I8(99))),
1265 WASM_GET_LOCAL(0))); 1210 WASM_GET_LOCAL(0)));
1266 CHECK_EQ(99, r.Call(0)); 1211 CHECK_EQ(99, r.Call(0));
1267 CHECK_EQ(3, r.Call(3)); 1212 CHECK_EQ(3, r.Call(3));
1268 CHECK_EQ(10000, r.Call(10000)); 1213 CHECK_EQ(10000, r.Call(10000));
1269 CHECK_EQ(-29, r.Call(-29)); 1214 CHECK_EQ(-29, r.Call(-29));
1270 } 1215 }
1271 1216
1272
1273 TEST(Run_Wasm_Loop_if_break2) { 1217 TEST(Run_Wasm_Loop_if_break2) {
1274 WasmRunner<int32_t> r(MachineType::Int32()); 1218 WasmRunner<int32_t> r(MachineType::Int32());
1275 BUILD(r, B2(WASM_LOOP(2, WASM_BR_IF(1, WASM_GET_LOCAL(0)), 1219 BUILD(r, B2(WASM_LOOP(2, WASM_BR_IF(1, WASM_GET_LOCAL(0)),
1276 WASM_SET_LOCAL(0, WASM_I8(99))), 1220 WASM_SET_LOCAL(0, WASM_I8(99))),
1277 WASM_GET_LOCAL(0))); 1221 WASM_GET_LOCAL(0)));
1278 CHECK_EQ(99, r.Call(0)); 1222 CHECK_EQ(99, r.Call(0));
1279 CHECK_EQ(3, r.Call(3)); 1223 CHECK_EQ(3, r.Call(3));
1280 CHECK_EQ(10000, r.Call(10000)); 1224 CHECK_EQ(10000, r.Call(10000));
1281 CHECK_EQ(-29, r.Call(-29)); 1225 CHECK_EQ(-29, r.Call(-29));
1282 } 1226 }
1283 1227
1284
1285 TEST(Run_Wasm_Loop_if_break_fallthru) { 1228 TEST(Run_Wasm_Loop_if_break_fallthru) {
1286 WasmRunner<int32_t> r(MachineType::Int32()); 1229 WasmRunner<int32_t> r(MachineType::Int32());
1287 BUILD(r, B1(WASM_LOOP(2, WASM_IF(WASM_GET_LOCAL(0), WASM_BREAK(1)), 1230 BUILD(r, B1(WASM_LOOP(2, WASM_IF(WASM_GET_LOCAL(0), WASM_BREAK(1)),
1288 WASM_SET_LOCAL(0, WASM_I8(93)))), 1231 WASM_SET_LOCAL(0, WASM_I8(93)))),
1289 WASM_GET_LOCAL(0)); 1232 WASM_GET_LOCAL(0));
1290 CHECK_EQ(93, r.Call(0)); 1233 CHECK_EQ(93, r.Call(0));
1291 CHECK_EQ(3, r.Call(3)); 1234 CHECK_EQ(3, r.Call(3));
1292 CHECK_EQ(10001, r.Call(10001)); 1235 CHECK_EQ(10001, r.Call(10001));
1293 CHECK_EQ(-22, r.Call(-22)); 1236 CHECK_EQ(-22, r.Call(-22));
1294 } 1237 }
(...skipping 27 matching lines...) Expand all
1322 memory[0] = 99999999; 1265 memory[0] = 99999999;
1323 CHECK_EQ(99999999, r.Call(0)); 1266 CHECK_EQ(99999999, r.Call(0));
1324 1267
1325 memory[0] = 88888888; 1268 memory[0] = 88888888;
1326 CHECK_EQ(88888888, r.Call(0)); 1269 CHECK_EQ(88888888, r.Call(0));
1327 1270
1328 memory[0] = 77777777; 1271 memory[0] = 77777777;
1329 CHECK_EQ(77777777, r.Call(0)); 1272 CHECK_EQ(77777777, r.Call(0));
1330 } 1273 }
1331 1274
1332
1333 TEST(Run_Wasm_LoadMemI32_oob) { 1275 TEST(Run_Wasm_LoadMemI32_oob) {
1334 TestingModule module; 1276 TestingModule module;
1335 int32_t* memory = module.AddMemoryElems<int32_t>(8); 1277 int32_t* memory = module.AddMemoryElems<int32_t>(8);
1336 WasmRunner<int32_t> r(&module, MachineType::Uint32()); 1278 WasmRunner<int32_t> r(&module, MachineType::Uint32());
1337 module.RandomizeMemory(1111); 1279 module.RandomizeMemory(1111);
1338 1280
1339 BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0))); 1281 BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0)));
1340 1282
1341 memory[0] = 88888888; 1283 memory[0] = 88888888;
1342 CHECK_EQ(88888888, r.Call(0u)); 1284 CHECK_EQ(88888888, r.Call(0u));
1343 for (uint32_t offset = 29; offset < 40; offset++) { 1285 for (uint32_t offset = 29; offset < 40; offset++) {
1344 CHECK_TRAP(r.Call(offset)); 1286 CHECK_TRAP(r.Call(offset));
1345 } 1287 }
1346 1288
1347 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) { 1289 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) {
1348 CHECK_TRAP(r.Call(offset)); 1290 CHECK_TRAP(r.Call(offset));
1349 } 1291 }
1350 } 1292 }
1351 1293
1352
1353 TEST(Run_Wasm_LoadMem_offset_oob) { 1294 TEST(Run_Wasm_LoadMem_offset_oob) {
1354 TestingModule module; 1295 TestingModule module;
1355 module.AddMemoryElems<int32_t>(8); 1296 module.AddMemoryElems<int32_t>(8);
1356 1297
1357 static const MachineType machineTypes[] = { 1298 static const MachineType machineTypes[] = {
1358 MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(), 1299 MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(),
1359 MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(), 1300 MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(),
1360 MachineType::Int64(), MachineType::Uint64(), MachineType::Float32(), 1301 MachineType::Int64(), MachineType::Uint64(), MachineType::Float32(),
1361 MachineType::Float64()}; 1302 MachineType::Float64()};
1362 1303
1363 for (size_t m = 0; m < arraysize(machineTypes); m++) { 1304 for (size_t m = 0; m < arraysize(machineTypes); m++) {
1364 module.RandomizeMemory(1116 + static_cast<int>(m)); 1305 module.RandomizeMemory(1116 + static_cast<int>(m));
1365 WasmRunner<int32_t> r(&module, MachineType::Uint32()); 1306 WasmRunner<int32_t> r(&module, MachineType::Uint32());
1366 uint32_t boundary = 24 - WasmOpcodes::MemSize(machineTypes[m]); 1307 uint32_t boundary = 24 - WasmOpcodes::MemSize(machineTypes[m]);
1367 1308
1368 BUILD(r, WASM_LOAD_MEM_OFFSET(machineTypes[m], 8, WASM_GET_LOCAL(0)), 1309 BUILD(r, WASM_LOAD_MEM_OFFSET(machineTypes[m], 8, WASM_GET_LOCAL(0)),
1369 WASM_ZERO); 1310 WASM_ZERO);
1370 1311
1371 CHECK_EQ(0, r.Call(boundary)); // in bounds. 1312 CHECK_EQ(0, r.Call(boundary)); // in bounds.
1372 1313
1373 for (uint32_t offset = boundary + 1; offset < boundary + 19; offset++) { 1314 for (uint32_t offset = boundary + 1; offset < boundary + 19; offset++) {
1374 CHECK_TRAP(r.Call(offset)); // out of bounds. 1315 CHECK_TRAP(r.Call(offset)); // out of bounds.
1375 } 1316 }
1376 } 1317 }
1377 } 1318 }
1378 1319
1379
1380 TEST(Run_Wasm_LoadMemI32_offset) { 1320 TEST(Run_Wasm_LoadMemI32_offset) {
1381 TestingModule module; 1321 TestingModule module;
1382 int32_t* memory = module.AddMemoryElems<int32_t>(4); 1322 int32_t* memory = module.AddMemoryElems<int32_t>(4);
1383 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1323 WasmRunner<int32_t> r(&module, MachineType::Int32());
1384 module.RandomizeMemory(1111); 1324 module.RandomizeMemory(1111);
1385 1325
1386 BUILD(r, WASM_LOAD_MEM_OFFSET(MachineType::Int32(), 4, WASM_GET_LOCAL(0))); 1326 BUILD(r, WASM_LOAD_MEM_OFFSET(MachineType::Int32(), 4, WASM_GET_LOCAL(0)));
1387 1327
1388 memory[0] = 66666666; 1328 memory[0] = 66666666;
1389 memory[1] = 77777777; 1329 memory[1] = 77777777;
1390 memory[2] = 88888888; 1330 memory[2] = 88888888;
1391 memory[3] = 99999999; 1331 memory[3] = 99999999;
1392 CHECK_EQ(77777777, r.Call(0)); 1332 CHECK_EQ(77777777, r.Call(0));
1393 CHECK_EQ(88888888, r.Call(4)); 1333 CHECK_EQ(88888888, r.Call(4));
1394 CHECK_EQ(99999999, r.Call(8)); 1334 CHECK_EQ(99999999, r.Call(8));
1395 1335
1396 memory[0] = 11111111; 1336 memory[0] = 11111111;
1397 memory[1] = 22222222; 1337 memory[1] = 22222222;
1398 memory[2] = 33333333; 1338 memory[2] = 33333333;
1399 memory[3] = 44444444; 1339 memory[3] = 44444444;
1400 CHECK_EQ(22222222, r.Call(0)); 1340 CHECK_EQ(22222222, r.Call(0));
1401 CHECK_EQ(33333333, r.Call(4)); 1341 CHECK_EQ(33333333, r.Call(4));
1402 CHECK_EQ(44444444, r.Call(8)); 1342 CHECK_EQ(44444444, r.Call(8));
1403 } 1343 }
1404 1344
1405
1406 #if !V8_TARGET_ARCH_MIPS && !V8_TARGET_ARCH_MIPS64 1345 #if !V8_TARGET_ARCH_MIPS && !V8_TARGET_ARCH_MIPS64
1407 1346
1408 TEST(Run_Wasm_LoadMemI32_const_oob_misaligned) { 1347 TEST(Run_Wasm_LoadMemI32_const_oob_misaligned) {
1409 const int kMemSize = 12; 1348 const int kMemSize = 12;
1410 // TODO(titzer): Fix misaligned accesses on MIPS and re-enable. 1349 // TODO(titzer): Fix misaligned accesses on MIPS and re-enable.
1411 for (int offset = 0; offset < kMemSize + 5; offset++) { 1350 for (int offset = 0; offset < kMemSize + 5; offset++) {
1412 for (int index = 0; index < kMemSize + 5; index++) { 1351 for (int index = 0; index < kMemSize + 5; index++) {
1413 TestingModule module; 1352 TestingModule module;
1414 module.AddMemoryElems<byte>(kMemSize); 1353 module.AddMemoryElems<byte>(kMemSize);
1415 1354
1416 WasmRunner<int32_t> r(&module); 1355 WasmRunner<int32_t> r(&module);
1417 module.RandomizeMemory(); 1356 module.RandomizeMemory();
1418 1357
1419 BUILD(r, 1358 BUILD(r,
1420 WASM_LOAD_MEM_OFFSET(MachineType::Int32(), offset, WASM_I8(index))); 1359 WASM_LOAD_MEM_OFFSET(MachineType::Int32(), offset, WASM_I8(index)));
1421 1360
1422 if ((offset + index) <= (kMemSize - sizeof(int32_t))) { 1361 if ((offset + index) <= (kMemSize - sizeof(int32_t))) {
1423 CHECK_EQ(module.raw_val_at<int32_t>(offset + index), r.Call()); 1362 CHECK_EQ(module.raw_val_at<int32_t>(offset + index), r.Call());
1424 } else { 1363 } else {
1425 CHECK_TRAP(r.Call()); 1364 CHECK_TRAP(r.Call());
1426 } 1365 }
1427 } 1366 }
1428 } 1367 }
1429 } 1368 }
1430 1369
1431 #endif 1370 #endif
1432 1371
1433
1434 TEST(Run_Wasm_LoadMemI32_const_oob) { 1372 TEST(Run_Wasm_LoadMemI32_const_oob) {
1435 const int kMemSize = 24; 1373 const int kMemSize = 24;
1436 for (int offset = 0; offset < kMemSize + 5; offset += 4) { 1374 for (int offset = 0; offset < kMemSize + 5; offset += 4) {
1437 for (int index = 0; index < kMemSize + 5; index += 4) { 1375 for (int index = 0; index < kMemSize + 5; index += 4) {
1438 TestingModule module; 1376 TestingModule module;
1439 module.AddMemoryElems<byte>(kMemSize); 1377 module.AddMemoryElems<byte>(kMemSize);
1440 1378
1441 WasmRunner<int32_t> r(&module); 1379 WasmRunner<int32_t> r(&module);
1442 module.RandomizeMemory(); 1380 module.RandomizeMemory();
1443 1381
1444 BUILD(r, 1382 BUILD(r,
1445 WASM_LOAD_MEM_OFFSET(MachineType::Int32(), offset, WASM_I8(index))); 1383 WASM_LOAD_MEM_OFFSET(MachineType::Int32(), offset, WASM_I8(index)));
1446 1384
1447 if ((offset + index) <= (kMemSize - sizeof(int32_t))) { 1385 if ((offset + index) <= (kMemSize - sizeof(int32_t))) {
1448 CHECK_EQ(module.raw_val_at<int32_t>(offset + index), r.Call()); 1386 CHECK_EQ(module.raw_val_at<int32_t>(offset + index), r.Call());
1449 } else { 1387 } else {
1450 CHECK_TRAP(r.Call()); 1388 CHECK_TRAP(r.Call());
1451 } 1389 }
1452 } 1390 }
1453 } 1391 }
1454 } 1392 }
1455 1393
1456
1457 TEST(Run_Wasm_StoreMemI32_offset) { 1394 TEST(Run_Wasm_StoreMemI32_offset) {
1458 TestingModule module; 1395 TestingModule module;
1459 int32_t* memory = module.AddMemoryElems<int32_t>(4); 1396 int32_t* memory = module.AddMemoryElems<int32_t>(4);
1460 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1397 WasmRunner<int32_t> r(&module, MachineType::Int32());
1461 const int32_t kWritten = 0xaabbccdd; 1398 const int32_t kWritten = 0xaabbccdd;
1462 1399
1463 BUILD(r, WASM_STORE_MEM_OFFSET(MachineType::Int32(), 4, WASM_GET_LOCAL(0), 1400 BUILD(r, WASM_STORE_MEM_OFFSET(MachineType::Int32(), 4, WASM_GET_LOCAL(0),
1464 WASM_I32V_5(kWritten))); 1401 WASM_I32V_5(kWritten)));
1465 1402
1466 for (int i = 0; i < 2; i++) { 1403 for (int i = 0; i < 2; i++) {
1467 module.RandomizeMemory(1111); 1404 module.RandomizeMemory(1111);
1468 memory[0] = 66666666; 1405 memory[0] = 66666666;
1469 memory[1] = 77777777; 1406 memory[1] = 77777777;
1470 memory[2] = 88888888; 1407 memory[2] = 88888888;
1471 memory[3] = 99999999; 1408 memory[3] = 99999999;
1472 CHECK_EQ(kWritten, r.Call(i * 4)); 1409 CHECK_EQ(kWritten, r.Call(i * 4));
1473 CHECK_EQ(66666666, memory[0]); 1410 CHECK_EQ(66666666, memory[0]);
1474 CHECK_EQ(i == 0 ? kWritten : 77777777, memory[1]); 1411 CHECK_EQ(i == 0 ? kWritten : 77777777, memory[1]);
1475 CHECK_EQ(i == 1 ? kWritten : 88888888, memory[2]); 1412 CHECK_EQ(i == 1 ? kWritten : 88888888, memory[2]);
1476 CHECK_EQ(i == 2 ? kWritten : 99999999, memory[3]); 1413 CHECK_EQ(i == 2 ? kWritten : 99999999, memory[3]);
1477 } 1414 }
1478 } 1415 }
1479 1416
1480
1481 TEST(Run_Wasm_StoreMem_offset_oob) { 1417 TEST(Run_Wasm_StoreMem_offset_oob) {
1482 TestingModule module; 1418 TestingModule module;
1483 byte* memory = module.AddMemoryElems<byte>(32); 1419 byte* memory = module.AddMemoryElems<byte>(32);
1484 1420
1485 #if WASM_64 1421 #if WASM_64
1486 static const MachineType machineTypes[] = { 1422 static const MachineType machineTypes[] = {
1487 MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(), 1423 MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(),
1488 MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(), 1424 MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(),
1489 MachineType::Int64(), MachineType::Uint64(), MachineType::Float32(), 1425 MachineType::Int64(), MachineType::Uint64(), MachineType::Float32(),
1490 MachineType::Float64()}; 1426 MachineType::Float64()};
(...skipping 16 matching lines...) Expand all
1507 uint32_t boundary = 24 - memsize; 1443 uint32_t boundary = 24 - memsize;
1508 CHECK_EQ(0, r.Call(boundary)); // in bounds. 1444 CHECK_EQ(0, r.Call(boundary)); // in bounds.
1509 CHECK_EQ(0, memcmp(&memory[0], &memory[8 + boundary], memsize)); 1445 CHECK_EQ(0, memcmp(&memory[0], &memory[8 + boundary], memsize));
1510 1446
1511 for (uint32_t offset = boundary + 1; offset < boundary + 19; offset++) { 1447 for (uint32_t offset = boundary + 1; offset < boundary + 19; offset++) {
1512 CHECK_TRAP(r.Call(offset)); // out of bounds. 1448 CHECK_TRAP(r.Call(offset)); // out of bounds.
1513 } 1449 }
1514 } 1450 }
1515 } 1451 }
1516 1452
1517
1518 TEST(Run_Wasm_LoadMemI32_P) { 1453 TEST(Run_Wasm_LoadMemI32_P) {
1519 const int kNumElems = 8; 1454 const int kNumElems = 8;
1520 TestingModule module; 1455 TestingModule module;
1521 int32_t* memory = module.AddMemoryElems<int32_t>(kNumElems); 1456 int32_t* memory = module.AddMemoryElems<int32_t>(kNumElems);
1522 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1457 WasmRunner<int32_t> r(&module, MachineType::Int32());
1523 module.RandomizeMemory(2222); 1458 module.RandomizeMemory(2222);
1524 1459
1525 BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0))); 1460 BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0)));
1526 1461
1527 for (int i = 0; i < kNumElems; i++) { 1462 for (int i = 0; i < kNumElems; i++) {
1528 CHECK_EQ(memory[i], r.Call(i * 4)); 1463 CHECK_EQ(memory[i], r.Call(i * 4));
1529 } 1464 }
1530 } 1465 }
1531 1466
1532
1533 TEST(Run_Wasm_MemI32_Sum) { 1467 TEST(Run_Wasm_MemI32_Sum) {
1534 const int kNumElems = 20; 1468 const int kNumElems = 20;
1535 TestingModule module; 1469 TestingModule module;
1536 uint32_t* memory = module.AddMemoryElems<uint32_t>(kNumElems); 1470 uint32_t* memory = module.AddMemoryElems<uint32_t>(kNumElems);
1537 WasmRunner<uint32_t> r(&module, MachineType::Int32()); 1471 WasmRunner<uint32_t> r(&module, MachineType::Int32());
1538 const byte kSum = r.AllocateLocal(kAstI32); 1472 const byte kSum = r.AllocateLocal(kAstI32);
1539 1473
1540 BUILD(r, WASM_BLOCK( 1474 BUILD(r, WASM_BLOCK(
1541 2, WASM_WHILE( 1475 2, WASM_WHILE(
1542 WASM_GET_LOCAL(0), 1476 WASM_GET_LOCAL(0),
(...skipping 12 matching lines...) Expand all
1555 module.RandomizeMemory(i * 33); 1489 module.RandomizeMemory(i * 33);
1556 uint32_t expected = 0; 1490 uint32_t expected = 0;
1557 for (size_t j = kNumElems - 1; j > 0; j--) { 1491 for (size_t j = kNumElems - 1; j > 0; j--) {
1558 expected += memory[j]; 1492 expected += memory[j];
1559 } 1493 }
1560 uint32_t result = r.Call(static_cast<int>(4 * (kNumElems - 1))); 1494 uint32_t result = r.Call(static_cast<int>(4 * (kNumElems - 1)));
1561 CHECK_EQ(expected, result); 1495 CHECK_EQ(expected, result);
1562 } 1496 }
1563 } 1497 }
1564 1498
1565
1566 TEST(Run_Wasm_CheckMachIntsZero) { 1499 TEST(Run_Wasm_CheckMachIntsZero) {
1567 const int kNumElems = 55; 1500 const int kNumElems = 55;
1568 TestingModule module; 1501 TestingModule module;
1569 module.AddMemoryElems<uint32_t>(kNumElems); 1502 module.AddMemoryElems<uint32_t>(kNumElems);
1570 WasmRunner<uint32_t> r(&module, MachineType::Int32()); 1503 WasmRunner<uint32_t> r(&module, MachineType::Int32());
1571 1504
1572 BUILD(r, kExprLoop, kExprGetLocal, 0, kExprIf, kExprGetLocal, 0, 1505 BUILD(r, kExprLoop, kExprGetLocal, 0, kExprIf, kExprGetLocal, 0,
1573 kExprI32LoadMem, 0, 0, kExprIf, kExprI8Const, 255, kExprReturn, ARITY_1, 1506 kExprI32LoadMem, 0, 0, kExprIf, kExprI8Const, 255, kExprReturn, ARITY_1,
1574 kExprEnd, kExprGetLocal, 0, kExprI8Const, 4, kExprI32Sub, kExprSetLocal, 1507 kExprEnd, kExprGetLocal, 0, kExprI8Const, 4, kExprI32Sub, kExprSetLocal,
1575 0, kExprBr, ARITY_1, DEPTH_0, kExprEnd, kExprEnd, kExprI8Const, 0); 1508 0, kExprBr, ARITY_1, DEPTH_0, kExprEnd, kExprEnd, kExprI8Const, 0);
1576 1509
1577 module.BlankMemory(); 1510 module.BlankMemory();
1578 CHECK_EQ(0, r.Call((kNumElems - 1) * 4)); 1511 CHECK_EQ(0, r.Call((kNumElems - 1) * 4));
1579 } 1512 }
1580 1513
1581
1582 TEST(Run_Wasm_MemF32_Sum) { 1514 TEST(Run_Wasm_MemF32_Sum) {
1583 const int kSize = 5; 1515 const int kSize = 5;
1584 TestingModule module; 1516 TestingModule module;
1585 module.AddMemoryElems<float>(kSize); 1517 module.AddMemoryElems<float>(kSize);
1586 float* buffer = module.raw_mem_start<float>(); 1518 float* buffer = module.raw_mem_start<float>();
1587 buffer[0] = -99.25; 1519 buffer[0] = -99.25;
1588 buffer[1] = -888.25; 1520 buffer[1] = -888.25;
1589 buffer[2] = -77.25; 1521 buffer[2] = -77.25;
1590 buffer[3] = 66666.25; 1522 buffer[3] = 66666.25;
1591 buffer[4] = 5555.25; 1523 buffer[4] = 5555.25;
(...skipping 13 matching lines...) Expand all
1605 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(4))))), 1537 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(4))))),
1606 WASM_STORE_MEM(MachineType::Float32(), WASM_ZERO, 1538 WASM_STORE_MEM(MachineType::Float32(), WASM_ZERO,
1607 WASM_GET_LOCAL(kSum)), 1539 WASM_GET_LOCAL(kSum)),
1608 WASM_GET_LOCAL(0))); 1540 WASM_GET_LOCAL(0)));
1609 1541
1610 CHECK_EQ(0, r.Call(4 * (kSize - 1))); 1542 CHECK_EQ(0, r.Call(4 * (kSize - 1)));
1611 CHECK_NE(-99.25, buffer[0]); 1543 CHECK_NE(-99.25, buffer[0]);
1612 CHECK_EQ(71256.0f, buffer[0]); 1544 CHECK_EQ(71256.0f, buffer[0]);
1613 } 1545 }
1614 1546
1615
1616 template <typename T> 1547 template <typename T>
1617 T GenerateAndRunFold(WasmOpcode binop, T* buffer, size_t size, 1548 T GenerateAndRunFold(WasmOpcode binop, T* buffer, size_t size,
1618 LocalType astType, MachineType memType) { 1549 LocalType astType, MachineType memType) {
1619 TestingModule module; 1550 TestingModule module;
1620 module.AddMemoryElems<T>(size); 1551 module.AddMemoryElems<T>(size);
1621 for (size_t i = 0; i < size; i++) { 1552 for (size_t i = 0; i < size; i++) {
1622 module.raw_mem_start<T>()[i] = buffer[i]; 1553 module.raw_mem_start<T>()[i] = buffer[i];
1623 } 1554 }
1624 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1555 WasmRunner<int32_t> r(&module, MachineType::Int32());
1625 const byte kAccum = r.AllocateLocal(astType); 1556 const byte kAccum = r.AllocateLocal(astType);
(...skipping 10 matching lines...) Expand all
1636 WASM_BINOP(binop, WASM_GET_LOCAL(kAccum), 1567 WASM_BINOP(binop, WASM_GET_LOCAL(kAccum),
1637 WASM_LOAD_MEM(memType, WASM_GET_LOCAL(0)))), 1568 WASM_LOAD_MEM(memType, WASM_GET_LOCAL(0)))),
1638 WASM_SET_LOCAL( 1569 WASM_SET_LOCAL(
1639 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(sizeof(T)))))), 1570 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(sizeof(T)))))),
1640 WASM_STORE_MEM(memType, WASM_ZERO, WASM_GET_LOCAL(kAccum)), 1571 WASM_STORE_MEM(memType, WASM_ZERO, WASM_GET_LOCAL(kAccum)),
1641 WASM_GET_LOCAL(0))); 1572 WASM_GET_LOCAL(0)));
1642 r.Call(static_cast<int>(sizeof(T) * (size - 1))); 1573 r.Call(static_cast<int>(sizeof(T) * (size - 1)));
1643 return module.raw_mem_at<double>(0); 1574 return module.raw_mem_at<double>(0);
1644 } 1575 }
1645 1576
1646
1647 TEST(Run_Wasm_MemF64_Mul) { 1577 TEST(Run_Wasm_MemF64_Mul) {
1648 const size_t kSize = 6; 1578 const size_t kSize = 6;
1649 double buffer[kSize] = {1, 2, 2, 2, 2, 2}; 1579 double buffer[kSize] = {1, 2, 2, 2, 2, 2};
1650 double result = GenerateAndRunFold<double>(kExprF64Mul, buffer, kSize, 1580 double result = GenerateAndRunFold<double>(kExprF64Mul, buffer, kSize,
1651 kAstF64, MachineType::Float64()); 1581 kAstF64, MachineType::Float64());
1652 CHECK_EQ(32, result); 1582 CHECK_EQ(32, result);
1653 } 1583 }
1654 1584
1655
1656 TEST(Build_Wasm_Infinite_Loop) { 1585 TEST(Build_Wasm_Infinite_Loop) {
1657 WasmRunner<int32_t> r(MachineType::Int32()); 1586 WasmRunner<int32_t> r(MachineType::Int32());
1658 // Only build the graph and compile, don't run. 1587 // Only build the graph and compile, don't run.
1659 BUILD(r, WASM_INFINITE_LOOP); 1588 BUILD(r, WASM_INFINITE_LOOP);
1660 } 1589 }
1661 1590
1662
1663 TEST(Build_Wasm_Infinite_Loop_effect) { 1591 TEST(Build_Wasm_Infinite_Loop_effect) {
1664 TestingModule module; 1592 TestingModule module;
1665 module.AddMemoryElems<int8_t>(16); 1593 module.AddMemoryElems<int8_t>(16);
1666 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1594 WasmRunner<int32_t> r(&module, MachineType::Int32());
1667 1595
1668 // Only build the graph and compile, don't run. 1596 // Only build the graph and compile, don't run.
1669 BUILD(r, WASM_LOOP(1, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO))); 1597 BUILD(r, WASM_LOOP(1, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)));
1670 } 1598 }
1671 1599
1672
1673 TEST(Run_Wasm_Unreachable0a) { 1600 TEST(Run_Wasm_Unreachable0a) {
1674 WasmRunner<int32_t> r(MachineType::Int32()); 1601 WasmRunner<int32_t> r(MachineType::Int32());
1675 BUILD(r, B2(WASM_BRV(0, WASM_I8(9)), RET(WASM_GET_LOCAL(0)))); 1602 BUILD(r, B2(WASM_BRV(0, WASM_I8(9)), RET(WASM_GET_LOCAL(0))));
1676 CHECK_EQ(9, r.Call(0)); 1603 CHECK_EQ(9, r.Call(0));
1677 CHECK_EQ(9, r.Call(1)); 1604 CHECK_EQ(9, r.Call(1));
1678 } 1605 }
1679 1606
1680
1681 TEST(Run_Wasm_Unreachable0b) { 1607 TEST(Run_Wasm_Unreachable0b) {
1682 WasmRunner<int32_t> r(MachineType::Int32()); 1608 WasmRunner<int32_t> r(MachineType::Int32());
1683 BUILD(r, B2(WASM_BRV(0, WASM_I8(7)), WASM_UNREACHABLE)); 1609 BUILD(r, B2(WASM_BRV(0, WASM_I8(7)), WASM_UNREACHABLE));
1684 CHECK_EQ(7, r.Call(0)); 1610 CHECK_EQ(7, r.Call(0));
1685 CHECK_EQ(7, r.Call(1)); 1611 CHECK_EQ(7, r.Call(1));
1686 } 1612 }
1687 1613
1688
1689 TEST(Build_Wasm_Unreachable1) { 1614 TEST(Build_Wasm_Unreachable1) {
1690 WasmRunner<int32_t> r(MachineType::Int32()); 1615 WasmRunner<int32_t> r(MachineType::Int32());
1691 BUILD(r, WASM_UNREACHABLE); 1616 BUILD(r, WASM_UNREACHABLE);
1692 } 1617 }
1693 1618
1694
1695 TEST(Build_Wasm_Unreachable2) { 1619 TEST(Build_Wasm_Unreachable2) {
1696 WasmRunner<int32_t> r(MachineType::Int32()); 1620 WasmRunner<int32_t> r(MachineType::Int32());
1697 BUILD(r, WASM_UNREACHABLE, WASM_UNREACHABLE); 1621 BUILD(r, WASM_UNREACHABLE, WASM_UNREACHABLE);
1698 } 1622 }
1699 1623
1700
1701 TEST(Build_Wasm_Unreachable3) { 1624 TEST(Build_Wasm_Unreachable3) {
1702 WasmRunner<int32_t> r(MachineType::Int32()); 1625 WasmRunner<int32_t> r(MachineType::Int32());
1703 BUILD(r, WASM_UNREACHABLE, WASM_UNREACHABLE, WASM_UNREACHABLE); 1626 BUILD(r, WASM_UNREACHABLE, WASM_UNREACHABLE, WASM_UNREACHABLE);
1704 } 1627 }
1705 1628
1706
1707 TEST(Build_Wasm_UnreachableIf1) { 1629 TEST(Build_Wasm_UnreachableIf1) {
1708 WasmRunner<int32_t> r(MachineType::Int32()); 1630 WasmRunner<int32_t> r(MachineType::Int32());
1709 BUILD(r, WASM_UNREACHABLE, WASM_IF(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0))); 1631 BUILD(r, WASM_UNREACHABLE, WASM_IF(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0)));
1710 } 1632 }
1711 1633
1712
1713 TEST(Build_Wasm_UnreachableIf2) { 1634 TEST(Build_Wasm_UnreachableIf2) {
1714 WasmRunner<int32_t> r(MachineType::Int32()); 1635 WasmRunner<int32_t> r(MachineType::Int32());
1715 BUILD(r, WASM_UNREACHABLE, 1636 BUILD(r, WASM_UNREACHABLE,
1716 WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_UNREACHABLE)); 1637 WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_UNREACHABLE));
1717 } 1638 }
1718 1639
1719
1720 TEST(Run_Wasm_Unreachable_Load) { 1640 TEST(Run_Wasm_Unreachable_Load) {
1721 WasmRunner<int32_t> r(MachineType::Int32()); 1641 WasmRunner<int32_t> r(MachineType::Int32());
1722 BUILD(r, B2(WASM_BRV(0, WASM_GET_LOCAL(0)), 1642 BUILD(r, B2(WASM_BRV(0, WASM_GET_LOCAL(0)),
1723 WASM_LOAD_MEM(MachineType::Int8(), WASM_GET_LOCAL(0)))); 1643 WASM_LOAD_MEM(MachineType::Int8(), WASM_GET_LOCAL(0))));
1724 CHECK_EQ(11, r.Call(11)); 1644 CHECK_EQ(11, r.Call(11));
1725 CHECK_EQ(21, r.Call(21)); 1645 CHECK_EQ(21, r.Call(21));
1726 } 1646 }
1727 1647
1728
1729 TEST(Run_Wasm_Infinite_Loop_not_taken1) { 1648 TEST(Run_Wasm_Infinite_Loop_not_taken1) {
1730 WasmRunner<int32_t> r(MachineType::Int32()); 1649 WasmRunner<int32_t> r(MachineType::Int32());
1731 BUILD(r, B2(WASM_IF(WASM_GET_LOCAL(0), WASM_INFINITE_LOOP), WASM_I8(45))); 1650 BUILD(r, B2(WASM_IF(WASM_GET_LOCAL(0), WASM_INFINITE_LOOP), WASM_I8(45)));
1732 // Run the code, but don't go into the infinite loop. 1651 // Run the code, but don't go into the infinite loop.
1733 CHECK_EQ(45, r.Call(0)); 1652 CHECK_EQ(45, r.Call(0));
1734 } 1653 }
1735 1654
1736
1737 TEST(Run_Wasm_Infinite_Loop_not_taken2) { 1655 TEST(Run_Wasm_Infinite_Loop_not_taken2) {
1738 WasmRunner<int32_t> r(MachineType::Int32()); 1656 WasmRunner<int32_t> r(MachineType::Int32());
1739 BUILD(r, B1(WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_BRV(1, WASM_I8(45)), 1657 BUILD(r, B1(WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_BRV(1, WASM_I8(45)),
1740 WASM_INFINITE_LOOP))); 1658 WASM_INFINITE_LOOP)));
1741 // Run the code, but don't go into the infinite loop. 1659 // Run the code, but don't go into the infinite loop.
1742 CHECK_EQ(45, r.Call(1)); 1660 CHECK_EQ(45, r.Call(1));
1743 } 1661 }
1744 1662
1745
1746 TEST(Run_Wasm_Infinite_Loop_not_taken2_brif) { 1663 TEST(Run_Wasm_Infinite_Loop_not_taken2_brif) {
1747 WasmRunner<int32_t> r(MachineType::Int32()); 1664 WasmRunner<int32_t> r(MachineType::Int32());
1748 BUILD(r, 1665 BUILD(r,
1749 B2(WASM_BRV_IF(0, WASM_I8(45), WASM_GET_LOCAL(0)), WASM_INFINITE_LOOP)); 1666 B2(WASM_BRV_IF(0, WASM_I8(45), WASM_GET_LOCAL(0)), WASM_INFINITE_LOOP));
1750 // Run the code, but don't go into the infinite loop. 1667 // Run the code, but don't go into the infinite loop.
1751 CHECK_EQ(45, r.Call(1)); 1668 CHECK_EQ(45, r.Call(1));
1752 } 1669 }
1753 1670
1754
1755 static void TestBuildGraphForSimpleExpression(WasmOpcode opcode) { 1671 static void TestBuildGraphForSimpleExpression(WasmOpcode opcode) {
1756 Isolate* isolate = CcTest::InitIsolateOnce(); 1672 Isolate* isolate = CcTest::InitIsolateOnce();
1757 Zone zone(isolate->allocator()); 1673 Zone zone(isolate->allocator());
1758 HandleScope scope(isolate); 1674 HandleScope scope(isolate);
1759 // Enable all optional operators. 1675 // Enable all optional operators.
1760 CommonOperatorBuilder common(&zone); 1676 CommonOperatorBuilder common(&zone);
1761 MachineOperatorBuilder machine(&zone, MachineType::PointerRepresentation(), 1677 MachineOperatorBuilder machine(&zone, MachineType::PointerRepresentation(),
1762 MachineOperatorBuilder::kAllOptionalOps); 1678 MachineOperatorBuilder::kAllOptionalOps);
1763 Graph graph(&zone); 1679 Graph graph(&zone);
1764 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); 1680 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine);
1765 FunctionSig* sig = WasmOpcodes::Signature(opcode); 1681 FunctionSig* sig = WasmOpcodes::Signature(opcode);
1766 1682
1767 if (sig->parameter_count() == 1) { 1683 if (sig->parameter_count() == 1) {
1768 byte code[] = {WASM_NO_LOCALS, kExprGetLocal, 0, static_cast<byte>(opcode)}; 1684 byte code[] = {WASM_NO_LOCALS, kExprGetLocal, 0, static_cast<byte>(opcode)};
1769 TestBuildingGraph(&zone, &jsgraph, nullptr, sig, nullptr, code, 1685 TestBuildingGraph(&zone, &jsgraph, nullptr, sig, nullptr, code,
1770 code + arraysize(code)); 1686 code + arraysize(code));
1771 } else { 1687 } else {
1772 CHECK_EQ(2, sig->parameter_count()); 1688 CHECK_EQ(2, sig->parameter_count());
1773 byte code[] = {WASM_NO_LOCALS, kExprGetLocal, 0, kExprGetLocal, 1, 1689 byte code[] = {WASM_NO_LOCALS, kExprGetLocal, 0, kExprGetLocal, 1,
1774 static_cast<byte>(opcode)}; 1690 static_cast<byte>(opcode)};
1775 TestBuildingGraph(&zone, &jsgraph, nullptr, sig, nullptr, code, 1691 TestBuildingGraph(&zone, &jsgraph, nullptr, sig, nullptr, code,
1776 code + arraysize(code)); 1692 code + arraysize(code));
1777 } 1693 }
1778 } 1694 }
1779 1695
1780
1781 TEST(Build_Wasm_SimpleExprs) { 1696 TEST(Build_Wasm_SimpleExprs) {
1782 // Test that the decoder can build a graph for all supported simple expressions. 1697 // Test that the decoder can build a graph for all supported simple expressions.
1783 #define GRAPH_BUILD_TEST(name, opcode, sig) \ 1698 #define GRAPH_BUILD_TEST(name, opcode, sig) \
1784 TestBuildGraphForSimpleExpression(kExpr##name); 1699 TestBuildGraphForSimpleExpression(kExpr##name);
1785 1700
1786 FOREACH_SIMPLE_OPCODE(GRAPH_BUILD_TEST); 1701 FOREACH_SIMPLE_OPCODE(GRAPH_BUILD_TEST);
1787 1702
1788 #undef GRAPH_BUILD_TEST 1703 #undef GRAPH_BUILD_TEST
1789 } 1704 }
1790 1705
1791
1792 TEST(Run_Wasm_Int32LoadInt8_signext) { 1706 TEST(Run_Wasm_Int32LoadInt8_signext) {
1793 TestingModule module; 1707 TestingModule module;
1794 const int kNumElems = 16; 1708 const int kNumElems = 16;
1795 int8_t* memory = module.AddMemoryElems<int8_t>(kNumElems); 1709 int8_t* memory = module.AddMemoryElems<int8_t>(kNumElems);
1796 module.RandomizeMemory(); 1710 module.RandomizeMemory();
1797 memory[0] = -1; 1711 memory[0] = -1;
1798 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1712 WasmRunner<int32_t> r(&module, MachineType::Int32());
1799 BUILD(r, WASM_LOAD_MEM(MachineType::Int8(), WASM_GET_LOCAL(0))); 1713 BUILD(r, WASM_LOAD_MEM(MachineType::Int8(), WASM_GET_LOCAL(0)));
1800 1714
1801 for (size_t i = 0; i < kNumElems; i++) { 1715 for (size_t i = 0; i < kNumElems; i++) {
1802 CHECK_EQ(memory[i], r.Call(static_cast<int>(i))); 1716 CHECK_EQ(memory[i], r.Call(static_cast<int>(i)));
1803 } 1717 }
1804 } 1718 }
1805 1719
1806
1807 TEST(Run_Wasm_Int32LoadInt8_zeroext) { 1720 TEST(Run_Wasm_Int32LoadInt8_zeroext) {
1808 TestingModule module; 1721 TestingModule module;
1809 const int kNumElems = 16; 1722 const int kNumElems = 16;
1810 byte* memory = module.AddMemory(kNumElems); 1723 byte* memory = module.AddMemory(kNumElems);
1811 module.RandomizeMemory(77); 1724 module.RandomizeMemory(77);
1812 memory[0] = 255; 1725 memory[0] = 255;
1813 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1726 WasmRunner<int32_t> r(&module, MachineType::Int32());
1814 BUILD(r, WASM_LOAD_MEM(MachineType::Uint8(), WASM_GET_LOCAL(0))); 1727 BUILD(r, WASM_LOAD_MEM(MachineType::Uint8(), WASM_GET_LOCAL(0)));
1815 1728
1816 for (size_t i = 0; i < kNumElems; i++) { 1729 for (size_t i = 0; i < kNumElems; i++) {
1817 CHECK_EQ(memory[i], r.Call(static_cast<int>(i))); 1730 CHECK_EQ(memory[i], r.Call(static_cast<int>(i)));
1818 } 1731 }
1819 } 1732 }
1820 1733
1821
1822 TEST(Run_Wasm_Int32LoadInt16_signext) { 1734 TEST(Run_Wasm_Int32LoadInt16_signext) {
1823 TestingModule module; 1735 TestingModule module;
1824 const int kNumBytes = 16; 1736 const int kNumBytes = 16;
1825 byte* memory = module.AddMemory(kNumBytes); 1737 byte* memory = module.AddMemory(kNumBytes);
1826 module.RandomizeMemory(888); 1738 module.RandomizeMemory(888);
1827 memory[1] = 200; 1739 memory[1] = 200;
1828 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1740 WasmRunner<int32_t> r(&module, MachineType::Int32());
1829 BUILD(r, WASM_LOAD_MEM(MachineType::Int16(), WASM_GET_LOCAL(0))); 1741 BUILD(r, WASM_LOAD_MEM(MachineType::Int16(), WASM_GET_LOCAL(0)));
1830 1742
1831 for (size_t i = 0; i < kNumBytes; i += 2) { 1743 for (size_t i = 0; i < kNumBytes; i += 2) {
1832 int32_t expected = memory[i] | (static_cast<int8_t>(memory[i + 1]) << 8); 1744 int32_t expected = memory[i] | (static_cast<int8_t>(memory[i + 1]) << 8);
1833 CHECK_EQ(expected, r.Call(static_cast<int>(i))); 1745 CHECK_EQ(expected, r.Call(static_cast<int>(i)));
1834 } 1746 }
1835 } 1747 }
1836 1748
1837
1838 TEST(Run_Wasm_Int32LoadInt16_zeroext) { 1749 TEST(Run_Wasm_Int32LoadInt16_zeroext) {
1839 TestingModule module; 1750 TestingModule module;
1840 const int kNumBytes = 16; 1751 const int kNumBytes = 16;
1841 byte* memory = module.AddMemory(kNumBytes); 1752 byte* memory = module.AddMemory(kNumBytes);
1842 module.RandomizeMemory(9999); 1753 module.RandomizeMemory(9999);
1843 memory[1] = 204; 1754 memory[1] = 204;
1844 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1755 WasmRunner<int32_t> r(&module, MachineType::Int32());
1845 BUILD(r, WASM_LOAD_MEM(MachineType::Uint16(), WASM_GET_LOCAL(0))); 1756 BUILD(r, WASM_LOAD_MEM(MachineType::Uint16(), WASM_GET_LOCAL(0)));
1846 1757
1847 for (size_t i = 0; i < kNumBytes; i += 2) { 1758 for (size_t i = 0; i < kNumBytes; i += 2) {
1848 int32_t expected = memory[i] | (memory[i + 1] << 8); 1759 int32_t expected = memory[i] | (memory[i + 1] << 8);
1849 CHECK_EQ(expected, r.Call(static_cast<int>(i))); 1760 CHECK_EQ(expected, r.Call(static_cast<int>(i)));
1850 } 1761 }
1851 } 1762 }
1852 1763
1853
1854 TEST(Run_WasmInt32Global) { 1764 TEST(Run_WasmInt32Global) {
1855 TestingModule module; 1765 TestingModule module;
1856 int32_t* global = module.AddGlobal<int32_t>(MachineType::Int32()); 1766 int32_t* global = module.AddGlobal<int32_t>(MachineType::Int32());
1857 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1767 WasmRunner<int32_t> r(&module, MachineType::Int32());
1858 // global = global + p0 1768 // global = global + p0
1859 BUILD(r, WASM_STORE_GLOBAL( 1769 BUILD(r, WASM_STORE_GLOBAL(
1860 0, WASM_I32_ADD(WASM_LOAD_GLOBAL(0), WASM_GET_LOCAL(0)))); 1770 0, WASM_I32_ADD(WASM_LOAD_GLOBAL(0), WASM_GET_LOCAL(0))));
1861 1771
1862 *global = 116; 1772 *global = 116;
1863 for (int i = 9; i < 444444; i += 111111) { 1773 for (int i = 9; i < 444444; i += 111111) {
1864 int32_t expected = *global + i; 1774 int32_t expected = *global + i;
1865 r.Call(i); 1775 r.Call(i);
1866 CHECK_EQ(expected, *global); 1776 CHECK_EQ(expected, *global);
1867 } 1777 }
1868 } 1778 }
1869 1779
1870
1871 TEST(Run_WasmInt32Globals_DontAlias) { 1780 TEST(Run_WasmInt32Globals_DontAlias) {
1872 const int kNumGlobals = 3; 1781 const int kNumGlobals = 3;
1873 TestingModule module; 1782 TestingModule module;
1874 int32_t* globals[] = {module.AddGlobal<int32_t>(MachineType::Int32()), 1783 int32_t* globals[] = {module.AddGlobal<int32_t>(MachineType::Int32()),
1875 module.AddGlobal<int32_t>(MachineType::Int32()), 1784 module.AddGlobal<int32_t>(MachineType::Int32()),
1876 module.AddGlobal<int32_t>(MachineType::Int32())}; 1785 module.AddGlobal<int32_t>(MachineType::Int32())};
1877 1786
1878 for (int g = 0; g < kNumGlobals; g++) { 1787 for (int g = 0; g < kNumGlobals; g++) {
1879 // global = global + p0 1788 // global = global + p0
1880 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1789 WasmRunner<int32_t> r(&module, MachineType::Int32());
1881 BUILD(r, WASM_STORE_GLOBAL( 1790 BUILD(r, WASM_STORE_GLOBAL(
1882 g, WASM_I32_ADD(WASM_LOAD_GLOBAL(g), WASM_GET_LOCAL(0)))); 1791 g, WASM_I32_ADD(WASM_LOAD_GLOBAL(g), WASM_GET_LOCAL(0))));
1883 1792
1884 // Check that reading/writing global number {g} doesn't alter the others. 1793 // Check that reading/writing global number {g} doesn't alter the others.
1885 *globals[g] = 116 * g; 1794 *globals[g] = 116 * g;
1886 int32_t before[kNumGlobals]; 1795 int32_t before[kNumGlobals];
1887 for (int i = 9; i < 444444; i += 111113) { 1796 for (int i = 9; i < 444444; i += 111113) {
1888 int32_t sum = *globals[g] + i; 1797 int32_t sum = *globals[g] + i;
1889 for (int j = 0; j < kNumGlobals; j++) before[j] = *globals[j]; 1798 for (int j = 0; j < kNumGlobals; j++) before[j] = *globals[j];
1890 r.Call(i); 1799 r.Call(i);
1891 for (int j = 0; j < kNumGlobals; j++) { 1800 for (int j = 0; j < kNumGlobals; j++) {
1892 int32_t expected = j == g ? sum : before[j]; 1801 int32_t expected = j == g ? sum : before[j];
1893 CHECK_EQ(expected, *globals[j]); 1802 CHECK_EQ(expected, *globals[j]);
1894 } 1803 }
1895 } 1804 }
1896 } 1805 }
1897 } 1806 }
1898 1807
1899
1900 TEST(Run_WasmFloat32Global) { 1808 TEST(Run_WasmFloat32Global) {
1901 TestingModule module; 1809 TestingModule module;
1902 float* global = module.AddGlobal<float>(MachineType::Float32()); 1810 float* global = module.AddGlobal<float>(MachineType::Float32());
1903 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1811 WasmRunner<int32_t> r(&module, MachineType::Int32());
1904 // global = global + p0 1812 // global = global + p0
1905 BUILD(r, B2(WASM_STORE_GLOBAL( 1813 BUILD(r, B2(WASM_STORE_GLOBAL(
1906 0, WASM_F32_ADD(WASM_LOAD_GLOBAL(0), 1814 0, WASM_F32_ADD(WASM_LOAD_GLOBAL(0),
1907 WASM_F32_SCONVERT_I32(WASM_GET_LOCAL(0)))), 1815 WASM_F32_SCONVERT_I32(WASM_GET_LOCAL(0)))),
1908 WASM_ZERO)); 1816 WASM_ZERO));
1909 1817
1910 *global = 1.25; 1818 *global = 1.25;
1911 for (int i = 9; i < 4444; i += 1111) { 1819 for (int i = 9; i < 4444; i += 1111) {
1912 volatile float expected = *global + i; 1820 volatile float expected = *global + i;
1913 r.Call(i); 1821 r.Call(i);
1914 CHECK_EQ(expected, *global); 1822 CHECK_EQ(expected, *global);
1915 } 1823 }
1916 } 1824 }
1917 1825
1918
1919 TEST(Run_WasmFloat64Global) { 1826 TEST(Run_WasmFloat64Global) {
1920 TestingModule module; 1827 TestingModule module;
1921 double* global = module.AddGlobal<double>(MachineType::Float64()); 1828 double* global = module.AddGlobal<double>(MachineType::Float64());
1922 WasmRunner<int32_t> r(&module, MachineType::Int32()); 1829 WasmRunner<int32_t> r(&module, MachineType::Int32());
1923 // global = global + p0 1830 // global = global + p0
1924 BUILD(r, B2(WASM_STORE_GLOBAL( 1831 BUILD(r, B2(WASM_STORE_GLOBAL(
1925 0, WASM_F64_ADD(WASM_LOAD_GLOBAL(0), 1832 0, WASM_F64_ADD(WASM_LOAD_GLOBAL(0),
1926 WASM_F64_SCONVERT_I32(WASM_GET_LOCAL(0)))), 1833 WASM_F64_SCONVERT_I32(WASM_GET_LOCAL(0)))),
1927 WASM_ZERO)); 1834 WASM_ZERO));
1928 1835
1929 *global = 1.25; 1836 *global = 1.25;
1930 for (int i = 9; i < 4444; i += 1111) { 1837 for (int i = 9; i < 4444; i += 1111) {
1931 volatile double expected = *global + i; 1838 volatile double expected = *global + i;
1932 r.Call(i); 1839 r.Call(i);
1933 CHECK_EQ(expected, *global); 1840 CHECK_EQ(expected, *global);
1934 } 1841 }
1935 } 1842 }
1936 1843
1937
1938 TEST(Run_WasmMixedGlobals) { 1844 TEST(Run_WasmMixedGlobals) {
1939 TestingModule module; 1845 TestingModule module;
1940 int32_t* unused = module.AddGlobal<int32_t>(MachineType::Int32()); 1846 int32_t* unused = module.AddGlobal<int32_t>(MachineType::Int32());
1941 byte* memory = module.AddMemory(32); 1847 byte* memory = module.AddMemory(32);
1942 1848
1943 int8_t* var_int8 = module.AddGlobal<int8_t>(MachineType::Int8()); 1849 int8_t* var_int8 = module.AddGlobal<int8_t>(MachineType::Int8());
1944 uint8_t* var_uint8 = module.AddGlobal<uint8_t>(MachineType::Uint8()); 1850 uint8_t* var_uint8 = module.AddGlobal<uint8_t>(MachineType::Uint8());
1945 int16_t* var_int16 = module.AddGlobal<int16_t>(MachineType::Int16()); 1851 int16_t* var_int16 = module.AddGlobal<int16_t>(MachineType::Int16());
1946 uint16_t* var_uint16 = module.AddGlobal<uint16_t>(MachineType::Uint16()); 1852 uint16_t* var_uint16 = module.AddGlobal<uint16_t>(MachineType::Uint16());
1947 int32_t* var_int32 = module.AddGlobal<int32_t>(MachineType::Int32()); 1853 int32_t* var_int32 = module.AddGlobal<int32_t>(MachineType::Int32());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 CHECK(static_cast<int16_t>(0xccaa) == *var_int16); 1888 CHECK(static_cast<int16_t>(0xccaa) == *var_int16);
1983 CHECK(static_cast<uint16_t>(0xccaa) == *var_uint16); 1889 CHECK(static_cast<uint16_t>(0xccaa) == *var_uint16);
1984 CHECK(static_cast<int32_t>(0xee55ccaa) == *var_int32); 1890 CHECK(static_cast<int32_t>(0xee55ccaa) == *var_int32);
1985 CHECK(static_cast<uint32_t>(0xee55ccaa) == *var_uint32); 1891 CHECK(static_cast<uint32_t>(0xee55ccaa) == *var_uint32);
1986 CHECK(bit_cast<float>(0xee55ccaa) == *var_float); 1892 CHECK(bit_cast<float>(0xee55ccaa) == *var_float);
1987 CHECK(bit_cast<double>(0x99112233ee55ccaaULL) == *var_double); 1893 CHECK(bit_cast<double>(0x99112233ee55ccaaULL) == *var_double);
1988 1894
1989 USE(unused); 1895 USE(unused);
1990 } 1896 }
1991 1897
1992
1993 TEST(Run_WasmCallEmpty) { 1898 TEST(Run_WasmCallEmpty) {
1994 const int32_t kExpected = -414444; 1899 const int32_t kExpected = -414444;
1995 // Build the target function. 1900 // Build the target function.
1996 TestSignatures sigs; 1901 TestSignatures sigs;
1997 TestingModule module; 1902 TestingModule module;
1998 WasmFunctionCompiler t(sigs.i_v(), &module); 1903 WasmFunctionCompiler t(sigs.i_v(), &module);
1999 BUILD(t, WASM_I32V_3(kExpected)); 1904 BUILD(t, WASM_I32V_3(kExpected));
2000 uint32_t index = t.CompileAndAdd(); 1905 uint32_t index = t.CompileAndAdd();
2001 1906
2002 // Build the calling function. 1907 // Build the calling function.
2003 WasmRunner<int32_t> r(&module); 1908 WasmRunner<int32_t> r(&module);
2004 BUILD(r, WASM_CALL_FUNCTION0(index)); 1909 BUILD(r, WASM_CALL_FUNCTION0(index));
2005 1910
2006 int32_t result = r.Call(); 1911 int32_t result = r.Call();
2007 CHECK_EQ(kExpected, result); 1912 CHECK_EQ(kExpected, result);
2008 } 1913 }
2009 1914
2010
2011 TEST(Run_WasmCallF32StackParameter) { 1915 TEST(Run_WasmCallF32StackParameter) {
2012 // Build the target function. 1916 // Build the target function.
2013 LocalType param_types[20]; 1917 LocalType param_types[20];
2014 for (int i = 0; i < 20; i++) param_types[i] = kAstF32; 1918 for (int i = 0; i < 20; i++) param_types[i] = kAstF32;
2015 FunctionSig sig(1, 19, param_types); 1919 FunctionSig sig(1, 19, param_types);
2016 TestingModule module; 1920 TestingModule module;
2017 WasmFunctionCompiler t(&sig, &module); 1921 WasmFunctionCompiler t(&sig, &module);
2018 BUILD(t, WASM_GET_LOCAL(17)); 1922 BUILD(t, WASM_GET_LOCAL(17));
2019 uint32_t index = t.CompileAndAdd(); 1923 uint32_t index = t.CompileAndAdd();
2020 1924
2021 // Build the calling function. 1925 // Build the calling function.
2022 WasmRunner<float> r(&module); 1926 WasmRunner<float> r(&module);
2023 BUILD(r, WASM_CALL_FUNCTIONN( 1927 BUILD(r, WASM_CALL_FUNCTIONN(
2024 19, index, WASM_F32(1.0f), WASM_F32(2.0f), WASM_F32(4.0f), 1928 19, index, WASM_F32(1.0f), WASM_F32(2.0f), WASM_F32(4.0f),
2025 WASM_F32(8.0f), WASM_F32(16.0f), WASM_F32(32.0f), 1929 WASM_F32(8.0f), WASM_F32(16.0f), WASM_F32(32.0f),
2026 WASM_F32(64.0f), WASM_F32(128.0f), WASM_F32(256.0f), 1930 WASM_F32(64.0f), WASM_F32(128.0f), WASM_F32(256.0f),
2027 WASM_F32(1.5f), WASM_F32(2.5f), WASM_F32(4.5f), WASM_F32(8.5f), 1931 WASM_F32(1.5f), WASM_F32(2.5f), WASM_F32(4.5f), WASM_F32(8.5f),
2028 WASM_F32(16.5f), WASM_F32(32.5f), WASM_F32(64.5f), 1932 WASM_F32(16.5f), WASM_F32(32.5f), WASM_F32(64.5f),
2029 WASM_F32(128.5f), WASM_F32(256.5f), WASM_F32(512.5f))); 1933 WASM_F32(128.5f), WASM_F32(256.5f), WASM_F32(512.5f)));
2030 1934
2031 float result = r.Call(); 1935 float result = r.Call();
2032 CHECK_EQ(256.5f, result); 1936 CHECK_EQ(256.5f, result);
2033 } 1937 }
2034 1938
2035
2036 TEST(Run_WasmCallF64StackParameter) { 1939 TEST(Run_WasmCallF64StackParameter) {
2037 // Build the target function. 1940 // Build the target function.
2038 LocalType param_types[20]; 1941 LocalType param_types[20];
2039 for (int i = 0; i < 20; i++) param_types[i] = kAstF64; 1942 for (int i = 0; i < 20; i++) param_types[i] = kAstF64;
2040 FunctionSig sig(1, 19, param_types); 1943 FunctionSig sig(1, 19, param_types);
2041 TestingModule module; 1944 TestingModule module;
2042 WasmFunctionCompiler t(&sig, &module); 1945 WasmFunctionCompiler t(&sig, &module);
2043 BUILD(t, WASM_GET_LOCAL(17)); 1946 BUILD(t, WASM_GET_LOCAL(17));
2044 uint32_t index = t.CompileAndAdd(); 1947 uint32_t index = t.CompileAndAdd();
2045 1948
(...skipping 28 matching lines...) Expand all
2074 // Build the calling function. 1977 // Build the calling function.
2075 WasmRunner<int32_t> r(&module); 1978 WasmRunner<int32_t> r(&module);
2076 BUILD(r, WASM_CALL_FUNCTION0(index), 1979 BUILD(r, WASM_CALL_FUNCTION0(index),
2077 WASM_LOAD_MEM(MachineType::Int32(), WASM_I8(kMemOffset))); 1980 WASM_LOAD_MEM(MachineType::Int32(), WASM_I8(kMemOffset)));
2078 1981
2079 int32_t result = r.Call(); 1982 int32_t result = r.Call();
2080 CHECK_EQ(kExpected, result); 1983 CHECK_EQ(kExpected, result);
2081 CHECK_EQ(kExpected, module.raw_mem_start<int32_t>()[kElemNum]); 1984 CHECK_EQ(kExpected, module.raw_mem_start<int32_t>()[kElemNum]);
2082 } 1985 }
2083 1986
2084
2085 TEST(Run_WasmCall_Int32Add) { 1987 TEST(Run_WasmCall_Int32Add) {
2086 // Build the target function. 1988 // Build the target function.
2087 TestSignatures sigs; 1989 TestSignatures sigs;
2088 TestingModule module; 1990 TestingModule module;
2089 WasmFunctionCompiler t(sigs.i_ii(), &module); 1991 WasmFunctionCompiler t(sigs.i_ii(), &module);
2090 BUILD(t, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 1992 BUILD(t, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2091 uint32_t index = t.CompileAndAdd(); 1993 uint32_t index = t.CompileAndAdd();
2092 1994
2093 // Build the caller function. 1995 // Build the caller function.
2094 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32()); 1996 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32());
(...skipping 19 matching lines...) Expand all
2114 2016
2115 // Builder the caller function. 2017 // Builder the caller function.
2116 WasmRunner<float> r(&module, MachineType::Float32(), MachineType::Float32()); 2018 WasmRunner<float> r(&module, MachineType::Float32(), MachineType::Float32());
2117 BUILD(r, WASM_CALL_FUNCTION2(index, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2019 BUILD(r, WASM_CALL_FUNCTION2(index, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2118 2020
2119 FOR_FLOAT32_INPUTS(i) { 2021 FOR_FLOAT32_INPUTS(i) {
2120 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i - *j, r.Call(*i, *j)); } 2022 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(*i - *j, r.Call(*i, *j)); }
2121 } 2023 }
2122 } 2024 }
2123 2025
2124
2125 TEST(Run_WasmCall_Float64Sub) { 2026 TEST(Run_WasmCall_Float64Sub) {
2126 TestingModule module; 2027 TestingModule module;
2127 double* memory = module.AddMemoryElems<double>(16); 2028 double* memory = module.AddMemoryElems<double>(16);
2128 WasmRunner<int32_t> r(&module); 2029 WasmRunner<int32_t> r(&module);
2129 2030
2130 BUILD(r, WASM_BLOCK( 2031 BUILD(r, WASM_BLOCK(
2131 2, WASM_STORE_MEM( 2032 2, WASM_STORE_MEM(
2132 MachineType::Float64(), WASM_ZERO, 2033 MachineType::Float64(), WASM_ZERO,
2133 WASM_F64_SUB( 2034 WASM_F64_SUB(
2134 WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO), 2035 WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO),
(...skipping 14 matching lines...) Expand all
2149 } 2050 }
2150 } 2051 }
2151 } 2052 }
2152 2053
2153 #define ADD_CODE(vec, ...) \ 2054 #define ADD_CODE(vec, ...) \
2154 do { \ 2055 do { \
2155 byte __buf[] = {__VA_ARGS__}; \ 2056 byte __buf[] = {__VA_ARGS__}; \
2156 for (size_t i = 0; i < sizeof(__buf); i++) vec.push_back(__buf[i]); \ 2057 for (size_t i = 0; i < sizeof(__buf); i++) vec.push_back(__buf[i]); \
2157 } while (false) 2058 } while (false)
2158 2059
2159
2160 static void Run_WasmMixedCall_N(int start) { 2060 static void Run_WasmMixedCall_N(int start) {
2161 const int kExpected = 6333; 2061 const int kExpected = 6333;
2162 const int kElemSize = 8; 2062 const int kElemSize = 8;
2163 TestSignatures sigs; 2063 TestSignatures sigs;
2164 2064
2165 #if WASM_64 2065 #if WASM_64
2166 static MachineType mixed[] = { 2066 static MachineType mixed[] = {
2167 MachineType::Int32(), MachineType::Float32(), MachineType::Int64(), 2067 MachineType::Int32(), MachineType::Float32(), MachineType::Int64(),
2168 MachineType::Float64(), MachineType::Float32(), MachineType::Int64(), 2068 MachineType::Float64(), MachineType::Float32(), MachineType::Int64(),
2169 MachineType::Int32(), MachineType::Float64(), MachineType::Float32(), 2069 MachineType::Int32(), MachineType::Float64(), MachineType::Float32(),
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2237 for (int i = 0; i < size; i++) { 2137 for (int i = 0; i < size; i++) {
2238 int base = (which + 1) * kElemSize; 2138 int base = (which + 1) * kElemSize;
2239 byte expected = module.raw_mem_at<byte>(base + i); 2139 byte expected = module.raw_mem_at<byte>(base + i);
2240 byte result = module.raw_mem_at<byte>(i); 2140 byte result = module.raw_mem_at<byte>(i);
2241 CHECK_EQ(expected, result); 2141 CHECK_EQ(expected, result);
2242 } 2142 }
2243 } 2143 }
2244 } 2144 }
2245 } 2145 }
2246 2146
2247
2248 TEST(Run_WasmMixedCall_0) { Run_WasmMixedCall_N(0); } 2147 TEST(Run_WasmMixedCall_0) { Run_WasmMixedCall_N(0); }
2249 TEST(Run_WasmMixedCall_1) { Run_WasmMixedCall_N(1); } 2148 TEST(Run_WasmMixedCall_1) { Run_WasmMixedCall_N(1); }
2250 TEST(Run_WasmMixedCall_2) { Run_WasmMixedCall_N(2); } 2149 TEST(Run_WasmMixedCall_2) { Run_WasmMixedCall_N(2); }
2251 TEST(Run_WasmMixedCall_3) { Run_WasmMixedCall_N(3); } 2150 TEST(Run_WasmMixedCall_3) { Run_WasmMixedCall_N(3); }
2252 2151
2253 TEST(Run_Wasm_AddCall) { 2152 TEST(Run_Wasm_AddCall) {
2254 TestSignatures sigs; 2153 TestSignatures sigs;
2255 TestingModule module; 2154 TestingModule module;
2256 WasmFunctionCompiler t1(sigs.i_ii(), &module); 2155 WasmFunctionCompiler t1(sigs.i_ii(), &module);
2257 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2156 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
(...skipping 18 matching lines...) Expand all
2276 BUILD(r, WASM_LOOP( 2175 BUILD(r, WASM_LOOP(
2277 3, WASM_IF(WASM_NOT(WASM_GET_LOCAL(0)), 2176 3, WASM_IF(WASM_NOT(WASM_GET_LOCAL(0)),
2278 WASM_BREAKV(1, WASM_GET_LOCAL(0))), 2177 WASM_BREAKV(1, WASM_GET_LOCAL(0))),
2279 WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(1))), 2178 WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I8(1))),
2280 WASM_CONTINUE(0))); 2179 WASM_CONTINUE(0)));
2281 CHECK_EQ(0, r.Call(1)); 2180 CHECK_EQ(0, r.Call(1));
2282 CHECK_EQ(0, r.Call(10)); 2181 CHECK_EQ(0, r.Call(10));
2283 CHECK_EQ(0, r.Call(100)); 2182 CHECK_EQ(0, r.Call(100));
2284 } 2183 }
2285 2184
2286
2287 TEST(Run_Wasm_ExprBlock2a) { 2185 TEST(Run_Wasm_ExprBlock2a) {
2288 WasmRunner<int32_t> r(MachineType::Int32()); 2186 WasmRunner<int32_t> r(MachineType::Int32());
2289 BUILD(r, B2(WASM_IF(WASM_GET_LOCAL(0), WASM_BRV(1, WASM_I8(1))), WASM_I8(1))); 2187 BUILD(r, B2(WASM_IF(WASM_GET_LOCAL(0), WASM_BRV(1, WASM_I8(1))), WASM_I8(1)));
2290 CHECK_EQ(1, r.Call(0)); 2188 CHECK_EQ(1, r.Call(0));
2291 CHECK_EQ(1, r.Call(1)); 2189 CHECK_EQ(1, r.Call(1));
2292 } 2190 }
2293 2191
2294
2295 TEST(Run_Wasm_ExprBlock2b) { 2192 TEST(Run_Wasm_ExprBlock2b) {
2296 WasmRunner<int32_t> r(MachineType::Int32()); 2193 WasmRunner<int32_t> r(MachineType::Int32());
2297 BUILD(r, B2(WASM_IF(WASM_GET_LOCAL(0), WASM_BRV(1, WASM_I8(1))), WASM_I8(2))); 2194 BUILD(r, B2(WASM_IF(WASM_GET_LOCAL(0), WASM_BRV(1, WASM_I8(1))), WASM_I8(2)));
2298 CHECK_EQ(2, r.Call(0)); 2195 CHECK_EQ(2, r.Call(0));
2299 CHECK_EQ(1, r.Call(1)); 2196 CHECK_EQ(1, r.Call(1));
2300 } 2197 }
2301 2198
2302
2303 TEST(Run_Wasm_ExprBlock2c) { 2199 TEST(Run_Wasm_ExprBlock2c) {
2304 WasmRunner<int32_t> r(MachineType::Int32()); 2200 WasmRunner<int32_t> r(MachineType::Int32());
2305 BUILD(r, B2(WASM_BRV_IF(0, WASM_I8(1), WASM_GET_LOCAL(0)), WASM_I8(1))); 2201 BUILD(r, B2(WASM_BRV_IF(0, WASM_I8(1), WASM_GET_LOCAL(0)), WASM_I8(1)));
2306 CHECK_EQ(1, r.Call(0)); 2202 CHECK_EQ(1, r.Call(0));
2307 CHECK_EQ(1, r.Call(1)); 2203 CHECK_EQ(1, r.Call(1));
2308 } 2204 }
2309 2205
2310
2311 TEST(Run_Wasm_ExprBlock2d) { 2206 TEST(Run_Wasm_ExprBlock2d) {
2312 WasmRunner<int32_t> r(MachineType::Int32()); 2207 WasmRunner<int32_t> r(MachineType::Int32());
2313 BUILD(r, B2(WASM_BRV_IF(0, WASM_I8(1), WASM_GET_LOCAL(0)), WASM_I8(2))); 2208 BUILD(r, B2(WASM_BRV_IF(0, WASM_I8(1), WASM_GET_LOCAL(0)), WASM_I8(2)));
2314 CHECK_EQ(2, r.Call(0)); 2209 CHECK_EQ(2, r.Call(0));
2315 CHECK_EQ(1, r.Call(1)); 2210 CHECK_EQ(1, r.Call(1));
2316 } 2211 }
2317 2212
2318
2319 TEST(Run_Wasm_ExprBlock_ManualSwitch) { 2213 TEST(Run_Wasm_ExprBlock_ManualSwitch) {
2320 WasmRunner<int32_t> r(MachineType::Int32()); 2214 WasmRunner<int32_t> r(MachineType::Int32());
2321 BUILD(r, WASM_BLOCK(6, WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(1)), 2215 BUILD(r, WASM_BLOCK(6, WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(1)),
2322 WASM_BRV(1, WASM_I8(11))), 2216 WASM_BRV(1, WASM_I8(11))),
2323 WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(2)), 2217 WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(2)),
2324 WASM_BRV(1, WASM_I8(12))), 2218 WASM_BRV(1, WASM_I8(12))),
2325 WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(3)), 2219 WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(3)),
2326 WASM_BRV(1, WASM_I8(13))), 2220 WASM_BRV(1, WASM_I8(13))),
2327 WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(4)), 2221 WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(4)),
2328 WASM_BRV(1, WASM_I8(14))), 2222 WASM_BRV(1, WASM_I8(14))),
2329 WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(5)), 2223 WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(5)),
2330 WASM_BRV(1, WASM_I8(15))), 2224 WASM_BRV(1, WASM_I8(15))),
2331 WASM_I8(99))); 2225 WASM_I8(99)));
2332 CHECK_EQ(99, r.Call(0)); 2226 CHECK_EQ(99, r.Call(0));
2333 CHECK_EQ(11, r.Call(1)); 2227 CHECK_EQ(11, r.Call(1));
2334 CHECK_EQ(12, r.Call(2)); 2228 CHECK_EQ(12, r.Call(2));
2335 CHECK_EQ(13, r.Call(3)); 2229 CHECK_EQ(13, r.Call(3));
2336 CHECK_EQ(14, r.Call(4)); 2230 CHECK_EQ(14, r.Call(4));
2337 CHECK_EQ(15, r.Call(5)); 2231 CHECK_EQ(15, r.Call(5));
2338 CHECK_EQ(99, r.Call(6)); 2232 CHECK_EQ(99, r.Call(6));
2339 } 2233 }
2340 2234
2341
2342 TEST(Run_Wasm_ExprBlock_ManualSwitch_brif) { 2235 TEST(Run_Wasm_ExprBlock_ManualSwitch_brif) {
2343 WasmRunner<int32_t> r(MachineType::Int32()); 2236 WasmRunner<int32_t> r(MachineType::Int32());
2344 BUILD(r, 2237 BUILD(r,
2345 WASM_BLOCK(6, WASM_BRV_IF(0, WASM_I8(11), 2238 WASM_BLOCK(6, WASM_BRV_IF(0, WASM_I8(11),
2346 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(1))), 2239 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(1))),
2347 WASM_BRV_IF(0, WASM_I8(12), 2240 WASM_BRV_IF(0, WASM_I8(12),
2348 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(2))), 2241 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(2))),
2349 WASM_BRV_IF(0, WASM_I8(13), 2242 WASM_BRV_IF(0, WASM_I8(13),
2350 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(3))), 2243 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(3))),
2351 WASM_BRV_IF(0, WASM_I8(14), 2244 WASM_BRV_IF(0, WASM_I8(14),
2352 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(4))), 2245 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(4))),
2353 WASM_BRV_IF(0, WASM_I8(15), 2246 WASM_BRV_IF(0, WASM_I8(15),
2354 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(5))), 2247 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(5))),
2355 WASM_I8(99))); 2248 WASM_I8(99)));
2356 CHECK_EQ(99, r.Call(0)); 2249 CHECK_EQ(99, r.Call(0));
2357 CHECK_EQ(11, r.Call(1)); 2250 CHECK_EQ(11, r.Call(1));
2358 CHECK_EQ(12, r.Call(2)); 2251 CHECK_EQ(12, r.Call(2));
2359 CHECK_EQ(13, r.Call(3)); 2252 CHECK_EQ(13, r.Call(3));
2360 CHECK_EQ(14, r.Call(4)); 2253 CHECK_EQ(14, r.Call(4));
2361 CHECK_EQ(15, r.Call(5)); 2254 CHECK_EQ(15, r.Call(5));
2362 CHECK_EQ(99, r.Call(6)); 2255 CHECK_EQ(99, r.Call(6));
2363 } 2256 }
2364 2257
2365
2366 TEST(Run_Wasm_nested_ifs) { 2258 TEST(Run_Wasm_nested_ifs) {
2367 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); 2259 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32());
2368 2260
2369 BUILD(r, WASM_IF_ELSE( 2261 BUILD(r, WASM_IF_ELSE(
2370 WASM_GET_LOCAL(0), 2262 WASM_GET_LOCAL(0),
2371 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_I8(11), WASM_I8(12)), 2263 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_I8(11), WASM_I8(12)),
2372 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_I8(13), WASM_I8(14)))); 2264 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_I8(13), WASM_I8(14))));
2373 2265
2374
2375 CHECK_EQ(11, r.Call(1, 1)); 2266 CHECK_EQ(11, r.Call(1, 1));
2376 CHECK_EQ(12, r.Call(1, 0)); 2267 CHECK_EQ(12, r.Call(1, 0));
2377 CHECK_EQ(13, r.Call(0, 1)); 2268 CHECK_EQ(13, r.Call(0, 1));
2378 CHECK_EQ(14, r.Call(0, 0)); 2269 CHECK_EQ(14, r.Call(0, 0));
2379 } 2270 }
2380 2271
2381
2382 TEST(Run_Wasm_ExprBlock_if) { 2272 TEST(Run_Wasm_ExprBlock_if) {
2383 WasmRunner<int32_t> r(MachineType::Int32()); 2273 WasmRunner<int32_t> r(MachineType::Int32());
2384 2274
2385 BUILD(r, B1(WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_BRV(0, WASM_I8(11)), 2275 BUILD(r, B1(WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_BRV(0, WASM_I8(11)),
2386 WASM_BRV(1, WASM_I8(14))))); 2276 WASM_BRV(1, WASM_I8(14)))));
2387 2277
2388 CHECK_EQ(11, r.Call(1)); 2278 CHECK_EQ(11, r.Call(1));
2389 CHECK_EQ(14, r.Call(0)); 2279 CHECK_EQ(14, r.Call(0));
2390 } 2280 }
2391 2281
2392
2393 TEST(Run_Wasm_ExprBlock_nested_ifs) { 2282 TEST(Run_Wasm_ExprBlock_nested_ifs) {
2394 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); 2283 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32());
2395 2284
2396 BUILD(r, WASM_BLOCK( 2285 BUILD(r, WASM_BLOCK(
2397 1, WASM_IF_ELSE( 2286 1, WASM_IF_ELSE(
2398 WASM_GET_LOCAL(0), 2287 WASM_GET_LOCAL(0),
2399 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(0, WASM_I8(11)), 2288 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(0, WASM_I8(11)),
2400 WASM_BRV(1, WASM_I8(12))), 2289 WASM_BRV(1, WASM_I8(12))),
2401 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(0, WASM_I8(13)), 2290 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(0, WASM_I8(13)),
2402 WASM_BRV(1, WASM_I8(14)))))); 2291 WASM_BRV(1, WASM_I8(14))))));
2403 2292
2404 CHECK_EQ(11, r.Call(1, 1)); 2293 CHECK_EQ(11, r.Call(1, 1));
2405 CHECK_EQ(12, r.Call(1, 0)); 2294 CHECK_EQ(12, r.Call(1, 0));
2406 CHECK_EQ(13, r.Call(0, 1)); 2295 CHECK_EQ(13, r.Call(0, 1));
2407 CHECK_EQ(14, r.Call(0, 0)); 2296 CHECK_EQ(14, r.Call(0, 0));
2408 } 2297 }
2409 2298
2410
2411 TEST(Run_Wasm_ExprLoop_nested_ifs) { 2299 TEST(Run_Wasm_ExprLoop_nested_ifs) {
2412 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); 2300 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32());
2413 2301
2414 BUILD(r, WASM_LOOP( 2302 BUILD(r, WASM_LOOP(
2415 1, WASM_IF_ELSE( 2303 1, WASM_IF_ELSE(
2416 WASM_GET_LOCAL(0), 2304 WASM_GET_LOCAL(0),
2417 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(1, WASM_I8(11)), 2305 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(1, WASM_I8(11)),
2418 WASM_BRV(3, WASM_I8(12))), 2306 WASM_BRV(3, WASM_I8(12))),
2419 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(1, WASM_I8(13)), 2307 WASM_IF_ELSE(WASM_GET_LOCAL(1), WASM_BRV(1, WASM_I8(13)),
2420 WASM_BRV(3, WASM_I8(14)))))); 2308 WASM_BRV(3, WASM_I8(14))))));
(...skipping 28 matching lines...) Expand all
2449 2337
2450 // Builder the caller function. 2338 // Builder the caller function.
2451 WasmRunner<int32_t> r(&module, MachineType::Int32()); 2339 WasmRunner<int32_t> r(&module, MachineType::Int32());
2452 BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I8(66), WASM_I8(22))); 2340 BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I8(66), WASM_I8(22)));
2453 2341
2454 CHECK_EQ(88, r.Call(0)); 2342 CHECK_EQ(88, r.Call(0));
2455 CHECK_EQ(44, r.Call(1)); 2343 CHECK_EQ(44, r.Call(1));
2456 CHECK_TRAP(r.Call(2)); 2344 CHECK_TRAP(r.Call(2));
2457 } 2345 }
2458 2346
2459
2460 TEST(Run_Wasm_MultipleCallIndirect) { 2347 TEST(Run_Wasm_MultipleCallIndirect) {
2461 TestSignatures sigs; 2348 TestSignatures sigs;
2462 TestingModule module; 2349 TestingModule module;
2463 2350
2464 WasmFunctionCompiler t1(sigs.i_ii(), &module); 2351 WasmFunctionCompiler t1(sigs.i_ii(), &module);
2465 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2352 BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2466 t1.CompileAndAdd(/*sig_index*/ 1); 2353 t1.CompileAndAdd(/*sig_index*/ 1);
2467 2354
2468 WasmFunctionCompiler t2(sigs.i_ii(), &module); 2355 WasmFunctionCompiler t2(sigs.i_ii(), &module);
2469 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2356 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
2593 expected = *i; 2480 expected = *i;
2594 } else { 2481 } else {
2595 expected = *j; 2482 expected = *j;
2596 } 2483 }
2597 2484
2598 CHECK_FLOAT_EQ(expected, r.Call(*i, *j)); 2485 CHECK_FLOAT_EQ(expected, r.Call(*i, *j));
2599 } 2486 }
2600 } 2487 }
2601 } 2488 }
2602 2489
2603
2604 TEST(Run_Wasm_F64Min) { 2490 TEST(Run_Wasm_F64Min) {
2605 WasmRunner<double> r(MachineType::Float64(), MachineType::Float64()); 2491 WasmRunner<double> r(MachineType::Float64(), MachineType::Float64());
2606 BUILD(r, WASM_F64_MIN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2492 BUILD(r, WASM_F64_MIN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2607 2493
2608 FOR_FLOAT64_INPUTS(i) { 2494 FOR_FLOAT64_INPUTS(i) {
2609 FOR_FLOAT64_INPUTS(j) { 2495 FOR_FLOAT64_INPUTS(j) {
2610 double expected; 2496 double expected;
2611 if (*i < *j) { 2497 if (*i < *j) {
2612 expected = *i; 2498 expected = *i;
2613 } else if (*j < *i) { 2499 } else if (*j < *i) {
2614 expected = *j; 2500 expected = *j;
2615 } else if (*i != *i) { 2501 } else if (*i != *i) {
2616 // If *i or *j is NaN, then the result is NaN. 2502 // If *i or *j is NaN, then the result is NaN.
2617 expected = *i; 2503 expected = *i;
2618 } else { 2504 } else {
2619 expected = *j; 2505 expected = *j;
2620 } 2506 }
2621 2507
2622 CHECK_DOUBLE_EQ(expected, r.Call(*i, *j)); 2508 CHECK_DOUBLE_EQ(expected, r.Call(*i, *j));
2623 } 2509 }
2624 } 2510 }
2625 } 2511 }
2626 2512
2627
2628 TEST(Run_Wasm_F32Max) { 2513 TEST(Run_Wasm_F32Max) {
2629 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); 2514 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32());
2630 BUILD(r, WASM_F32_MAX(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2515 BUILD(r, WASM_F32_MAX(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2631 2516
2632 FOR_FLOAT32_INPUTS(i) { 2517 FOR_FLOAT32_INPUTS(i) {
2633 FOR_FLOAT32_INPUTS(j) { 2518 FOR_FLOAT32_INPUTS(j) {
2634 float expected; 2519 float expected;
2635 if (*i > *j) { 2520 if (*i > *j) {
2636 expected = *i; 2521 expected = *i;
2637 } else if (*j > *i) { 2522 } else if (*j > *i) {
2638 expected = *j; 2523 expected = *j;
2639 } else if (*i != *i) { 2524 } else if (*i != *i) {
2640 // If *i or *j is NaN, then the result is NaN. 2525 // If *i or *j is NaN, then the result is NaN.
2641 expected = *i; 2526 expected = *i;
2642 } else { 2527 } else {
2643 expected = *j; 2528 expected = *j;
2644 } 2529 }
2645 2530
2646 CHECK_FLOAT_EQ(expected, r.Call(*i, *j)); 2531 CHECK_FLOAT_EQ(expected, r.Call(*i, *j));
2647 } 2532 }
2648 } 2533 }
2649 } 2534 }
2650 2535
2651
2652 TEST(Run_Wasm_F64Max) { 2536 TEST(Run_Wasm_F64Max) {
2653 WasmRunner<double> r(MachineType::Float64(), MachineType::Float64()); 2537 WasmRunner<double> r(MachineType::Float64(), MachineType::Float64());
2654 BUILD(r, WASM_F64_MAX(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2538 BUILD(r, WASM_F64_MAX(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2655 2539
2656 FOR_FLOAT64_INPUTS(i) { 2540 FOR_FLOAT64_INPUTS(i) {
2657 FOR_FLOAT64_INPUTS(j) { 2541 FOR_FLOAT64_INPUTS(j) {
2658 double expected; 2542 double expected;
2659 if (*i > *j) { 2543 if (*i > *j) {
2660 expected = *i; 2544 expected = *i;
2661 } else if (*j > *i) { 2545 } else if (*j > *i) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2748 FOR_FLOAT32_INPUTS(i) { 2632 FOR_FLOAT32_INPUTS(i) {
2749 if (*i < static_cast<float>(INT32_MAX) && 2633 if (*i < static_cast<float>(INT32_MAX) &&
2750 *i >= static_cast<float>(INT32_MIN)) { 2634 *i >= static_cast<float>(INT32_MIN)) {
2751 CHECK_EQ(static_cast<int32_t>(*i), r.Call(*i)); 2635 CHECK_EQ(static_cast<int32_t>(*i), r.Call(*i));
2752 } else { 2636 } else {
2753 CHECK_TRAP32(r.Call(*i)); 2637 CHECK_TRAP32(r.Call(*i));
2754 } 2638 }
2755 } 2639 }
2756 } 2640 }
2757 2641
2758
2759 TEST(Run_Wasm_I32SConvertF64) { 2642 TEST(Run_Wasm_I32SConvertF64) {
2760 WasmRunner<int32_t> r(MachineType::Float64()); 2643 WasmRunner<int32_t> r(MachineType::Float64());
2761 BUILD(r, WASM_I32_SCONVERT_F64(WASM_GET_LOCAL(0))); 2644 BUILD(r, WASM_I32_SCONVERT_F64(WASM_GET_LOCAL(0)));
2762 2645
2763 FOR_FLOAT64_INPUTS(i) { 2646 FOR_FLOAT64_INPUTS(i) {
2764 if (*i < (static_cast<double>(INT32_MAX) + 1.0) && 2647 if (*i < (static_cast<double>(INT32_MAX) + 1.0) &&
2765 *i > (static_cast<double>(INT32_MIN) - 1.0)) { 2648 *i > (static_cast<double>(INT32_MIN) - 1.0)) {
2766 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); 2649 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i));
2767 } else { 2650 } else {
2768 CHECK_TRAP32(r.Call(*i)); 2651 CHECK_TRAP32(r.Call(*i));
2769 } 2652 }
2770 } 2653 }
2771 } 2654 }
2772 2655
2773
2774 TEST(Run_Wasm_I32UConvertF32) { 2656 TEST(Run_Wasm_I32UConvertF32) {
2775 WasmRunner<uint32_t> r(MachineType::Float32()); 2657 WasmRunner<uint32_t> r(MachineType::Float32());
2776 BUILD(r, WASM_I32_UCONVERT_F32(WASM_GET_LOCAL(0))); 2658 BUILD(r, WASM_I32_UCONVERT_F32(WASM_GET_LOCAL(0)));
2777 2659
2778 FOR_FLOAT32_INPUTS(i) { 2660 FOR_FLOAT32_INPUTS(i) {
2779 if (*i < (static_cast<float>(UINT32_MAX) + 1.0) && *i > -1) { 2661 if (*i < (static_cast<float>(UINT32_MAX) + 1.0) && *i > -1) {
2780 CHECK_EQ(static_cast<uint32_t>(*i), r.Call(*i)); 2662 CHECK_EQ(static_cast<uint32_t>(*i), r.Call(*i));
2781 } else { 2663 } else {
2782 CHECK_TRAP32(r.Call(*i)); 2664 CHECK_TRAP32(r.Call(*i));
2783 } 2665 }
2784 } 2666 }
2785 } 2667 }
2786 2668
2787
2788 TEST(Run_Wasm_I32UConvertF64) { 2669 TEST(Run_Wasm_I32UConvertF64) {
2789 WasmRunner<uint32_t> r(MachineType::Float64()); 2670 WasmRunner<uint32_t> r(MachineType::Float64());
2790 BUILD(r, WASM_I32_UCONVERT_F64(WASM_GET_LOCAL(0))); 2671 BUILD(r, WASM_I32_UCONVERT_F64(WASM_GET_LOCAL(0)));
2791 2672
2792 FOR_FLOAT64_INPUTS(i) { 2673 FOR_FLOAT64_INPUTS(i) {
2793 if (*i < (static_cast<float>(UINT32_MAX) + 1.0) && *i > -1) { 2674 if (*i < (static_cast<float>(UINT32_MAX) + 1.0) && *i > -1) {
2794 CHECK_EQ(static_cast<uint32_t>(*i), r.Call(*i)); 2675 CHECK_EQ(static_cast<uint32_t>(*i), r.Call(*i));
2795 } else { 2676 } else {
2796 CHECK_TRAP32(r.Call(*i)); 2677 CHECK_TRAP32(r.Call(*i));
2797 } 2678 }
2798 } 2679 }
2799 } 2680 }
2800 2681
2801 TEST(Run_Wasm_F64CopySign) { 2682 TEST(Run_Wasm_F64CopySign) {
2802 WasmRunner<double> r(MachineType::Float64(), MachineType::Float64()); 2683 WasmRunner<double> r(MachineType::Float64(), MachineType::Float64());
2803 BUILD(r, WASM_F64_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2684 BUILD(r, WASM_F64_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2804 2685
2805 FOR_FLOAT64_INPUTS(i) { 2686 FOR_FLOAT64_INPUTS(i) {
2806 FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(copysign(*i, *j), r.Call(*i, *j)); } 2687 FOR_FLOAT64_INPUTS(j) { CHECK_DOUBLE_EQ(copysign(*i, *j), r.Call(*i, *j)); }
2807 } 2688 }
2808 } 2689 }
2809 2690
2810
2811 TEST(Run_Wasm_F32CopySign) { 2691 TEST(Run_Wasm_F32CopySign) {
2812 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); 2692 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32());
2813 BUILD(r, WASM_F32_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 2693 BUILD(r, WASM_F32_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
2814 2694
2815 FOR_FLOAT32_INPUTS(i) { 2695 FOR_FLOAT32_INPUTS(i) {
2816 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(copysignf(*i, *j), r.Call(*i, *j)); } 2696 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(copysignf(*i, *j), r.Call(*i, *j)); }
2817 } 2697 }
2818 } 2698 }
2819 2699
2820 void CompileCallIndirectMany(LocalType param) { 2700 void CompileCallIndirectMany(LocalType param) {
(...skipping 18 matching lines...) Expand all
2839 for (byte p = 0; p < num_params; p++) { 2719 for (byte p = 0; p < num_params; p++) {
2840 ADD_CODE(code, kExprGetLocal, p); 2720 ADD_CODE(code, kExprGetLocal, p);
2841 } 2721 }
2842 ADD_CODE(code, kExprCallIndirect, static_cast<byte>(num_params), 1); 2722 ADD_CODE(code, kExprCallIndirect, static_cast<byte>(num_params), 1);
2843 2723
2844 t.Build(&code[0], &code[0] + code.size()); 2724 t.Build(&code[0], &code[0] + code.size());
2845 t.Compile(); 2725 t.Compile();
2846 } 2726 }
2847 } 2727 }
2848 2728
2849
2850 TEST(Compile_Wasm_CallIndirect_Many_i32) { CompileCallIndirectMany(kAstI32); } 2729 TEST(Compile_Wasm_CallIndirect_Many_i32) { CompileCallIndirectMany(kAstI32); }
2851 2730
2852
2853 #if WASM_64 2731 #if WASM_64
2854 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } 2732 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); }
2855 #endif 2733 #endif
2856 2734
2857
2858 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } 2735 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); }
2859 2736
2860
2861 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } 2737 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); }
2862 2738
2863 TEST(Run_WASM_Int32RemS_dead) { 2739 TEST(Run_WASM_Int32RemS_dead) {
2864 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); 2740 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32());
2865 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_ZERO); 2741 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_ZERO);
2866 const int32_t kMin = std::numeric_limits<int32_t>::min(); 2742 const int32_t kMin = std::numeric_limits<int32_t>::min();
2867 CHECK_EQ(0, r.Call(133, 100)); 2743 CHECK_EQ(0, r.Call(133, 100));
2868 CHECK_EQ(0, r.Call(kMin, -1)); 2744 CHECK_EQ(0, r.Call(kMin, -1));
2869 CHECK_EQ(0, r.Call(0, 1)); 2745 CHECK_EQ(0, r.Call(0, 1));
2870 CHECK_TRAP(r.Call(100, 0)); 2746 CHECK_TRAP(r.Call(100, 0));
2871 CHECK_TRAP(r.Call(-1001, 0)); 2747 CHECK_TRAP(r.Call(-1001, 0));
2872 CHECK_TRAP(r.Call(kMin, 0)); 2748 CHECK_TRAP(r.Call(kMin, 0));
2873 } 2749 }
OLDNEW
« no previous file with comments | « src/wasm/wasm-result.cc ('k') | test/cctest/wasm/test-run-wasm-js.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698