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

Side by Side Diff: test/mjsunit/wasm/indirect-tables.js

Issue 2643783002: [wasm] check that there is at most 1 table (Closed)
Patch Set: Tweak module builder Created 3 years, 11 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/module-decoder.cc ('k') | test/mjsunit/wasm/wasm-module-builder.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 AddFunctions(builder) { 10 function AddFunctions(builder) {
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 var sig_index2 = builder.addType(kSig_i_v); 312 var sig_index2 = builder.addType(kSig_i_v);
313 var f2 = builder.addFunction("f2", sig_index2) 313 var f2 = builder.addFunction("f2", sig_index2)
314 .addBody([kExprI32Const, 22]); 314 .addBody([kExprI32Const, 22]);
315 315
316 builder.addFunction("main", kSig_i_ii) 316 builder.addFunction("main", kSig_i_ii)
317 .addBody([ 317 .addBody([
318 kExprGetLocal, 0, // -- 318 kExprGetLocal, 0, // --
319 kExprCallIndirect, sig_index2, kTableZero]) // -- 319 kExprCallIndirect, sig_index2, kTableZero]) // --
320 .exportAs("main"); 320 .exportAs("main");
321 321
322 builder.setFunctionTableLength(kTableSize);
323 builder.addFunctionTableInit(1, false, [f2.index]);
324 builder.addImportedTable("z", "table", kTableSize, kTableSize); 322 builder.addImportedTable("z", "table", kTableSize, kTableSize);
323 builder.addFunctionTableInit(1, false, [f2.index], true);
325 324
326 var m2 = new WebAssembly.Module(builder.toBuffer()); 325 var m2 = new WebAssembly.Module(builder.toBuffer());
327 326
328 assertFalse(sig_index1 == sig_index2); 327 assertFalse(sig_index1 == sig_index2);
329 328
330 var i1 = new WebAssembly.Instance(m1); 329 var i1 = new WebAssembly.Instance(m1);
331 var i2 = new WebAssembly.Instance(m2, {z: {table: i1.exports.table}}); 330 var i2 = new WebAssembly.Instance(m2, {z: {table: i1.exports.table}});
332 331
333 assertEquals(11, i1.exports.main(0)); 332 assertEquals(11, i1.exports.main(0));
334 assertEquals(11, i2.exports.main(0)); 333 assertEquals(11, i2.exports.main(0));
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 {element: "anyfunc", initial: 3, maximum: 3})}})); 470 {element: "anyfunc", initial: 3, maximum: 3})}}));
472 471
473 // maximum size is too large 472 // maximum size is too large
474 assertThrows(() => builder.instantiate({t: {t: new WebAssembly.Table( 473 assertThrows(() => builder.instantiate({t: {t: new WebAssembly.Table(
475 {element: "anyfunc", initial: 1, maximum: 4})}})); 474 {element: "anyfunc", initial: 1, maximum: 4})}}));
476 475
477 // no maximum 476 // no maximum
478 assertThrows(() => builder.instantiate({t: {t: new WebAssembly.Table( 477 assertThrows(() => builder.instantiate({t: {t: new WebAssembly.Table(
479 {element: "anyfunc", initial: 1})}})); 478 {element: "anyfunc", initial: 1})}}));
480 })(); 479 })();
OLDNEW
« no previous file with comments | « src/wasm/module-decoder.cc ('k') | test/mjsunit/wasm/wasm-module-builder.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698