diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/abi/js.h | 10 | ||||
-rw-r--r-- | src/passes/LegalizeJSInterface.cpp | 43 | ||||
-rw-r--r-- | src/passes/pass.cpp | 4 | ||||
-rw-r--r-- | src/passes/passes.h | 1 | ||||
-rw-r--r-- | src/tools/wasm-emscripten-finalize.cpp | 6 |
5 files changed, 8 insertions, 56 deletions
diff --git a/src/abi/js.h b/src/abi/js.h index d22376c13..e121e9b28 100644 --- a/src/abi/js.h +++ b/src/abi/js.h @@ -25,16 +25,6 @@ namespace wasm { namespace ABI { -enum class LegalizationLevel { Full = 0, Minimal = 1 }; - -inline std::string getLegalizationPass(LegalizationLevel level) { - if (level == LegalizationLevel::Full) { - return "legalize-js-interface"; - } else { - return "legalize-js-interface-minimally"; - } -} - namespace wasm2js { extern IString SCRATCH_LOAD_I32; diff --git a/src/passes/LegalizeJSInterface.cpp b/src/passes/LegalizeJSInterface.cpp index 0082ba7ab..24d76ab09 100644 --- a/src/passes/LegalizeJSInterface.cpp +++ b/src/passes/LegalizeJSInterface.cpp @@ -22,13 +22,6 @@ // stub methods added in this pass, that thunk i64s into i32, i32 and // vice versa as necessary. // -// We can also legalize in a "minimal" way, that is, only JS-specific -// components, that only JS will care about, such as dynCall methods -// (wasm will never call them, as it can share the tables directly). E.g. -// is dynamic linking, where we can avoid legalizing wasm=>wasm calls -// across modules, we still want to legalize dynCalls so JS can call into the -// tables even to a signature that is not legal. -// // Another variation also "prunes" imports and exports that we cannot yet // legalize, like exports and imports with SIMD or multivalue. Until we write // the logic to legalize them, removing those imports/exports still allows us to @@ -65,9 +58,7 @@ struct LegalizeJSInterface : public Pass { // Adds calls to new imports. bool addsEffects() override { return true; } - bool full; - - LegalizeJSInterface(bool full) : full(full) {} + LegalizeJSInterface() {} void run(Module* module) override { setTempRet0 = nullptr; @@ -82,7 +73,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) && shouldBeLegalized(ex.get(), func)) { + if (isIllegal(func)) { // Provide a legal function for the export. auto legalName = makeLegalStub(func, module); ex->value = legalName; @@ -116,7 +107,7 @@ struct LegalizeJSInterface : public Pass { } // for each illegal import, we must call a legalized stub instead for (auto* im : originalFunctions) { - if (im->imported() && isIllegal(im) && shouldBeLegalized(im)) { + if (im->imported() && isIllegal(im)) { auto funcName = makeLegalStubForCalledImport(im, module); illegalImportsToLegal[im->name] = funcName; // we need to use the legalized version in the tables, as the import @@ -199,24 +190,6 @@ private: bool isDynCall(Name name) { return name.startsWith("dynCall_"); } - // Check if an export should be legalized. - bool shouldBeLegalized(Export* ex, Function* func) { - if (full) { - return true; - } - // We are doing minimal legalization - just what JS needs. - return isDynCall(ex->name); - } - - // Check if an import should be legalized. - bool shouldBeLegalized(Function* im) { - if (full) { - return true; - } - // We are doing minimal legalization - just what JS needs. - return im->module == ENV && im->base.startsWith("invoke_"); - } - Function* tempSetter(Module* module) { if (!setTempRet0) { if (exportedHelpers) { @@ -367,8 +340,8 @@ private: }; struct LegalizeAndPruneJSInterface : public LegalizeJSInterface { - // Legalize fully (true) and add pruning on top. - LegalizeAndPruneJSInterface() : LegalizeJSInterface(true) {} + // Legalize and add pruning on top. + LegalizeAndPruneJSInterface() : LegalizeJSInterface() {} void run(Module* module) override { LegalizeJSInterface::run(module); @@ -440,11 +413,7 @@ struct LegalizeAndPruneJSInterface : public LegalizeJSInterface { } // anonymous namespace -Pass* createLegalizeJSInterfacePass() { return new LegalizeJSInterface(true); } - -Pass* createLegalizeJSInterfaceMinimallyPass() { - return new LegalizeJSInterface(false); -} +Pass* createLegalizeJSInterfacePass() { return new LegalizeJSInterface(); } Pass* createLegalizeAndPruneJSInterfacePass() { return new LegalizeAndPruneJSInterface(); diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index 6faf77276..0955082ac 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -217,10 +217,6 @@ void PassRegistry::registerPasses() { registerPass("legalize-js-interface", "legalizes i64 types on the import/export boundary", createLegalizeJSInterfacePass); - registerPass("legalize-js-interface-minimally", - "legalizes i64 types on the import/export boundary in a minimal " - "manner, only on things only JS will call", - createLegalizeJSInterfaceMinimallyPass); registerPass("legalize-and-prune-js-interface", "legalizes the import/export boundary and prunes when needed", createLegalizeAndPruneJSInterfacePass); diff --git a/src/passes/passes.h b/src/passes/passes.h index 2f188a689..1b1ca99c6 100644 --- a/src/passes/passes.h +++ b/src/passes/passes.h @@ -69,7 +69,6 @@ Pass* createJSPIPass(); Pass* createJ2CLOptsPass(); Pass* createLegalizeAndPruneJSInterfacePass(); Pass* createLegalizeJSInterfacePass(); -Pass* createLegalizeJSInterfaceMinimallyPass(); Pass* createLimitSegmentsPass(); Pass* createLocalCSEPass(); Pass* createLocalSubtypingPass(); diff --git a/src/tools/wasm-emscripten-finalize.cpp b/src/tools/wasm-emscripten-finalize.cpp index 39b9e8e3a..a19d27328 100644 --- a/src/tools/wasm-emscripten-finalize.cpp +++ b/src/tools/wasm-emscripten-finalize.cpp @@ -260,10 +260,8 @@ int main(int argc, const char* argv[]) { } // Legalize the wasm, if BigInts don't make that moot. - if (!bigInt) { - passRunner.add(ABI::getLegalizationPass( - legalizeJavaScriptFFI ? ABI::LegalizationLevel::Full - : ABI::LegalizationLevel::Minimal)); + if (!bigInt && legalizeJavaScriptFFI) { + passRunner.add("legalize-js-interface"); } passRunner.add("strip-target-features"); |