mirror of
https://github.com/python/cpython.git
synced 2025-08-25 11:15:02 +00:00
gh-111968: Refactor _PyXXX_Fini to integrate with _PyObject_ClearFreeLists (gh-114899)
This commit is contained in:
parent
564385612c
commit
d4d5bae147
20 changed files with 38 additions and 107 deletions
|
@ -1468,20 +1468,6 @@ clear_datastack(PyThreadState *tstate)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
_Py_ClearFreeLists(_PyFreeListState *state, int is_finalization)
|
||||
{
|
||||
// In the free-threaded build, freelists are per-PyThreadState and cleared in PyThreadState_Clear()
|
||||
// In the default build, freelists are per-interpreter and cleared in finalize_interp_types()
|
||||
_PyFloat_ClearFreeList(state, is_finalization);
|
||||
_PyTuple_ClearFreeList(state, is_finalization);
|
||||
_PyList_ClearFreeList(state, is_finalization);
|
||||
_PyDict_ClearFreeList(state, is_finalization);
|
||||
_PyContext_ClearFreeList(state, is_finalization);
|
||||
_PyAsyncGen_ClearFreeLists(state, is_finalization);
|
||||
_PyObjectStackChunk_ClearFreeList(state, is_finalization);
|
||||
}
|
||||
|
||||
void
|
||||
PyThreadState_Clear(PyThreadState *tstate)
|
||||
{
|
||||
|
@ -1566,9 +1552,8 @@ PyThreadState_Clear(PyThreadState *tstate)
|
|||
}
|
||||
#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, 1);
|
||||
_PySlice_ClearCache(freelist_state);
|
||||
_PyFreeListState *freelist_state = _PyFreeListState_GET();
|
||||
_PyObject_ClearFreeLists(freelist_state, 1);
|
||||
|
||||
// Remove ourself from the biased reference counting table of threads.
|
||||
_Py_brc_remove_thread(tstate);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue