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

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

Issue 2345593003: [wasm] Master CL for Binary 0xC changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test failures and TSAN races. Created 4 years, 2 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/start-function.js ('k') | test/mjsunit/wasm/test-wasm-module-builder.js » ('j') | 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 // Flags: --expose-wasm --allow-natives-syntax 5 // Flags: --expose-wasm --allow-natives-syntax
6 6
7 load("test/mjsunit/wasm/wasm-constants.js"); 7 load("test/mjsunit/wasm/wasm-constants.js");
8 load("test/mjsunit/wasm/wasm-module-builder.js"); 8 load("test/mjsunit/wasm/wasm-module-builder.js");
9 9
10 var expect_elison = 0; 10 var expect_elison = 0;
11 var expect_no_elison = 1; 11 var expect_no_elison = 1;
12 // function calls stack: first_export -> first_func -> first_import -> 12 // function calls stack: first_export -> first_func -> first_import ->
13 // second_export -> second_import 13 // second_export -> second_import
14 // In this case, first_import and second_export have same signature, 14 // In this case, first_import and second_export have same signature,
15 // So that wrappers will be removed 15 // So that wrappers will be removed
16 (function TestWasmWrapperElision() { 16 (function TestWasmWrapperElision() {
17 var imported = function (a) { 17 var imported = function (a) {
18 return a; 18 return a;
19 }; 19 };
20 20
21 var second_module = new WasmModuleBuilder(); 21 var second_module = new WasmModuleBuilder();
22 var sig_index = second_module.addType(kSig_i_i); 22 var sig_index = second_module.addType(kSig_i_i);
23 second_module 23 second_module
24 .addImportWithModule("import_module_2", "import_name_2", sig_index); 24 .addImportWithModule("import_module_2", "import_name_2", sig_index);
25 second_module 25 second_module
26 .addFunction("second_export", sig_index) 26 .addFunction("second_export", sig_index)
27 .addBody([ 27 .addBody([
28 kExprGetLocal, 0, 28 kExprGetLocal, 0,
29 kExprCallImport, kArity1, 0, 29 kExprCallFunction, 0,
30 kExprReturn, kArity1 30 kExprReturn
31 ]) 31 ])
32 .exportFunc(); 32 .exportFunc();
33 33
34 var first_module = new WasmModuleBuilder(); 34 var first_module = new WasmModuleBuilder();
35 var sig_index = first_module.addType(kSig_i_i); 35 var sig_index = first_module.addType(kSig_i_i);
36 first_module 36 first_module
37 .addImportWithModule("import_module_1", "import_name_1", sig_index); 37 .addImportWithModule("import_module_1", "import_name_1", sig_index);
38 first_module 38 first_module
39 .addFunction("first_export", sig_index) 39 .addFunction("first_export", sig_index)
40 .addBody([ 40 .addBody([
41 kExprGetLocal, 0, 41 kExprGetLocal, 0,
42 kExprCallFunction, kArity1, 1, 42 kExprCallFunction, 2,
43 kExprReturn, kArity1 43 kExprReturn
44 ]) 44 ])
45 .exportFunc(); 45 .exportFunc();
46 first_module 46 first_module
47 .addFunction("first_func", sig_index) 47 .addFunction("first_func", sig_index)
48 .addBody([ 48 .addBody([
49 kExprI32Const, 1, 49 kExprI32Const, 1,
50 kExprGetLocal, 0, 50 kExprGetLocal, 0,
51 kExprI32Add, 51 kExprI32Add,
52 kExprCallImport, kArity1, 0, 52 kExprCallFunction, 0,
53 kExprReturn, kArity1 53 kExprReturn
54 ]); 54 ]);
55 55
56 var f = second_module 56 var f = second_module
57 .instantiate({import_module_2: {import_name_2: imported}}) 57 .instantiate({import_module_2: {import_name_2: imported}})
58 .exports.second_export; 58 .exports.second_export;
59 var the_export = first_module 59 var the_export = first_module
60 .instantiate({import_module_1: {import_name_1: f}}) 60 .instantiate({import_module_1: {import_name_1: f}})
61 .exports.first_export; 61 .exports.first_export;
62 assertEquals(the_export(2), 3); 62 assertEquals(the_export(2), 3);
63 assertEquals(the_export(-1), 0); 63 assertEquals(the_export(-1), 0);
(...skipping 12 matching lines...) Expand all
76 }; 76 };
77 77
78 var second_module = new WasmModuleBuilder(); 78 var second_module = new WasmModuleBuilder();
79 var sig_index_1 = second_module.addType(kSig_i_i); 79 var sig_index_1 = second_module.addType(kSig_i_i);
80 second_module 80 second_module
81 .addImportWithModule("import_module_2", "import_name_2", sig_index_1); 81 .addImportWithModule("import_module_2", "import_name_2", sig_index_1);
82 second_module 82 second_module
83 .addFunction("second_export", sig_index_1) 83 .addFunction("second_export", sig_index_1)
84 .addBody([ 84 .addBody([
85 kExprGetLocal, 0, 85 kExprGetLocal, 0,
86 kExprCallImport, kArity1, 0, 86 kExprCallFunction, 0,
87 kExprReturn, kArity1 87 kExprReturn
88 ]) 88 ])
89 .exportFunc(); 89 .exportFunc();
90 90
91 var first_module = new WasmModuleBuilder(); 91 var first_module = new WasmModuleBuilder();
92 var sig_index_2 = first_module.addType(kSig_i_ii); 92 var sig_index_2 = first_module.addType(kSig_i_ii);
93 first_module 93 first_module
94 .addImportWithModule("import_module_1", "import_name_1", sig_index_2); 94 .addImportWithModule("import_module_1", "import_name_1", sig_index_2);
95 first_module 95 first_module
96 .addFunction("first_export", sig_index_2) 96 .addFunction("first_export", sig_index_2)
97 .addBody([ 97 .addBody([
98 kExprGetLocal, 0, 98 kExprGetLocal, 0,
99 kExprGetLocal, 1, 99 kExprGetLocal, 1,
100 kExprCallFunction, kArity2, 1, 100 kExprCallFunction, 2,
101 kExprReturn, kArity1 101 kExprReturn
102 ]) 102 ])
103 .exportFunc(); 103 .exportFunc();
104 first_module 104 first_module
105 .addFunction("first_func", sig_index_2) 105 .addFunction("first_func", sig_index_2)
106 .addBody([ 106 .addBody([
107 kExprGetLocal, 0, 107 kExprGetLocal, 0,
108 kExprGetLocal, 1, 108 kExprGetLocal, 1,
109 kExprCallImport, kArity2, 0, 109 kExprCallFunction, 0,
110 kExprReturn, kArity1 110 kExprReturn
111 ]); 111 ]);
112 112
113 var f = second_module 113 var f = second_module
114 .instantiate({import_module_2: {import_name_2: imported}}) 114 .instantiate({import_module_2: {import_name_2: imported}})
115 .exports.second_export; 115 .exports.second_export;
116 var the_export = first_module 116 var the_export = first_module
117 .instantiate({import_module_1: {import_name_1: f}}) 117 .instantiate({import_module_1: {import_name_1: f}})
118 .exports.first_export; 118 .exports.first_export;
119 assertEquals(the_export(4, 5), 4); 119 assertEquals(the_export(4, 5), 4);
120 assertEquals(the_export(-1, 4), -1); 120 assertEquals(the_export(-1, 4), -1);
(...skipping 14 matching lines...) Expand all
135 var second_module = new WasmModuleBuilder(); 135 var second_module = new WasmModuleBuilder();
136 var sig_index_3 = second_module.addType(kSig_i_iii); 136 var sig_index_3 = second_module.addType(kSig_i_iii);
137 second_module 137 second_module
138 .addImportWithModule("import_module_2", "import_name_2", sig_index_3); 138 .addImportWithModule("import_module_2", "import_name_2", sig_index_3);
139 second_module 139 second_module
140 .addFunction("second_export", sig_index_3) 140 .addFunction("second_export", sig_index_3)
141 .addBody([ 141 .addBody([
142 kExprGetLocal, 0, 142 kExprGetLocal, 0,
143 kExprGetLocal, 1, 143 kExprGetLocal, 1,
144 kExprGetLocal, 2, 144 kExprGetLocal, 2,
145 kExprCallImport, kArity3, 0, 145 kExprCallFunction, 0,
146 kExprReturn, kArity1 146 kExprReturn
147 ]) 147 ])
148 .exportFunc(); 148 .exportFunc();
149 149
150 var first_module = new WasmModuleBuilder(); 150 var first_module = new WasmModuleBuilder();
151 var sig_index_2 = first_module.addType(kSig_i_ii); 151 var sig_index_2 = first_module.addType(kSig_i_ii);
152 first_module 152 first_module
153 .addImportWithModule("import_module_1", "import_name_1", sig_index_2); 153 .addImportWithModule("import_module_1", "import_name_1", sig_index_2);
154 first_module 154 first_module
155 .addFunction("first_export", sig_index_2) 155 .addFunction("first_export", sig_index_2)
156 .addBody([ 156 .addBody([
157 kExprGetLocal, 0, 157 kExprGetLocal, 0,
158 kExprGetLocal, 1, 158 kExprGetLocal, 1,
159 kExprCallFunction, kArity2, 1, 159 kExprCallFunction, 2,
160 kExprReturn, kArity1 160 kExprReturn
161 ]) 161 ])
162 .exportFunc(); 162 .exportFunc();
163 first_module 163 first_module
164 .addFunction("first_func", sig_index_2) 164 .addFunction("first_func", sig_index_2)
165 .addBody([ 165 .addBody([
166 kExprGetLocal, 0, 166 kExprGetLocal, 0,
167 kExprGetLocal, 1, 167 kExprGetLocal, 1,
168 kExprCallImport, kArity2, 0, 168 kExprCallFunction, 0,
169 kExprReturn, kArity1 169 kExprReturn
170 ]); 170 ]);
171 171
172 var f = second_module 172 var f = second_module
173 .instantiate({import_module_2: {import_name_2: imported}}) 173 .instantiate({import_module_2: {import_name_2: imported}})
174 .exports.second_export; 174 .exports.second_export;
175 var the_export = first_module 175 var the_export = first_module
176 .instantiate({import_module_1: {import_name_1: f}}) 176 .instantiate({import_module_1: {import_name_1: f}})
177 .exports.first_export; 177 .exports.first_export;
178 assertEquals(the_export(5, 6), 11); 178 assertEquals(the_export(5, 6), 11);
179 assertEquals(the_export(-1, -4), -5); 179 assertEquals(the_export(-1, -4), -5);
(...skipping 13 matching lines...) Expand all
193 193
194 var second_module = new WasmModuleBuilder(); 194 var second_module = new WasmModuleBuilder();
195 var sig_index_2 = second_module.addType(kSig_d_dd); 195 var sig_index_2 = second_module.addType(kSig_d_dd);
196 second_module 196 second_module
197 .addImportWithModule("import_module_2", "import_name_2", sig_index_2); 197 .addImportWithModule("import_module_2", "import_name_2", sig_index_2);
198 second_module 198 second_module
199 .addFunction("second_export", sig_index_2) 199 .addFunction("second_export", sig_index_2)
200 .addBody([ 200 .addBody([
201 kExprGetLocal, 0, 201 kExprGetLocal, 0,
202 kExprGetLocal, 1, 202 kExprGetLocal, 1,
203 kExprCallImport, kArity2, 0, 203 kExprCallFunction, 0,
204 kExprReturn, kArity1 204 kExprReturn
205 ]) 205 ])
206 .exportFunc(); 206 .exportFunc();
207 207
208 var first_module = new WasmModuleBuilder(); 208 var first_module = new WasmModuleBuilder();
209 var sig_index_2 = first_module.addType(kSig_i_ii); 209 var sig_index_2 = first_module.addType(kSig_i_ii);
210 first_module 210 first_module
211 .addImportWithModule("import_module_1", "import_name_1", sig_index_2); 211 .addImportWithModule("import_module_1", "import_name_1", sig_index_2);
212 first_module 212 first_module
213 .addFunction("first_export", sig_index_2) 213 .addFunction("first_export", sig_index_2)
214 .addBody([ 214 .addBody([
215 kExprGetLocal, 0, 215 kExprGetLocal, 0,
216 kExprGetLocal, 1, 216 kExprGetLocal, 1,
217 kExprCallFunction, kArity2, 1, 217 kExprCallFunction, 2,
218 kExprReturn, kArity1 218 kExprReturn
219 ]) 219 ])
220 .exportFunc(); 220 .exportFunc();
221 first_module 221 first_module
222 .addFunction("first_func", sig_index_2) 222 .addFunction("first_func", sig_index_2)
223 .addBody([ 223 .addBody([
224 kExprGetLocal, 0, 224 kExprGetLocal, 0,
225 kExprGetLocal, 1, 225 kExprGetLocal, 1,
226 kExprCallImport, kArity2, 0, 226 kExprCallFunction, 0,
227 kExprReturn, kArity1 227 kExprReturn
228 ]); 228 ]);
229 229
230 var f = second_module 230 var f = second_module
231 .instantiate({import_module_2: {import_name_2: imported}}) 231 .instantiate({import_module_2: {import_name_2: imported}})
232 .exports.second_export; 232 .exports.second_export;
233 var the_export = first_module 233 var the_export = first_module
234 .instantiate({import_module_1: {import_name_1: f}}) 234 .instantiate({import_module_1: {import_name_1: f}})
235 .exports.first_export; 235 .exports.first_export;
236 assertEquals(the_export(2.8, 9.1), 11); 236 assertEquals(the_export(2.8, 9.1), 11);
237 assertEquals(the_export(-1.7, -2.5), -3); 237 assertEquals(the_export(-1.7, -2.5), -3);
238 assertEquals(the_export(0.0, 0.0), 0); 238 assertEquals(the_export(0.0, 0.0), 0);
239 assertEquals(the_export(2, -2), 0); 239 assertEquals(the_export(2, -2), 0);
240 assertEquals(%CheckWasmWrapperElision(the_export, expect_no_elison), true); 240 assertEquals(%CheckWasmWrapperElision(the_export, expect_no_elison), true);
241 })(); 241 })();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/start-function.js ('k') | test/mjsunit/wasm/test-wasm-module-builder.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698