summaryrefslogtreecommitdiffstats
path: root/Python/pystate.c
diff options
context:
space:
mode:
authorDonghee Na <donghee.na@python.org>2024-02-10 00:57:04 (GMT)
committerGitHub <noreply@github.com>2024-02-10 00:57:04 (GMT)
commitd4d5bae1471788b345155e8e93a2fe4ab92d09dc (patch)
tree989f7efdc60aff606679d12b4f1853174dd4365d /Python/pystate.c
parent564385612cdf72c2fa8e629a68225fb2cd3b3d99 (diff)
downloadcpython-d4d5bae1471788b345155e8e93a2fe4ab92d09dc.zip
cpython-d4d5bae1471788b345155e8e93a2fe4ab92d09dc.tar.gz
cpython-d4d5bae1471788b345155e8e93a2fe4ab92d09dc.tar.bz2
gh-111968: Refactor _PyXXX_Fini to integrate with _PyObject_ClearFreeLists (gh-114899)
Diffstat (limited to 'Python/pystate.c')
-rw-r--r--Python/pystate.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index 6cd0347..937c430 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -1469,20 +1469,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)
{
assert(tstate->_status.initialized && !tstate->_status.cleared);
@@ -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);