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); |
})(); |