From e898c85924fa628463b14dfbc4f40619a6349ad9 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 17 Dec 2018 13:31:05 -0800 Subject: [PATCH 1/2] feedback --- src/abi/js.h | 4 ++-- src/asm2wasm.h | 2 +- src/passes/LegalizeJSInterface.cpp | 4 ++-- src/tools/wasm-emscripten-finalize.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/abi/js.h b/src/abi/js.h index 539b465fb81..bcc7dbb6e6e 100644 --- a/src/abi/js.h +++ b/src/abi/js.h @@ -23,13 +23,13 @@ namespace wasm { namespace ABI { -enum LegalizationLevel { +enum class LegalizationLevel { Full = 0, Minimal = 1 }; inline std::string getLegalizationPass(LegalizationLevel level) { - if (level == Full) { + if (level == LegalizationLevel::Full) { return "legalize-js-interface"; } else { return "legalize-js-interface-minimally"; diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 522d53a2b3c..b7315b079ac 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -1454,7 +1454,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) { // so that the output of the first pass is valid passRunner.add(this); passRunner.add(ABI::getLegalizationPass( - legalizeJavaScriptFFI ? ABI::Full : ABI::Minimal + legalizeJavaScriptFFI ? ABI::LegalizationLevel::Full : ABI::LegalizationLevel::Minimal )); if (runOptimizationPasses) { // autodrop can add some garbage diff --git a/src/passes/LegalizeJSInterface.cpp b/src/passes/LegalizeJSInterface.cpp index 8a8bb3e27fc..9d223390e94 100644 --- a/src/passes/LegalizeJSInterface.cpp +++ b/src/passes/LegalizeJSInterface.cpp @@ -57,7 +57,7 @@ struct LegalizeJSInterface : public Pass { if (ex->kind == ExternalKind::Function) { // if it's an import, ignore it auto* func = module->getFunction(ex->value); - if (isIllegal(func) && isRelevant(ex.get(), func)) { + if (isIllegal(func) && shouldBeLegalized(ex.get(), func)) { auto legalName = makeLegalStub(func, module); ex->value = legalName; } @@ -131,7 +131,7 @@ struct LegalizeJSInterface : public Pass { return false; } - bool isRelevant(Export* ex, Function* func) { + bool shouldBeLegalized(Export* ex, Function* func) { if (full) return true; // We are doing minimal legalization - just what JS needs. return ex->name.startsWith("dynCall_"); diff --git a/src/tools/wasm-emscripten-finalize.cpp b/src/tools/wasm-emscripten-finalize.cpp index e9e623e3cd4..5f1207a1e15 100644 --- a/src/tools/wasm-emscripten-finalize.cpp +++ b/src/tools/wasm-emscripten-finalize.cpp @@ -163,7 +163,7 @@ int main(int argc, const char *argv[]) { passRunner.setDebug(options.debug); passRunner.setDebugInfo(debugInfo); passRunner.add(ABI::getLegalizationPass( - legalizeJavaScriptFFI ? ABI::Full : ABI::Minimal + legalizeJavaScriptFFI ? ABI::LegalizationLevel::Full : ABI::LegalizationLevel::Minimal )); passRunner.run(); From 1b5506847448c4997fc8b0a02746ee14d3191b06 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 17 Dec 2018 13:32:45 -0800 Subject: [PATCH 2/2] whitespace --- src/asm2wasm.h | 3 ++- src/tools/wasm-emscripten-finalize.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/asm2wasm.h b/src/asm2wasm.h index b7315b079ac..edd54f06d7e 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -1454,7 +1454,8 @@ void Asm2WasmBuilder::processAsm(Ref ast) { // so that the output of the first pass is valid passRunner.add(this); passRunner.add(ABI::getLegalizationPass( - legalizeJavaScriptFFI ? ABI::LegalizationLevel::Full : ABI::LegalizationLevel::Minimal + legalizeJavaScriptFFI ? ABI::LegalizationLevel::Full + : ABI::LegalizationLevel::Minimal )); if (runOptimizationPasses) { // autodrop can add some garbage diff --git a/src/tools/wasm-emscripten-finalize.cpp b/src/tools/wasm-emscripten-finalize.cpp index 5f1207a1e15..3d74138cccb 100644 --- a/src/tools/wasm-emscripten-finalize.cpp +++ b/src/tools/wasm-emscripten-finalize.cpp @@ -163,7 +163,8 @@ int main(int argc, const char *argv[]) { passRunner.setDebug(options.debug); passRunner.setDebugInfo(debugInfo); passRunner.add(ABI::getLegalizationPass( - legalizeJavaScriptFFI ? ABI::LegalizationLevel::Full : ABI::LegalizationLevel::Minimal + legalizeJavaScriptFFI ? ABI::LegalizationLevel::Full + : ABI::LegalizationLevel::Minimal )); passRunner.run();