mirror of
https://github.com/python/cpython.git
synced 2025-08-31 22:18:28 +00:00
gh-112529: Remove PyGC_Head from object pre-header in free-threaded build (#114564)
* gh-112529: Remove PyGC_Head from object pre-header in free-threaded build This avoids allocating space for PyGC_Head in the free-threaded build. The GC implementation for free-threaded CPython does not use the PyGC_Head structure. * The trashcan mechanism uses the `ob_tid` field instead of `_gc_prev` in the free-threaded build. * The GDB libpython.py file now determines the offset of the managed dict field based on whether the running process is a free-threaded build. Those are identified by the `ob_ref_local` field in PyObject. * Fixes `_PySys_GetSizeOf()` which incorrectly incorrectly included the size of `PyGC_Head` in the size of static `PyTypeObject`.
This commit is contained in:
parent
500ede0117
commit
587d480203
9 changed files with 86 additions and 26 deletions
|
@ -2671,7 +2671,12 @@ _PyTrash_thread_deposit_object(struct _py_trashcan *trash, PyObject *op)
|
|||
_PyObject_ASSERT(op, _PyObject_IS_GC(op));
|
||||
_PyObject_ASSERT(op, !_PyObject_GC_IS_TRACKED(op));
|
||||
_PyObject_ASSERT(op, Py_REFCNT(op) == 0);
|
||||
#ifdef Py_GIL_DISABLED
|
||||
_PyObject_ASSERT(op, op->ob_tid == 0);
|
||||
op->ob_tid = (uintptr_t)trash->delete_later;
|
||||
#else
|
||||
_PyGCHead_SET_PREV(_Py_AS_GC(op), (PyGC_Head*)trash->delete_later);
|
||||
#endif
|
||||
trash->delete_later = op;
|
||||
}
|
||||
|
||||
|
@ -2697,8 +2702,12 @@ _PyTrash_thread_destroy_chain(struct _py_trashcan *trash)
|
|||
PyObject *op = trash->delete_later;
|
||||
destructor dealloc = Py_TYPE(op)->tp_dealloc;
|
||||
|
||||
trash->delete_later =
|
||||
(PyObject*) _PyGCHead_PREV(_Py_AS_GC(op));
|
||||
#ifdef Py_GIL_DISABLED
|
||||
trash->delete_later = (PyObject*) op->ob_tid;
|
||||
op->ob_tid = 0;
|
||||
#else
|
||||
trash->delete_later = (PyObject*) _PyGCHead_PREV(_Py_AS_GC(op));
|
||||
#endif
|
||||
|
||||
/* Call the deallocator directly. This used to try to
|
||||
* fool Py_DECREF into calling it indirectly, but
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue