mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
GH-108362: Incremental Cycle GC (GH-116206)
This commit is contained in:
parent
d5ebf8b71f
commit
15309329b6
14 changed files with 743 additions and 447 deletions
|
|
@ -2401,6 +2401,27 @@ _Py_NewReferenceNoTotal(PyObject *op)
|
|||
new_reference(op);
|
||||
}
|
||||
|
||||
void
|
||||
_Py_SetImmortalUntracked(PyObject *op)
|
||||
{
|
||||
#ifdef Py_GIL_DISABLED
|
||||
op->ob_tid = _Py_UNOWNED_TID;
|
||||
op->ob_ref_local = _Py_IMMORTAL_REFCNT_LOCAL;
|
||||
op->ob_ref_shared = 0;
|
||||
#else
|
||||
op->ob_refcnt = _Py_IMMORTAL_REFCNT;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
_Py_SetImmortal(PyObject *op)
|
||||
{
|
||||
if (PyObject_IS_GC(op) && _PyObject_GC_IS_TRACKED(op)) {
|
||||
_PyObject_GC_UNTRACK(op);
|
||||
}
|
||||
_Py_SetImmortalUntracked(op);
|
||||
}
|
||||
|
||||
void
|
||||
_Py_ResurrectReference(PyObject *op)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -603,6 +603,9 @@ _PyStructSequence_InitBuiltinWithFlags(PyInterpreterState *interp,
|
|||
PyStructSequence_Desc *desc,
|
||||
unsigned long tp_flags)
|
||||
{
|
||||
if (Py_TYPE(type) == NULL) {
|
||||
Py_SET_TYPE(type, &PyType_Type);
|
||||
}
|
||||
Py_ssize_t n_unnamed_members;
|
||||
Py_ssize_t n_members = count_members(desc, &n_unnamed_members);
|
||||
PyMemberDef *members = NULL;
|
||||
|
|
@ -618,7 +621,7 @@ _PyStructSequence_InitBuiltinWithFlags(PyInterpreterState *interp,
|
|||
}
|
||||
initialize_static_fields(type, desc, members, tp_flags);
|
||||
|
||||
_Py_SetImmortal(type);
|
||||
_Py_SetImmortal((PyObject *)type);
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue