From 8319114feedd2a5b77378bba24eb9fb2689c5033 Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Tue, 7 Dec 2021 16:02:53 +0000 Subject: bpo-45947: Place dict and values pointer at fixed (negative) offset just before GC header. (GH-29879) * Place __dict__ immediately before GC header for plain Python objects. * Fix up lazy dict creation logic to use managed dict pointers. * Manage values pointer, placing them directly before managed dict pointers. * Convert hint-based load/store attr specialization target managed dict classes. * Specialize LOAD_METHOD for managed dict objects. * Remove unsafe _PyObject_GC_Calloc function. * Remove unsafe _PyObject_GC_Malloc() function. * Add comment explaning use of Py_TPFLAGS_MANAGED_DICT. --- Python/sysmodule.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'Python/sysmodule.c') diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 13fae797b29..af4f926f0e4 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1681,10 +1681,7 @@ _PySys_GetSizeOf(PyObject *o) return (size_t)-1; } - /* add gc_head size */ - if (_PyObject_IS_GC(o)) - return ((size_t)size) + sizeof(PyGC_Head); - return (size_t)size; + return (size_t)size + _PyType_PreHeaderSize(Py_TYPE(o)); } static PyObject * -- cgit v1.2.3