Skip to content

Conversation

rhuanjl
Copy link
Collaborator

@rhuanjl rhuanjl commented Oct 10, 2025

The OpCode TryFinallyWithYield is intended for Finally {} blocks where either the try or finally statement contains a Yield or Await. BUT was being used for all Finally {} blocks occurring in Generator or Async functions.

This OpCode is not implemented in the JIT. This results in an Abort when jitting a Generator or async function (or a loop inside a generator or async function) that contained a finally block.

The for...of construction includes an implicit finally block, it was the trigger for the Abort in issue 7034.

As we currently only try and Jit loops inside Async/Generator functions that do not contain Yield/Await, nothing we currently Jit ought to need the TryFInallyWithYield OpCode. Fix the issue by detecting when a Try/Finally statement actually contains a Yield or Await and only using the TryFinallyWithYield OpCode in those cases (Which are not due to be Jitted anyway), in cases without Yield/Await use the alternative Opcode TryFinally (which the Jit does support).

Fix:#7016
Fix:#7034

@rhuanjl
Copy link
Collaborator Author

rhuanjl commented Oct 10, 2025

@ppenzin I saw a bug I ought to fix, please could you review it?

Implement partial tracking of Yield within ByteCodeGenerator to enable this.

The OpCode TryFinallyWithYield is not supported by the Jit. It was being used unnecessarily in various code patterns that should be safe to Jit, such patterns were hitting an Abort in the Jit because of the unimplemented OpCode.

As the OpCode is unnecessary when there is no Yield (the cases we currently try to jit) fix logic so we do not use it in those cases.
@rhuanjl rhuanjl force-pushed the fixFinallyinJitGenLoop branch from a09538f to 5e72ccf Compare October 13, 2025 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant