Skip to content

Commit 6873555

Browse files
authored
pythonGH-112354: Treat _EXIT_TRACE like an unconditional side exit (pythonGH-113104)
1 parent d9e1b57 commit 6873555

File tree

5 files changed

+5
-22
lines changed

5 files changed

+5
-22
lines changed

Include/internal/pycore_opcode_metadata.h

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4027,7 +4027,7 @@ dummy_func(
40274027

40284028
op(_EXIT_TRACE, (--)) {
40294029
TIER_TWO_ONLY
4030-
GOTO_TIER_ONE();
4030+
DEOPT_IF(1);
40314031
}
40324032

40334033
op(_INSERT, (unused[oparg], top -- top, unused[oparg])) {

Python/ceval.c

+2-17
Original file line numberDiff line numberDiff line change
@@ -1063,31 +1063,16 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
10631063

10641064
// Jump here from DEOPT_IF()
10651065
deoptimize:
1066-
// On DEOPT_IF we just repeat the last instruction.
1067-
// This presumes nothing was popped from the stack (nor pushed).
1068-
frame->instr_ptr = next_uop[-1].target + _PyCode_CODE(_PyFrame_GetCode(frame));
1066+
next_instr = next_uop[-1].target + _PyCode_CODE(_PyFrame_GetCode(frame));
10691067
DPRINTF(2, "DEOPT: [UOp %d (%s), oparg %d, operand %" PRIu64 ", target %d @ %d -> %s]\n",
10701068
uopcode, _PyUOpName(uopcode), next_uop[-1].oparg, next_uop[-1].operand, next_uop[-1].target,
10711069
(int)(next_uop - current_executor->trace - 1),
10721070
_PyOpcode_OpName[frame->instr_ptr->op.code]);
10731071
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
10741072
UOP_STAT_INC(uopcode, miss);
1075-
frame->return_offset = 0; // Dispatch to frame->instr_ptr
1076-
_PyFrame_SetStackPointer(frame, stack_pointer);
10771073
Py_DECREF(current_executor);
1078-
// Fall through
1079-
// Jump here from ENTER_EXECUTOR
1080-
enter_tier_one:
1081-
next_instr = frame->instr_ptr;
1082-
goto resume_frame;
1074+
DISPATCH();
10831075

1084-
// Jump here from _EXIT_TRACE
1085-
exit_trace:
1086-
_PyFrame_SetStackPointer(frame, stack_pointer);
1087-
frame->instr_ptr = next_uop[-1].target + _PyCode_CODE(_PyFrame_GetCode(frame));
1088-
Py_DECREF(current_executor);
1089-
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
1090-
goto enter_tier_one;
10911076
}
10921077
#if defined(__GNUC__)
10931078
# pragma GCC diagnostic pop

Python/ceval_macros.h

-2
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,6 @@ stack_pointer = _PyFrame_GetStackPointer(frame);
392392

393393
#define GOTO_TIER_TWO() goto enter_tier_two;
394394

395-
#define GOTO_TIER_ONE() goto exit_trace;
396-
397395
#define CURRENT_OPARG() (next_uop[-1].oparg)
398396

399397
#define CURRENT_OPERAND() (next_uop[-1].operand)

Python/executor_cases.c.h

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)