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

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

Issue 2627763002: [wasm] JS APIs & memory (Closed)
Patch Set: 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 | « test/mjsunit/wasm/import-memory.js ('k') | test/mjsunit/wasm/js-api.js » ('j') | 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 5e3d1095d24b6f7d69ddf3d4636c36bcbd3c82d4..70043e42b8d620a5b0cd8a484f366aeb94abd3f4 100644
--- a/test/mjsunit/wasm/instantiate-module-basic.js
+++ b/test/mjsunit/wasm/instantiate-module-basic.js
@@ -29,7 +29,7 @@ function CheckInstance(instance) {
assertFalse(Object.isExtensible(instance.exports));
assertTrue(Object.isFrozen(instance.exports));
- // Check the memory is an ArrayBuffer.
+ // Check the memory is WebAssembly.Memory.
var mem = instance.exports.memory;
assertFalse(mem === undefined);
assertFalse(mem === null);
@@ -117,7 +117,7 @@ assertFalse(WebAssembly.validate(bytes(88, 88, 88, 88, 88, 88, 88, 88)));
(function InstancesAreIsolatedFromEachother() {
print("InstancesAreIsolatedFromEachother...");
var builder = new WasmModuleBuilder();
- builder.addMemory(1,1, true);
+ builder.addImportedMemory("", "memory", 1,1);
var kSig_v_i = makeSig([kWasmI32], []);
var signature = builder.addType(kSig_v_i);
builder.addImport("m", "some_value", kSig_i_v);
@@ -156,11 +156,12 @@ assertFalse(WebAssembly.validate(bytes(88, 88, 88, 88, 88, 88, 88, 88)));
var outval_1;
var outval_2;
var i1 = new WebAssembly.Instance(module, {m: {some_value: () => 1,
- writer: (x)=>outval_1 = x }},
- mem_1);
+ writer: (x)=>outval_1 = x },
+ "": {memory: mem_1}});
+
var i2 = new WebAssembly.Instance(module, {m: {some_value: () => 2,
- writer: (x)=>outval_2 = x }},
- mem_2);
+ writer: (x)=>outval_2 = x },
+ "": {memory: mem_2}});
assertEquals(43, i1.exports.main(0));
assertEquals(1002, i2.exports.main(0));
@@ -197,7 +198,7 @@ assertFalse(WebAssembly.validate(bytes(88, 88, 88, 88, 88, 88, 88, 88)));
(function InstanceMemoryIsIsolated() {
print("InstanceMemoryIsIsolated...");
var builder = new WasmModuleBuilder();
- builder.addMemory(1,1, true);
+ builder.addImportedMemory("", "memory", 1,1);
builder.addFunction("f", kSig_i_v)
.addBody([
@@ -213,8 +214,8 @@ assertFalse(WebAssembly.validate(bytes(88, 88, 88, 88, 88, 88, 88, 88)));
view_2[0] = 1000;
var module = new WebAssembly.Module(builder.toBuffer());
- var i1 = new WebAssembly.Instance(module, null, mem_1);
- var i2 = new WebAssembly.Instance(module, null, mem_2);
+ var i1 = new WebAssembly.Instance(module, {"":{memory:mem_1}});
+ var i2 = new WebAssembly.Instance(module, {"":{memory:mem_2}});
assertEquals(1, i1.exports.f());
assertEquals(1000, i2.exports.f());
@@ -223,6 +224,11 @@ assertFalse(WebAssembly.validate(bytes(88, 88, 88, 88, 88, 88, 88, 88)));
(function MustBeMemory() {
print("MustBeMemory...");
var memory = new ArrayBuffer(65536);
- var module = new WebAssembly.Module(buffer);
- assertThrows(() => new WebAssembly.Instance(module, null, memory), TypeError);
+ let builder = new WasmModuleBuilder();
+ builder.addImportedMemory("", "memory");
+
+ let module = new WebAssembly.Module(builder.toBuffer());
+
+
+ assertThrows(() => new WebAssembly.Instance(module, {"":{memory:memory}}), WebAssembly.LinkError);
})();
« no previous file with comments | « test/mjsunit/wasm/import-memory.js ('k') | test/mjsunit/wasm/js-api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698