Skip to content

Commit

Permalink
[EH] Add translator from old to new EH instructions (#6210)
Browse files Browse the repository at this point in the history
This 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 as a standalone tool by users of the
previous EH toolchain to generate binaries for the new spec without
recompiling, and also can be used at the end of the Binaryen pipeline to
produce binaries for the new spec while the end-to-end toolchain
implementation for the new spec is in progress.

While the goal of this pass is not optimization, this tries to a little
better than the most naive implementation, namely by omitting a few
instructions where possible and trying to minimize the number of
additional locals, because this can be used as a standalone translator
or the last stage of the pipeline while we can't post-optimize the
results because the whole pipeline (-On) is not ready for the new EH.
  • Loading branch information
aheejin authored Jan 24, 2024
1 parent 9090ce5 commit 1ce851d
Show file tree
Hide file tree
Showing 8 changed files with 2,312 additions and 0 deletions.
1 change: 1 addition & 0 deletions scripts/fuzz_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ def is_git_repo():
'typed_continuations_resume.wast',
# New EH implementation is in progress
'exception-handling.wast',
'translate-eh-old-to-new.wast',
]


Expand Down
1 change: 1 addition & 0 deletions src/passes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ set(passes_SOURCES
StripEH.cpp
SSAify.cpp
TupleOptimization.cpp
TranslateEH.cpp
TypeFinalizing.cpp
Unsubtyping.cpp
Untee.cpp
Expand Down
Loading

0 comments on commit 1ce851d

Please sign in to comment.