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 = 17; | 10 let kReturnValue = 17; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 promise.then(compiled_module => { | 119 promise.then(compiled_module => { |
120 let instance_1 = new WebAssembly.Instance(compiled_module); | 120 let instance_1 = new WebAssembly.Instance(compiled_module); |
121 let instance_2 = new WebAssembly.Instance(compiled_module); | 121 let instance_2 = new WebAssembly.Instance(compiled_module); |
122 assertTrue(instance_1 != instance_2); | 122 assertTrue(instance_1 != instance_2); |
123 }); | 123 }); |
124 })(); | 124 })(); |
125 | 125 |
126 (function InstancesAreIsolatedFromEachother() { | 126 (function InstancesAreIsolatedFromEachother() { |
127 print("InstancesAreIsolatedFromEachother..."); | 127 print("InstancesAreIsolatedFromEachother..."); |
128 var builder = new WasmModuleBuilder(); | 128 var builder = new WasmModuleBuilder(); |
129 builder.addImportedMemory("", "memory", 1,1); | 129 builder.addImportedMemory("", "memory", 1); |
130 var kSig_v_i = makeSig([kWasmI32], []); | 130 var kSig_v_i = makeSig([kWasmI32], []); |
131 var signature = builder.addType(kSig_v_i); | 131 var signature = builder.addType(kSig_v_i); |
132 builder.addImport("m", "some_value", kSig_i_v); | 132 builder.addImport("m", "some_value", kSig_i_v); |
133 builder.addImport("m", "writer", signature); | 133 builder.addImport("m", "writer", signature); |
134 | 134 |
135 builder.addFunction("main", kSig_i_i) | 135 builder.addFunction("main", kSig_i_i) |
136 .addBody([ | 136 .addBody([ |
137 kExprGetLocal, 0, | 137 kExprGetLocal, 0, |
138 kExprI32LoadMem, 0, 0, | 138 kExprI32LoadMem, 0, 0, |
139 kExprI32Const, 1, | 139 kExprI32Const, 1, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 i1.exports.write(1); | 200 i1.exports.write(1); |
201 i2.exports.write(2); | 201 i2.exports.write(2); |
202 assertEquals(1, i1.exports.read()); | 202 assertEquals(1, i1.exports.read()); |
203 assertEquals(2, i2.exports.read()); | 203 assertEquals(2, i2.exports.read()); |
204 })(); | 204 })(); |
205 | 205 |
206 | 206 |
207 (function InstanceMemoryIsIsolated() { | 207 (function InstanceMemoryIsIsolated() { |
208 print("InstanceMemoryIsIsolated..."); | 208 print("InstanceMemoryIsIsolated..."); |
209 var builder = new WasmModuleBuilder(); | 209 var builder = new WasmModuleBuilder(); |
210 builder.addImportedMemory("", "memory", 1,1); | 210 builder.addImportedMemory("", "memory", 1); |
211 | 211 |
212 builder.addFunction("f", kSig_i_v) | 212 builder.addFunction("f", kSig_i_v) |
213 .addBody([ | 213 .addBody([ |
214 kExprI32Const, 0, | 214 kExprI32Const, 0, |
215 kExprI32LoadMem, 0, 0 | 215 kExprI32LoadMem, 0, 0 |
216 ]).exportFunc(); | 216 ]).exportFunc(); |
217 | 217 |
218 var mem_1 = new WebAssembly.Memory({initial: 1}); | 218 var mem_1 = new WebAssembly.Memory({initial: 1}); |
219 var mem_2 = new WebAssembly.Memory({initial: 1}); | 219 var mem_2 = new WebAssembly.Memory({initial: 1}); |
220 var view_1 = new Int32Array(mem_1.buffer); | 220 var view_1 = new Int32Array(mem_1.buffer); |
(...skipping 19 matching lines...) Expand all Loading... |
240 | 240 |
241 | 241 |
242 assertThrows(() => new WebAssembly.Instance(module, {"":{memory:memory}}), Web
Assembly.LinkError); | 242 assertThrows(() => new WebAssembly.Instance(module, {"":{memory:memory}}), Web
Assembly.LinkError); |
243 })(); | 243 })(); |
244 | 244 |
245 (function TestNoMemoryToExport() { | 245 (function TestNoMemoryToExport() { |
246 let builder = new WasmModuleBuilder(); | 246 let builder = new WasmModuleBuilder(); |
247 builder.exportMemoryAs('memory'); | 247 builder.exportMemoryAs('memory'); |
248 assertThrows(() => builder.instantiate(), WebAssembly.CompileError); | 248 assertThrows(() => builder.instantiate(), WebAssembly.CompileError); |
249 })(); | 249 })(); |
OLD | NEW |