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

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

Issue 2474333003: [wasm] Exported memory should set maximum property when maximum is defined. (Closed)
Patch Set: Remove large allocation, fails on mac Created 4 years, 1 month 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 | « test/mjsunit/wasm/grow-memory.js ('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 85f6fbf8c0ad72f60d81b82c26a94c6ef3cbbd59..845da91d1d17bca6545d322edaeb05ef6ed9f49e 100644
--- a/test/mjsunit/wasm/import-memory.js
+++ b/test/mjsunit/wasm/import-memory.js
@@ -199,3 +199,33 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
assertEquals(10*kPageSize, memory.buffer.byteLength);
assertThrows(() => memory.grow(1));
})();
+
+(function TestGrowMemoryExportedMaximum() {
+ print("TestGrowMemoryExportedMaximum");
+ let initial_size = 1, maximum_size = 10;
+ var exp_instance;
+ {
+ let builder = new WasmModuleBuilder();
+ builder.addMemory(initial_size, maximum_size, true);
+ builder.exportMemoryAs("exported_mem");
+ exp_instance = builder.instantiate();
+ }
+ var instance;
+ {
+ var builder = new WasmModuleBuilder();
+ builder.addImportedMemory("imported_mem");
+ builder.addFunction("mem_size", kSig_i_v)
+ .addBody([kExprMemorySize, kMemoryZero])
+ .exportFunc();
+ builder.addFunction("grow", kSig_i_i)
+ .addBody([kExprGetLocal, 0, kExprGrowMemory, kMemoryZero])
+ .exportFunc();
+ instance = builder.instantiate({
+ imported_mem: exp_instance.exports.exported_mem});
+ }
+ for (var i = initial_size; i < maximum_size; i++) {
+ assertEquals(i, instance.exports.grow(1));
+ assertEquals((i+1), instance.exports.mem_size());
+ }
+ assertEquals(-1, instance.exports.grow(1));
+})();
« no previous file with comments | « test/mjsunit/wasm/grow-memory.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698