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

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

Issue 2438673006: [wasm] GrowMemory should update imported memory objects. (Closed)
Patch Set: Improve 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
« 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/import-memory.js
diff --git a/test/mjsunit/wasm/import-memory.js b/test/mjsunit/wasm/import-memory.js
index 414f1c8f4f9d458f3c13bdfc23c1b88f2302f914..0918326dec143a271c9434acffa38e9ddef280b9 100644
--- a/test/mjsunit/wasm/import-memory.js
+++ b/test/mjsunit/wasm/import-memory.js
@@ -181,3 +181,21 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
}
assertThrows(() => memory.grow(16381));
})();
+
+(function ImportedMemoryBufferLength() {
+ print("ImportedMemoryBufferLength");
+ let memory = new WebAssembly.Memory({initial: 2, maximum: 10});
+ assertEquals(2*kPageSize, memory.buffer.byteLength);
+ let builder = new WasmModuleBuilder();
+ builder.addFunction("grow", kSig_i_i)
+ .addBody([kExprGetLocal, 0, kExprGrowMemory])
+ .exportFunc();
+ builder.addImportedMemory("mine");
+ let instance = builder.instantiate({mine: memory});
+ function grow(pages) { return instance.exports.grow(pages); }
+ assertEquals(2, grow(3));
+ assertEquals(5*kPageSize, memory.buffer.byteLength);
+ assertEquals(5, grow(5));
+ assertEquals(10*kPageSize, memory.buffer.byteLength);
+ assertThrows(() => memory.grow(1));
+})();
« 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