@@ -625,7 +625,6 @@ _PyJit_translate_single_bytecode_to_trace(
625625 int trace_length = _tstate -> jit_tracer_state .prev_state .code_curr_size ;
626626 _PyUOpInstruction * trace = _tstate -> jit_tracer_state .code_buffer ;
627627 int max_length = _tstate -> jit_tracer_state .prev_state .code_max_size ;
628- int exit_op = stop_tracing_opcode == 0 ? _EXIT_TRACE : stop_tracing_opcode ;
629628
630629 _Py_CODEUNIT * this_instr = _tstate -> jit_tracer_state .prev_state .instr ;
631630 _Py_CODEUNIT * target_instr = this_instr ;
@@ -691,13 +690,18 @@ _PyJit_translate_single_bytecode_to_trace(
691690 goto full ;
692691 }
693692
694- if (stop_tracing_opcode != 0 ) {
693+ if (stop_tracing_opcode == _DEOPT ) {
695694 // gh-143183: It's important we rewind to the last known proper target.
696695 // The current target might be garbage as stop tracing usually indicates
697696 // we are in something that we can't trace.
698697 DPRINTF (2 , "Told to stop tracing\n" );
699698 goto unsupported ;
700699 }
700+ else if (stop_tracing_opcode != 0 ) {
701+ assert (stop_tracing_opcode == _EXIT_TRACE );
702+ ADD_TO_TRACE (stop_tracing_opcode , 0 , 0 , target );
703+ goto done ;
704+ }
701705
702706 DPRINTF (2 , "%p %d: %s(%d) %d %d\n" , old_code , target , _PyOpcode_OpName [opcode ], oparg , needs_guard_ip , old_stack_level );
703707
@@ -733,7 +737,7 @@ _PyJit_translate_single_bytecode_to_trace(
733737 int32_t old_target = (int32_t )uop_get_target (curr );
734738 curr ++ ;
735739 trace_length ++ ;
736- curr -> opcode = exit_op ;
740+ curr -> opcode = stop_tracing_opcode ;
737741 curr -> format = UOP_FORMAT_TARGET ;
738742 curr -> target = old_target ;
739743 }
0 commit comments