summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/abi/js.h10
-rw-r--r--src/passes/LegalizeJSInterface.cpp43
-rw-r--r--src/passes/pass.cpp4
-rw-r--r--src/passes/passes.h1
-rw-r--r--src/tools/wasm-emscripten-finalize.cpp6
-rw-r--r--test/lit/help/wasm-opt.test5
-rw-r--r--test/lit/help/wasm2js.test5
-rw-r--r--test/lit/passes/legalize-js-interface-minimally.wast86
8 files changed, 8 insertions, 152 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");
diff --git a/test/lit/help/wasm-opt.test b/test/lit/help/wasm-opt.test
index 0cf76e52e..84b5049dd 100644
--- a/test/lit/help/wasm-opt.test
+++ b/test/lit/help/wasm-opt.test
@@ -231,11 +231,6 @@
;; CHECK-NEXT: --legalize-js-interface legalizes i64 types on the
;; CHECK-NEXT: import/export boundary
;; CHECK-NEXT:
-;; CHECK-NEXT: --legalize-js-interface-minimally legalizes i64 types on the
-;; CHECK-NEXT: import/export boundary in a
-;; CHECK-NEXT: minimal manner, only on things
-;; CHECK-NEXT: only JS will call
-;; CHECK-NEXT:
;; CHECK-NEXT: --licm loop invariant code motion
;; CHECK-NEXT:
;; CHECK-NEXT: --limit-segments attempt to merge segments to fit
diff --git a/test/lit/help/wasm2js.test b/test/lit/help/wasm2js.test
index 9804718a8..3ab4099de 100644
--- a/test/lit/help/wasm2js.test
+++ b/test/lit/help/wasm2js.test
@@ -185,11 +185,6 @@
;; CHECK-NEXT: --legalize-js-interface legalizes i64 types on the
;; CHECK-NEXT: import/export boundary
;; CHECK-NEXT:
-;; CHECK-NEXT: --legalize-js-interface-minimally legalizes i64 types on the
-;; CHECK-NEXT: import/export boundary in a
-;; CHECK-NEXT: minimal manner, only on things
-;; CHECK-NEXT: only JS will call
-;; CHECK-NEXT:
;; CHECK-NEXT: --licm loop invariant code motion
;; CHECK-NEXT:
;; CHECK-NEXT: --limit-segments attempt to merge segments to fit
diff --git a/test/lit/passes/legalize-js-interface-minimally.wast b/test/lit/passes/legalize-js-interface-minimally.wast
deleted file mode 100644
index 664b024b3..000000000
--- a/test/lit/passes/legalize-js-interface-minimally.wast
+++ /dev/null
@@ -1,86 +0,0 @@
-;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
-;; NOTE: This test was ported using port_passes_tests_to_lit.py and could be cleaned up.
-
-;; RUN: foreach %s %t wasm-opt --legalize-js-interface-minimally -S -o - | filecheck %s
-
-(module
- ;; CHECK: (type $0 (func (result i64)))
-
- ;; CHECK: (type $1 (func (param i32)))
-
- ;; CHECK: (type $2 (func (result i32)))
-
- ;; CHECK: (type $3 (func (param i64)))
-
- ;; CHECK: (type $4 (func (param i32 i32)))
-
- ;; CHECK: (import "env" "imported" (func $imported (result i64)))
- (import "env" "imported" (func $imported (result i64)))
- (import "env" "invoke_vj" (func $invoke_vj (param i64)))
- ;; CHECK: (import "env" "setTempRet0" (func $setTempRet0 (param i32)))
-
- ;; CHECK: (import "env" "invoke_vj" (func $legalimport$invoke_vj (param i32 i32)))
-
- ;; CHECK: (export "func" (func $func))
- (export "func" (func $func))
- (export "dynCall_foo" (func $dyn))
- ;; CHECK: (export "dynCall_foo" (func $legalstub$dyn))
-
- ;; CHECK: (func $func (result i64)
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (call $imported)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (call $legalfunc$invoke_vj
- ;; CHECK-NEXT: (i64.const 0)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (unreachable)
- ;; CHECK-NEXT: )
- (func $func (result i64)
- (drop (call $imported))
- (call $invoke_vj (i64.const 0))
- (unreachable)
- )
- ;; CHECK: (func $dyn (result i64)
- ;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (call $imported)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (unreachable)
- ;; CHECK-NEXT: )
- (func $dyn (result i64)
- (drop (call $imported))
- (unreachable)
- )
-)
-;; CHECK: (func $legalstub$dyn (result i32)
-;; CHECK-NEXT: (local $0 i64)
-;; CHECK-NEXT: (local.set $0
-;; CHECK-NEXT: (call $dyn)
-;; CHECK-NEXT: )
-;; CHECK-NEXT: (call $setTempRet0
-;; CHECK-NEXT: (i32.wrap_i64
-;; CHECK-NEXT: (i64.shr_u
-;; CHECK-NEXT: (local.get $0)
-;; CHECK-NEXT: (i64.const 32)
-;; CHECK-NEXT: )
-;; CHECK-NEXT: )
-;; CHECK-NEXT: )
-;; CHECK-NEXT: (i32.wrap_i64
-;; CHECK-NEXT: (local.get $0)
-;; CHECK-NEXT: )
-;; CHECK-NEXT: )
-
-;; CHECK: (func $legalfunc$invoke_vj (param $0 i64)
-;; CHECK-NEXT: (call $legalimport$invoke_vj
-;; CHECK-NEXT: (i32.wrap_i64
-;; CHECK-NEXT: (local.get $0)
-;; CHECK-NEXT: )
-;; CHECK-NEXT: (i32.wrap_i64
-;; CHECK-NEXT: (i64.shr_u
-;; CHECK-NEXT: (local.get $0)
-;; CHECK-NEXT: (i64.const 32)
-;; CHECK-NEXT: )
-;; CHECK-NEXT: )
-;; CHECK-NEXT: )
-;; CHECK-NEXT: )
-(module)
-