Skip to content

Commit 661a2b8

Browse files
committed
Squeeze the flag elsewhere
1 parent e547f07 commit 661a2b8

93 files changed

Lines changed: 103 additions & 1053 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Include/cpython/tupleobject.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ typedef struct {
66
PyObject_VAR_HEAD
77
/* Cached hash. Initially set to -1. */
88
Py_hash_t ob_hash;
9-
int contains_mortal;
109
/* ob_item contains space for 'ob_size' elements.
1110
Items must normally not be NULL, except during construction when
1211
the tuple is not yet visible outside the function that builds it. */
@@ -29,6 +28,8 @@ static inline Py_ssize_t PyTuple_GET_SIZE(PyObject *op) {
2928

3029
#define PyTuple_GET_ITEM(op, index) (_PyTuple_CAST(op)->ob_item[(index)])
3130

31+
#define _PyTuple_UPDATE_IMMORTAL_CHILD(tuple, item) if (!_Py_IsImmortal((item))) { ((PyObject *)tuple)->ob_flags &= ~_Py_IMMORTAL_CHILDREN_FLAG; }
32+
3233
/* Function *only* to be used to fill in brand new tuples */
3334
static inline void
3435
PyTuple_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) {
@@ -37,7 +38,7 @@ PyTuple_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) {
3738
assert(index < Py_SIZE(tuple));
3839
tuple->ob_item[index] = value;
3940
if (value != NULL) {
40-
tuple->contains_mortal |= !_Py_IsImmortal(value);
41+
_PyTuple_UPDATE_IMMORTAL_CHILD(tuple, value);
4142
}
4243
}
4344
#define PyTuple_SET_ITEM(op, index, value) \

Include/internal/pycore_runtime_init.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ extern PyTypeObject _PyExc_MemoryError;
108108
.tuple_empty = { \
109109
.ob_base = _PyVarObject_HEAD_INIT(&PyTuple_Type, 0), \
110110
.ob_hash = _PyTuple_HASH_EMPTY, \
111-
.contains_mortal = 0, \
112111
}, \
113112
.hamt_bitmap_node_empty = { \
114113
.ob_base = _PyVarObject_HEAD_INIT(&_PyHamt_BitmapNode_Type, 0), \

Include/internal/pycore_tuple.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ typedef struct {
4444
static inline void
4545
_PyTuple_Recycle(PyObject *op)
4646
{
47-
((PyTupleObject *)op)->contains_mortal = 0;
47+
op->ob_flags |= _Py_IMMORTAL_CHILDREN_FLAG;
4848
_PyTuple_RESET_HASH_CACHE(op);
4949
if (!_PyObject_GC_IS_TRACKED(op)) {
5050
_PyObject_GC_TRACK(op);

Include/refcount.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ cleanup during runtime finalization.
2121

2222
#define _Py_STATICALLY_ALLOCATED_FLAG 4
2323
#define _Py_IMMORTAL_FLAGS 1
24+
#define _Py_IMMORTAL_CHILDREN_FLAG 2
2425

2526
#if SIZEOF_VOID_P > 4
2627
/*

Modules/_ctypes/clinic/cfield.c.h

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/_iomodule.c.h

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/bufferedio.c.h

Lines changed: 1 addition & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/bytesio.c.h

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/fileio.c.h

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/stringio.c.h

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)