GH-96421: Insert shim frame on entry to interpreter (GH-96319) · python/cpython@1e197e6

GitHub

@@ -42,27 +42,27 @@ typedef enum _framestate {

4242enum_frameowner {

4343FRAME_OWNED_BY_THREAD=0,

4444FRAME_OWNED_BY_GENERATOR=1,

45-FRAME_OWNED_BY_FRAME_OBJECT=2

45+FRAME_OWNED_BY_FRAME_OBJECT=2,

46+FRAME_OWNED_BY_CSTACK=3,

4647};

47484849typedefstruct_PyInterpreterFrame {

4950/* "Specials" section */

50-PyObject*f_funcobj; /* Strong reference */

51-PyObject*f_globals; /* Borrowed reference */

52-PyObject*f_builtins; /* Borrowed reference */

53-PyObject*f_locals; /* Strong reference, may be NULL */

51+PyObject*f_funcobj; /* Strong reference. Only valid if not on C stack */

52+PyObject*f_globals; /* Borrowed reference. Only valid if not on C stack */

53+PyObject*f_builtins; /* Borrowed reference. Only valid if not on C stack */

54+PyObject*f_locals; /* Strong reference, may be NULL. Only valid if not on C stack */

5455PyCodeObject*f_code; /* Strong reference */

55-PyFrameObject*frame_obj; /* Strong reference, may be NULL */

56+PyFrameObject*frame_obj; /* Strong reference, may be NULL. Only valid if not on C stack */

5657/* Linkage section */

5758struct_PyInterpreterFrame*previous;

5859// NOTE: This is not necessarily the last instruction started in the given

5960// frame. Rather, it is the code unit *prior to* the *next* instruction. For

6061// example, it may be an inline CACHE entry, an instruction we just jumped

6162// over, or (in the case of a newly-created frame) a totally invalid value:

6263_Py_CODEUNIT*prev_instr;

63-intstacktop; /* Offset of TOS from localsplus */

64+intstacktop; /* Offset of TOS from localsplus */

6465uint16_tyield_offset;

65-boolis_entry; // Whether this is the "root" frame for the current _PyCFrame.

6666charowner;

6767/* Locals and stack */

6868PyObject*localsplus[1];

@@ -110,7 +110,6 @@ _PyFrame_InitializeSpecials(

110110frame->stacktop=code->co_nlocalsplus;

111111frame->frame_obj=NULL;

112112frame->prev_instr=_PyCode_CODE(code) -1;

113-frame->is_entry= false;

114113frame->yield_offset=0;

115114frame->owner=FRAME_OWNED_BY_THREAD;

116115}