Skip to content

Commit 2f42cb0

Browse files
committed
Don't use entry.frame in tailcalling interpreter
1 parent 89e4668 commit 2f42cb0

File tree

3 files changed

+34
-15
lines changed

3 files changed

+34
-15
lines changed

Python/bytecodes.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,8 +1169,11 @@ dummy_func(
11691169
tstate->current_frame = frame->previous;
11701170
assert(!_PyErr_Occurred(tstate));
11711171
PyObject *result = PyStackRef_AsPyObjectSteal(retval);
1172-
#if !Py_TAIL_CALL_INTERP && defined(_Py_TIER2)
1173-
_PyStackRef executor = entry.frame.localsplus[0];
1172+
#if !Py_TAIL_CALL_INTERP
1173+
assert(frame == &entry.frame);
1174+
#endif
1175+
#ifdef _Py_TIER2
1176+
_PyStackRef executor = frame->localsplus[0];
11741177
assert(tstate->current_executor == NULL);
11751178
if (!PyStackRef_IsNull(executor)) {
11761179
tstate->current_executor = PyStackRef_AsPyObjectBorrow(executor);
@@ -5469,6 +5472,17 @@ dummy_func(
54695472
if (frame->owner == FRAME_OWNED_BY_INTERPRETER) {
54705473
/* Restore previous frame and exit */
54715474
tstate->current_frame = frame->previous;
5475+
#if !Py_TAIL_CALL_INTERP
5476+
assert(frame == &entry.frame);
5477+
#endif
5478+
#ifdef _Py_TIER2
5479+
_PyStackRef executor = frame->localsplus[0];
5480+
assert(tstate->current_executor == NULL);
5481+
if (!PyStackRef_IsNull(executor)) {
5482+
tstate->current_executor = PyStackRef_AsPyObjectBorrow(executor);
5483+
PyStackRef_CLOSE(executor);
5484+
}
5485+
#endif
54725486
return NULL;
54735487
}
54745488
next_instr = frame->instr_ptr;

Python/ceval.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,19 +1083,10 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
10831083
stack_pointer = _PyFrame_GetStackPointer(frame);
10841084
#if Py_TAIL_CALL_INTERP
10851085
# if Py_STATS
1086-
PyObject *res = _TAIL_CALL_error(frame, stack_pointer, tstate, next_instr, 0, lastopcode);
1086+
return _TAIL_CALL_error(frame, stack_pointer, tstate, next_instr, 0, lastopcode);
10871087
# else
1088-
PyObject *res = _TAIL_CALL_error(frame, stack_pointer, tstate, next_instr, 0);
1088+
return _TAIL_CALL_error(frame, stack_pointer, tstate, next_instr, 0);
10891089
# endif
1090-
# ifdef _Py_TIER2
1091-
_PyStackRef executor = entry.frame.localsplus[0];
1092-
assert(tstate->current_executor == NULL);
1093-
if (!PyStackRef_IsNull(executor)) {
1094-
tstate->current_executor = PyStackRef_AsPyObjectBorrow(executor);
1095-
PyStackRef_CLOSE(executor);
1096-
}
1097-
# endif
1098-
return res;
10991090
#else
11001091
goto error;
11011092
#endif

Python/generated_cases.c.h

Lines changed: 16 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)