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

Side by Side Diff: test/mjsunit/wasm/instance-gc.js

Issue 2361053004: Revert of [wasm] Master CL for Binary 0xC changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 3 months 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 | « test/mjsunit/wasm/indirect-calls.js ('k') | test/mjsunit/wasm/instantiate-module-basic.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // Flags: --expose-wasm --expose-gc
6
7 load("test/mjsunit/wasm/wasm-constants.js");
8 load("test/mjsunit/wasm/wasm-module-builder.js");
9
10 let nogc = () => {};
11
12 function newModule() {
13 let builder = new WasmModuleBuilder();
14 builder.addMemory(1, 1, true);
15 builder.addFunction("main", kSig_i)
16 .addBody([kExprI32Const, 0, kExprI32LoadMem, 0, 0])
17 .exportFunc();
18
19 return new WebAssembly.Module(builder.toBuffer());
20 }
21
22 function newInstance(module, val) {
23 var instance = new WebAssembly.Instance(module);
24 var view = new Int32Array(instance.exports.memory.buffer);
25 view[0] = val;
26 return instance;
27 }
28
29 function TestSingleLiveInstance(gc) {
30 let module = newModule();
31
32 print("TestSingleLiveInstance...");
33 for (var i = 0; i < 5; i++) {
34 (() => { // don't leak references between iterations.
35 print(" [" + i + "]...");
36 gc();
37 var instance = newInstance(module, i + 99);
38 assertEquals(i + 99, instance.exports.main());
39 })();
40 }
41 }
42
43 TestSingleLiveInstance(nogc);
44 TestSingleLiveInstance(gc);
45
46 function TestMultiInstance(gc) {
47 let module = newModule();
48
49 print("TestMultiInstance...");
50 // Note: compute the root instances in another function to be
51 // sure that {roots} really is the only set of roots to the instances.
52 let roots = (() => { return [
53 newInstance(module, 33),
54 newInstance(module, 4444),
55 newInstance(module, 555555)
56 ];})();
57
58 (() => { // don't leak references!
59 print(" [0]...");
60 gc();
61 assertEquals(33, roots[0].exports.main());
62 roots[0] = null;
63 })();
64
65 (() => { // don't leak references!
66 print(" [1]...");
67 gc();
68 assertEquals(4444, roots[1].exports.main());
69 roots[1] = null;
70 })();
71
72 (() => { // don't leak references!
73 print(" [2]...");
74 gc();
75 assertEquals(555555, roots[2].exports.main());
76 roots[2] = null;
77 })();
78 }
79
80 TestMultiInstance(nogc);
81 TestMultiInstance(gc);
82
83 function TestReclaimingCompiledModule() {
84 let module = newModule();
85
86 print("TestReclaimingCompiledModule...");
87 let roots = (() => { return [
88 newInstance(module, 7777),
89 newInstance(module, 8888),
90 ];})();
91
92 (() => { // don't leak references!
93 print(" [0]...");
94 assertEquals(7777, roots[0].exports.main());
95 assertEquals(8888, roots[1].exports.main());
96 roots[1] = null;
97 })();
98
99 (() => { // don't leak references!
100 print(" [1]...");
101 gc();
102 roots[1] = newInstance(module, 9999);
103 assertEquals(7777, roots[0].exports.main());
104 assertEquals(9999, roots[1].exports.main());
105 roots[0] = null;
106 roots[1] = null;
107 })();
108
109 (() => { // don't leak references!
110 print(" [2]...");
111 gc();
112 roots[0] = newInstance(module, 11111);
113 roots[1] = newInstance(module, 22222);
114 assertEquals(11111, roots[0].exports.main());
115 assertEquals(22222, roots[1].exports.main());
116 roots[0] = null;
117 roots[1] = null;
118 })();
119 }
120
121 TestReclaimingCompiledModule(nogc);
122 TestReclaimingCompiledModule(gc);
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/indirect-calls.js ('k') | test/mjsunit/wasm/instantiate-module-basic.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698