diff options
author | Mark Shannon <mark@hotpy.org> | 2022-11-10 04:34:57 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-10 12:34:57 +0000 |
commit | 1e197e63e21f77b102ff2601a549dda4b6439455 (patch) | |
tree | 5d8524091404607c838bb9a0ea168c8d9c28fd6a /Include/internal/pycore_frame.h | |
parent | dbf2faf579b4094387d65ee41f049456ca67c446 (diff) | |
download | cpython-git-1e197e63e21f77b102ff2601a549dda4b6439455.tar.gz |
GH-96421: Insert shim frame on entry to interpreter (GH-96319)
* Adds EXIT_INTERPRETER instruction to exit PyEval_EvalDefault()
* Simplifies RETURN_VALUE, YIELD_VALUE and RETURN_GENERATOR instructions as they no longer need to check for entry frames.
Diffstat (limited to 'Include/internal/pycore_frame.h')
-rw-r--r-- | Include/internal/pycore_frame.h | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/Include/internal/pycore_frame.h b/Include/internal/pycore_frame.h index feee692d0f..7fa410d288 100644 --- a/Include/internal/pycore_frame.h +++ b/Include/internal/pycore_frame.h @@ -42,17 +42,18 @@ typedef enum _framestate { enum _frameowner { FRAME_OWNED_BY_THREAD = 0, FRAME_OWNED_BY_GENERATOR = 1, - FRAME_OWNED_BY_FRAME_OBJECT = 2 + FRAME_OWNED_BY_FRAME_OBJECT = 2, + FRAME_OWNED_BY_CSTACK = 3, }; typedef struct _PyInterpreterFrame { /* "Specials" section */ - PyObject *f_funcobj; /* Strong reference */ - PyObject *f_globals; /* Borrowed reference */ - PyObject *f_builtins; /* Borrowed reference */ - PyObject *f_locals; /* Strong reference, may be NULL */ + PyObject *f_funcobj; /* Strong reference. Only valid if not on C stack */ + PyObject *f_globals; /* Borrowed reference. Only valid if not on C stack */ + PyObject *f_builtins; /* Borrowed reference. Only valid if not on C stack */ + PyObject *f_locals; /* Strong reference, may be NULL. Only valid if not on C stack */ PyCodeObject *f_code; /* Strong reference */ - PyFrameObject *frame_obj; /* Strong reference, may be NULL */ + PyFrameObject *frame_obj; /* Strong reference, may be NULL. Only valid if not on C stack */ /* Linkage section */ struct _PyInterpreterFrame *previous; // NOTE: This is not necessarily the last instruction started in the given @@ -60,9 +61,8 @@ typedef struct _PyInterpreterFrame { // example, it may be an inline CACHE entry, an instruction we just jumped // over, or (in the case of a newly-created frame) a totally invalid value: _Py_CODEUNIT *prev_instr; - int stacktop; /* Offset of TOS from localsplus */ + int stacktop; /* Offset of TOS from localsplus */ uint16_t yield_offset; - bool is_entry; // Whether this is the "root" frame for the current _PyCFrame. char owner; /* Locals and stack */ PyObject *localsplus[1]; @@ -110,7 +110,6 @@ _PyFrame_InitializeSpecials( frame->stacktop = code->co_nlocalsplus; frame->frame_obj = NULL; frame->prev_instr = _PyCode_CODE(code) - 1; - frame->is_entry = false; frame->yield_offset = 0; frame->owner = FRAME_OWNED_BY_THREAD; } |