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

Side by Side Diff: test/mjsunit/wasm/import-table.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, 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/grow-memory.js ('k') | test/mjsunit/wasm/incrementer.wasm » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 5 // Flags: --expose-wasm
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 function testCallImport(func, check) { 10 function testCallImport(func, check) {
11 var builder = new WasmModuleBuilder(); 11 var builder = new WasmModuleBuilder();
12 12
13 var sig_index = builder.addType(kSig_i_dd); 13 var sig_index = builder.addType(kSig_i_dd);
14 builder.addImport("func", sig_index); 14 builder.addImport("func", sig_index);
15 builder.addFunction("main", sig_index) 15 builder.addFunction("main", sig_index)
16 .addBody([ 16 .addBody([
17 kExprGetLocal, 0, // -- 17 kExprGetLocal, 0, // --
18 kExprGetLocal, 1, // -- 18 kExprGetLocal, 1, // --
19 kExprCallFunction, 0]) // -- 19 kExprCallImport, 2, 0]) // --
20 .exportAs("main"); 20 .exportAs("main");
21 21
22 var main = builder.instantiate({func: func}).exports.main; 22 var main = builder.instantiate({func: func}).exports.main;
23 23
24 for (var i = 0; i < 100000; i += 10003) { 24 for (var i = 0; i < 100000; i += 10003) {
25 var a = 22.5 + i, b = 10.5 + i; 25 var a = 22.5 + i, b = 10.5 + i;
26 var r = main(a, b); 26 var r = main(a, b);
27 check(r, a, b); 27 check(r, a, b);
28 } 28 }
29 } 29 }
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 args_b = arguments[1]; 184 args_b = arguments[1];
185 } 185 }
186 186
187 var builder = new WasmModuleBuilder(); 187 var builder = new WasmModuleBuilder();
188 188
189 builder.addImport("func", makeSig_v_xx(type)); 189 builder.addImport("func", makeSig_v_xx(type));
190 builder.addFunction("main", makeSig_r_xx(kAstI32, type)) 190 builder.addFunction("main", makeSig_r_xx(kAstI32, type))
191 .addBody([ 191 .addBody([
192 kExprGetLocal, 0, // -- 192 kExprGetLocal, 0, // --
193 kExprGetLocal, 1, // -- 193 kExprGetLocal, 1, // --
194 kExprCallFunction, 0, // -- 194 kExprCallImport, 2, 0, // --
195 kExprI8Const, 99, // -- 195 kExprI8Const, 99, // --
196 ]) 196 ])
197 .exportFunc("main"); 197 .exportFunc("main");
198 198
199 var main = builder.instantiate(ffi).exports.main; 199 var main = builder.instantiate(ffi).exports.main;
200 200
201 print("testCallBinopVoid", type); 201 print("testCallBinopVoid", type);
202 202
203 for (var i = 0; i < 100000; i += 10003.1) { 203 for (var i = 0; i < 100000; i += 10003.1) {
204 var a = 22.5 + i, b = 10.5 + i; 204 var a = 22.5 + i, b = 10.5 + i;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 239
240 240
241 241
242 function testCallPrint() { 242 function testCallPrint() {
243 var builder = new WasmModuleBuilder(); 243 var builder = new WasmModuleBuilder();
244 builder.addImport("print", makeSig_v_x(kAstI32)); 244 builder.addImport("print", makeSig_v_x(kAstI32));
245 builder.addImport("print", makeSig_r_x(kAstF64, kAstF64)); 245 builder.addImport("print", makeSig_r_x(kAstF64, kAstF64));
246 builder.addFunction("main", makeSig_r_x(kAstF64, kAstF64)) 246 builder.addFunction("main", makeSig_r_x(kAstF64, kAstF64))
247 .addBody([ 247 .addBody([
248 kExprI8Const, 97, // -- 248 kExprI8Const, 97, // --
249 kExprCallFunction, 0, // -- 249 kExprCallImport, kArity1, 0, // --
250 kExprGetLocal, 0, // -- 250 kExprGetLocal, 0, // --
251 kExprCallFunction, 1 // -- 251 kExprCallImport, kArity1, 1 // --
252 ]) 252 ])
253 .exportFunc(); 253 .exportFunc();
254 254
255 var main = builder.instantiate({print: print}).exports.main; 255 var main = builder.instantiate({print: print}).exports.main;
256 256
257 for (var i = -9; i < 900; i += 16.125) { 257 for (var i = -9; i < 900; i += 16.125) {
258 main(i); 258 main(i);
259 } 259 }
260 } 260 }
261 261
262 testCallPrint(); 262 testCallPrint();
263 testCallPrint(); 263 testCallPrint();
264 264
265 265
266 function testCallImport2(foo, bar, expected) { 266 function testCallImport2(foo, bar, expected) {
267 var builder = new WasmModuleBuilder(); 267 var builder = new WasmModuleBuilder();
268 268
269 builder.addImport("foo", kSig_i); 269 builder.addImport("foo", kSig_i);
270 builder.addImport("bar", kSig_i); 270 builder.addImport("bar", kSig_i);
271 builder.addFunction("main", kSig_i) 271 builder.addFunction("main", kSig_i)
272 .addBody([ 272 .addBody([
273 kExprCallFunction, 0, // -- 273 kExprCallImport, kArity0, 0, // --
274 kExprCallFunction, 1, // -- 274 kExprCallImport, kArity0, 1, // --
275 kExprI32Add, // -- 275 kExprI32Add, // --
276 ]) // -- 276 ]) // --
277 .exportFunc(); 277 .exportFunc();
278 278
279 var main = builder.instantiate({foo: foo, bar: bar}).exports.main; 279 var main = builder.instantiate({foo: foo, bar: bar}).exports.main;
280 assertEquals(expected, main()); 280 assertEquals(expected, main());
281 } 281 }
282 282
283 testCallImport2(function() { return 33; }, function () { return 44; }, 77); 283 testCallImport2(function() { return 33; }, function () { return 44; }, 77);
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/grow-memory.js ('k') | test/mjsunit/wasm/incrementer.wasm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698