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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/import-table.js
diff --git a/test/mjsunit/wasm/import-table.js b/test/mjsunit/wasm/import-table.js
index 0ee9577569f58c970308338dd8e9c73d297fdcec..33d1c3551ccc79a14243f90d05c792ace75d54b5 100644
--- a/test/mjsunit/wasm/import-table.js
+++ b/test/mjsunit/wasm/import-table.js
@@ -334,3 +334,54 @@ function testCallPrint() {
testCallPrint();
testCallPrint();
+
+
+function testCallImport2(foo, bar, expected) {
+ var kBodySize = 5;
+ var kNameFooOffset = 37 + kBodySize + 1;
+ var kNameBarOffset = kNameFooOffset + 4;
+ var kNameMainOffset = kNameBarOffset + 4;
+
+ var ffi = new Object();
+ ffi.foo = foo;
+ ffi.bar = bar;
+
+ var data = bytes(
+ // signatures
+ kDeclSignatures, 1,
+ 0, kAstI32, // void -> i32
+ // -- main function
+ kDeclFunctions,
+ 1,
+ kDeclFunctionName | kDeclFunctionExport,
+ 0, 0,
+ kNameMainOffset, 0, 0, 0, // name offset
+ kBodySize, 0,
+ // main body
+ kExprI32Add, // --
+ kExprCallImport, 0, // --
+ kExprCallImport, 1, // --
+ // imports
+ kDeclImportTable,
+ 2,
+ 0, 0, // sig index
+ 0, 0, 0, 0, // module name offset
+ kNameFooOffset, 0, 0, 0, // function name offset
+ 0, 0, // sig index
+ 0, 0, 0, 0, // module name offset
+ kNameBarOffset, 0, 0, 0, // function name offset
+ // names
+ kDeclEnd,
+ 'f', 'o', 'o', 0, // --
+ 'b', 'a', 'r', 0, // --
+ 'm', 'a', 'i', 'n', 0 // --
+ );
+
+ var module = _WASMEXP_.instantiateModule(data, ffi);
+
+ assertEquals("function", typeof module.main);
+
+ assertEquals(expected, module.main());
+}
+
+testCallImport2(function() { return 33; }, function () { return 44; }, 77);
« 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