mirror of https://github.com/python/cpython
gh-109176: replace _PyFrame_OpAlreadyRan by an assertion that the frame is complete. (#119234)
This commit is contained in:
parent
f49df4f486
commit
77ff28bb67
|
@ -1828,32 +1828,6 @@ PyFrame_New(PyThreadState *tstate, PyCodeObject *code,
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
_PyFrame_OpAlreadyRan(_PyInterpreterFrame *frame, int opcode, int oparg)
|
|
||||||
{
|
|
||||||
// This only works when opcode is a non-quickened form:
|
|
||||||
assert(_PyOpcode_Deopt[opcode] == opcode);
|
|
||||||
int check_oparg = 0;
|
|
||||||
for (_Py_CODEUNIT *instruction = _PyCode_CODE(_PyFrame_GetCode(frame));
|
|
||||||
instruction < frame->instr_ptr; instruction++)
|
|
||||||
{
|
|
||||||
int check_opcode = _PyOpcode_Deopt[instruction->op.code];
|
|
||||||
check_oparg |= instruction->op.arg;
|
|
||||||
if (check_opcode == opcode && check_oparg == oparg) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (check_opcode == EXTENDED_ARG) {
|
|
||||||
check_oparg <<= 8;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
check_oparg = 0;
|
|
||||||
}
|
|
||||||
instruction += _PyOpcode_Caches[check_opcode];
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Initialize frame free variables if needed
|
// Initialize frame free variables if needed
|
||||||
static void
|
static void
|
||||||
frame_init_get_vars(_PyInterpreterFrame *frame)
|
frame_init_get_vars(_PyInterpreterFrame *frame)
|
||||||
|
@ -1907,14 +1881,9 @@ frame_get_var(_PyInterpreterFrame *frame, PyCodeObject *co, int i,
|
||||||
value = PyCell_GET(value);
|
value = PyCell_GET(value);
|
||||||
}
|
}
|
||||||
else if (kind & CO_FAST_CELL) {
|
else if (kind & CO_FAST_CELL) {
|
||||||
// Note that no *_DEREF ops can happen before MAKE_CELL
|
|
||||||
// executes. So there's no need to duplicate the work
|
|
||||||
// that MAKE_CELL would otherwise do later, if it hasn't
|
|
||||||
// run yet.
|
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
if (PyCell_Check(value) &&
|
if (PyCell_Check(value)) {
|
||||||
_PyFrame_OpAlreadyRan(frame, MAKE_CELL, i)) {
|
assert(!_PyFrame_IsIncomplete(frame));
|
||||||
// (likely) MAKE_CELL must have executed already.
|
|
||||||
value = PyCell_GET(value);
|
value = PyCell_GET(value);
|
||||||
}
|
}
|
||||||
// (likely) Otherwise it is an arg (kind & CO_FAST_LOCAL),
|
// (likely) Otherwise it is an arg (kind & CO_FAST_LOCAL),
|
||||||
|
|
Loading…
Reference in New Issue