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

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

Issue 2661773002: [wasm] Update table bounds when module is instantiated with a table import (Closed)
Patch Set: [wasm] Fix bounds check for imported size > declared initial size of table Created 3 years, 10 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-module.cc ('k') | no next file » | 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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 {element: "anyfunc", initial: 3, maximum: 3})}})); 470 {element: "anyfunc", initial: 3, maximum: 3})}}));
471 471
472 // maximum size is too large 472 // maximum size is too large
473 assertThrows(() => builder.instantiate({t: {t: new WebAssembly.Table( 473 assertThrows(() => builder.instantiate({t: {t: new WebAssembly.Table(
474 {element: "anyfunc", initial: 1, maximum: 4})}})); 474 {element: "anyfunc", initial: 1, maximum: 4})}}));
475 475
476 // no maximum 476 // no maximum
477 assertThrows(() => builder.instantiate({t: {t: new WebAssembly.Table( 477 assertThrows(() => builder.instantiate({t: {t: new WebAssembly.Table(
478 {element: "anyfunc", initial: 1})}})); 478 {element: "anyfunc", initial: 1})}}));
479 })(); 479 })();
480
481 (function TableImportLargerThanCompiled() {
482 print("TableImportLargerThanCompiled...");
483 var kMaxSize = 30, kInitSize = 5;
484 var builder = new WasmModuleBuilder();
485 builder.addImportedTable("x", "table", 1, 35);
486 let table = new WebAssembly.Table({element: "anyfunc",
487 initial: kInitSize, maximum: kMaxSize});
488 let module = new WebAssembly.Module(builder.toBuffer());
489 let instance = new WebAssembly.Instance(module, {x: {base: 1, table: table}});
490 for (var i = 0; i < kInitSize; ++i) table.set(i, null);
491 for (var i = 0; i < kInitSize; ++i) assertEquals(null, table.get(i));
492 assertThrows(() => table.set(kInitSize, null));
493 })();
494
495 (function ModulesShareTableAndGrow() {
496 print("ModulesShareTableAndGrow...");
497 let module1 = (() => {
498 let builder = new WasmModuleBuilder();
499 builder.addImportedTable("x", "table", 1, 35);
500 return new WebAssembly.Module(builder.toBuffer());
501 })();
502 let module2 = (() => {
503 let builder = new WasmModuleBuilder();
504 builder.addImportedTable("x", "table", 2, 40);
505 return new WebAssembly.Module(builder.toBuffer());
506 })();
507
508 var kMaxSize = 30, kInitSize = 5;
509 let table = new WebAssembly.Table({element: "anyfunc",
510 initial: kInitSize, maximum: kMaxSize});
511 let instance1 = new WebAssembly.Instance(
512 module1, {x: {base: 1, table: table}});
513 let instance2 = new WebAssembly.Instance(
514 module2, {x: {base: 1, table: table}});
515
516 for (var i = 0; i < kInitSize; ++i) table.set(i, null);
517 for (var i = 0; i < kInitSize; ++i) assertEquals(null, table.get(i));
518 assertThrows(() => table.set(kInitSize, null));
519 assertEquals(kInitSize, table.grow(5));
520 for (var i = 0; i < 2*kInitSize; ++i) table.set(i, null);
521 for (var i = 0; i < 2*kInitSize; ++i) assertEquals(null, table.get(i));
522 assertThrows(() => table.set(2*kInitSize, null));
523 // Try to grow past imported maximum
524 assertThrows(() => table.grow(21));
525 })();
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698