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

Unified Diff: test/mjsunit/wasm/instantiate-module-basic.js

Issue 2305903002: [wasm] reuse the first compiled module (Closed)
Patch Set: GC before cloning Created 4 years, 3 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 | « test/mjsunit/wasm/compiled-module-management.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/instantiate-module-basic.js
diff --git a/test/mjsunit/wasm/instantiate-module-basic.js b/test/mjsunit/wasm/instantiate-module-basic.js
index 0328bad31b76abd2787fec520b14ca6c9b1329c4..04fc903010db1b17935e374df2f72820d92488df 100644
--- a/test/mjsunit/wasm/instantiate-module-basic.js
+++ b/test/mjsunit/wasm/instantiate-module-basic.js
@@ -155,24 +155,50 @@ promise.then(module => CheckInstance(new WebAssembly.Instance(module)));
})();
(function GlobalsArePrivateToTheInstance() {
+ var builder = new WasmModuleBuilder();
+ builder.addGlobal(kAstI32);
+ builder.addFunction("read", kSig_i_v)
+ .addBody([
+ kExprGetGlobal, 0])
+ .exportFunc();
+
+ builder.addFunction("write", kSig_v_i)
+ .addBody([
+ kExprGetLocal, 0,
+ kExprSetGlobal, 0])
+ .exportFunc();
+
+ var module = new WebAssembly.Module(builder.toBuffer());
+ var i1 = new WebAssembly.Instance(module);
+ var i2 = new WebAssembly.Instance(module);
+ i1.exports.write(1);
+ i2.exports.write(2);
+ assertEquals(1, i1.exports.read());
+ assertEquals(2, i2.exports.read());
+})();
+
+
+(function InstanceMemoryIsIsolated() {
var builder = new WasmModuleBuilder();
- builder.addGlobal(kAstI32);
- builder.addFunction("read", kSig_i_v)
- .addBody([
- kExprGetGlobal, 0])
- .exportFunc();
+ builder.addMemory(1,1, true);
- builder.addFunction("write", kSig_v_i)
+ builder.addFunction("f", kSig_i)
.addBody([
- kExprGetLocal, 0,
- kExprSetGlobal, 0])
- .exportFunc();
+ kExprI32Const, 0,
+ kExprI32LoadMem, 0, 0
+ ]).exportFunc();
+
+ var mem_1 = new ArrayBuffer(65536);
+ var mem_2 = new ArrayBuffer(65536);
+ var view_1 = new Int32Array(mem_1);
+ var view_2 = new Int32Array(mem_2);
+ view_1[0] = 1;
+ view_2[0] = 1000;
var module = new WebAssembly.Module(builder.toBuffer());
- var i1 = new WebAssembly.Instance(module);
- var i2 = new WebAssembly.Instance(module);
- i1.exports.write(1);
- i2.exports.write(2);
- assertEquals(1, i1.exports.read());
- assertEquals(2, i2.exports.read());
+ var i1 = new WebAssembly.Instance(module, null, mem_1);
+ var i2 = new WebAssembly.Instance(module, null, mem_2);
+
+ assertEquals(1, i1.exports.f());
+ assertEquals(1000, i2.exports.f());
})();
« no previous file with comments | « test/mjsunit/wasm/compiled-module-management.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698