mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03: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
|
|
@ -1752,8 +1752,18 @@ module_exec(PyObject *module)
|
|||
return 1;
|
||||
}
|
||||
|
||||
Py_ssize_t sizeof_gc_head = 0;
|
||||
#ifndef Py_GIL_DISABLED
|
||||
sizeof_gc_head = sizeof(PyGC_Head);
|
||||
#endif
|
||||
|
||||
if (PyModule_Add(module, "SIZEOF_PYGC_HEAD",
|
||||
PyLong_FromSsize_t(sizeof(PyGC_Head))) < 0) {
|
||||
PyLong_FromSsize_t(sizeof_gc_head)) < 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (PyModule_Add(module, "SIZEOF_MANAGED_PRE_HEADER",
|
||||
PyLong_FromSsize_t(2 * sizeof(PyObject*))) < 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue