Skip to content

Commit 5cfc7a9

Browse files
special case first instr properly
1 parent 6429b2f commit 5cfc7a9

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Python/optimizer.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,16 @@ _PyJit_translate_single_bytecode_to_trace(
628628
goto done;
629629
}
630630

631+
/* Special case the first instruction,
632+
* so that we can guarantee forward progress */
633+
if (progress_needed && tstate->interp->jit_state.code_curr_size <= 2) {
634+
if (OPCODE_HAS_EXIT(opcode) || OPCODE_HAS_DEOPT(opcode)) {
635+
opcode = _PyOpcode_Deopt[opcode];
636+
}
637+
assert(!OPCODE_HAS_EXIT(opcode));
638+
assert(!OPCODE_HAS_DEOPT(opcode));
639+
}
640+
631641
// Strange control-flow
632642
bool has_dynamic_jump_taken = OPCODE_HAS_UNPREDICTABLE_JUMP(opcode) &&
633643
(next_instr != this_instr + 1 + _PyOpcode_Caches[_PyOpcode_Deopt[opcode]]);
@@ -696,15 +706,6 @@ _PyJit_translate_single_bytecode_to_trace(
696706
assert(opcode != ENTER_EXECUTOR && opcode != EXTENDED_ARG);
697707
assert(!_PyErr_Occurred(tstate));
698708

699-
/* Special case the first instruction,
700-
* so that we can guarantee forward progress */
701-
if (progress_needed && tstate->interp->jit_state.code_curr_size <= 2) {
702-
if (OPCODE_HAS_EXIT(opcode) || OPCODE_HAS_DEOPT(opcode)) {
703-
opcode = _PyOpcode_Deopt[opcode];
704-
}
705-
assert(!OPCODE_HAS_EXIT(opcode));
706-
assert(!OPCODE_HAS_DEOPT(opcode));
707-
}
708709

709710
if (OPCODE_HAS_EXIT(opcode)) {
710711
// Make space for side exit and final _EXIT_TRACE:

0 commit comments

Comments
 (0)