mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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:
parent
292ac4bfe9
commit
cabd6e8a10
5 changed files with 63 additions and 30 deletions
|
@ -372,9 +372,7 @@ translate_bytecode_to_trace(
|
|||
_PyUOpInstruction *trace,
|
||||
int buffer_size)
|
||||
{
|
||||
#ifdef Py_DEBUG
|
||||
_Py_CODEUNIT *initial_instr = instr;
|
||||
#endif
|
||||
int trace_length = 0;
|
||||
int max_length = buffer_size;
|
||||
|
||||
|
@ -456,6 +454,19 @@ translate_bytecode_to_trace(
|
|||
break;
|
||||
}
|
||||
|
||||
case JUMP_BACKWARD:
|
||||
{
|
||||
if (instr + 2 - oparg == initial_instr
|
||||
&& trace_length + 3 <= max_length)
|
||||
{
|
||||
ADD_TO_TRACE(JUMP_TO_TOP, 0);
|
||||
}
|
||||
else {
|
||||
DPRINTF(2, "JUMP_BACKWARD not to top ends trace\n");
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
const struct opcode_macro_expansion *expansion = &_PyOpcode_macro_expansion[opcode];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue