Skip to content

Conversation

@graalvmbot
Copy link
Collaborator

The new exception handling proposal as opposed to the legacy one uses a new try_table block for exception catching, if inside that block an exception is thrown, Wasm breaks to the block specified in the try_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-exnref flag.


WithExceptionNodes are now lowered to the following (see WasmIRWalker#lowerWithException for more details):

(block $exnBlock (result $throwable)
    (try_table (catch $exc_tag $exnBlock)
        WithExceptionNode();
        br Successor
    )
)
(local.set $exc_var)
ExceptionEdge();

This is optimal in terms of number of required blocks.

This does not seem to have an effect on code size.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Oct 29, 2025
@graalvmbot graalvmbot force-pushed the pz/GR-54677-exceptions branch from 2c36a18 to af545ea Compare October 31, 2025 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants