-
Notifications
You must be signed in to change notification settings - Fork 830
Add basic exception handling support #2282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This adds basic support for exception handling instructions, according to the spec: https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md This PR includes support for: - Binary reading/writing - Wast reading/writing - Stack IR - Validation (including a br_on_exn validator) - binaryen.js + C API - Few IR routines: branch-utils, type-updating, etc - Few passes: just enough to make `wasm-opt -O` pass - Tests This PR does not include support for many optimization passes or the fuzzer. They will be follow-up PRs. Try-catch construct is modeled in Binaryen IR in a similar manner to that of if-else: each of try body and catch body will contain a block, which can be omitted if there is only a single instruction. This block will not be emitted in wast or binary, as in if-else. As in if-else, `class Try` contains two expressions each for try body and catch body, and `catch` is not modeled as an instruction. `exnref` value pushed by `catch` or `br_on_exn` is get by `pop` instruction. `br_on_exn` is special: it returns different types of values when taken and not taken. This makes validation a little complicated.
kripken
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
|
We currently have a Travis CI error which is not reproducible locally, so I added a few debugging commits that comment out some tests or add debug printfs. They will be deleted after debugging. (Added later: this has been deleted now) |
|
Talked with @kripken offline and decided do these things:
Will update the code with this change soon. |
Updated. |
kripken
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! lgtm, with just some final minor comments/suggestions.
kripken
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, lgtm!
|
Thank you for the review! |
This adds basic support for exception handling instructions, according
to the spec:
https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md
This PR includes support for:
wasm-opt -OpassThis PR does not include support for many optimization passes, fuzzer,
or interpreter. They will be follow-up PRs.
Try-catch construct is modeled in Binaryen IR in a similar manner to
that of if-else: each of try body and catch body will contain a block,
which can be omitted if there is only a single instruction. This block
will not be emitted in wast or binary, as in if-else. As in if-else,
class Trycontains two expressions each for try body and catch body,and
catchis not modeled as an instruction.exnrefvalue pushed bycatchis get bypopinstruction.br_on_exnis special: it returns different types of values when takenand not taken. We make
exnref, the typebr_on_exnpushes if nottaken, as
br_on_exn's type.