[wasm] Implement the ENDFINALLY opcode in the jiterpreter #84273
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.
By marking the opcode following each CALL_HANDLER opcode as a back-branch target, we can then generate a conditional backwards branch in the jiterpreter for ENDFINALLY opcodes and allow traces to keep executing after a finally block. This should improve performance for traces containing try/finally, especially ones that have it inside of a loop body. I added a simple browser-bench measurement that shows a measurable improvement (950usec -> 700usec) from this.
Currently the support is limited for methods with at most three CALL_HANDLER opcodes, because the codegen for the ENDFINALLY will get too bloated beyond that.
One risk to this is that now more traces will contain backwards branches than before, which results in them having a dispatch loop at entry.
This PR also tweaks the CFG to generate fewer entries in the backward branch dispatcher in some cases, which helps compensate for the new targets introduced by finally support.