gh-111968: Introduce _PyFreeListState and _PyFreeListState_GET API (gh-113584)

This commit is contained in:
Donghee Na 2024-01-10 08:04:41 +09:00 committed by GitHub
parent cdca0ce0ad
commit 57bdc6c30d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 171 additions and 50 deletions

View file

@ -1455,6 +1455,12 @@ clear_datastack(PyThreadState *tstate)
}
}
void
_Py_ClearFreeLists(_PyFreeListState *state, int is_finalization)
{
_PyList_ClearFreeList(state, is_finalization);
}
void
PyThreadState_Clear(PyThreadState *tstate)
{
@ -1537,6 +1543,11 @@ PyThreadState_Clear(PyThreadState *tstate)
// don't call _PyInterpreterState_SetNotRunningMain() yet.
tstate->on_delete(tstate->on_delete_data);
}
#ifdef Py_GIL_DISABLED
// Each thread should clear own freelists in free-threading builds.
_PyFreeListState *freelist_state = &((_PyThreadStateImpl*)tstate)->freelist_state;
_Py_ClearFreeLists(freelist_state, 0);
#endif
_PyThreadState_ClearMimallocHeaps(tstate);