From f1c992f946438ba8785c418e769ee024606fdde0 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 24 Mar 2017 15:45:31 -0700 Subject: New binaryen.js (#922) New binaryen.js implementation, based on the C API underneath and with a JS-friendly API on top. See docs under docs/ for API details. --- src/wasm-js.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/wasm-js.cpp') diff --git a/src/wasm-js.cpp b/src/wasm-js.cpp index 22f1f1a18..94404aeb9 100644 --- a/src/wasm-js.cpp +++ b/src/wasm-js.cpp @@ -80,7 +80,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE load_asm2wasm(char *input) { module->memory.max = pre.memoryGrowth ? Address(Memory::kMaxSize) : module->memory.initial; if (wasmJSDebug) std::cerr << "wasming...\n"; - asm2wasm = new Asm2WasmBuilder(*module, pre, debug, false /* TODO: support imprecise? */, PassOptions(), false /* TODO: support optimizing? */, false /* TODO: support asm2wasm-i64? */); + asm2wasm = new Asm2WasmBuilder(*module, pre, debug, Asm2WasmBuilder::TrapMode::JS, PassOptions(), false /* TODO: support optimizing? */, false /* TODO: support asm2wasm-i64? */); asm2wasm->processAsm(asmjs); } @@ -171,7 +171,10 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() { if (wasmJSDebug) std::cerr << "creating instance...\n"; struct JSExternalInterface : ModuleInstance::ExternalInterface { + Module* module = nullptr; + void init(Module& wasm, ModuleInstance& instance) override { + module = &wasm; // look for imported memory { bool found = false; @@ -302,7 +305,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() { if (wasmJSDebug) std::cout << "calling import returning " << ret << '\n'; - return getResultFromJS(ret, import->functionType->result); + return getResultFromJS(ret, module->getFunctionType(import->functionType)->result); } Literal callTable(Index index, LiteralList& arguments, WasmType result, ModuleInstance& instance) override { -- cgit v1.2.3