summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2024-05-15 12:36:00 -0700
committerGitHub <noreply@github.com>2024-05-15 12:36:00 -0700
commitae9499448c9221290f46eac26169db378fcd6997 (patch)
tree421f530a1bd76b77810c07b0bf0c771ac1c5653f /src
parentb70d8dff27ccea2d4546909dba83bf8cae072aba (diff)
downloadbinaryen-ae9499448c9221290f46eac26169db378fcd6997.tar.gz
binaryen-ae9499448c9221290f46eac26169db378fcd6997.tar.bz2
binaryen-ae9499448c9221290f46eac26169db378fcd6997.zip
[EH] Rename option/pass names for new EH (exnref) (#6592)
We settled on the name `WASM_EXNREF` for the new setting in Emscripten for the name for the new EH option. https://github.com/emscripten-core/emscripten/blob/2bc5e3156f07e603bc4f3580cf84c038ea99b2df/src/settings.js#L782-L786 "New EH" sounds vague and I'm not sure if "experimental" is really necessary anyway, given that the potential users of this option is aware that this is a new spec that has been adopted recently. To make the option names consistent, this renames `--translate-to-eh` (the option that only runs the translator) to `--translate-to-exnref`, and `--experimental-new-eh` to `--emit-exnref` (the option that runs the translator at the end of the whole pipeline), and renames the pass and variable names in the code accordingly as well. In case anyone is using the old option names (and also to make the Chromium CI pass), this does not delete the old options.
Diffstat (limited to 'src')
-rw-r--r--src/passes/TranslateEH.cpp8
-rw-r--r--src/passes/pass.cpp7
-rw-r--r--src/passes/passes.h2
-rw-r--r--src/tools/wasm-opt.cpp23
4 files changed, 22 insertions, 18 deletions
diff --git a/src/passes/TranslateEH.cpp b/src/passes/TranslateEH.cpp
index 42cea6199..3d2f01510 100644
--- a/src/passes/TranslateEH.cpp
+++ b/src/passes/TranslateEH.cpp
@@ -15,7 +15,7 @@
*/
//
-// TranslateToNewEH translates the old Phase 3 EH instructions, which include
+// TranslateToExnref translates the old Phase 3 EH instructions, which include
// try, catch, catch_all, delegate, and rethrow, into the new EH instructions,
// which include try_table (with catch / catch_ref / catch_all / catch_all_ref)
// and throw_ref, passed at the Oct 2023 CG meeting. This translator can be used
@@ -39,7 +39,7 @@ namespace {
// Translates the old EH instructions (try / catch / catch_all / delegate /
// rethrow) into the new ones (try_table (+ catch / catch_ref / catch_all /
// catch_all_ref) / throw_ref).
-struct TranslateToNewEH : public WalkerPass<PostWalker<TranslateToNewEH>> {
+struct TranslateToExnref : public WalkerPass<PostWalker<TranslateToExnref>> {
bool isFunctionParallel() override { return true; }
// Scans and records which try labels are targeted by delegates and rethrows.
@@ -195,7 +195,7 @@ struct TranslateToNewEH : public WalkerPass<PostWalker<TranslateToNewEH>> {
std::unordered_map<Type, Index> typeToScratchLocal;
std::unique_ptr<Pass> create() override {
- return std::make_unique<TranslateToNewEH>();
+ return std::make_unique<TranslateToExnref>();
}
// Get a scratch local for a given type. These locals are used to contain
@@ -814,6 +814,6 @@ struct TranslateToNewEH : public WalkerPass<PostWalker<TranslateToNewEH>> {
} // namespace
-Pass* createTranslateToNewEHPass() { return new TranslateToNewEH(); }
+Pass* createTranslateToExnrefPass() { return new TranslateToExnref(); }
} // namespace wasm
diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp
index c5a2bcc55..5e5ee04a4 100644
--- a/src/passes/pass.cpp
+++ b/src/passes/pass.cpp
@@ -501,8 +501,11 @@ void PassRegistry::registerPasses() {
"strip the wasm target features section",
createStripTargetFeaturesPass);
registerPass("translate-to-new-eh",
- "translate old EH instructions to new ones",
- createTranslateToNewEHPass);
+ "deprecated; same as translate-to-exnref",
+ createTranslateToExnrefPass);
+ registerPass("translate-to-exnref",
+ "translate old Phase 3 EH instructions to new ones with exnref",
+ createTranslateToExnrefPass);
registerPass("trap-mode-clamp",
"replace trapping operations with clamping semantics",
createTrapModeClamp);
diff --git a/src/passes/passes.h b/src/passes/passes.h
index ac3e1ef29..88e0a7ccc 100644
--- a/src/passes/passes.h
+++ b/src/passes/passes.h
@@ -166,7 +166,7 @@ Pass* createStripEHPass();
Pass* createStubUnsupportedJSOpsPass();
Pass* createSSAifyPass();
Pass* createSSAifyNoMergePass();
-Pass* createTranslateToNewEHPass();
+Pass* createTranslateToExnrefPass();
Pass* createTrapModeClamp();
Pass* createTrapModeJS();
Pass* createTupleOptimizationPass();
diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp
index cb6d0bcec..73908afb7 100644
--- a/src/tools/wasm-opt.cpp
+++ b/src/tools/wasm-opt.cpp
@@ -91,7 +91,7 @@ int main(int argc, const char* argv[]) {
std::string inputSourceMapFilename;
std::string outputSourceMapFilename;
std::string outputSourceMapUrl;
- bool experimentalNewEH = false;
+ bool emitExnref = false;
const std::string WasmOptOption = "wasm-opt options";
@@ -241,15 +241,19 @@ int main(int argc, const char* argv[]) {
})
.add("--experimental-new-eh",
"",
+ "Deprecated; same as --emit-exnref",
+ WasmOptOption,
+ Options::Arguments::Zero,
+ [&emitExnref](Options*, const std::string&) { emitExnref = true; })
+ .add("--emit-exnref",
+ "",
"After running all requested transformations / optimizations, "
"translate the instruction to use the new EH instructions at the end. "
"Depending on the optimization level specified, this may do some more "
"post-translation optimizations.",
WasmOptOption,
Options::Arguments::Zero,
- [&experimentalNewEH](Options*, const std::string&) {
- experimentalNewEH = true;
- });
+ [&emitExnref](Options*, const std::string&) { emitExnref = true; });
options.parse(argc, argv);
Module wasm;
@@ -356,11 +360,10 @@ int main(int argc, const char* argv[]) {
std::cout << "[extra-fuzz-command first output:]\n" << firstOutput << '\n';
}
- bool translateToNewEH =
- wasm.features.hasExceptionHandling() && experimentalNewEH;
+ bool translateToExnref = wasm.features.hasExceptionHandling() && emitExnref;
if (!options.runningPasses()) {
- if (!options.quiet && !translateToNewEH) {
+ if (!options.quiet && !translateToExnref) {
std::cerr << "warning: no passes specified, not doing any work\n";
}
} else {
@@ -397,12 +400,10 @@ int main(int argc, const char* argv[]) {
}
}
- if (translateToNewEH) {
+ if (translateToExnref) {
BYN_TRACE("translating to new EH instructions...\n");
PassRunner runner(&wasm, options.passOptions);
- runner.add("translate-to-new-eh");
- // Perform Stack IR optimizations here, at the very end of the
- // optimization pipeline.
+ runner.add("translate-to-exnref");
runner.run();
if (options.passOptions.validate) {
bool valid = WasmValidator().validate(wasm, options.passOptions);