OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 --expose-gc | 5 // Flags: --expose-wasm --expose-gc |
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 nogc = () => {}; | 10 let nogc = () => {}; |
11 | 11 |
12 function newModule() { | 12 function newModule() { |
13 let builder = new WasmModuleBuilder(); | 13 let builder = new WasmModuleBuilder(); |
14 builder.addMemory(1, 1, true); | 14 builder.addMemory(1, 1, true); |
15 builder.addFunction("main", kSig_i) | 15 builder.addFunction("main", kSig_i_v) |
16 .addBody([kExprI32Const, 0, kExprI32LoadMem, 0, 0]) | 16 .addBody([kExprI32Const, 0, kExprI32LoadMem, 0, 0]) |
17 .exportFunc(); | 17 .exportFunc(); |
18 | 18 |
19 return new WebAssembly.Module(builder.toBuffer()); | 19 return new WebAssembly.Module(builder.toBuffer()); |
20 } | 20 } |
21 | 21 |
22 function newInstance(module, val) { | 22 function newInstance(module, val) { |
23 var instance = new WebAssembly.Instance(module); | 23 var instance = new WebAssembly.Instance(module); |
24 var view = new Int32Array(instance.exports.memory.buffer); | 24 var view = new Int32Array(instance.exports.memory.buffer); |
25 view[0] = val; | 25 view[0] = val; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 roots[1] = newInstance(module, 22222); | 113 roots[1] = newInstance(module, 22222); |
114 assertEquals(11111, roots[0].exports.main()); | 114 assertEquals(11111, roots[0].exports.main()); |
115 assertEquals(22222, roots[1].exports.main()); | 115 assertEquals(22222, roots[1].exports.main()); |
116 roots[0] = null; | 116 roots[0] = null; |
117 roots[1] = null; | 117 roots[1] = null; |
118 })(); | 118 })(); |
119 } | 119 } |
120 | 120 |
121 TestReclaimingCompiledModule(nogc); | 121 TestReclaimingCompiledModule(nogc); |
122 TestReclaimingCompiledModule(gc); | 122 TestReclaimingCompiledModule(gc); |
OLD | NEW |