mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
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.
This commit is contained in:
parent
1d9406e426
commit
ac7d5ba96e
13 changed files with 176 additions and 54 deletions
|
|
@ -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) \
|
||||
{ \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue