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

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

Issue 1717993002: [wasm] Fix bug in CallImport. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 | « src/compiler/wasm-compiler.cc ('k') | 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 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 8
9 function testCallImport(func, check) { 9 function testCallImport(func, check) {
10 var kBodySize = 6; 10 var kBodySize = 6;
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 327
328 assertEquals("function", typeof module.main); 328 assertEquals("function", typeof module.main);
329 329
330 for (var i = -9; i < 900; i += 6.125) { 330 for (var i = -9; i < 900; i += 6.125) {
331 module.main(i); 331 module.main(i);
332 } 332 }
333 } 333 }
334 334
335 testCallPrint(); 335 testCallPrint();
336 testCallPrint(); 336 testCallPrint();
337
338
339 function testCallImport2(foo, bar, expected) {
340 var kBodySize = 5;
341 var kNameFooOffset = 37 + kBodySize + 1;
342 var kNameBarOffset = kNameFooOffset + 4;
343 var kNameMainOffset = kNameBarOffset + 4;
344
345 var ffi = new Object();
346 ffi.foo = foo;
347 ffi.bar = bar;
348
349 var data = bytes(
350 // signatures
351 kDeclSignatures, 1,
352 0, kAstI32, // void -> i32
353 // -- main function
354 kDeclFunctions,
355 1,
356 kDeclFunctionName | kDeclFunctionExport,
357 0, 0,
358 kNameMainOffset, 0, 0, 0, // name offset
359 kBodySize, 0,
360 // main body
361 kExprI32Add, // --
362 kExprCallImport, 0, // --
363 kExprCallImport, 1, // --
364 // imports
365 kDeclImportTable,
366 2,
367 0, 0, // sig index
368 0, 0, 0, 0, // module name offset
369 kNameFooOffset, 0, 0, 0, // function name offset
370 0, 0, // sig index
371 0, 0, 0, 0, // module name offset
372 kNameBarOffset, 0, 0, 0, // function name offset
373 // names
374 kDeclEnd,
375 'f', 'o', 'o', 0, // --
376 'b', 'a', 'r', 0, // --
377 'm', 'a', 'i', 'n', 0 // --
378 );
379
380 var module = _WASMEXP_.instantiateModule(data, ffi);
381
382 assertEquals("function", typeof module.main);
383
384 assertEquals(expected, module.main());
385 }
386
387 testCallImport2(function() { return 33; }, function () { return 44; }, 77);
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698