FRAME_OWNED_BY_THREAD = 0,
FRAME_OWNED_BY_GENERATOR = 1,
FRAME_OWNED_BY_FRAME_OBJECT = 2,
- FRAME_OWNED_BY_CSTACK = 3,
+ FRAME_OWNED_BY_INTERPRETER = 3,
+ FRAME_OWNED_BY_CSTACK = 4,
};
typedef struct _PyInterpreterFrame {
static inline bool
_PyFrame_IsIncomplete(_PyInterpreterFrame *frame)
{
- if (frame->owner == FRAME_OWNED_BY_CSTACK) {
+ if (frame->owner >= FRAME_OWNED_BY_INTERPRETER) {
return true;
}
return frame->owner != FRAME_OWNED_BY_GENERATOR &&
return -1;
}
- if (owner == FRAME_OWNED_BY_CSTACK) {
+ if (owner >= FRAME_OWNED_BY_INTERPRETER) {
return 0;
}
assert(frame != NULL);
_PyInterpreterFrame *f = frame->f_frame;
assert(!_PyFrame_IsIncomplete(f));
- return f->previous && f->previous->owner == FRAME_OWNED_BY_CSTACK;
+ return f->previous && f->previous->owner == FRAME_OWNED_BY_INTERPRETER;
}
PyCodeObject *
}
tier1 inst(INTERPRETER_EXIT, (retval --)) {
- assert(frame == &entry_frame);
+ assert(frame->owner == FRAME_OWNED_BY_INTERPRETER);
assert(_PyFrame_IsIncomplete(frame));
/* Restore previous frame and return. */
tstate->current_frame = frame->previous;
// retval is popped from the stack, but res
// is pushed to a different frame, the callers' frame.
inst(RETURN_VALUE, (retval -- res)) {
- #if TIER_ONE
- assert(frame != &entry_frame);
- #endif
+ assert(frame->owner != FRAME_OWNED_BY_INTERPRETER);
_PyStackRef temp = retval;
DEAD(retval);
SAVE_STACK();
PyObject *receiver_o = PyStackRef_AsPyObjectBorrow(receiver);
PyObject *retval_o;
- assert(frame != &entry_frame);
+ assert(frame->owner != FRAME_OWNED_BY_INTERPRETER);
if ((tstate->interp->eval_frame == NULL) &&
(Py_TYPE(receiver_o) == &PyGen_Type || Py_TYPE(receiver_o) == &PyCoro_Type) &&
((PyGenObject *)receiver_o)->gi_frame_state < FRAME_EXECUTING)
// NOTE: It's important that YIELD_VALUE never raises an exception!
// The compiler treats any exception raised here as a failed close()
// or throw() call.
- #if TIER_ONE
- assert(frame != &entry_frame);
- #endif
+ assert(frame->owner != FRAME_OWNED_BY_INTERPRETER);
frame->instr_ptr++;
PyGenObject *gen = _PyGen_GetGeneratorFromFrame(frame);
assert(FRAME_SUSPENDED_YIELD_FROM == FRAME_SUSPENDED + 1);
int opcode,
int oparg)
{
- if (frame->owner == FRAME_OWNED_BY_CSTACK) {
+ if (frame->owner >= FRAME_OWNED_BY_INTERPRETER) {
return;
}
dump_stack(frame, stack_pointer);
}
static int
-maybe_lltrace_resume_frame(_PyInterpreterFrame *frame, _PyInterpreterFrame *skip_frame, PyObject *globals)
+maybe_lltrace_resume_frame(_PyInterpreterFrame *frame, PyObject *globals)
{
if (globals == NULL) {
return 0;
}
- if (frame == skip_frame) {
+ if (frame->owner >= FRAME_OWNED_BY_INTERPRETER) {
return 0;
}
int r = PyDict_Contains(globals, &_Py_ID(__lltrace__));
entry_frame.f_executable = PyStackRef_None;
entry_frame.instr_ptr = (_Py_CODEUNIT *)_Py_INTERPRETER_TRAMPOLINE_INSTRUCTIONS + 1;
entry_frame.stackpointer = entry_frame.localsplus;
- entry_frame.owner = FRAME_OWNED_BY_CSTACK;
+ entry_frame.owner = FRAME_OWNED_BY_INTERPRETER;
entry_frame.visited = 0;
entry_frame.return_offset = 0;
/* Push frame */
stack_pointer = _PyFrame_GetStackPointer(frame);
#ifdef LLTRACE
- lltrace = maybe_lltrace_resume_frame(frame, &entry_frame, GLOBALS());
+ lltrace = maybe_lltrace_resume_frame(frame, GLOBALS());
if (lltrace < 0) {
goto exit_unwind;
}
#if LLTRACE
#define LLTRACE_RESUME_FRAME() \
do { \
- lltrace = maybe_lltrace_resume_frame(frame, &entry_frame, GLOBALS()); \
+ lltrace = maybe_lltrace_resume_frame(frame, GLOBALS()); \
if (lltrace < 0) { \
goto exit_unwind; \
} \
#endif
#define WITHIN_STACK_BOUNDS() \
- (frame == &entry_frame || (STACK_LEVEL() >= 0 && STACK_LEVEL() <= STACK_SIZE()))
+ (frame->owner == FRAME_OWNED_BY_INTERPRETER || (STACK_LEVEL() >= 0 && STACK_LEVEL() <= STACK_SIZE()))
/* Data access macros */
#define FRAME_CO_CONSTS (_PyFrame_GetCode(frame)->co_consts)
_PyStackRef retval;
_PyStackRef res;
retval = stack_pointer[-1];
- #if TIER_ONE
- assert(frame != &entry_frame);
- #endif
+ assert(frame->owner != FRAME_OWNED_BY_INTERPRETER);
_PyStackRef temp = retval;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
// NOTE: It's important that YIELD_VALUE never raises an exception!
// The compiler treats any exception raised here as a failed close()
// or throw() call.
- #if TIER_ONE
- assert(frame != &entry_frame);
- #endif
+ assert(frame->owner != FRAME_OWNED_BY_INTERPRETER);
frame->instr_ptr++;
PyGenObject *gen = _PyGen_GetGeneratorFromFrame(frame);
assert(FRAME_SUSPENDED_YIELD_FROM == FRAME_SUSPENDED + 1);
static void
take_ownership(PyFrameObject *f, _PyInterpreterFrame *frame)
{
- assert(frame->owner != FRAME_OWNED_BY_CSTACK);
+ assert(frame->owner < FRAME_OWNED_BY_INTERPRETER);
assert(frame->owner != FRAME_OWNED_BY_FRAME_OBJECT);
Py_ssize_t size = ((char*)frame->stackpointer) - (char *)frame;
memcpy((_PyInterpreterFrame *)f->_f_frame_data, frame, size);
_PyInterpreterFrame *prev = _PyFrame_GetFirstComplete(frame->previous);
frame->previous = NULL;
if (prev) {
- assert(prev->owner != FRAME_OWNED_BY_CSTACK);
+ assert(prev->owner < FRAME_OWNED_BY_INTERPRETER);
/* Link PyFrameObjects.f_back and remove link through _PyInterpreterFrame.previous */
PyFrameObject *back = _PyFrame_GetFrameObject(prev);
if (back == NULL) {
while (ts) {
_PyInterpreterFrame *frame = ts->current_frame;
while (frame) {
- if (frame->owner == FRAME_OWNED_BY_CSTACK) {
+ if (frame->owner >= FRAME_OWNED_BY_INTERPRETER) {
frame = frame->previous;
continue;
}
// _RETURN_VALUE
{
retval = val;
- #if TIER_ONE
- assert(frame != &entry_frame);
- #endif
+ assert(frame->owner != FRAME_OWNED_BY_INTERPRETER);
_PyStackRef temp = retval;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
// NOTE: It's important that YIELD_VALUE never raises an exception!
// The compiler treats any exception raised here as a failed close()
// or throw() call.
- #if TIER_ONE
- assert(frame != &entry_frame);
- #endif
+ assert(frame->owner != FRAME_OWNED_BY_INTERPRETER);
frame->instr_ptr++;
PyGenObject *gen = _PyGen_GetGeneratorFromFrame(frame);
assert(FRAME_SUSPENDED_YIELD_FROM == FRAME_SUSPENDED + 1);
INSTRUCTION_STATS(INTERPRETER_EXIT);
_PyStackRef retval;
retval = stack_pointer[-1];
- assert(frame == &entry_frame);
+ assert(frame->owner == FRAME_OWNED_BY_INTERPRETER);
assert(_PyFrame_IsIncomplete(frame));
/* Restore previous frame and return. */
tstate->current_frame = frame->previous;
_PyStackRef retval;
_PyStackRef res;
retval = stack_pointer[-1];
- #if TIER_ONE
- assert(frame != &entry_frame);
- #endif
+ assert(frame->owner != FRAME_OWNED_BY_INTERPRETER);
_PyStackRef temp = retval;
stack_pointer += -1;
assert(WITHIN_STACK_BOUNDS());
v = stack_pointer[-1];
PyObject *receiver_o = PyStackRef_AsPyObjectBorrow(receiver);
PyObject *retval_o;
- assert(frame != &entry_frame);
+ assert(frame->owner != FRAME_OWNED_BY_INTERPRETER);
if ((tstate->interp->eval_frame == NULL) &&
(Py_TYPE(receiver_o) == &PyGen_Type || Py_TYPE(receiver_o) == &PyCoro_Type) &&
((PyGenObject *)receiver_o)->gi_frame_state < FRAME_EXECUTING)
// NOTE: It's important that YIELD_VALUE never raises an exception!
// The compiler treats any exception raised here as a failed close()
// or throw() call.
- #if TIER_ONE
- assert(frame != &entry_frame);
- #endif
+ assert(frame->owner != FRAME_OWNED_BY_INTERPRETER);
frame->instr_ptr++;
PyGenObject *gen = _PyGen_GetGeneratorFromFrame(frame);
assert(FRAME_SUSPENDED_YIELD_FROM == FRAME_SUSPENDED + 1);
while (ts) {
_PyInterpreterFrame *frame = ts->current_frame;
while (frame) {
- if (frame->owner != FRAME_OWNED_BY_CSTACK) {
+ if (frame->owner < FRAME_OWNED_BY_INTERPRETER) {
if (instrument_lock_held(_PyFrame_GetCode(frame), interp)) {
return -1;
}
static void
dump_frame(int fd, _PyInterpreterFrame *frame)
{
- assert(frame->owner != FRAME_OWNED_BY_CSTACK);
+ assert(frame->owner < FRAME_OWNED_BY_INTERPRETER);
PyCodeObject *code =_PyFrame_GetCode(frame);
PUTS(fd, " File ");
unsigned int depth = 0;
while (1) {
- if (frame->owner == FRAME_OWNED_BY_CSTACK) {
+ if (frame->owner == FRAME_OWNED_BY_INTERPRETER) {
/* Trampoline frame */
frame = frame->previous;
if (frame == NULL) {
}
/* Can't have more than one shim frame in a row */
- assert(frame->owner != FRAME_OWNED_BY_CSTACK);
+ assert(frame->owner != FRAME_OWNED_BY_INTERPRETER);
}
if (MAX_FRAME_DEPTH <= depth) {
Py_TPFLAGS_TYPE_SUBCLASS = (1 << 31)
#From pycore_frame.h
-FRAME_OWNED_BY_CSTACK = 3
+FRAME_OWNED_BY_INTERPRETER = 3
MAX_OUTPUT_LEN=1024
return int(instr_ptr - first_instr)
def is_shim(self):
- return self._f_special("owner", int) == FRAME_OWNED_BY_CSTACK
+ return self._f_special("owner", int) == FRAME_OWNED_BY_INTERPRETER
def previous(self):
return self._f_special("previous", PyFramePtr)