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 // TODO (mtrofin): re-enable ignition (v8:5345) | 5 // TODO (mtrofin): re-enable ignition (v8:5345) |
6 // Flags: --no-ignition --no-ignition-staging | 6 // Flags: --no-ignition --no-ignition-staging |
7 // Flags: --expose-wasm --expose-gc --allow-natives-syntax | 7 // Flags: --expose-wasm --expose-gc --allow-natives-syntax |
8 | 8 |
9 load("test/mjsunit/wasm/wasm-constants.js"); | 9 load("test/mjsunit/wasm/wasm-constants.js"); |
10 load("test/mjsunit/wasm/wasm-module-builder.js"); | 10 load("test/mjsunit/wasm/wasm-module-builder.js"); |
11 | 11 |
12 | 12 |
13 (function CompiledModuleInstancesAreGCed() { | 13 (function CompiledModuleInstancesAreGCed() { |
14 var builder = new WasmModuleBuilder(); | 14 var builder = new WasmModuleBuilder(); |
15 | 15 |
16 builder.addMemory(1,1, true); | 16 builder.addMemory(1,1, true); |
17 builder.addImport("getValue", kSig_i); | 17 builder.addImport("getValue", kSig_i_v); |
18 builder.addFunction("f", kSig_i) | 18 builder.addFunction("f", kSig_i_v) |
19 .addBody([ | 19 .addBody([ |
20 kExprCallFunction, 0 | 20 kExprCallFunction, 0 |
21 ]).exportFunc(); | 21 ]).exportFunc(); |
22 | 22 |
23 var module = new WebAssembly.Module(builder.toBuffer()); | 23 var module = new WebAssembly.Module(builder.toBuffer()); |
24 %ValidateWasmModuleState(module); | 24 %ValidateWasmModuleState(module); |
25 %ValidateWasmInstancesChain(module, 0); | 25 %ValidateWasmInstancesChain(module, 0); |
26 var i1 = new WebAssembly.Instance(module, {getValue: () => 1}); | 26 var i1 = new WebAssembly.Instance(module, {getValue: () => 1}); |
27 %ValidateWasmInstancesChain(module, 1); | 27 %ValidateWasmInstancesChain(module, 1); |
28 var i2 = new WebAssembly.Instance(module, {getValue: () => 2}); | 28 var i2 = new WebAssembly.Instance(module, {getValue: () => 2}); |
(...skipping 12 matching lines...) Expand all Loading... |
41 assertEquals(2, i2.exports.f()); | 41 assertEquals(2, i2.exports.f()); |
42 i2 = null; | 42 i2 = null; |
43 gc(); | 43 gc(); |
44 %ValidateWasmModuleState(module); | 44 %ValidateWasmModuleState(module); |
45 var i4 = new WebAssembly.Instance(module, {getValue: () => 4}); | 45 var i4 = new WebAssembly.Instance(module, {getValue: () => 4}); |
46 assertEquals(4, i4.exports.f()); | 46 assertEquals(4, i4.exports.f()); |
47 module = null; | 47 module = null; |
48 gc(); | 48 gc(); |
49 %ValidateWasmOrphanedInstance(i4); | 49 %ValidateWasmOrphanedInstance(i4); |
50 })(); | 50 })(); |
OLD | NEW |