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

@ -6969,7 +6969,6 @@
Py_CLEAR(exit->executor);
stack_pointer = _PyFrame_GetStackPointer(frame);
}
tstate->previous_executor = (PyObject *)current_executor;
if (exit->executor == NULL) {
_Py_BackoffCounter temperature = exit->temperature;
if (!backoff_counter_triggers(temperature)) {
@ -6994,7 +6993,6 @@
}
exit->executor = executor;
}
Py_INCREF(exit->executor);
GOTO_TIER_TWO(exit->executor);
break;
}
@ -7098,9 +7096,6 @@
case _START_EXECUTOR: {
PyObject *executor = (PyObject *)CURRENT_OPERAND0();
_PyFrame_SetStackPointer(frame, stack_pointer);
Py_CLEAR(tstate->previous_executor);
stack_pointer = _PyFrame_GetStackPointer(frame);
#ifndef _Py_JIT
current_executor = (_PyExecutorObject*)executor;
#endif
@ -7123,7 +7118,6 @@
}
case _DEOPT: {
tstate->previous_executor = (PyObject *)current_executor;
GOTO_TIER_ONE(_PyFrame_GetBytecode(frame) + CURRENT_TARGET());
break;
}
@ -7131,7 +7125,6 @@
case _ERROR_POP_N: {
oparg = CURRENT_OPARG();
uint32_t target = (uint32_t)CURRENT_OPERAND0();
tstate->previous_executor = (PyObject *)current_executor;
assert(oparg == 0);
frame->instr_ptr = _PyFrame_GetBytecode(frame) + target;
GOTO_TIER_ONE(NULL);