From 6bd1541a8ad54d08a8a49837b300cae58904179e Mon Sep 17 00:00:00 2001 From: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Date: Fri, 24 Oct 2025 16:40:00 +0100 Subject: [PATCH] Fix FT --- Python/bytecodes.c | 10 +++++----- Python/ceval_macros.h | 6 +++++- Python/executor_cases.c.h | 8 ++++---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 31a433721fe4..fc12dc787bce 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -5229,7 +5229,7 @@ dummy_func( ERROR_IF(err < 0); DISPATCH_GOTO_NON_TRACING(); } - // Super instructions. Instruction deopted, There's a mismatch in what the stack expects + // Super instructions. Instruction deopted. There's a mismatch in what the stack expects // in the optimizer. So we have to reflect in the trace correctly. if ((tstate->interp->jit_state.prev_instr->op.code == CALL_LIST_APPEND && opcode == POP_TOP) || @@ -5470,10 +5470,6 @@ dummy_func( assert(exit != NULL); _Py_CODEUNIT *target = _PyFrame_GetBytecode(frame) + exit->target; _Py_BackoffCounter temperature = exit->temperature; - if (!backoff_counter_triggers(temperature)) { - exit->temperature = advance_backoff_counter(temperature); - GOTO_TIER_ONE(target); - } _PyExecutorObject *executor; if (target->op.code == ENTER_EXECUTOR) { PyCodeObject *code = _PyFrame_GetCode(frame); @@ -5481,6 +5477,10 @@ dummy_func( Py_INCREF(executor); } else { + if (!backoff_counter_triggers(temperature)) { + exit->temperature = advance_backoff_counter(temperature); + GOTO_TIER_ONE(target); + } _PyExecutorObject *previous_executor = _PyExecutor_FromExit(exit); assert(tstate->current_executor == (PyObject *)previous_executor); int chain_depth = previous_executor->vm_data.chain_depth + 1; diff --git a/Python/ceval_macros.h b/Python/ceval_macros.h index abef480b902a..f85a7f9e271a 100644 --- a/Python/ceval_macros.h +++ b/Python/ceval_macros.h @@ -355,7 +355,11 @@ GETITEM(PyObject *v, Py_ssize_t i) { #define RECORD_BRANCH_TAKEN(bitset, flag) #endif -#define RECORD_DYNAMIC_JUMP_TAKEN() tstate->interp->jit_state.dynamic_jump_taken = true; +#if _Py_TIER2 +# define RECORD_DYNAMIC_JUMP_TAKEN() tstate->interp->jit_state.dynamic_jump_taken = true; +#else +# define RECORD_DYNAMIC_JUMP_TAKEN() +#endif #define UNBOUNDLOCAL_ERROR_MSG \ "cannot access local variable '%s' where it is not associated with a value" diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 6d155cf81796..2fa109b049d1 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -7487,10 +7487,6 @@ assert(exit != NULL); _Py_CODEUNIT *target = _PyFrame_GetBytecode(frame) + exit->target; _Py_BackoffCounter temperature = exit->temperature; - if (!backoff_counter_triggers(temperature)) { - exit->temperature = advance_backoff_counter(temperature); - GOTO_TIER_ONE(target); - } _PyExecutorObject *executor; if (target->op.code == ENTER_EXECUTOR) { PyCodeObject *code = _PyFrame_GetCode(frame); @@ -7498,6 +7494,10 @@ Py_INCREF(executor); } else { + if (!backoff_counter_triggers(temperature)) { + exit->temperature = advance_backoff_counter(temperature); + GOTO_TIER_ONE(target); + } _PyExecutorObject *previous_executor = _PyExecutor_FromExit(exit); assert(tstate->current_executor == (PyObject *)previous_executor); int chain_depth = previous_executor->vm_data.chain_depth + 1; -- 2.47.3