diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-01-04 13:37:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-04 13:37:06 (GMT) |
commit | c31e356a10aa60b5967b9aaf80b9984059e46461 (patch) | |
tree | 774e48afaea4e83f9b14c46e8d20cc14e018d92d /Include | |
parent | 5fb1c08e15b864d8ea9353a0e013166e2e0e2160 (diff) | |
download | cpython-c31e356a10aa60b5967b9aaf80b9984059e46461.zip cpython-c31e356a10aa60b5967b9aaf80b9984059e46461.tar.gz cpython-c31e356a10aa60b5967b9aaf80b9984059e46461.tar.bz2 |
gh-100720: refactor calculation of number of frame slots for a code object into the new function _PyFrame_NumSlotsForCodeObject (#100722)
Diffstat (limited to 'Include')
-rw-r--r-- | Include/internal/pycore_frame.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Include/internal/pycore_frame.h b/Include/internal/pycore_frame.h index f18723b..d5c1dcc 100644 --- a/Include/internal/pycore_frame.h +++ b/Include/internal/pycore_frame.h @@ -92,7 +92,16 @@ static inline void _PyFrame_StackPush(_PyInterpreterFrame *f, PyObject *value) { f->stacktop++; } -#define FRAME_SPECIALS_SIZE ((sizeof(_PyInterpreterFrame)-1)/sizeof(PyObject *)) +#define FRAME_SPECIALS_SIZE ((int)((sizeof(_PyInterpreterFrame)-1)/sizeof(PyObject *))) + +static inline int +_PyFrame_NumSlotsForCodeObject(PyCodeObject *code) +{ + /* This function needs to remain in sync with the calculation of + * co_framesize in Tools/build/deepfreeze.py */ + assert(code->co_framesize >= FRAME_SPECIALS_SIZE); + return code->co_framesize - FRAME_SPECIALS_SIZE; +} void _PyFrame_Copy(_PyInterpreterFrame *src, _PyInterpreterFrame *dest); |