aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/generated_cases.c.h
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-01-24 15:10:17 +0000
committerGitHub <noreply@github.com>2024-01-24 15:10:17 +0000
commit981d172f7f0613d30bef4a8934b361db7fcf0672 (patch)
treebda610af879108b30ba43e39579900e35689543c /Python/generated_cases.c.h
parent6fadd68da5dd928847264b17f62a5b8b369c1c1e (diff)
downloadcpython-981d172f7f0613d30bef4a8934b361db7fcf0672.tar.gz
cpython-981d172f7f0613d30bef4a8934b361db7fcf0672.zip
GH-112354: `END_FOR` instruction to only pop one value. (GH-114247)
* Compiler emits END_FOR; POP_TOP instead of END_FOR. To support tier 2 side exits in loops.
Diffstat (limited to 'Python/generated_cases.c.h')
-rw-r--r--Python/generated_cases.c.h35
1 files changed, 13 insertions, 22 deletions
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index c4bb3aeec5e..16f1db30620 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -2342,17 +2342,9 @@
next_instr += 1;
INSTRUCTION_STATS(END_FOR);
PyObject *value;
- // _POP_TOP
value = stack_pointer[-1];
- {
- Py_DECREF(value);
- }
- // _POP_TOP
- value = stack_pointer[-2];
- {
- Py_DECREF(value);
- }
- stack_pointer += -2;
+ Py_DECREF(value);
+ stack_pointer += -1;
DISPATCH();
}
@@ -2505,8 +2497,8 @@
next_instr[oparg].op.code == INSTRUMENTED_END_FOR);
Py_DECREF(iter);
STACK_SHRINK(1);
- /* Jump forward oparg, then skip following END_FOR instruction */
- JUMPBY(oparg + 1);
+ /* Jump forward oparg, then skip following END_FOR and POP_TOP instruction */
+ JUMPBY(oparg + 2);
DISPATCH();
}
// Common case: no jump, leave it to the code generator
@@ -2567,8 +2559,8 @@
}
Py_DECREF(iter);
STACK_SHRINK(1);
- /* Jump forward oparg, then skip following END_FOR instruction */
- JUMPBY(oparg + 1);
+ /* Jump forward oparg, then skip following END_FOR and POP_TOP instructions */
+ JUMPBY(oparg + 2);
DISPATCH();
}
}
@@ -2608,8 +2600,8 @@
if (r->len <= 0) {
STACK_SHRINK(1);
Py_DECREF(r);
- // Jump over END_FOR instruction.
- JUMPBY(oparg + 1);
+ // Jump over END_FOR and POP_TOP instructions.
+ JUMPBY(oparg + 2);
DISPATCH();
}
}
@@ -2655,8 +2647,8 @@
}
Py_DECREF(iter);
STACK_SHRINK(1);
- /* Jump forward oparg, then skip following END_FOR instruction */
- JUMPBY(oparg + 1);
+ /* Jump forward oparg, then skip following END_FOR and POP_TOP instructions */
+ JUMPBY(oparg + 2);
DISPATCH();
}
}
@@ -2952,9 +2944,8 @@
}
PyErr_SetRaisedException(NULL);
}
- Py_DECREF(receiver);
Py_DECREF(value);
- stack_pointer += -2;
+ stack_pointer += -1;
DISPATCH();
}
@@ -3005,8 +2996,8 @@
next_instr[oparg].op.code == INSTRUMENTED_END_FOR);
STACK_SHRINK(1);
Py_DECREF(iter);
- /* Skip END_FOR */
- target = next_instr + oparg + 1;
+ /* Skip END_FOR and POP_TOP */
+ target = next_instr + oparg + 2;
}
INSTRUMENTED_JUMP(this_instr, target, PY_MONITORING_EVENT_BRANCH);
DISPATCH();