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

Unified Diff: test/mjsunit/wasm/import-memory.js

Issue 2410763002: [wasm] GrowMemory should use maximum size declared in WebAssembly.Memory (Closed)
Patch Set: Separate refactoring, add test Created 4 years, 2 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
« src/wasm/wasm-module.cc ('K') | « 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/import-memory.js
diff --git a/test/mjsunit/wasm/import-memory.js b/test/mjsunit/wasm/import-memory.js
index 30c1acc25a914e1074922bf760b11c300c197326..1e842aa2c0d8b3415ca031caaa376a6145f16199 100644
--- a/test/mjsunit/wasm/import-memory.js
+++ b/test/mjsunit/wasm/import-memory.js
@@ -80,3 +80,32 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
}
}
})();
+
+(function TestGrowMemMaxDesc() {
+ print("Maximum descriptor");
+ let memory = new WebAssembly.Memory({initial: 1, maximum: 5});
+ assertEquals(kPageSize, memory.buffer.byteLength);
+ let i32 = new Int32Array(memory.buffer);
+ let builder = new WasmModuleBuilder();
+ builder.addImportedMemory("mine");
+ builder.addFunction("main", kSig_i_v)
+ .addBody([
+ kExprI32Const, 0,
+ kExprI32LoadMem, 0, 0])
+ .exportAs("main");
+
+ let main = builder.instantiate({mine: memory}).exports.main;
+ assertEquals(0, main());
+ i32[0] = 993377;
+ assertEquals(993377, main());
+
+ for (var i = 1; i < 4; i++) {
+ assertEquals(i, memory.grow(1));
+ assertEquals(993377, main());
+ }
+ try {
+ memory.grow(1);
+ } catch (e) {
+ assertEquals("object", typeof e);
+ }
+})();
« src/wasm/wasm-module.cc ('K') | « src/wasm/wasm-module.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698