summaryrefslogtreecommitdiffstats
path: root/Python/optimizer.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-04-25 10:32:47 (GMT)
committerGitHub <noreply@github.com>2024-04-25 10:32:47 (GMT)
commitf180b31e7629d36265fa36f1560365358b4fd47c (patch)
tree3a887125f428f481fd85753d3f6b896843e84b3a /Python/optimizer.c
parent10bb90ed49a81a525b126ce8e4d8564c1616d0b3 (diff)
downloadcpython-f180b31e7629d36265fa36f1560365358b4fd47c.zip
cpython-f180b31e7629d36265fa36f1560365358b4fd47c.tar.gz
cpython-f180b31e7629d36265fa36f1560365358b4fd47c.tar.bz2
GH-118095: Handle `RETURN_GENERATOR` in tier 2 (GH-118180)
Diffstat (limited to 'Python/optimizer.c')
-rw-r--r--Python/optimizer.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/optimizer.c b/Python/optimizer.c
index b17c299..e5c70f7 100644
--- a/Python/optimizer.c
+++ b/Python/optimizer.c
@@ -697,7 +697,8 @@ top: // Jump here after _PUSH_FRAME or likely branches
// Reserve space for nuops (+ _SET_IP + _EXIT_TRACE)
int nuops = expansion->nuops;
RESERVE(nuops + 1); /* One extra for exit */
- if (expansion->uops[nuops-1].uop == _POP_FRAME) {
+ int16_t last_op = expansion->uops[nuops-1].uop;
+ if (last_op == _POP_FRAME || last_op == _RETURN_GENERATOR) {
// Check for trace stack underflow now:
// We can't bail e.g. in the middle of
// LOAD_CONST + _POP_FRAME.
@@ -756,7 +757,7 @@ top: // Jump here after _PUSH_FRAME or likely branches
Py_FatalError("garbled expansion");
}
- if (uop == _POP_FRAME) {
+ if (uop == _POP_FRAME || uop == _RETURN_GENERATOR) {
TRACE_STACK_POP();
/* Set the operand to the function or code object returned to,
* to assist optimization passes. (See _PUSH_FRAME below.)