8000 Move immortal bit to 2nd MSB · python/cpython@5949df4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5949df4

Browse files
Move immortal bit to 2nd MSB
1 parent c829257 commit 5949df4

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

Include/moduleobject.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ typedef struct PyModuleDef_Base {
4848
PyObject* m_copy;
4949
} PyModuleDef_Base;
5050

51-
// TODO(eduardo-elizondo): This is only used to simplify the review of GH-19474
52-
// Rather than changing this API, we'll introduce PyModuleDef_HEAD_IMMORTAL_INIT
5351
#define PyModuleDef_HEAD_INIT { \
5452
PyObject_HEAD_IMMORTAL_INIT(NULL) \
5553
NULL, /* m_init */ \

Include/object.h

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,15 @@ typedef struct _typeobject PyTypeObject;
8484
/*
8585
Immortalization:
8686
87-
This marks the reference count bit that will be used to define immortality.
88-
The GC bit-shifts refcounts left by two, and after that shift it still needs
89-
to be larger than zero, so it's placed after the first three high bits.
90-
91-
For backwards compatibility the actual reference count of an immortal instance
92-
is set to higher than just the immortal bit. This will ensure that the immortal
93-
bit will remain active, even with extensions compiled without the updated checks
94-
in Py_INCREF and Py_DECREF. This can be safely changed to a smaller value if
95-
additional bits are needed in the reference count field.
87+
This marks the reference count bit that will be used to define immortality which
88+
is set right after the sign bit. For backwards compatibility the actual
89+
reference count of an immortal instance is set to higher than the immortal bit.
90+
This will ensure that the immortal bit will remain active, even with extensions
91+
compiled without the updated checks in Py_INCREF and Py_DECREF.
92+
This extra value can be safely changed to a smaller value if additional bits are
93+
needed in the reference count field.
9694
*/
97-
#define _Py_IMMORTAL_BIT_OFFSET (8 * sizeof(Py_ssize_t) - 4)
95+
#define _Py_IMMORTAL_BIT_OFFSET (8 * sizeof(Py_ssize_t) - 2)
9896
#define _Py_IMMORTAL_BIT (1LL << _Py_IMMORTAL_BIT_OFFSET)
9997
#define _Py_IMMORTAL_REFCNT (_Py_IMMORTAL_BIT + (_Py_IMMORTAL_BIT / 2))
10098

@@ -105,8 +103,6 @@ additional bits are needed in the reference count field.
105103
#define PyObject_HEAD_IMMORTAL_INIT(type) \
106104
{ _PyObject_EXTRA_INIT _Py_IMMORTAL_REFCNT, type },
107105

108-
// TODO(eduardo-elizondo): This is only used to simplify the review of GH-19474
109-
// Rather than changing this API, we'll introduce PyVarObject_HEAD_IMMORTAL_INIT
110106
#define PyVarObject_HEAD_INIT(type, size) \
111107
{ PyObject_HEAD_IMMORTAL_INIT(type) size },
112108

0 commit comments

Comments
 (0)
0