Skip to content

Commit 7b87fac

Browse files
Use _PyGC_BITS_DEFERRED for all immortal objects
1 parent fbda208 commit 7b87fac

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Include/internal/pycore_stackref.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ PyStackRef_IsHeapSafe(_PyStackRef stackref)
523523
{
524524
if (PyStackRef_IsDeferred(stackref)) {
525525
PyObject *obj = PyStackRef_AsPyObjectBorrow(stackref);
526-
return obj == NULL || _Py_IsImmortal(obj) || _PyObject_HasDeferredRefcount(obj);
526+
return obj == NULL || _PyObject_HasDeferredRefcount(obj);
527527
}
528528
return true;
529529
}
@@ -554,7 +554,7 @@ PyStackRef_FromPyObjectNew(PyObject *obj)
554554
// Make sure we don't take an already tagged value.
555555
assert(((uintptr_t)obj & Py_TAG_BITS) == 0);
556556
assert(obj != NULL);
557-
if (_PyObject_HasDeferredRefcount(obj) || _Py_IsImmortal(obj)) {
557+
if (_PyObject_HasDeferredRefcount(obj)) {
558558
return (_PyStackRef){ .bits = (uintptr_t)obj | Py_TAG_DEFERRED };
559559
}
560560
else {

Objects/object.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2675,6 +2675,9 @@ _Py_SetImmortalUntracked(PyObject *op)
26752675
assert(PyUnicode_CHECK_INTERNED(op) == SSTATE_INTERNED_IMMORTAL
26762676
|| PyUnicode_CHECK_INTERNED(op) == SSTATE_INTERNED_IMMORTAL_STATIC);
26772677
}
2678+
#endif
2679+
#ifdef Py_GIL_DISABLED
2680+
_Py_atomic_or_uint8(&op->ob_gc_bits, _PyGC_BITS_DEFERRED);
26782681
#endif
26792682
// Check if already immortal to avoid degrading from static immortal to plain immortal
26802683
if (_Py_IsImmortal(op)) {
@@ -2684,7 +2687,6 @@ _Py_SetImmortalUntracked(PyObject *op)
26842687
op->ob_tid = _Py_UNOWNED_TID;
26852688
op->ob_ref_local = _Py_IMMORTAL_REFCNT_LOCAL;
26862689
op->ob_ref_shared = 0;
2687-
_Py_atomic_or_uint8(&op->ob_gc_bits, _PyGC_BITS_DEFERRED);
26882690
#elif SIZEOF_VOID_P > 4
26892691
op->ob_flags = _Py_IMMORTAL_FLAGS;
26902692
op->ob_refcnt = _Py_IMMORTAL_INITIAL_REFCNT;

0 commit comments

Comments
 (0)