mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +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
|
@ -2010,16 +2010,6 @@ _PyFloat_ClearFreeList(_PyFreeListState *freelist_state, int is_finalization)
|
|||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
_PyFloat_Fini(_PyFreeListState *state)
|
||||
{
|
||||
// With Py_GIL_DISABLED:
|
||||
// the freelists for the current thread state have already been cleared.
|
||||
#ifndef Py_GIL_DISABLED
|
||||
_PyFloat_ClearFreeList(state, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
_PyFloat_FiniType(PyInterpreterState *interp)
|
||||
{
|
||||
|
|
|
@ -1682,17 +1682,6 @@ _PyAsyncGen_ClearFreeLists(_PyFreeListState *freelist_state, int is_finalization
|
|||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
_PyAsyncGen_Fini(_PyFreeListState *state)
|
||||
{
|
||||
// With Py_GIL_DISABLED:
|
||||
// the freelists for the current thread state have already been cleared.
|
||||
#ifndef Py_GIL_DISABLED
|
||||
_PyAsyncGen_ClearFreeLists(state, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
async_gen_unwrap_value(PyAsyncGenObject *gen, PyObject *result)
|
||||
{
|
||||
|
|
|
@ -135,16 +135,6 @@ _PyList_ClearFreeList(_PyFreeListState *freelist_state, int is_finalization)
|
|||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
_PyList_Fini(_PyFreeListState *state)
|
||||
{
|
||||
// With Py_GIL_DISABLED:
|
||||
// the freelists for the current thread state have already been cleared.
|
||||
#ifndef Py_GIL_DISABLED
|
||||
_PyList_ClearFreeList(state, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Print summary info about the state of the optimized allocator */
|
||||
void
|
||||
_PyList_DebugMallocStats(FILE *out)
|
||||
|
|
|
@ -793,6 +793,21 @@ PyObject_Bytes(PyObject *v)
|
|||
return PyBytes_FromObject(v);
|
||||
}
|
||||
|
||||
void
|
||||
_PyObject_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);
|
||||
// Only be cleared if is_finalization is true.
|
||||
_PyObjectStackChunk_ClearFreeList(state, is_finalization);
|
||||
_PySlice_ClearFreeList(state, is_finalization);
|
||||
}
|
||||
|
||||
/*
|
||||
def _PyObject_FunctionStr(x):
|
||||
|
|
|
@ -103,8 +103,11 @@ PyObject _Py_EllipsisObject = _PyObject_HEAD_INIT(&PyEllipsis_Type);
|
|||
|
||||
/* Slice object implementation */
|
||||
|
||||
void _PySlice_ClearCache(_PyFreeListState *state)
|
||||
void _PySlice_ClearFreeList(_PyFreeListState *state, int is_finalization)
|
||||
{
|
||||
if (!is_finalization) {
|
||||
return;
|
||||
}
|
||||
#ifdef WITH_FREELISTS
|
||||
PySliceObject *obj = state->slices.slice_cache;
|
||||
if (obj != NULL) {
|
||||
|
@ -114,13 +117,6 @@ void _PySlice_ClearCache(_PyFreeListState *state)
|
|||
#endif
|
||||
}
|
||||
|
||||
void _PySlice_Fini(_PyFreeListState *state)
|
||||
{
|
||||
#ifdef WITH_FREELISTS
|
||||
_PySlice_ClearCache(state);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* start, stop, and step are python objects with None indicating no
|
||||
index is present.
|
||||
*/
|
||||
|
|
|
@ -964,11 +964,6 @@ _PyTuple_Resize(PyObject **pv, Py_ssize_t newsize)
|
|||
|
||||
static void maybe_freelist_clear(_PyFreeListState *, int);
|
||||
|
||||
void
|
||||
_PyTuple_Fini(_PyFreeListState *state)
|
||||
{
|
||||
maybe_freelist_clear(state, 1);
|
||||
}
|
||||
|
||||
void
|
||||
_PyTuple_ClearFreeList(_PyFreeListState *state, int is_finalization)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue