aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/ceval_macros.h
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2025-05-04 10:05:35 +0100
committerGitHub <noreply@github.com>2025-05-04 10:05:35 +0100
commitac7d5ba96eb780b13877456b118ff1183bc6c4b3 (patch)
tree6ab67a7735fb68da63b2924e51eb0b1e09d15271 /Python/ceval_macros.h
parent1d9406e426d95eb088e4a474fccf294cc106b2b6 (diff)
downloadcpython-ac7d5ba96eb780b13877456b118ff1183bc6c4b3.tar.gz
cpython-ac7d5ba96eb780b13877456b118ff1183bc6c4b3.zip
GH-133231: Changes to executor management to support proposed `sys._jit` module (GH-133287)
* Track the current executor, not the previous one, on the thread-state. * Batch executors for deallocation to avoid having to constantly incref executors; this is an ad-hoc form of deferred reference counting.
Diffstat (limited to 'Python/ceval_macros.h')
-rw-r--r--Python/ceval_macros.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/Python/ceval_macros.h b/Python/ceval_macros.h
index e1d2673848c..187ec8fdd26 100644
--- a/Python/ceval_macros.h
+++ b/Python/ceval_macros.h
@@ -359,12 +359,12 @@ _PyFrame_SetStackPointer(frame, stack_pointer)
do { \
OPT_STAT_INC(traces_executed); \
_PyExecutorObject *_executor = (EXECUTOR); \
+ tstate->current_executor = (PyObject *)_executor; \
jit_func jitted = _executor->jit_code; \
/* Keep the shim frame alive via the executor: */ \
Py_INCREF(_executor); \
next_instr = jitted(frame, stack_pointer, tstate); \
Py_DECREF(_executor); \
- Py_CLEAR(tstate->previous_executor); \
frame = tstate->current_frame; \
stack_pointer = _PyFrame_GetStackPointer(frame); \
if (next_instr == NULL) { \
@@ -377,7 +377,9 @@ do { \
#define GOTO_TIER_TWO(EXECUTOR) \
do { \
OPT_STAT_INC(traces_executed); \
- next_uop = (EXECUTOR)->trace; \
+ _PyExecutorObject *_executor = (EXECUTOR); \
+ tstate->current_executor = (PyObject *)_executor; \
+ next_uop = _executor->trace; \
assert(next_uop->opcode == _START_EXECUTOR); \
goto enter_tier_two; \
} while (0)
@@ -386,10 +388,11 @@ do { \
#define GOTO_TIER_ONE(TARGET) \
do \
{ \
+ tstate->current_executor = NULL; \
next_instr = (TARGET); \
+ assert(tstate->current_executor == NULL); \
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist); \
_PyFrame_SetStackPointer(frame, stack_pointer); \
- Py_CLEAR(tstate->previous_executor); \
stack_pointer = _PyFrame_GetStackPointer(frame); \
if (next_instr == NULL) \
{ \