pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/pull/115329/commits/06bbbcc8fa9199b26b4fe1671ff58be21f515105

imer-primitives-10bf9dd67e3d70bd.css" /> gh-111968: Rename freelist related struct names to Eric's suggestion by corona10 · Pull Request #115329 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename state to freelists as possible
  • Loading branch information
corona10 committed Feb 13, 2024
commit 06bbbcc8fa9199b26b4fe1671ff58be21f515105
18 changes: 9 additions & 9 deletions Include/internal/pycore_freelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ struct _Py_object_freelists {
struct _Py_object_stack_freelist object_stacks;
};

extern void _PyObject_ClearFreeLists(struct _Py_object_freelists *state, int is_finalization);
extern void _PyTuple_ClearFreeList(struct _Py_object_freelists *state, int is_finalization);
extern void _PyFloat_ClearFreeList(struct _Py_object_freelists *state, int is_finalization);
extern void _PyList_ClearFreeList(struct _Py_object_freelists *state, int is_finalization);
extern void _PySlice_ClearFreeList(struct _Py_object_freelists *state, int is_finalization);
extern void _PyDict_ClearFreeList(struct _Py_object_freelists *state, int is_finalization);
extern void _PyAsyncGen_ClearFreeLists(struct _Py_object_freelists *state, int is_finalization);
extern void _PyContext_ClearFreeList(struct _Py_object_freelists *state, int is_finalization);
extern void _PyObjectStackChunk_ClearFreeList(struct _Py_object_freelists *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
}
Expand Down
4 changes: 2 additions & 2 deletions Objects/dictobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ dict_setdefault_ref_lock_held(PyObject *d, PyObject *key, PyObject *default_valu
static struct _Py_dict_freelist *
get_dict_state(void)
{
struct _Py_object_freelists *state = _Py_object_freelists_GET();
return &state->dicts;
struct _Py_object_freelists *freelists = _Py_object_freelists_GET();
return &freelists->dicts;
}
#endif

Expand Down
10 changes: 5 additions & 5 deletions Objects/floatobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class float "PyObject *" "&PyFloat_Type"
static struct _Py_float_freelist *
get_float_state(void)
{
struct _Py_object_freelists *state = _Py_object_freelists_GET();
assert(state != NULL);
return &state->floats;
struct _Py_object_freelists *freelists = _Py_object_freelists_GET();
assert(freelists != NULL);
return &freelists->floats;
}
#endif

Expand Down Expand Up @@ -1990,10 +1990,10 @@ _PyFloat_InitTypes(PyInterpreterState *interp)
}

void
_PyFloat_ClearFreeList(struct _Py_object_freelists *freelist_state, int is_finalization)
_PyFloat_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization)
{
#ifdef WITH_FREELISTS
struct _Py_float_freelist *state = &freelist_state->floats;
struct _Py_float_freelist *state = &freelists->floats;
PyFloatObject *f = state->free_list;
while (f != NULL) {
PyFloatObject *next = (PyFloatObject*) Py_TYPE(f);
Expand Down
4 changes: 2 additions & 2 deletions Objects/genobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1632,8 +1632,8 @@ PyTypeObject PyAsyncGen_Type = {
static struct _Py_async_gen_freelist *
get_async_gen_state(void)
{
struct _Py_object_freelists *state = _Py_object_freelists_GET();
return &state->async_gens;
struct _Py_object_freelists *freelists = _Py_object_freelists_GET();
return &freelists->async_gens;
}
#endif

Expand Down
10 changes: 5 additions & 5 deletions Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ _Py_DECLARE_STR(list_err, "list index out of range");
static struct _Py_list_freelist *
get_list_state(void)
{
struct _Py_object_freelists *state = _Py_object_freelists_GET();
assert(state != NULL);
return &state->lists;
struct _Py_object_freelists *freelists = _Py_object_freelists_GET();
assert(freelists != NULL);
return &freelists->lists;
}
#endif

Expand Down Expand Up @@ -120,10 +120,10 @@ list_preallocate_exact(PyListObject *self, Py_ssize_t size)
}

void
_PyList_ClearFreeList(struct _Py_object_freelists *freelist_state, int is_finalization)
_PyList_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization)
{
#ifdef WITH_FREELISTS
struct _Py_list_freelist *state = &freelist_state->lists;
struct _Py_list_freelist *state = &freelists->lists;
while (state->numfree > 0) {
PyListObject *op = state->free_list[--state->numfree];
assert(PyList_CheckExact(op));
Expand Down
18 changes: 9 additions & 9 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,19 +794,19 @@ PyObject_Bytes(PyObject *v)
}

void
_PyObject_ClearFreeLists(struct _Py_object_freelists *state, int is_finalization)
_PyObject_ClearFreeLists(struct _Py_object_freelists *freelists, 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);
_PyFloat_ClearFreeList(freelists, is_finalization);
_PyTuple_ClearFreeList(freelists, is_finalization);
_PyList_ClearFreeList(freelists, is_finalization);
_PyDict_ClearFreeList(freelists, is_finalization);
_PyContext_ClearFreeList(freelists, is_finalization);
_PyAsyncGen_ClearFreeLists(freelists, is_finalization);
// Only be cleared if is_finalization is true.
_PyObjectStackChunk_ClearFreeList(state, is_finalization);
_PySlice_ClearFreeList(state, is_finalization);
_PyObjectStackChunk_ClearFreeList(freelists, is_finalization);
_PySlice_ClearFreeList(freelists, is_finalization);
}

/*
Expand Down
14 changes: 7 additions & 7 deletions Objects/sliceobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ PyObject _Py_EllipsisObject = _PyObject_HEAD_INIT(&PyEllipsis_Type);

/* Slice object implementation */

void _PySlice_ClearFreeList(struct _Py_object_freelists *state, int is_finalization)
void _PySlice_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization)
{
if (!is_finalization) {
return;
}
#ifdef WITH_FREELISTS
PySliceObject *obj = state->slices.slice_cache;
PySliceObject *obj = freelists->slices.slice_cache;
if (obj != NULL) {
state->slices.slice_cache = NULL;
freelists->slices.slice_cache = NULL;
PyObject_GC_Del(obj);
}
#endif
Expand All @@ -127,10 +127,10 @@ _PyBuildSlice_Consume2(PyObject *start, PyObject *stop, PyObject *step)
assert(start != NULL && stop != NULL && step != NULL);
PySliceObject *obj;
#ifdef WITH_FREELISTS
struct _Py_object_freelists *state = _Py_object_freelists_GET();
if (state->slices.slice_cache != NULL) {
obj = state->slices.slice_cache;
state->slices.slice_cache = NULL;
struct _Py_object_freelists *freelists = _Py_object_freelists_GET();
if (freelists->slices.slice_cache != NULL) {
obj = freelists->slices.slice_cache;
freelists->slices.slice_cache = NULL;
_Py_NewReference((PyObject *)obj);
}
else
Expand Down
14 changes: 7 additions & 7 deletions Objects/tupleobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -966,9 +966,9 @@ static void maybe_freelist_clear(struct _Py_object_freelists *, int);


void
_PyTuple_ClearFreeList(struct _Py_object_freelists *state, int is_finalization)
_PyTuple_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization)
{
maybe_freelist_clear(state, is_finalization);
maybe_freelist_clear(freelists, is_finalization);
}

/*********************** Tuple Iterator **************************/
Expand Down Expand Up @@ -1120,14 +1120,14 @@ tuple_iter(PyObject *seq)
* freelists *
*************/

#define STATE (state->tuples)
#define STATE (freelists->tuples)
#define FREELIST_FINALIZED (STATE.numfree[0] < 0)

static inline PyTupleObject *
maybe_freelist_pop(Py_ssize_t size)
{
#ifdef WITH_FREELISTS
struct _Py_object_freelists *state = _Py_object_freelists_GET();
struct _Py_object_freelists *freelists = _Py_object_freelists_GET();
if (size == 0) {
return NULL;
}
Expand Down Expand Up @@ -1161,7 +1161,7 @@ static inline int
maybe_freelist_push(PyTupleObject *op)
{
#ifdef WITH_FREELISTS
struct _Py_object_freelists *state = _Py_object_freelists_GET();
struct _Py_object_freelists *freelists = _Py_object_freelists_GET();
if (Py_SIZE(op) == 0) {
return 0;
}
Expand All @@ -1184,7 +1184,7 @@ maybe_freelist_push(PyTupleObject *op)
}

static void
maybe_freelist_clear(struct _Py_object_freelists *state, int fini)
maybe_freelist_clear(struct _Py_object_freelists *freelists, int fini)
{
#ifdef WITH_FREELISTS
for (Py_ssize_t i = 0; i < PyTuple_NFREELISTS; i++) {
Expand All @@ -1205,7 +1205,7 @@ void
_PyTuple_DebugMallocStats(FILE *out)
{
#ifdef WITH_FREELISTS
struct _Py_object_freelists *state = _Py_object_freelists_GET();
struct _Py_object_freelists *freelists = _Py_object_freelists_GET();
for (int i = 0; i < PyTuple_NFREELISTS; i++) {
int len = i + 1;
char buf[128];
Expand Down
8 changes: 4 additions & 4 deletions Python/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ contextvar_del(PyContextVar *var);
static struct _Py_context_freelist *
get_context_state(void)
{
struct _Py_object_freelists *state = _Py_object_freelists_GET();
return &state->contexts;
struct _Py_object_freelists *freelists = _Py_object_freelists_GET();
return &freelists->contexts;
}
#endif

Expand Down Expand Up @@ -1267,10 +1267,10 @@ get_token_missing(void)


void
_PyContext_ClearFreeList(struct _Py_object_freelists *freelist_state, int is_finalization)
_PyContext_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization)
{
#ifdef WITH_FREELISTS
struct _Py_context_freelist *state = &freelist_state->contexts;
struct _Py_context_freelist *state = &freelists->contexts;
for (; state->numfree > 0; state->numfree--) {
PyContext *ctx = state->freelist;
state->freelist = (PyContext *)ctx->ctx_weakreflist;
Expand Down
8 changes: 4 additions & 4 deletions Python/object_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ extern void _PyObjectStackChunk_Free(_PyObjectStackChunk *);
static struct _Py_object_stack_freelist *
get_state(void)
{
struct _Py_object_freelists *state = _Py_object_freelists_GET();
return &state->object_stacks;
struct _Py_object_freelists *freelists = _Py_object_freelists_GET();
return &freelists->object_stacks;
}

_PyObjectStackChunk *
Expand Down Expand Up @@ -89,15 +89,15 @@ _PyObjectStack_Merge(_PyObjectStack *dst, _PyObjectStack *src)
}

void
_PyObjectStackChunk_ClearFreeList(struct _Py_object_freelists *free_lists, int is_finalization)
_PyObjectStackChunk_ClearFreeList(struct _Py_object_freelists *freelists, int is_finalization)
{
if (!is_finalization) {
// Ignore requests to clear the free list during GC. We use object
// stacks during GC, so emptying the free-list is counterproductive.
return;
}

struct _Py_object_stack_freelist *state = &free_lists->object_stacks;
struct _Py_object_stack_freelist *state = &freelists->object_stacks;
while (state->numfree > 0) {
_PyObjectStackChunk *buf = state->free_list;
state->free_list = buf->prev;
Expand Down
4 changes: 2 additions & 2 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1795,8 +1795,8 @@ finalize_interp_types(PyInterpreterState *interp)
#ifndef Py_GIL_DISABLED
// With Py_GIL_DISABLED:
// the freelists for the current thread state have already been cleared.
struct _Py_object_freelists *state = _Py_object_freelists_GET();
_PyObject_ClearFreeLists(state, 1);
struct _Py_object_freelists *freelists = _Py_object_freelists_GET();
_PyObject_ClearFreeLists(freelists, 1);
#endif

#ifdef Py_DEBUG
Expand Down
4 changes: 2 additions & 2 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1552,8 +1552,8 @@ PyThreadState_Clear(PyThreadState *tstate)
}
#ifdef Py_GIL_DISABLED
// Each thread should clear own freelists in free-threading builds.
struct _Py_object_freelists *freelist_state = _Py_object_freelists_GET();
_PyObject_ClearFreeLists(freelist_state, 1);
struct _Py_object_freelists *freelists = _Py_object_freelists_GET();
_PyObject_ClearFreeLists(freelists, 1);

// Remove ourself from the biased reference counting table of threads.
_Py_brc_remove_thread(tstate);
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy