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

Side by Side Diff: test/mjsunit/wasm/test-import-export-wrapper.js

Issue 2204703002: [wasm] Get rid of extra wrappers when import another wasm export (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Made code more clean according to code reviews Created 4 years, 4 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
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 --allow-natives-syntax
6
7 load("test/mjsunit/wasm/wasm-constants.js");
8 load("test/mjsunit/wasm/wasm-module-builder.js");
9
10 var expect_elison = 0;
11 var expect_no_elison = 1;
12 // function calls stack: first_export -> first_func -> first_import ->
13 // second_export -> second_import
14 // In this case, first_import and second_export have same signature,
15 // So that wrappers will be removed
16 (function TestWasmWrapperElison() {
17 var second_module = new WasmModuleBuilder();
18 var sig_index = second_module.addType(kSig_v_i);
19 second_module.addImportWithModule("import_module_2", "import_name_2", sig_in dex);
20 second_module.addFunction("second_export", sig_index)
21 .addBody([
22 kExprGetLocal, 0,
23 kExprCallImport, kArity1, 0,
24 ])
25 .exportFunc();
26
27 var first_module = new WasmModuleBuilder();
28 var sig_index = first_module.addType(kSig_v_i);
29 first_module.addImportWithModule("import_module_1", "import_name_1", sig_ind ex);
30 first_module.addFunction("first_export", sig_index)
31 .addBody([
32 kExprGetLocal, 0,
33 kExprCallFunction, kArity1, 1
34 ])
35 .exportFunc();
36 first_module.addFunction("first_func", sig_index)
37 .addBody([
38 kExprI32Const, 1,
39 kExprGetLocal, 0,
40 kExprI32Add,
41 kExprCallImport, kArity1, 0
42 ]);
43
44 var f = second_module.instantiate({import_module_2:{import_name_2:print}})
45 .exports.second_export;
46 var the_export = first_module.instantiate({import_module_1:{import_name_1:f} })
Mircea Trofin 2016/08/04 00:51:28 don't you want to still call the_export, to make s
Chen 2016/08/04 17:21:53 Done.
47 .exports.first_export;
48 %CheckWasmWrapperElison(the_export, expect_elison);
49 })();
50
51 // function calls stack: first_export -> first_func -> first_import ->
52 // second_export -> second_import
53 // In this case, second_export has less params than first_import,
54 // So that wrappers will not be removed
55 (function TestWasmWrapperNoElisonLessParams() {
56 var second_module = new WasmModuleBuilder();
57 var sig_index_1 = second_module.addType(kSig_v_i);
58 second_module.addImportWithModule("import_module_2", "import_name_2", sig_in dex_1);
59 second_module.addFunction("second_export", sig_index_1)
60 .addBody([
61 kExprGetLocal, 0,
62 kExprCallImport, kArity1, 0
63 ])
64 .exportFunc();
65
66 var first_module = new WasmModuleBuilder();
67 var sig_index_2 = first_module.addType(kSig_v_ii);
68 first_module.addImportWithModule("import_module_1", "import_name_1", sig_ind ex_2);
69 first_module.addFunction("first_export", sig_index_2)
70 .addBody([
71 kExprGetLocal, 0,
72 kExprGetLocal, 1,
73 kExprCallFunction, kArity2, 1
74 ])
75 .exportFunc();
76 first_module.addFunction("first_func", sig_index_2)
77 .addBody([
78 kExprGetLocal, 0,
79 kExprGetLocal, 1,
80 kExprCallImport, kArity2, 0
81 ]);
82
83 var f = second_module.instantiate({import_module_2:{import_name_2:print}})
84 .exports.second_export;
85 var the_export = first_module.instantiate({import_module_1:{import_name_1:f} })
86 .exports.first_export;
87 %CheckWasmWrapperElison(the_export, expect_no_elison);
88 })();
89
90 // function calls stack: first_export -> first_func -> first_import ->
91 // second_export -> second_import
92 // In this case, second_export has more params than first_import,
93 // So that wrappers will not be removed
94 (function TestWasmWrapperNoElisonMoreParams() {
95 var second_module = new WasmModuleBuilder();
96 var sig_index_3 = second_module.addType(kSig_v_iii);
97 second_module.addImportWithModule("import_module_2", "import_name_2", sig_in dex_3);
98 second_module.addFunction("second_export", sig_index_3)
99 .addBody([
100 kExprGetLocal, 0,
101 kExprGetLocal, 1,
102 kExprGetLocal, 2,
103 kExprCallImport, kArity3, 0
104 ])
105 .exportFunc();
106
107 var first_module = new WasmModuleBuilder();
108 var sig_index_2 = first_module.addType(kSig_v_ii);
109 first_module.addImportWithModule("import_module_1", "import_name_1", sig_ind ex_2);
110 first_module.addFunction("first_export", sig_index_2)
111 .addBody([
112 kExprGetLocal, 0,
113 kExprGetLocal, 1,
114 kExprCallFunction, kArity2, 1
115 ])
116 .exportFunc();
117 first_module.addFunction("first_func", sig_index_2)
118 .addBody([
119 kExprGetLocal, 0,
120 kExprGetLocal, 1,
121 kExprCallImport, kArity2, 0
122 ]);
123
124 var f = second_module.instantiate({import_module_2:{import_name_2:print}})
125 .exports.second_export;
126 var the_export = first_module.instantiate({import_module_1:{import_name_1:f} })
127 .exports.first_export;
128 %CheckWasmWrapperElison(the_export, expect_no_elison);
129 })();
130
131 // function calls stack: first_export -> first_func -> first_import ->
132 // second_export -> second_import
133 // In this case, second_export has different params type with first_import,
134 // So that wrappers will not be removed
135 (function TestWasmWrapperNoElisonTypeMismatch() {
136 var second_module = new WasmModuleBuilder();
137 var sig_index_2 = second_module.addType(kSig_v_dd);
138 second_module.addImportWithModule("import_module_2", "import_name_2", sig_in dex_2);
139 second_module.addFunction("second_export", sig_index_2)
140 .addBody([
141 kExprGetLocal, 0,
142 kExprGetLocal, 1,
143 kExprCallImport, kArity2, 0
144 ])
145 .exportFunc();
146
147 var first_module = new WasmModuleBuilder();
148 var sig_index_2 = first_module.addType(kSig_v_ii);
149 first_module.addImportWithModule("import_module_1", "import_name_1", sig_ind ex_2);
150 first_module.addFunction("first_export", sig_index_2)
151 .addBody([
152 kExprGetLocal, 0,
153 kExprGetLocal, 1,
154 kExprCallFunction, kArity2, 1
155 ])
156 .exportFunc();
157 first_module.addFunction("first_func", sig_index_2)
158 .addBody([
159 kExprGetLocal, 0,
160 kExprGetLocal, 1,
161 kExprCallImport, kArity2, 0
162 ]);
163
164 var f = second_module.instantiate({import_module_2:{import_name_2:print}})
165 .exports.second_export;
166 var the_export = first_module.instantiate({import_module_1:{import_name_1:f} })
167 .exports.first_export;
168 %CheckWasmWrapperElison(the_export, expect_no_elison);
169 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698