Skip to content

Commit 37f1e18

Browse files
committed
Remove use of Py_TAG_IMMORTAL
1 parent 0f9c865 commit 37f1e18

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

Include/internal/pycore_stackref.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -368,25 +368,24 @@ PyStackRef_AsStrongReference(_PyStackRef stackref)
368368

369369
#define Py_TAG_BITS 3
370370
#define Py_TAG_REFCNT 1
371-
#if _Py_IMMORTAL_FLAGS != Py_TAG_REFCNT
371+
#if Py_TAG_REFCNT != Py_TAG_REFCNT
372372
# error "_Py_IMMORTAL_FLAGS != Py_TAG_REFCNT"
373373
#endif
374-
#define Py_TAG_IMMORTAL _Py_IMMORTAL_FLAGS
375374

376375
#define BITS_TO_PTR(REF) ((PyObject *)((REF).bits))
377376
#define BITS_TO_PTR_MASKED(REF) ((PyObject *)(((REF).bits) & (~Py_TAG_BITS)))
378377

379-
#define PyStackRef_NULL_BITS Py_TAG_IMMORTAL
378+
#define PyStackRef_NULL_BITS Py_TAG_REFCNT
380379
static const _PyStackRef PyStackRef_NULL = { .bits = PyStackRef_NULL_BITS };
381380

382381
#define PyStackRef_IsNull(ref) ((ref).bits == PyStackRef_NULL_BITS)
383-
#define PyStackRef_True ((_PyStackRef){.bits = ((uintptr_t)&_Py_TrueStruct) | Py_TAG_IMMORTAL })
384-
#define PyStackRef_False ((_PyStackRef){.bits = ((uintptr_t)&_Py_FalseStruct) | Py_TAG_IMMORTAL })
385-
#define PyStackRef_None ((_PyStackRef){.bits = ((uintptr_t)&_Py_NoneStruct) | Py_TAG_IMMORTAL })
382+
#define PyStackRef_True ((_PyStackRef){.bits = ((uintptr_t)&_Py_TrueStruct) | Py_TAG_REFCNT })
383+
#define PyStackRef_False ((_PyStackRef){.bits = ((uintptr_t)&_Py_FalseStruct) | Py_TAG_REFCNT })
384+
#define PyStackRef_None ((_PyStackRef){.bits = ((uintptr_t)&_Py_NoneStruct) | Py_TAG_REFCNT })
386385

387-
#define PyStackRef_IsTrue(REF) ((REF).bits == (((uintptr_t)&_Py_TrueStruct) | Py_TAG_IMMORTAL))
388-
#define PyStackRef_IsFalse(REF) ((REF).bits == (((uintptr_t)&_Py_FalseStruct) | Py_TAG_IMMORTAL))
389-
#define PyStackRef_IsNone(REF) ((REF).bits == (((uintptr_t)&_Py_NoneStruct) | Py_TAG_IMMORTAL))
386+
#define PyStackRef_IsTrue(REF) ((REF).bits == (((uintptr_t)&_Py_TrueStruct) | Py_TAG_REFCNT))
387+
#define PyStackRef_IsFalse(REF) ((REF).bits == (((uintptr_t)&_Py_FalseStruct) | Py_TAG_REFCNT))
388+
#define PyStackRef_IsNone(REF) ((REF).bits == (((uintptr_t)&_Py_NoneStruct) | Py_TAG_REFCNT))
390389

391390
#ifdef Py_DEBUG
392391

@@ -399,7 +398,7 @@ static inline void PyStackRef_CheckValid(_PyStackRef ref) {
399398
/* Can be immortal if object was made immortal after reference came into existence */
400399
assert(!_Py_IsStaticImmortal(obj));
401400
break;
402-
case Py_TAG_IMMORTAL:
401+
case Py_TAG_REFCNT:
403402
assert(obj == NULL || _Py_IsImmortal(obj));
404403
break;
405404
default:
@@ -449,7 +448,7 @@ PyStackRef_FromPyObjectSteal(PyObject *obj)
449448
#if SIZEOF_VOID_P > 4
450449
unsigned int tag = obj->ob_flags & Py_TAG_BITS;
451450
#else
452-
unsigned int tag = _Py_IsImmortal(obj) ? Py_TAG_IMMORTAL : 0;
451+
unsigned int tag = _Py_IsImmortal(obj) ? Py_TAG_REFCNT : 0;
453452
#endif
454453
_PyStackRef ref = ((_PyStackRef){.bits = ((uintptr_t)(obj)) | tag});
455454
PyStackRef_CheckValid(ref);
@@ -477,7 +476,7 @@ _PyStackRef_FromPyObjectNew(PyObject *obj)
477476
{
478477
assert(obj != NULL);
479478
if (_Py_IsImmortal(obj)) {
480-
return (_PyStackRef){ .bits = ((uintptr_t)obj) | Py_TAG_IMMORTAL};
479+
return (_PyStackRef){ .bits = ((uintptr_t)obj) | Py_TAG_REFCNT};
481480
}
482481
Py_INCREF_MORTAL(obj);
483482
_PyStackRef ref = (_PyStackRef){ .bits = (uintptr_t)obj };
@@ -502,7 +501,7 @@ static inline _PyStackRef
502501
PyStackRef_FromPyObjectImmortal(PyObject *obj)
503502
{
504503
assert(_Py_IsImmortal(obj));
505-
return (_PyStackRef){ .bits = (uintptr_t)obj | Py_TAG_IMMORTAL};
504+
return (_PyStackRef){ .bits = (uintptr_t)obj | Py_TAG_REFCNT};
506505
}
507506

508507
/* WARNING: This macro evaluates its argument twice */

0 commit comments

Comments
 (0)