@@ -58,26 +58,16 @@ typedef struct _PyInterpreterFrame {
5858 PyObject * f_builtins ; /* Borrowed reference. Only valid if not on C stack */
5959 PyObject * f_locals ; /* Strong reference, may be NULL. Only valid if not on C stack */
6060 PyFrameObject * frame_obj ; /* Strong reference, may be NULL. Only valid if not on C stack */
61- // NOTE: This is not necessarily the last instruction started in the given
62- // frame. Rather, it is the code unit *prior to* the *next* instruction. For
63- // example, it may be an inline CACHE entry, an instruction we just jumped
64- // over, or (in the case of a newly-created frame) a totally invalid value:
65- _Py_CODEUNIT * prev_instr ;
61+ _Py_CODEUNIT * instr_ptr ; /* Instruction currently executing (or about to begin) */
6662 int stacktop ; /* Offset of TOS from localsplus */
67- /* The return_offset determines where a `RETURN` should go in the caller,
68- * relative to `prev_instr`.
69- * It is only meaningful to the callee,
70- * so it needs to be set in any CALL (to a Python function)
71- * or SEND (to a coroutine or generator).
72- * If there is no callee, then it is meaningless. */
73- uint16_t return_offset ;
63+ uint16_t return_offset ; /* Only relevant during a function call */
7464 char owner ;
7565 /* Locals and stack */
7666 PyObject * localsplus [1 ];
7767} _PyInterpreterFrame ;
7868
7969#define _PyInterpreterFrame_LASTI (IF ) \
80- ((int)((IF)->prev_instr - _PyCode_CODE(_PyFrame_GetCode(IF))))
70+ ((int)((IF)->instr_ptr - _PyCode_CODE(_PyFrame_GetCode(IF))))
8171
8272static inline PyCodeObject * _PyFrame_GetCode (_PyInterpreterFrame * f ) {
8373 assert (PyCode_Check (f -> f_executable ));
@@ -134,7 +124,7 @@ _PyFrame_Initialize(
134124 frame -> f_locals = locals ;
135125 frame -> stacktop = code -> co_nlocalsplus ;
136126 frame -> frame_obj = NULL ;
137- frame -> prev_instr = _PyCode_CODE (code ) - 1 ;
127+ frame -> instr_ptr = _PyCode_CODE (code );
138128 frame -> return_offset = 0 ;
139129 frame -> owner = FRAME_OWNED_BY_THREAD ;
140130
@@ -185,7 +175,7 @@ _PyFrame_IsIncomplete(_PyInterpreterFrame *frame)
185175 return true;
186176 }
187177 return frame -> owner != FRAME_OWNED_BY_GENERATOR &&
188- frame -> prev_instr < _PyCode_CODE (_PyFrame_GetCode (frame )) + _PyFrame_GetCode (frame )-> _co_firsttraceable ;
178+ frame -> instr_ptr < _PyCode_CODE (_PyFrame_GetCode (frame )) + _PyFrame_GetCode (frame )-> _co_firsttraceable ;
189179}
190180
191181static inline _PyInterpreterFrame *
@@ -297,7 +287,7 @@ _PyFrame_PushTrampolineUnchecked(PyThreadState *tstate, PyCodeObject *code, int
297287 frame -> f_locals = NULL ;
298288 frame -> stacktop = code -> co_nlocalsplus + stackdepth ;
299289 frame -> frame_obj = NULL ;
300- frame -> prev_instr = _PyCode_CODE (code );
290+ frame -> instr_ptr = _PyCode_CODE (code );
301291 frame -> owner = FRAME_OWNED_BY_THREAD ;
302292 frame -> return_offset = 0 ;
303293 return frame ;
0 commit comments