OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // TODO (mtrofin): re-enable ignition (v8:5345) |
| 6 // Flags: --no-ignition --no-ignition-staging |
| 7 // Flags: --expose-wasm --expose-gc --allow-natives-syntax |
| 8 |
| 9 load("test/mjsunit/wasm/wasm-constants.js"); |
| 10 load("test/mjsunit/wasm/wasm-module-builder.js"); |
| 11 |
| 12 |
| 13 (function CompiledModuleInstancesAreGCed() { |
| 14 var builder = new WasmModuleBuilder(); |
| 15 |
| 16 builder.addMemory(1,1, true); |
| 17 builder.addImport("getValue", kSig_i); |
| 18 builder.addFunction("f", kSig_i) |
| 19 .addBody([ |
| 20 kExprCallImport, kArity0, 0 |
| 21 ]).exportFunc(); |
| 22 |
| 23 var module = new WebAssembly.Module(builder.toBuffer()); |
| 24 %ValidateWasmModuleState(module); |
| 25 %ValidateWasmInstancesChain(module, 0); |
| 26 var i1 = new WebAssembly.Instance(module, {getValue: () => 1}); |
| 27 %ValidateWasmInstancesChain(module, 1); |
| 28 var i2 = new WebAssembly.Instance(module, {getValue: () => 2}); |
| 29 %ValidateWasmInstancesChain(module, 2); |
| 30 var i3 = new WebAssembly.Instance(module, {getValue: () => 3}); |
| 31 %ValidateWasmInstancesChain(module, 3); |
| 32 |
| 33 assertEquals(1, i1.exports.f()); |
| 34 i1 = null; |
| 35 gc(); |
| 36 %ValidateWasmInstancesChain(module, 2); |
| 37 assertEquals(3, i3.exports.f()); |
| 38 i3 = null; |
| 39 gc(); |
| 40 %ValidateWasmInstancesChain(module, 1); |
| 41 assertEquals(2, i2.exports.f()); |
| 42 i2 = null; |
| 43 gc(); |
| 44 %ValidateWasmModuleState(module); |
| 45 var i4 = new WebAssembly.Instance(module, {getValue: () => 4}); |
| 46 assertEquals(4, i4.exports.f()); |
| 47 module = null; |
| 48 gc(); |
| 49 %ValidateWasmOrphanedInstance(i4); |
| 50 })(); |
OLD | NEW |