Skip to content

Commit a6a8c6f

Browse files
authored
gh-128954: Reorder _PyInterpreterFrame fields for reduced memory usage (#128958)
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.
1 parent 8a5a18a commit a6a8c6f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Include/internal/pycore_frame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ typedef struct _PyInterpreterFrame {
6969
PyObject *f_locals; /* Strong reference, may be NULL. Only valid if not on C stack */
7070
PyFrameObject *frame_obj; /* Strong reference, may be NULL. Only valid if not on C stack */
7171
_Py_CODEUNIT *instr_ptr; /* Instruction currently executing (or about to begin) */
72+
_PyStackRef *stackpointer;
7273
#ifdef Py_GIL_DISABLED
7374
/* Index of thread-local bytecode containing instr_ptr. */
7475
int32_t tlbc_index;
7576
#endif
76-
_PyStackRef *stackpointer;
7777
uint16_t return_offset; /* Only relevant during a function call */
7878
char owner;
7979
#ifdef Py_DEBUG

Lib/test/test_sys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,7 @@ def func():
16211621
return sys._getframe()
16221622
x = func()
16231623
if support.Py_GIL_DISABLED:
1624-
INTERPRETER_FRAME = '10PhcP'
1624+
INTERPRETER_FRAME = '9PihcP'
16251625
else:
16261626
INTERPRETER_FRAME = '9PhcP'
16271627
check(x, size('3PiccPP' + INTERPRETER_FRAME + 'P'))

0 commit comments

Comments
 (0)