@@ -544,9 +544,6 @@ add_to_trace(
544544 goto full; \
545545 }
546546
547- // Reserve space for N uops, plus 3 for _SET_IP, _CHECK_VALIDITY and _EXIT_TRACE
548- #define RESERVE (needed ) RESERVE_RAW((needed) + 3, _PyUOpName(opcode))
549-
550547
551548/* Returns 1 on success (added to trace), 0 on trace end.
552549 */
@@ -688,19 +685,13 @@ _PyJit_translate_single_bytecode_to_trace(
688685 }
689686
690687 // One for possible _DEOPT, one because _CHECK_VALIDITY itself might _DEOPT
691- max_length -= 2 ;
688+ max_length -= 1 ;
692689
693690 const struct opcode_macro_expansion * expansion = & _PyOpcode_macro_expansion [opcode ];
694691
695- ADD_TO_TRACE (_CHECK_VALIDITY , 0 , 0 , target );
696-
697692 assert (opcode != ENTER_EXECUTOR && opcode != EXTENDED_ARG );
698693 assert (!_PyErr_Occurred (tstate ));
699694
700- if (!OPCODE_HAS_NO_SAVE_IP (opcode )) {
701- ADD_TO_TRACE (_SET_IP , 0 , (uintptr_t )target_instr , target );
702- }
703-
704695 /* Special case the first instruction,
705696 * so that we can guarantee forward progress */
706697 if (progress_needed && tstate -> interp -> jit_state .code_curr_size <= 2 ) {
@@ -720,7 +711,13 @@ _PyJit_translate_single_bytecode_to_trace(
720711 max_length -- ;
721712 }
722713
723- RESERVE_RAW (expansion -> nuops + needs_guard_ip + 4 , "uop and various checks" );
714+ RESERVE_RAW (expansion -> nuops + needs_guard_ip + 3 + (!OPCODE_HAS_NO_SAVE_IP (opcode )), "uop and various checks" );
715+
716+ ADD_TO_TRACE (_CHECK_VALIDITY , 0 , 0 , target );
717+
718+ if (!OPCODE_HAS_NO_SAVE_IP (opcode )) {
719+ ADD_TO_TRACE (_SET_IP , 0 , (uintptr_t )target_instr , target );
720+ }
724721
725722
726723 switch (opcode ) {
@@ -780,7 +777,6 @@ _PyJit_translate_single_bytecode_to_trace(
780777 goto unsupported ;
781778 }
782779 assert (nuops > 0 );
783- RESERVE (nuops + 1 ); /* One extra for exit */
784780 uint32_t orig_oparg = oparg ; // For OPARG_TOP/BOTTOM
785781 uint32_t orig_target = target ;
786782 for (int i = 0 ; i < nuops ; i ++ ) {
0 commit comments