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:
Mark Shannon 2025-05-04 10:05:35 +01:00 committed by GitHub
parent 1d9406e426
commit ac7d5ba96e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 176 additions and 54 deletions

View file

@ -50,13 +50,16 @@
#define GOTO_TIER_TWO(EXECUTOR) \
do { \
OPT_STAT_INC(traces_executed); \
jit_func_preserve_none jitted = (EXECUTOR)->jit_side_entry; \
_PyExecutorObject *_executor = (EXECUTOR); \
tstate->current_executor = (PyObject *)_executor; \
jit_func_preserve_none jitted = _executor->jit_side_entry; \
__attribute__((musttail)) return jitted(frame, stack_pointer, tstate); \
} while (0)
#undef GOTO_TIER_ONE
#define GOTO_TIER_ONE(TARGET) \
do { \
tstate->current_executor = NULL; \
_PyFrame_SetStackPointer(frame, stack_pointer); \
return TARGET; \
} while (0)