Skip to content

Commit 77ff28b

Browse files
authored
gh-109176: replace _PyFrame_OpAlreadyRan by an assertion that the frame is complete. (#119234)
1 parent f49df4f commit 77ff28b

File tree

1 file changed

+2
-33
lines changed

1 file changed

+2
-33
lines changed

Objects/frameobject.c

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,32 +1828,6 @@ PyFrame_New(PyThreadState *tstate, PyCodeObject *code,
18281828
return f;
18291829
}
18301830

1831-
static int
1832-
_PyFrame_OpAlreadyRan(_PyInterpreterFrame *frame, int opcode, int oparg)
1833-
{
1834-
// This only works when opcode is a non-quickened form:
1835-
assert(_PyOpcode_Deopt[opcode] == opcode);
1836-
int check_oparg = 0;
1837-
for (_Py_CODEUNIT *instruction = _PyCode_CODE(_PyFrame_GetCode(frame));
1838-
instruction < frame->instr_ptr; instruction++)
1839-
{
1840-
int check_opcode = _PyOpcode_Deopt[instruction->op.code];
1841-
check_oparg |= instruction->op.arg;
1842-
if (check_opcode == opcode && check_oparg == oparg) {
1843-
return 1;
1844-
}
1845-
if (check_opcode == EXTENDED_ARG) {
1846-
check_oparg <<= 8;
1847-
}
1848-
else {
1849-
check_oparg = 0;
1850-
}
1851-
instruction += _PyOpcode_Caches[check_opcode];
1852-
}
1853-
return 0;
1854-
}
1855-
1856-
18571831
// Initialize frame free variables if needed
18581832
static void
18591833
frame_init_get_vars(_PyInterpreterFrame *frame)
@@ -1907,14 +1881,9 @@ frame_get_var(_PyInterpreterFrame *frame, PyCodeObject *co, int i,
19071881
value = PyCell_GET(value);
19081882
}
19091883
else if (kind & CO_FAST_CELL) {
1910-
// Note that no *_DEREF ops can happen before MAKE_CELL
1911-
// executes. So there's no need to duplicate the work
1912-
// that MAKE_CELL would otherwise do later, if it hasn't
1913-
// run yet.
19141884
if (value != NULL) {
1915-
if (PyCell_Check(value) &&
1916-
_PyFrame_OpAlreadyRan(frame, MAKE_CELL, i)) {
1917-
// (likely) MAKE_CELL must have executed already.
1885+
if (PyCell_Check(value)) {
1886+
assert(!_PyFrame_IsIncomplete(frame));
19181887
value = PyCell_GET(value);
19191888
}
19201889
// (likely) Otherwise it is an arg (kind & CO_FAST_LOCAL),

0 commit comments

Comments
 (0)