[GR-54677] Support new exception handling proposal #12452
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The new exception handling proposal as opposed to the legacy one uses a new
try_tableblock for exception catching, if inside that block an exception is thrown, Wasm breaks to the block specified in thetry_table's catch clauses. This makes exception control-flow the same as any other break-based control-flow, but makes it a bit harder for us.This required support for Wasm blocks that return a result, which also made the validator more complex.
The new exception handling is used by default. The legacy proposal can be re-enabled using
-H:+LegacyExceptions. In node (before version 25), the new exceptions are behind the--experimental-wasm-exnrefflag.WithExceptionNodes are now lowered to the following (seeWasmIRWalker#lowerWithExceptionfor more details):This is optimal in terms of number of required blocks.
This does not seem to have an effect on code size.