@@ -58,26 +58,16 @@ typedef struct _PyInterpreterFrame {
58
58
PyObject * f_builtins ; /* Borrowed reference. Only valid if not on C stack */
59
59
PyObject * f_locals ; /* Strong reference, may be NULL. Only valid if not on C stack */
60
60
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) */
66
62
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 */
74
64
char owner ;
75
65
/* Locals and stack */
76
66
PyObject * localsplus [1 ];
77
67
} _PyInterpreterFrame ;
78
68
79
69
#define _PyInterpreterFrame_LASTI (IF ) \
80
- ((int)((IF)->prev_instr - _PyCode_CODE(_PyFrame_GetCode(IF))))
70
+ ((int)((IF)->instr_ptr - _PyCode_CODE(_PyFrame_GetCode(IF))))
81
71
82
72
static inline PyCodeObject * _PyFrame_GetCode (_PyInterpreterFrame * f ) {
83
73
assert (PyCode_Check (f -> f_executable ));
@@ -134,7 +124,7 @@ _PyFrame_Initialize(
134
124
frame -> f_locals = locals ;
135
125
frame -> stacktop = code -> co_nlocalsplus ;
136
126
frame -> frame_obj = NULL ;
137
- frame -> prev_instr = _PyCode_CODE (code ) - 1 ;
127
+ frame -> instr_ptr = _PyCode_CODE (code );
138
128
frame -> return_offset = 0 ;
139
129
frame -> owner = FRAME_OWNED_BY_THREAD ;
140
130
@@ -185,7 +175,7 @@ _PyFrame_IsIncomplete(_PyInterpreterFrame *frame)
185
175
return true;
186
176
}
187
177
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 ;
189
179
}
190
180
191
181
static inline _PyInterpreterFrame *
@@ -297,7 +287,7 @@ _PyFrame_PushTrampolineUnchecked(PyThreadState *tstate, PyCodeObject *code, int
297
287
frame -> f_locals = NULL ;
298
288
frame -> stacktop = code -> co_nlocalsplus + stackdepth ;
299
289
frame -> frame_obj = NULL ;
300
- frame -> prev_instr = _PyCode_CODE (code );
290
+ frame -> instr_ptr = _PyCode_CODE (code );
301
291
frame -> owner = FRAME_OWNED_BY_THREAD ;
302
292
frame -> return_offset = 0 ;
303
293
return frame ;
0 commit comments