diff options
author | Heejin Ahn <aheejin@gmail.com> | 2023-12-19 11:10:27 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-19 11:10:27 -0800 |
commit | 4c53361b205ad30acc05136388b789296a4180f7 (patch) | |
tree | a5802be899e365b733efacba4364027b0af9c2e0 /src/wasm/wasm-validator.cpp | |
parent | cad983c975a05bc262437a6d7ed3a61020ef4e8d (diff) | |
download | binaryen-4c53361b205ad30acc05136388b789296a4180f7.tar.gz binaryen-4c53361b205ad30acc05136388b789296a4180f7.tar.bz2 binaryen-4c53361b205ad30acc05136388b789296a4180f7.zip |
[EH] Add instructions for new proposal (#6181)
This adds basic support for the new instructions in the new EH proposal
passed at the Oct CG hybrid CG meeting:
https://github.com/WebAssembly/meetings/blob/main/main/2023/CG-10.md
https://github.com/WebAssembly/exception-handling/blob/main/proposals/exception-handling/Exceptions.md
This mainly adds two instructions: `try_table` and `throw_ref`. This is
the bare minimum required to read and write text and binary format, and
does not include analyses or optimizations. (It includes some analysis
required for validation of existing instructions.) Validation for
the new instructions is not yet included.
`try_table` faces the same problem with the `resume` instruction in
#6083 that without the module-level tag info, we are unable to know the
'sent types' of `try_table`. This solves it with a similar approach
taken in #6083: this adds `Module*` parameter to `finalize` methods,
which defaults to `nullptr` when not given. The `Module*` parameter is
given when called from the binary and text parser, and we cache those
tag types in `sentTypes` array within `TryTable` class. In later
optimization passes, as long as they don't touch tags, it is fine to
call `finalize` without the `Module*`. Refer to
https://github.com/WebAssembly/binaryen/pull/6083#issuecomment-1854634679
and #6096 for related discussions when `resume` was added.
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r-- | src/wasm/wasm-validator.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index cb54e1597..c1b4a86e7 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -354,7 +354,8 @@ public: case Expression::ReturnId: case Expression::UnreachableId: case Expression::ThrowId: - case Expression::RethrowId: { + case Expression::RethrowId: + case Expression::ThrowRefId: { // These can all be unreachable without an unreachable child. return; } @@ -445,8 +446,10 @@ public: void noteDelegate(Name name, Expression* curr); void noteRethrow(Name name, Expression* curr); void visitTry(Try* curr); + void visitTryTable(TryTable* curr); void visitThrow(Throw* curr); void visitRethrow(Rethrow* curr); + void visitThrowRef(ThrowRef* curr); void visitTupleMake(TupleMake* curr); void visitTupleExtract(TupleExtract* curr); void visitCallRef(CallRef* curr); @@ -2442,6 +2445,10 @@ void FunctionValidator::visitTry(Try* curr) { rethrowTargetNames.erase(curr->name); } +void FunctionValidator::visitTryTable(TryTable* curr) { + // TODO +} + void FunctionValidator::visitThrow(Throw* curr) { shouldBeTrue( getModule()->features.hasExceptionHandling(), @@ -2516,6 +2523,10 @@ void FunctionValidator::visitTupleMake(TupleMake* curr) { "Type of tuple.make does not match types of its operands"); } +void FunctionValidator::visitThrowRef(ThrowRef* curr) { + // TODO +} + void FunctionValidator::visitTupleExtract(TupleExtract* curr) { shouldBeTrue(getModule()->features.hasMultivalue(), curr, |