mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
gh-109094: replace frame->prev_instr by frame->instr_ptr (#109095)
This commit is contained in:
parent
573eff3e2e
commit
67a91f78e4
23 changed files with 249 additions and 164 deletions
|
@ -58,26 +58,16 @@ typedef struct _PyInterpreterFrame {
|
|||
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 */
|
||||
PyFrameObject *frame_obj; /* Strong reference, may be NULL. Only valid if not on C stack */
|
||||
// NOTE: This is not necessarily the last instruction started in the given
|
||||
// frame. Rather, it is the code unit *prior to* the *next* instruction. For
|
||||
// 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;
|
||||
_Py_CODEUNIT *instr_ptr; /* Instruction currently executing (or about to begin) */
|
||||
int stacktop; /* Offset of TOS from localsplus */
|
||||
/* The return_offset determines where a `RETURN` should go in the caller,
|
||||
* relative to `prev_instr`.
|
||||
* It is only meaningful to the callee,
|
||||
* so it needs to be set in any CALL (to a Python function)
|
||||
* or SEND (to a coroutine or generator).
|
||||
* If there is no callee, then it is meaningless. */
|
||||
uint16_t return_offset;
|
||||
uint16_t return_offset; /* Only relevant during a function call */
|
||||
char owner;
|
||||
/* Locals and stack */
|
||||
PyObject *localsplus[1];
|
||||
} _PyInterpreterFrame;
|
||||
|
||||
#define _PyInterpreterFrame_LASTI(IF) \
|
||||
((int)((IF)->prev_instr - _PyCode_CODE(_PyFrame_GetCode(IF))))
|
||||
((int)((IF)->instr_ptr - _PyCode_CODE(_PyFrame_GetCode(IF))))
|
||||
|
||||
static inline PyCodeObject *_PyFrame_GetCode(_PyInterpreterFrame *f) {
|
||||
assert(PyCode_Check(f->f_executable));
|
||||
|
@ -134,7 +124,7 @@ _PyFrame_Initialize(
|
|||
frame->f_locals = locals;
|
||||
frame->stacktop = code->co_nlocalsplus;
|
||||
frame->frame_obj = NULL;
|
||||
frame->prev_instr = _PyCode_CODE(code) - 1;
|
||||
frame->instr_ptr = _PyCode_CODE(code);
|
||||
frame->return_offset = 0;
|
||||
frame->owner = FRAME_OWNED_BY_THREAD;
|
||||
|
||||
|
@ -185,7 +175,7 @@ _PyFrame_IsIncomplete(_PyInterpreterFrame *frame)
|
|||
return true;
|
||||
}
|
||||
return frame->owner != FRAME_OWNED_BY_GENERATOR &&
|
||||
frame->prev_instr < _PyCode_CODE(_PyFrame_GetCode(frame)) + _PyFrame_GetCode(frame)->_co_firsttraceable;
|
||||
frame->instr_ptr < _PyCode_CODE(_PyFrame_GetCode(frame)) + _PyFrame_GetCode(frame)->_co_firsttraceable;
|
||||
}
|
||||
|
||||
static inline _PyInterpreterFrame *
|
||||
|
@ -297,7 +287,7 @@ _PyFrame_PushTrampolineUnchecked(PyThreadState *tstate, PyCodeObject *code, int
|
|||
frame->f_locals = NULL;
|
||||
frame->stacktop = code->co_nlocalsplus + stackdepth;
|
||||
frame->frame_obj = NULL;
|
||||
frame->prev_instr = _PyCode_CODE(code);
|
||||
frame->instr_ptr = _PyCode_CODE(code);
|
||||
frame->owner = FRAME_OWNED_BY_THREAD;
|
||||
frame->return_offset = 0;
|
||||
return frame;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue