mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +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
|
@ -1392,6 +1392,7 @@ class SizeofTest(unittest.TestCase):
|
|||
self.longdigit = sys.int_info.sizeof_digit
|
||||
import _testinternalcapi
|
||||
self.gc_headsize = _testinternalcapi.SIZEOF_PYGC_HEAD
|
||||
self.managed_pre_header_size = _testinternalcapi.SIZEOF_MANAGED_PRE_HEADER
|
||||
|
||||
check_sizeof = test.support.check_sizeof
|
||||
|
||||
|
@ -1427,7 +1428,7 @@ class SizeofTest(unittest.TestCase):
|
|||
def __sizeof__(self):
|
||||
return int(self)
|
||||
self.assertEqual(sys.getsizeof(OverflowSizeof(sys.maxsize)),
|
||||
sys.maxsize + self.gc_headsize*2)
|
||||
sys.maxsize + self.gc_headsize + self.managed_pre_header_size)
|
||||
with self.assertRaises(OverflowError):
|
||||
sys.getsizeof(OverflowSizeof(sys.maxsize + 1))
|
||||
with self.assertRaises(ValueError):
|
||||
|
@ -1650,7 +1651,7 @@ class SizeofTest(unittest.TestCase):
|
|||
# type
|
||||
# static type: PyTypeObject
|
||||
fmt = 'P2nPI13Pl4Pn9Pn12PIPc'
|
||||
s = vsize('2P' + fmt)
|
||||
s = vsize(fmt)
|
||||
check(int, s)
|
||||
# class
|
||||
s = vsize(fmt + # PyTypeObject
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue