From db14d0477f2715e3071687f42b77d8712477d83e Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 19 Apr 2019 15:22:55 -0700 Subject: wasm2js2 import fixes (#2031) * Don't assume function types exist in legalize-js-interface. * Properly handle (ignore) imports in RemoveNonJSOps - do not try to recurse into them. * Run legalize-js-interface and remove-unused-module-elements in wasm2js, the first is necessary, the last is nice to have. --- src/wasm2js.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/wasm2js.h') diff --git a/src/wasm2js.h b/src/wasm2js.h index 34471e213..faad6c3fa 100644 --- a/src/wasm2js.h +++ b/src/wasm2js.h @@ -290,6 +290,7 @@ private: Ref Wasm2JSBuilder::processWasm(Module* wasm, Name funcName) { PassRunner runner(wasm); runner.add(); + runner.add("legalize-js-interface"); // First up remove as many non-JS operations we can, including things like // 64-bit integer multiplication/division, `f32.nearest` instructions, etc. // This may inject intrinsics which use i64 so it needs to be run before the @@ -303,6 +304,7 @@ Ref Wasm2JSBuilder::processWasm(Module* wasm, Name funcName) { runner.add("simplify-locals-notee-nostructure"); runner.add("reorder-locals"); runner.add("vacuum"); + runner.add("remove-unused-module-elements"); runner.setDebug(flags.debug); runner.run(); @@ -311,7 +313,7 @@ Ref Wasm2JSBuilder::processWasm(Module* wasm, Name funcName) { #ifndef NDEBUG if (!WasmValidator().validate(*wasm)) { WasmPrinter::printModule(wasm); - Fatal() << "error in validating input"; + Fatal() << "error in validating wasm2js output"; } #endif -- cgit v1.2.3