gh-106529: Support JUMP_BACKWARD in Tier 2 (uops) (#106543)

During superblock generation, a JUMP_BACKWARD instruction is translated to either a JUMP_TO_TOP micro-op (when the target of the jump is exactly the beginning of the superblock, closing the loop), or a SAVE_IP + EXIT_TRACE pair, when the jump goes elsewhere.

The new JUMP_TO_TOP instruction includes a CHECK_EVAL_BREAKER() call, so a closed loop can still be interrupted.
This commit is contained in:
Guido van Rossum 2023-07-11 11:08:10 -07:00 committed by GitHub
parent 292ac4bfe9
commit cabd6e8a10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 30 deletions

View file

@ -2783,6 +2783,13 @@ _PyUopExecute(_PyExecutorObject *executor, _PyInterpreterFrame *frame, PyObject
break;
}
case JUMP_TO_TOP:
{
pc = 0;
CHECK_EVAL_BREAKER();
break;
}
case SAVE_IP:
{
frame->prev_instr = ip_offset + oparg;