mirror of
https://github.com/python/cpython.git
synced 2025-11-03 19:34:08 +00:00
gh-111968: Rename freelist related struct names to Eric's suggestion (gh-115329)
This commit is contained in:
parent
518af37eb5
commit
f15795c9a0
19 changed files with 189 additions and 206 deletions
|
|
@ -67,12 +67,6 @@ typedef struct {
|
|||
extern PyObject* _PyDictView_New(PyObject *, PyTypeObject *);
|
||||
extern PyObject* _PyDictView_Intersect(PyObject* self, PyObject *other);
|
||||
|
||||
|
||||
/* runtime lifecycle */
|
||||
|
||||
extern void _PyDict_Fini(PyInterpreterState *state);
|
||||
|
||||
|
||||
/* other API */
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
|
|
@ -33,14 +33,14 @@ extern "C" {
|
|||
# define _PyObjectStackChunk_MAXFREELIST 0
|
||||
#endif
|
||||
|
||||
struct _Py_list_state {
|
||||
struct _Py_list_freelist {
|
||||
#ifdef WITH_FREELISTS
|
||||
PyListObject *free_list[PyList_MAXFREELIST];
|
||||
int numfree;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct _Py_tuple_state {
|
||||
struct _Py_tuple_freelist {
|
||||
#if WITH_FREELISTS
|
||||
/* There is one freelist for each size from 1 to PyTuple_MAXSAVESIZE.
|
||||
The empty tuple is handled separately.
|
||||
|
|
@ -57,7 +57,7 @@ struct _Py_tuple_state {
|
|||
#endif
|
||||
};
|
||||
|
||||
struct _Py_float_state {
|
||||
struct _Py_float_freelist {
|
||||
#ifdef WITH_FREELISTS
|
||||
/* Special free list
|
||||
free_list is a singly-linked list of available PyFloatObjects,
|
||||
|
|
@ -77,7 +77,7 @@ struct _Py_dict_freelist {
|
|||
#endif
|
||||
};
|
||||
|
||||
struct _Py_slice_state {
|
||||
struct _Py_slice_freelist {
|
||||
#ifdef WITH_FREELISTS
|
||||
/* Using a cache is very effective since typically only a single slice is
|
||||
created and then deleted again. */
|
||||
|
|
@ -85,7 +85,7 @@ struct _Py_slice_state {
|
|||
#endif
|
||||
};
|
||||
|
||||
struct _Py_context_state {
|
||||
struct _Py_context_freelist {
|
||||
#ifdef WITH_FREELISTS
|
||||
// List of free PyContext objects
|
||||
PyContext *freelist;
|
||||
|
|
@ -93,7 +93,7 @@ struct _Py_context_state {
|
|||
#endif
|
||||
};
|
||||
|
||||
struct _Py_async_gen_state {
|
||||
struct _Py_async_gen_freelist {
|
||||
#ifdef WITH_FREELISTS
|
||||
/* Freelists boost performance 6-10%; they also reduce memory
|
||||
fragmentation, as _PyAsyncGenWrappedValue and PyAsyncGenASend
|
||||
|
|
@ -109,31 +109,31 @@ struct _Py_async_gen_state {
|
|||
|
||||
struct _PyObjectStackChunk;
|
||||
|
||||
struct _Py_object_stack_state {
|
||||
struct _Py_object_stack_freelist {
|
||||
struct _PyObjectStackChunk *free_list;
|
||||
Py_ssize_t numfree;
|
||||
};
|
||||
|
||||
typedef struct _Py_freelist_state {
|
||||
struct _Py_float_state floats;
|
||||
struct _Py_tuple_state tuples;
|
||||
struct _Py_list_state lists;
|
||||
struct _Py_object_freelists {
|
||||
struct _Py_float_freelist floats;
|
||||
struct _Py_tuple_freelist tuples;
|
||||
struct _Py_list_freelist lists;
|
||||
struct _Py_dict_freelist dicts;
|
||||
struct _Py_slice_state slices;
|
||||
struct _Py_context_state contexts;
|
||||
struct _Py_async_gen_state async_gens;
|
||||
struct _Py_object_stack_state object_stacks;
|
||||
} _PyFreeListState;
|
||||
struct _Py_slice_freelist slices;
|
||||
struct _Py_context_freelist contexts;
|
||||
struct _Py_async_gen_freelist async_gens;
|
||||
struct _Py_object_stack_freelist object_stacks;
|
||||
};
|
||||
|
||||
extern void _PyObject_ClearFreeLists(_PyFreeListState *state, int is_finalization);
|
||||
extern void _PyTuple_ClearFreeList(_PyFreeListState *state, int is_finalization);
|
||||
extern void _PyFloat_ClearFreeList(_PyFreeListState *state, int is_finalization);
|
||||
extern void _PyList_ClearFreeList(_PyFreeListState *state, int is_finalization);
|
||||
extern void _PySlice_ClearFreeList(_PyFreeListState *state, int is_finalization);
|
||||
extern void _PyDict_ClearFreeList(_PyFreeListState *state, int is_finalization);
|
||||
extern void _PyAsyncGen_ClearFreeLists(_PyFreeListState *state, int is_finalization);
|
||||
extern void _PyContext_ClearFreeList(_PyFreeListState *state, int is_finalization);
|
||||
extern void _PyObjectStackChunk_ClearFreeList(_PyFreeListState *state, int is_finalization);
|
||||
extern void _PyObject_ClearFreeLists(struct _Py_object_freelists *freelists, int is_finalization);
|
||||
extern void _PyTuple_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization);
|
||||
extern void _PyFloat_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization);
|
||||
extern void _PyList_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization);
|
||||
extern void _PySlice_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization);
|
||||
extern void _PyDict_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization);
|
||||
extern void _PyAsyncGen_ClearFreeLists(struct _Py_object_freelists *freelists, int is_finalization);
|
||||
extern void _PyContext_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization);
|
||||
extern void _PyObjectStackChunk_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ extern "C" {
|
|||
#include "pycore_dtoa.h" // struct _dtoa_state
|
||||
#include "pycore_exceptions.h" // struct _Py_exc_state
|
||||
#include "pycore_floatobject.h" // struct _Py_float_state
|
||||
#include "pycore_freelist.h" // struct _Py_freelist_state
|
||||
#include "pycore_function.h" // FUNC_MAX_WATCHERS
|
||||
#include "pycore_gc.h" // struct _gc_runtime_state
|
||||
#include "pycore_genobject.h" // struct _Py_async_gen_state
|
||||
|
|
@ -222,9 +221,6 @@ struct _is {
|
|||
// One bit is set for each non-NULL entry in code_watchers
|
||||
uint8_t active_code_watchers;
|
||||
|
||||
#if !defined(Py_GIL_DISABLED)
|
||||
struct _Py_freelist_state freelist_state;
|
||||
#endif
|
||||
struct _py_object_state object_state;
|
||||
struct _Py_unicode_state unicode;
|
||||
struct _Py_long_state long_state;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ extern "C" {
|
|||
# error "this header requires Py_BUILD_CORE define"
|
||||
#endif
|
||||
|
||||
#include "pycore_freelist.h" // _PyObject_freelists
|
||||
#include "pycore_hashtable.h" // _Py_hashtable_t
|
||||
|
||||
struct _py_object_runtime_state {
|
||||
|
|
@ -18,6 +19,9 @@ struct _py_object_runtime_state {
|
|||
};
|
||||
|
||||
struct _py_object_state {
|
||||
#if !defined(Py_GIL_DISABLED)
|
||||
struct _Py_object_freelists freelists;
|
||||
#endif
|
||||
#ifdef Py_REF_DEBUG
|
||||
Py_ssize_t reftotal;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ PyAPI_FUNC(const PyConfig*) _Py_GetConfig(void);
|
|||
// See also PyInterpreterState_Get() and _PyInterpreterState_GET().
|
||||
extern PyInterpreterState* _PyGILState_GetInterpreterStateUnsafe(void);
|
||||
|
||||
static inline _PyFreeListState* _PyFreeListState_GET(void)
|
||||
static inline struct _Py_object_freelists* _Py_object_freelists_GET(void)
|
||||
{
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
#ifdef Py_DEBUG
|
||||
|
|
@ -276,9 +276,9 @@ static inline _PyFreeListState* _PyFreeListState_GET(void)
|
|||
#endif
|
||||
|
||||
#ifdef Py_GIL_DISABLED
|
||||
return &((_PyThreadStateImpl*)tstate)->freelist_state;
|
||||
return &((_PyThreadStateImpl*)tstate)->freelists;
|
||||
#else
|
||||
return &tstate->interp->freelist_state;
|
||||
return &tstate->interp->object_state.freelists;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ typedef struct _PyThreadStateImpl {
|
|||
|
||||
#ifdef Py_GIL_DISABLED
|
||||
struct _mimalloc_thread_state mimalloc;
|
||||
struct _Py_freelist_state freelist_state;
|
||||
struct _Py_object_freelists freelists;
|
||||
struct _brc_thread_state brc;
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue