]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-128954: Reorder _PyInterpreterFrame fields for reduced memory usage (#128958)
authorSam Gross <colesbury@gmail.com>
Mon, 27 Jan 2025 17:14:51 +0000 (12:14 -0500)
committerGitHub <noreply@github.com>
Mon, 27 Jan 2025 17:14:51 +0000 (17:14 +0000)
This reduces the size of _PyInterpreterFrame by 8 bytes on 64-bit
platforms using the free threading build due to alignment requirements.

This allows for slightly more recursive calls into the interpreter (from
C), but `test_call.test_super_deep` still crashes.

Include/internal/pycore_frame.h
Lib/test/test_sys.py

index 14dc91e54298ce9380966ba16aac9bd84049edbf..155a6f3ce054a2894367f05c0476e6bcc7d9287a 100644 (file)
@@ -69,11 +69,11 @@ typedef struct _PyInterpreterFrame {
     PyObject *f_locals; /* Strong reference, may be NULL. Only valid if not on C stack */
     PyFrameObject *frame_obj; /* Strong reference, may be NULL. Only valid if not on C stack */
     _Py_CODEUNIT *instr_ptr; /* Instruction currently executing (or about to begin) */
+    _PyStackRef *stackpointer;
 #ifdef Py_GIL_DISABLED
     /* Index of thread-local bytecode containing instr_ptr. */
     int32_t tlbc_index;
 #endif
-    _PyStackRef *stackpointer;
     uint16_t return_offset;  /* Only relevant during a function call */
     char owner;
 #ifdef Py_DEBUG
index d839893d2c657eb823396348aa615476a4e640b2..39857445a02255d5093e5305e448082273e21b34 100644 (file)
@@ -1621,7 +1621,7 @@ class SizeofTest(unittest.TestCase):
             return sys._getframe()
         x = func()
         if support.Py_GIL_DISABLED:
-            INTERPRETER_FRAME = '10PhcP'
+            INTERPRETER_FRAME = '9PihcP'
         else:
             INTERPRETER_FRAME = '9PhcP'
         check(x, size('3PiccPP' + INTERPRETER_FRAME + 'P'))