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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/indirect-tables.js
diff --git a/test/mjsunit/wasm/indirect-tables.js b/test/mjsunit/wasm/indirect-tables.js
index 5e3c14e213862920e5c5fe7d4f22ac62d9244868..7583d05968a6c185e1aa7f49feacd21c635759db 100644
--- a/test/mjsunit/wasm/indirect-tables.js
+++ b/test/mjsunit/wasm/indirect-tables.js
@@ -477,3 +477,49 @@ function js_div(a, b) { return (a / b) | 0; }
assertThrows(() => builder.instantiate({t: {t: new WebAssembly.Table(
{element: "anyfunc", initial: 1})}}));
})();
+
+(function TableImportLargerThanCompiled() {
+ print("TableImportLargerThanCompiled...");
+ var kMaxSize = 30, kInitSize = 5;
+ var builder = new WasmModuleBuilder();
+ builder.addImportedTable("x", "table", 1, 35);
+ let table = new WebAssembly.Table({element: "anyfunc",
+ initial: kInitSize, maximum: kMaxSize});
+ let module = new WebAssembly.Module(builder.toBuffer());
+ let instance = new WebAssembly.Instance(module, {x: {base: 1, table: table}});
+ for (var i = 0; i < kInitSize; ++i) table.set(i, null);
+ for (var i = 0; i < kInitSize; ++i) assertEquals(null, table.get(i));
+ assertThrows(() => table.set(kInitSize, null));
+})();
+
+(function ModulesShareTableAndGrow() {
+ print("ModulesShareTableAndGrow...");
+ let module1 = (() => {
+ let builder = new WasmModuleBuilder();
+ builder.addImportedTable("x", "table", 1, 35);
+ return new WebAssembly.Module(builder.toBuffer());
+ })();
+ let module2 = (() => {
+ let builder = new WasmModuleBuilder();
+ builder.addImportedTable("x", "table", 2, 40);
+ return new WebAssembly.Module(builder.toBuffer());
+ })();
+
+ var kMaxSize = 30, kInitSize = 5;
+ let table = new WebAssembly.Table({element: "anyfunc",
+ initial: kInitSize, maximum: kMaxSize});
+ let instance1 = new WebAssembly.Instance(
+ module1, {x: {base: 1, table: table}});
+ let instance2 = new WebAssembly.Instance(
+ module2, {x: {base: 1, table: table}});
+
+ for (var i = 0; i < kInitSize; ++i) table.set(i, null);
+ for (var i = 0; i < kInitSize; ++i) assertEquals(null, table.get(i));
+ assertThrows(() => table.set(kInitSize, null));
+ assertEquals(kInitSize, table.grow(5));
+ for (var i = 0; i < 2*kInitSize; ++i) table.set(i, null);
+ for (var i = 0; i < 2*kInitSize; ++i) assertEquals(null, table.get(i));
+ assertThrows(() => table.set(2*kInitSize, null));
+ // Try to grow past imported maximum
+ assertThrows(() => table.grow(21));
+})();
« 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