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

Side by Side Diff: test/mjsunit/wasm/import-table.js

Issue 2594993002: [wasm] Rename wasm::LocalType to wasm::ValueType and kAst* to kWasm* (Closed)
Patch Set: Fix inspector tests Created 3 years, 12 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 | « test/mjsunit/wasm/globals.js ('k') | test/mjsunit/wasm/indirect-calls.js » ('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 // Flags: --expose-wasm 5 // Flags: --expose-wasm
6 6
7 load("test/mjsunit/wasm/wasm-constants.js"); 7 load("test/mjsunit/wasm/wasm-constants.js");
8 load("test/mjsunit/wasm/wasm-module-builder.js"); 8 load("test/mjsunit/wasm/wasm-module-builder.js");
9 9
10 function testCallImport(func, check) { 10 function testCallImport(func, check) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 passed_length = arguments.length; 178 passed_length = arguments.length;
179 passed_a = a; 179 passed_a = a;
180 passed_b = b; 180 passed_b = b;
181 args_a = arguments[0]; 181 args_a = arguments[0];
182 args_b = arguments[1]; 182 args_b = arguments[1];
183 }}}; 183 }}};
184 184
185 var builder = new WasmModuleBuilder(); 185 var builder = new WasmModuleBuilder();
186 186
187 builder.addImport("q", "func", makeSig_v_xx(type)); 187 builder.addImport("q", "func", makeSig_v_xx(type));
188 builder.addFunction("main", makeSig_r_xx(kAstI32, type)) 188 builder.addFunction("main", makeSig_r_xx(kWasmI32, type))
189 .addBody([ 189 .addBody([
190 kExprGetLocal, 0, // -- 190 kExprGetLocal, 0, // --
191 kExprGetLocal, 1, // -- 191 kExprGetLocal, 1, // --
192 kExprCallFunction, 0, // -- 192 kExprCallFunction, 0, // --
193 kExprI8Const, 99, // -- 193 kExprI8Const, 99, // --
194 ]) 194 ])
195 .exportFunc("main"); 195 .exportFunc("main");
196 196
197 var main = builder.instantiate(ffi).exports.main; 197 var main = builder.instantiate(ffi).exports.main;
198 198
199 print("testCallBinopVoid", type); 199 print("testCallBinopVoid", type);
200 200
201 for (var i = 0; i < 100000; i += 10003.1) { 201 for (var i = 0; i < 100000; i += 10003.1) {
202 var a = 22.5 + i, b = 10.5 + i; 202 var a = 22.5 + i, b = 10.5 + i;
203 var r = main(a, b); 203 var r = main(a, b);
204 assertEquals(99, r); 204 assertEquals(99, r);
205 assertEquals(2, passed_length); 205 assertEquals(2, passed_length);
206 var expected_a, expected_b; 206 var expected_a, expected_b;
207 switch (type) { 207 switch (type) {
208 case kAstI32: { 208 case kWasmI32: {
209 expected_a = a | 0; 209 expected_a = a | 0;
210 expected_b = b | 0; 210 expected_b = b | 0;
211 break; 211 break;
212 } 212 }
213 case kAstF32: { 213 case kWasmF32: {
214 expected_a = Math.fround(a); 214 expected_a = Math.fround(a);
215 expected_b = Math.fround(b); 215 expected_b = Math.fround(b);
216 break; 216 break;
217 } 217 }
218 case kAstF64: { 218 case kWasmF64: {
219 expected_a = a; 219 expected_a = a;
220 expected_b = b; 220 expected_b = b;
221 break; 221 break;
222 } 222 }
223 } 223 }
224 224
225 assertEquals(expected_a, args_a); 225 assertEquals(expected_a, args_a);
226 assertEquals(expected_b, args_b); 226 assertEquals(expected_b, args_b);
227 assertEquals(expected_a, passed_a); 227 assertEquals(expected_a, passed_a);
228 assertEquals(expected_b, passed_b); 228 assertEquals(expected_b, passed_b);
229 } 229 }
230 } 230 }
231 231
232 232
233 testCallBinopVoid(kAstI32); 233 testCallBinopVoid(kWasmI32);
234 // TODO testCallBinopVoid(kAstI64); 234 // TODO testCallBinopVoid(kWasmI64);
235 testCallBinopVoid(kAstF32); 235 testCallBinopVoid(kWasmF32);
236 testCallBinopVoid(kAstF64); 236 testCallBinopVoid(kWasmF64);
237 237
238 238
239 239
240 function testCallPrint() { 240 function testCallPrint() {
241 var builder = new WasmModuleBuilder(); 241 var builder = new WasmModuleBuilder();
242 builder.addImport("q", "print", makeSig_v_x(kAstI32)); 242 builder.addImport("q", "print", makeSig_v_x(kWasmI32));
243 builder.addImport("q", "print", makeSig_r_x(kAstF64, kAstF64)); 243 builder.addImport("q", "print", makeSig_r_x(kWasmF64, kWasmF64));
244 builder.addFunction("main", makeSig_r_x(kAstF64, kAstF64)) 244 builder.addFunction("main", makeSig_r_x(kWasmF64, kWasmF64))
245 .addBody([ 245 .addBody([
246 kExprI8Const, 97, // -- 246 kExprI8Const, 97, // --
247 kExprCallFunction, 0, // -- 247 kExprCallFunction, 0, // --
248 kExprGetLocal, 0, // -- 248 kExprGetLocal, 0, // --
249 kExprCallFunction, 1 // -- 249 kExprCallFunction, 1 // --
250 ]) 250 ])
251 .exportFunc(); 251 .exportFunc();
252 252
253 var main = builder.instantiate({q: {print: print}}).exports.main; 253 var main = builder.instantiate({q: {print: print}}).exports.main;
254 254
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 292
293 let main = builder.instantiate({M: {[name]: () => 42}}).exports.main; 293 let main = builder.instantiate({M: {[name]: () => 42}}).exports.main;
294 assertEquals(42, main()); 294 assertEquals(42, main());
295 } 295 }
296 296
297 testImportName("bla"); 297 testImportName("bla");
298 testImportName("0"); 298 testImportName("0");
299 testImportName(" a @#$2 324 "); 299 testImportName(" a @#$2 324 ");
300 // TODO(bradnelson): This should succeed. 300 // TODO(bradnelson): This should succeed.
301 // testImportName(""); 301 // testImportName("");
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/globals.js ('k') | test/mjsunit/wasm/indirect-calls.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698