@@ -2939,9 +2939,9 @@ dummy_func(
29392939 };
29402940
29412941 specializing tier1 op (_SPECIALIZE_JUMP_BACKWARD , (-- )) {
2942- #if ENABLE_SPECIALIZATION
2942+ #if ENABLE_SPECIALIZATION_FT
29432943 if (this_instr -> op .code == JUMP_BACKWARD ) {
2944- uint8_t desired = (( _PyThreadStateImpl * )tstate )-> jit_executor_state .jit ? JUMP_BACKWARD_JIT : JUMP_BACKWARD_NO_JIT ;
2944+ uint8_t desired = FT_ATOMIC_LOAD_CHAR_RELAXED ((( _PyThreadStateImpl * )tstate )-> jit_executor_state .jit ) ? JUMP_BACKWARD_JIT : JUMP_BACKWARD_NO_JIT ;
29452945 FT_ATOMIC_STORE_UINT8_RELAXED (this_instr -> op .code , desired );
29462946 // Need to re-dispatch so the warmup counter isn't off by one:
29472947 next_instr = this_instr ;
@@ -3018,11 +3018,25 @@ dummy_func(
30183018 goto stop_tracing ;
30193019 }
30203020 PyCodeObject * code = _PyFrame_GetCode (frame );
3021+ #ifdef Py_GIL_DISABLED
3022+ LOCK_OBJECT_SLOW (code );
3023+ _PyExecutorObject * executor = code -> co_executors -> executors [oparg & 255 ];
3024+ // On FT, we are responsible for cleaning up after ourselves.
3025+ if (!_Py_atomic_load_uint8_relaxed (& executor -> vm_data .valid )) {
3026+ opcode = executor -> vm_data .opcode ;
3027+ oparg = (oparg & ~255 ) | executor -> vm_data .oparg ;
3028+ next_instr = this_instr ;
3029+ _Py_ExecutorDetach (executor );
3030+ UNLOCK_OBJECT_SLOW (code );
3031+ DISPATCH_GOTO ();
3032+ }
3033+ #else
30213034 _PyExecutorObject * executor = code -> co_executors -> executors [oparg & 255 ];
3022- assert (executor -> vm_data .index == INSTR_OFFSET () - 1 );
3023- assert (executor -> vm_data .code == code );
30243035 assert (executor -> vm_data .valid );
3036+ #endif
30253037 assert (tstate -> current_executor == NULL );
3038+ assert (executor -> vm_data .index == INSTR_OFFSET () - 1 );
3039+ assert (executor -> vm_data .code == code );
30263040 /* If the eval breaker is set then stay in tier 1.
30273041 * This avoids any potentially infinite loops
30283042 * involving _RESUME_CHECK */
@@ -3033,10 +3047,15 @@ dummy_func(
30333047 if (_PyOpcode_Caches [_PyOpcode_Deopt [opcode ]]) {
30343048 PAUSE_ADAPTIVE_COUNTER (this_instr [1 ].counter );
30353049 }
3050+ #ifdef Py_GIL_DISABLED
3051+ UNLOCK_OBJECT_SLOW (code );
3052+ #endif
30363053 DISPATCH_GOTO ();
30373054 }
30383055 assert (executor != ((_PyThreadStateImpl * )tstate )-> jit_executor_state .cold_executor );
30393056 tstate -> jit_exit = NULL ;
3057+ Py_INCREF (executor );
3058+ UNLOCK_OBJECT_SLOW (code );
30403059 TIER1_TO_TIER2 (executor );
30413060 #else
30423061 Py_FatalError ("ENTER_EXECUTOR is not supported in this build" );
0 commit comments