Index: test/mjsunit/wasm/ffi-error.js |
diff --git a/test/mjsunit/wasm/ffi-error.js b/test/mjsunit/wasm/ffi-error.js |
index 6aff071102687a830203d1fde21dc0982c3ef268..649ee273ae4fc4d03f8da44478cf779d1ad519db 100644 |
--- a/test/mjsunit/wasm/ffi-error.js |
+++ b/test/mjsunit/wasm/ffi-error.js |
@@ -5,40 +5,21 @@ |
// Flags: --expose-wasm |
load("test/mjsunit/wasm/wasm-constants.js"); |
+load("test/mjsunit/wasm/wasm-module-builder.js"); |
function testCallFFI(ffi) { |
- var kBodySize = 6; |
- var kNameAddOffset = kHeaderSize + 28 + kBodySize + 1; |
- var kNameMainOffset = kNameAddOffset + 4; |
- |
- var data = bytesWithHeader( |
- kDeclMemory, |
- 1, 1, 1, // memory |
- // -- signatures |
- kDeclSignatures, 1, |
- 2, kAstI32, kAstF64, kAstF64, // (f64,f64)->int |
- // -- foreign function |
- kDeclFunctions, 2, |
- kDeclFunctionName | kDeclFunctionImport, |
- 0, 0, // signature index |
- kNameAddOffset, 0, 0, 0, // name offset |
- // -- main function |
- kDeclFunctionName | kDeclFunctionExport, |
- 0, 0, // signature index |
- kNameMainOffset, 0, 0, 0, // name offset |
- kBodySize, 0, |
- // main body |
- kExprCallFunction, 0, // -- |
- kExprGetLocal, 0, // -- |
- kExprGetLocal, 1, // -- |
- // names |
- kDeclEnd, |
- 'f', 'u', 'n', 0, // -- |
- 'm', 'a', 'i', 'n', 0 // -- |
- ); |
- |
- print("instantiate FFI"); |
- var module = _WASMEXP_.instantiateModule(data, ffi); |
+ var builder = new WasmModuleBuilder(); |
+ |
+ var sig_index = [kAstI32, kAstF64, kAstF64]; |
+ builder.addImport("fun", sig_index); |
+ builder.addFunction("main", sig_index) |
+ .addBody([ |
+ kExprCallImport, 0, // -- |
+ kExprGetLocal, 0, // -- |
+ kExprGetLocal, 1]) // -- |
+ .exportFunc(); |
+ |
+ var module = builder.instantiate(ffi); |
} |
// everything is good. |