Handle Finally Block When Jitting a loop in a Generator or Async function#7043
Conversation
|
@ppenzin I saw a bug I ought to fix, please could you review it? |
a09538f to
5e72ccf
Compare
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.
5e72ccf to
1c242f7
Compare
ppenzin
left a comment
There was a problem hiding this comment.
Seems to be relatively straight-forward, sorry about the delay.
|
@rhuanjl Nice addition! EDIT: Wrong, GitHub just wanted an additional space... ( |
Interesting - I wonder if that has changed or if it's just too long since I did it.... I'm sure I used to put a : in there maybe |
|
Oh, actually you are right; You can use a colon if you also include a space!
(Never saw that note) |
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