| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Flags: --expose-wasm | 5 // Flags: --expose-wasm |
| 6 | 6 |
| 7 load("test/mjsunit/wasm/wasm-constants.js"); | 7 load("test/mjsunit/wasm/wasm-constants.js"); |
| 8 load("test/mjsunit/wasm/wasm-module-builder.js"); | 8 load("test/mjsunit/wasm/wasm-module-builder.js"); |
| 9 | 9 |
| 10 let kReturnValue = 117; | 10 let kReturnValue = 117; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 let instance_1 = new WebAssembly.Instance(compiled_module); | 111 let instance_1 = new WebAssembly.Instance(compiled_module); |
| 112 let instance_2 = new WebAssembly.Instance(compiled_module); | 112 let instance_2 = new WebAssembly.Instance(compiled_module); |
| 113 assertTrue(instance_1 != instance_2); | 113 assertTrue(instance_1 != instance_2); |
| 114 }); | 114 }); |
| 115 })(); | 115 })(); |
| 116 | 116 |
| 117 (function InstancesAreIsolatedFromEachother() { | 117 (function InstancesAreIsolatedFromEachother() { |
| 118 print("InstancesAreIsolatedFromEachother..."); | 118 print("InstancesAreIsolatedFromEachother..."); |
| 119 var builder = new WasmModuleBuilder(); | 119 var builder = new WasmModuleBuilder(); |
| 120 builder.addMemory(1,1, true); | 120 builder.addMemory(1,1, true); |
| 121 var kSig_v_i = makeSig([kAstI32], []); | 121 var kSig_v_i = makeSig([kWasmI32], []); |
| 122 var signature = builder.addType(kSig_v_i); | 122 var signature = builder.addType(kSig_v_i); |
| 123 builder.addImport("m", "some_value", kSig_i_v); | 123 builder.addImport("m", "some_value", kSig_i_v); |
| 124 builder.addImport("m", "writer", signature); | 124 builder.addImport("m", "writer", signature); |
| 125 | 125 |
| 126 builder.addFunction("main", kSig_i_i) | 126 builder.addFunction("main", kSig_i_i) |
| 127 .addBody([ | 127 .addBody([ |
| 128 kExprGetLocal, 0, | 128 kExprGetLocal, 0, |
| 129 kExprI32LoadMem, 0, 0, | 129 kExprI32LoadMem, 0, 0, |
| 130 kExprI32Const, 1, | 130 kExprI32Const, 1, |
| 131 kExprCallIndirect, signature, kTableZero, | 131 kExprCallIndirect, signature, kTableZero, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 assertEquals(43, i1.exports.main(0)); | 165 assertEquals(43, i1.exports.main(0)); |
| 166 assertEquals(1002, i2.exports.main(0)); | 166 assertEquals(1002, i2.exports.main(0)); |
| 167 | 167 |
| 168 assertEquals(42, outval_1); | 168 assertEquals(42, outval_1); |
| 169 assertEquals(1000, outval_2); | 169 assertEquals(1000, outval_2); |
| 170 })(); | 170 })(); |
| 171 | 171 |
| 172 (function GlobalsArePrivateToTheInstance() { | 172 (function GlobalsArePrivateToTheInstance() { |
| 173 print("GlobalsArePrivateToTheInstance..."); | 173 print("GlobalsArePrivateToTheInstance..."); |
| 174 var builder = new WasmModuleBuilder(); | 174 var builder = new WasmModuleBuilder(); |
| 175 builder.addGlobal(kAstI32, true); | 175 builder.addGlobal(kWasmI32, true); |
| 176 builder.addFunction("read", kSig_i_v) | 176 builder.addFunction("read", kSig_i_v) |
| 177 .addBody([ | 177 .addBody([ |
| 178 kExprGetGlobal, 0]) | 178 kExprGetGlobal, 0]) |
| 179 .exportFunc(); | 179 .exportFunc(); |
| 180 | 180 |
| 181 builder.addFunction("write", kSig_v_i) | 181 builder.addFunction("write", kSig_v_i) |
| 182 .addBody([ | 182 .addBody([ |
| 183 kExprGetLocal, 0, | 183 kExprGetLocal, 0, |
| 184 kExprSetGlobal, 0]) | 184 kExprSetGlobal, 0]) |
| 185 .exportFunc(); | 185 .exportFunc(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 assertEquals(1, i1.exports.f()); | 219 assertEquals(1, i1.exports.f()); |
| 220 assertEquals(1000, i2.exports.f()); | 220 assertEquals(1000, i2.exports.f()); |
| 221 })(); | 221 })(); |
| 222 | 222 |
| 223 (function MustBeMemory() { | 223 (function MustBeMemory() { |
| 224 print("MustBeMemory..."); | 224 print("MustBeMemory..."); |
| 225 var memory = new ArrayBuffer(65536); | 225 var memory = new ArrayBuffer(65536); |
| 226 var module = new WebAssembly.Module(buffer); | 226 var module = new WebAssembly.Module(buffer); |
| 227 assertThrows(() => new WebAssembly.Instance(module, null, memory), TypeError); | 227 assertThrows(() => new WebAssembly.Instance(module, null, memory), TypeError); |
| 228 })(); | 228 })(); |
| OLD | NEW |