Index: test/mjsunit/wasm/import-table.js |
diff --git a/test/mjsunit/wasm/ffi.js b/test/mjsunit/wasm/import-table.js |
similarity index 85% |
copy from test/mjsunit/wasm/ffi.js |
copy to test/mjsunit/wasm/import-table.js |
index 95d655dc6dfdcfbe1746bea3e3e5d4538a72bba4..0ee9577569f58c970308338dd8e9c73d297fdcec 100644 |
--- a/test/mjsunit/wasm/ffi.js |
+++ b/test/mjsunit/wasm/import-table.js |
@@ -6,9 +6,9 @@ |
load("test/mjsunit/wasm/wasm-constants.js"); |
-function testCallFFI(func, check) { |
+function testCallImport(func, check) { |
var kBodySize = 6; |
- var kNameFunOffset = 24 + kBodySize + 1; |
+ var kNameFunOffset = 29 + kBodySize + 1; |
var kNameMainOffset = kNameFunOffset + 4; |
var ffi = new Object(); |
@@ -18,24 +18,27 @@ function testCallFFI(func, check) { |
// signatures |
kDeclSignatures, 1, |
2, kAstI32, kAstF64, kAstF64, // (f64,f64) -> int |
- // -- foreign function |
- kDeclFunctions, 2, |
- kDeclFunctionName | kDeclFunctionImport, |
- 0, 0, |
- kNameFunOffset, 0, 0, 0, // name offset |
// -- main function |
+ kDeclFunctions, |
+ 1, |
kDeclFunctionName | kDeclFunctionExport, |
0, 0, |
- kNameMainOffset, 0, 0, 0, // name offset |
+ kNameMainOffset, 0, 0, 0, // name offset |
kBodySize, 0, |
// main body |
- kExprCallFunction, 0, // -- |
- kExprGetLocal, 0, // -- |
- kExprGetLocal, 1, // -- |
+ kExprCallImport, 0, // -- |
+ kExprGetLocal, 0, // -- |
+ kExprGetLocal, 1, // -- |
+ // imports |
+ kDeclImportTable, |
+ 1, |
+ 0, 0, // sig index |
+ 0, 0, 0, 0, // module name offset |
+ kNameFunOffset, 0, 0, 0, // function name offset |
// names |
kDeclEnd, |
- 'f', 'u', 'n', 0, // -- |
- 'm', 'a', 'i', 'n', 0 // -- |
+ 'f', 'u', 'n', 0, // -- |
+ 'm', 'a', 'i', 'n', 0 // -- |
); |
var module = _WASMEXP_.instantiateModule(data, ffi); |
@@ -72,7 +75,7 @@ function check_FOREIGN_SUB(r, a, b) { |
was_called = false; |
} |
-testCallFFI(FOREIGN_SUB, check_FOREIGN_SUB); |
+testCallImport(FOREIGN_SUB, check_FOREIGN_SUB); |
function FOREIGN_ABCD(a, b, c, d) { |
@@ -97,7 +100,7 @@ function check_FOREIGN_ABCD(r, a, b) { |
was_called = false; |
} |
-testCallFFI(FOREIGN_ABCD, check_FOREIGN_ABCD); |
+testCallImport(FOREIGN_ABCD, check_FOREIGN_ABCD); |
function FOREIGN_ARGUMENTS0() { |
print("FOREIGN_ARGUMENTS0"); |
@@ -159,11 +162,11 @@ function check_FOREIGN_ARGUMENTS(r, a, b) { |
} |
// Check a bunch of uses of the arguments object. |
-testCallFFI(FOREIGN_ARGUMENTS0, check_FOREIGN_ARGUMENTS); |
-testCallFFI(FOREIGN_ARGUMENTS1, check_FOREIGN_ARGUMENTS); |
-testCallFFI(FOREIGN_ARGUMENTS2, check_FOREIGN_ARGUMENTS); |
-testCallFFI(FOREIGN_ARGUMENTS3, check_FOREIGN_ARGUMENTS); |
-testCallFFI(FOREIGN_ARGUMENTS4, check_FOREIGN_ARGUMENTS); |
+testCallImport(FOREIGN_ARGUMENTS0, check_FOREIGN_ARGUMENTS); |
+testCallImport(FOREIGN_ARGUMENTS1, check_FOREIGN_ARGUMENTS); |
+testCallImport(FOREIGN_ARGUMENTS2, check_FOREIGN_ARGUMENTS); |
+testCallImport(FOREIGN_ARGUMENTS3, check_FOREIGN_ARGUMENTS); |
+testCallImport(FOREIGN_ARGUMENTS4, check_FOREIGN_ARGUMENTS); |
function returnValue(val) { |
return function(a, b) { |
@@ -178,14 +181,14 @@ function checkReturn(expected) { |
} |
// Check that returning weird values doesn't crash |
-testCallFFI(returnValue(undefined), checkReturn(0)); |
-testCallFFI(returnValue(null), checkReturn(0)); |
-testCallFFI(returnValue("0"), checkReturn(0)); |
-testCallFFI(returnValue("-77"), checkReturn(-77)); |
+testCallImport(returnValue(undefined), checkReturn(0)); |
+testCallImport(returnValue(null), checkReturn(0)); |
+testCallImport(returnValue("0"), checkReturn(0)); |
+testCallImport(returnValue("-77"), checkReturn(-77)); |
var objWithValueOf = {valueOf: function() { return 198; }} |
-testCallFFI(returnValue(objWithValueOf), checkReturn(198)); |
+testCallImport(returnValue(objWithValueOf), checkReturn(198)); |
function testCallBinopVoid(type, func, check) { |