From 909ac3410093c0b35b3181abcd44b9fb9ceb4781 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 3 May 2019 11:26:41 -0700 Subject: wasm2js: avoid some slow operations when not optimizing (#2082) Without this PR, wasm2js0.test_printf in emscripten took an extremely long time to compile. --- src/wasm2js.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/wasm2js.h b/src/wasm2js.h index 731bf0a8c..e721d3d58 100644 --- a/src/wasm2js.h +++ b/src/wasm2js.h @@ -301,12 +301,14 @@ Ref Wasm2JSBuilder::processWasm(Module* wasm, Name funcName) { // Finally, get the code into the flat form we need for wasm2js itself, and // optimize that a little in a way that keeps flat property. runner.add("flatten"); - runner.add("remove-unused-names"); - runner.add("merge-blocks"); + // Regardless of optimization level, run some simple optimizations to undo + // some of the effects of flattening. runner.add("simplify-locals-notee-nostructure"); - // Coalescing is slow if we didn't run full optimizations earlier, so don't - // run it automatically. + // Some operations can be very slow if we didn't run full optimizations + // earlier, so don't run them automatically. if (options.optimizeLevel > 0) { + runner.add("remove-unused-names"); + runner.add("merge-blocks"); runner.add("coalesce-locals"); } runner.add("reorder-locals"); -- cgit v1.2.3