Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: test/mjsunit/wasm/compiled-module-management.js

Issue 2474053002: [wasm] Fix compiled-module-management lifetime issues. (Closed)
Patch Set: Added comment. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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)
6 // Flags: --no-turbo --no-ignition --no-ignition-staging
7 // Flags: --expose-wasm --expose-gc --allow-natives-syntax 5 // Flags: --expose-wasm --expose-gc --allow-natives-syntax
8 6
9 load("test/mjsunit/wasm/wasm-constants.js"); 7 load("test/mjsunit/wasm/wasm-constants.js");
10 load("test/mjsunit/wasm/wasm-module-builder.js"); 8 load("test/mjsunit/wasm/wasm-module-builder.js");
11 9
10 // Use global variables for all values where the test wants to maintain strict
11 // control over value lifetime. Using local variables would not give sufficient
12 // guarantees of the value lifetime.
13 var module;
14 var instance1;
15 var instance2;
16 var instance3;
17 var instance4;
12 18
13 (function CompiledModuleInstancesAreGCed() { 19 (function CompiledModuleInstancesInitialize1to3() {
14 var builder = new WasmModuleBuilder(); 20 var builder = new WasmModuleBuilder();
15 21
16 builder.addMemory(1,1, true); 22 builder.addMemory(1,1, true);
17 builder.addImport("getValue", kSig_i_v); 23 builder.addImport("getValue", kSig_i_v);
18 builder.addFunction("f", kSig_i_v) 24 builder.addFunction("f", kSig_i_v)
19 .addBody([ 25 .addBody([
20 kExprCallFunction, 0 26 kExprCallFunction, 0
21 ]).exportFunc(); 27 ]).exportFunc();
22 28
23 var module = new WebAssembly.Module(builder.toBuffer()); 29 module = new WebAssembly.Module(builder.toBuffer());
24 %ValidateWasmModuleState(module); 30 %ValidateWasmModuleState(module);
25 %ValidateWasmInstancesChain(module, 0); 31 %ValidateWasmInstancesChain(module, 0);
26 var i1 = new WebAssembly.Instance(module, {getValue: () => 1}); 32 instance1 = new WebAssembly.Instance(module, {getValue: () => 1});
27 %ValidateWasmInstancesChain(module, 1); 33 %ValidateWasmInstancesChain(module, 1);
28 var i2 = new WebAssembly.Instance(module, {getValue: () => 2}); 34 instance2 = new WebAssembly.Instance(module, {getValue: () => 2});
29 %ValidateWasmInstancesChain(module, 2); 35 %ValidateWasmInstancesChain(module, 2);
30 var i3 = new WebAssembly.Instance(module, {getValue: () => 3}); 36 instance3 = new WebAssembly.Instance(module, {getValue: () => 3});
31 %ValidateWasmInstancesChain(module, 3); 37 %ValidateWasmInstancesChain(module, 3);
38 })();
32 39
33 assertEquals(1, i1.exports.f()); 40 (function CompiledModuleInstancesClear1() {
34 i1 = null; 41 assertEquals(1, instance1.exports.f());
35 gc(); 42 instance1 = null;
36 %ValidateWasmInstancesChain(module, 2); 43 })();
37 assertEquals(3, i3.exports.f()); 44
38 i3 = null; 45 gc();
39 gc(); 46 %ValidateWasmInstancesChain(module, 2);
40 %ValidateWasmInstancesChain(module, 1); 47
41 assertEquals(2, i2.exports.f()); 48 (function CompiledModuleInstancesClear3() {
42 i2 = null; 49 assertEquals(3, instance3.exports.f());
43 gc(); 50 instance3 = null;
44 %ValidateWasmModuleState(module); 51 })();
45 var i4 = new WebAssembly.Instance(module, {getValue: () => 4}); 52
46 assertEquals(4, i4.exports.f()); 53 gc();
54 %ValidateWasmInstancesChain(module, 1);
55
56 (function CompiledModuleInstancesClear2() {
57 assertEquals(2, instance2.exports.f());
58 instance2 = null;
59 })();
60
61 gc();
62 %ValidateWasmModuleState(module);
63
64 (function CompiledModuleInstancesInitialize4AndClearModule() {
65 instance4 = new WebAssembly.Instance(module, {getValue: () => 4});
66 assertEquals(4, instance4.exports.f());
47 module = null; 67 module = null;
48 gc();
49 %ValidateWasmOrphanedInstance(i4);
50 })(); 68 })();
69
70 gc();
71 %ValidateWasmOrphanedInstance(instance4);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698