summaryrefslogtreecommitdiffstats
path: root/Python/optimizer.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-04-29 06:54:05 (GMT)
committerGitHub <noreply@github.com>2024-04-29 06:54:05 (GMT)
commitab6eda0ee59587e84cb417dd84452b9c6845434c (patch)
treea8b35575dc02021f8e043926023763895b477cf9 /Python/optimizer.c
parentaa8f6d2708bce1462544d2e2cae05a2595ffd9ec (diff)
downloadcpython-ab6eda0ee59587e84cb417dd84452b9c6845434c.zip
cpython-ab6eda0ee59587e84cb417dd84452b9c6845434c.tar.gz
cpython-ab6eda0ee59587e84cb417dd84452b9c6845434c.tar.bz2
GH-118095: Allow a variant of RESUME_CHECK in tier 2 (GH-118286)
Diffstat (limited to 'Python/optimizer.c')
-rw-r--r--Python/optimizer.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/Python/optimizer.c b/Python/optimizer.c
index 02c9b39..fcd7d18 100644
--- a/Python/optimizer.c
+++ b/Python/optimizer.c
@@ -690,6 +690,12 @@ top: // Jump here after _PUSH_FRAME or likely branches
break;
}
+ case RESUME:
+ /* Use a special tier 2 version of RESUME_CHECK to allow traces to
+ * start with RESUME_CHECK */
+ ADD_TO_TRACE(_TIER2_RESUME_CHECK, 0, 0, target);
+ break;
+
default:
{
const struct opcode_macro_expansion *expansion = &_PyOpcode_macro_expansion[opcode];
@@ -967,7 +973,18 @@ prepare_for_execution(_PyUOpInstruction *buffer, int length)
int32_t target = (int32_t)uop_get_target(inst);
if (_PyUop_Flags[opcode] & (HAS_EXIT_FLAG | HAS_DEOPT_FLAG)) {
if (target != current_jump_target) {
- uint16_t exit_op = (_PyUop_Flags[opcode] & HAS_EXIT_FLAG) ? _SIDE_EXIT : _DEOPT;
+ uint16_t exit_op;
+ if (_PyUop_Flags[opcode] & HAS_EXIT_FLAG) {
+ if (opcode == _TIER2_RESUME_CHECK) {
+ exit_op = _EVAL_BREAKER_EXIT;
+ }
+ else {
+ exit_op = _SIDE_EXIT;
+ }
+ }
+ else {
+ exit_op = _DEOPT;
+ }
make_exit(&buffer[next_spare], exit_op, target);
current_jump_target = target;
current_jump = next_spare;
@@ -1075,6 +1092,7 @@ sanity_check(_PyExecutorObject *executor)
CHECK(
opcode == _DEOPT ||
opcode == _SIDE_EXIT ||
+ opcode == _EVAL_BREAKER_EXIT ||
opcode == _ERROR_POP_N);
if (opcode == _SIDE_EXIT) {
CHECK(inst->format == UOP_FORMAT_EXIT);