GH-136410: Faster side exits by using a cold exit stub (GH-136411)

This commit is contained in:
Mark Shannon 2025-08-01 16:26:07 +01:00 committed by GitHub
parent 718e0c89ba
commit e7b55f564d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 387 additions and 267 deletions

View file

@ -815,7 +815,13 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState *tstate)
/* Last garbage collection on this interpreter */
_PyGC_CollectNoFail(tstate);
_PyGC_Fini(interp);
struct _PyExecutorObject *cold = interp->cold_executor;
if (cold != NULL) {
interp->cold_executor = NULL;
assert(cold->vm_data.valid);
assert(cold->vm_data.warm);
_PyExecutor_Free(cold);
}
/* We don't clear sysdict and builtins until the end of this function.
Because clearing other attributes can execute arbitrary Python code
which requires sysdict and builtins. */
@ -1469,6 +1475,7 @@ init_threadstate(_PyThreadStateImpl *_tstate,
tstate->datastack_limit = NULL;
tstate->what_event = -1;
tstate->current_executor = NULL;
tstate->jit_exit = NULL;
tstate->dict_global_version = 0;
_tstate->c_stack_soft_limit = UINTPTR_MAX;