summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2023-12-14 14:26:44 (GMT)
committerGitHub <noreply@github.com>2023-12-14 14:26:44 (GMT)
commit6873555955497e9adbc72fc0e38df5261844aafd (patch)
treeeda67dbe91ff5e80a437343651c78c646b519e8a /Python
parentd9e1b5794a8fade21773d18f91a07f80b55c839c (diff)
downloadcpython-6873555955497e9adbc72fc0e38df5261844aafd.zip
cpython-6873555955497e9adbc72fc0e38df5261844aafd.tar.gz
cpython-6873555955497e9adbc72fc0e38df5261844aafd.tar.bz2
GH-112354: Treat _EXIT_TRACE like an unconditional side exit (GH-113104)
Diffstat (limited to 'Python')
-rw-r--r--Python/bytecodes.c2
-rw-r--r--Python/ceval.c19
-rw-r--r--Python/ceval_macros.h2
-rw-r--r--Python/executor_cases.c.h2
4 files changed, 4 insertions, 21 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 1ae8342..68bb15c 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -4027,7 +4027,7 @@ dummy_func(
op(_EXIT_TRACE, (--)) {
TIER_TWO_ONLY
- GOTO_TIER_ONE();
+ DEOPT_IF(1);
}
op(_INSERT, (unused[oparg], top -- top, unused[oparg])) {
diff --git a/Python/ceval.c b/Python/ceval.c
index 8e0be70..27304d3 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1063,31 +1063,16 @@ error_tier_two:
// Jump here from DEOPT_IF()
deoptimize:
- // On DEOPT_IF we just repeat the last instruction.
- // This presumes nothing was popped from the stack (nor pushed).
- frame->instr_ptr = next_uop[-1].target + _PyCode_CODE(_PyFrame_GetCode(frame));
+ next_instr = next_uop[-1].target + _PyCode_CODE(_PyFrame_GetCode(frame));
DPRINTF(2, "DEOPT: [UOp %d (%s), oparg %d, operand %" PRIu64 ", target %d @ %d -> %s]\n",
uopcode, _PyUOpName(uopcode), next_uop[-1].oparg, next_uop[-1].operand, next_uop[-1].target,
(int)(next_uop - current_executor->trace - 1),
_PyOpcode_OpName[frame->instr_ptr->op.code]);
OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
UOP_STAT_INC(uopcode, miss);
- frame->return_offset = 0; // Dispatch to frame->instr_ptr
- _PyFrame_SetStackPointer(frame, stack_pointer);
Py_DECREF(current_executor);
- // Fall through
-// Jump here from ENTER_EXECUTOR
-enter_tier_one:
- next_instr = frame->instr_ptr;
- goto resume_frame;
+ DISPATCH();
-// Jump here from _EXIT_TRACE
-exit_trace:
- _PyFrame_SetStackPointer(frame, stack_pointer);
- frame->instr_ptr = next_uop[-1].target + _PyCode_CODE(_PyFrame_GetCode(frame));
- Py_DECREF(current_executor);
- OPT_HIST(trace_uop_execution_counter, trace_run_length_hist);
- goto enter_tier_one;
}
#if defined(__GNUC__)
# pragma GCC diagnostic pop
diff --git a/Python/ceval_macros.h b/Python/ceval_macros.h
index ac44aec..a3606b1 100644
--- a/Python/ceval_macros.h
+++ b/Python/ceval_macros.h
@@ -392,8 +392,6 @@ stack_pointer = _PyFrame_GetStackPointer(frame);
#define GOTO_TIER_TWO() goto enter_tier_two;
-#define GOTO_TIER_ONE() goto exit_trace;
-
#define CURRENT_OPARG() (next_uop[-1].oparg)
#define CURRENT_OPERAND() (next_uop[-1].operand)
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index 14d9dd6..2519a4e 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -3516,7 +3516,7 @@
case _EXIT_TRACE: {
TIER_TWO_ONLY
- GOTO_TIER_ONE();
+ if (1) goto deoptimize;
break;
}