diff options
author | Mark Shannon <mark@hotpy.org> | 2024-04-25 11:32:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-25 11:32:47 +0100 |
commit | f180b31e7629d36265fa36f1560365358b4fd47c (patch) | |
tree | 3a887125f428f481fd85753d3f6b896843e84b3a /Python/optimizer_bytecodes.c | |
parent | 10bb90ed49a81a525b126ce8e4d8564c1616d0b3 (diff) | |
download | cpython-f180b31e7629d36265fa36f1560365358b4fd47c.tar.gz cpython-f180b31e7629d36265fa36f1560365358b4fd47c.zip |
GH-118095: Handle `RETURN_GENERATOR` in tier 2 (GH-118180)
Diffstat (limited to 'Python/optimizer_bytecodes.c')
-rw-r--r-- | Python/optimizer_bytecodes.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c index 481fb8387af..8bc56342774 100644 --- a/Python/optimizer_bytecodes.c +++ b/Python/optimizer_bytecodes.c @@ -651,6 +651,28 @@ dummy_func(void) { } } + op(_RETURN_GENERATOR, ( -- res)) { + SYNC_SP(); + ctx->frame->stack_pointer = stack_pointer; + frame_pop(ctx); + stack_pointer = ctx->frame->stack_pointer; + OUT_OF_SPACE_IF_NULL(res = sym_new_unknown(ctx)); + + /* Stack space handling */ + assert(corresponding_check_stack == NULL); + assert(co != NULL); + int framesize = co->co_framesize; + assert(framesize > 0); + assert(framesize <= curr_space); + curr_space -= framesize; + + co = get_code(this_instr); + if (co == NULL) { + // might be impossible, but bailing is still safe + goto done; + } + } + op(_CHECK_STACK_SPACE, ( --)) { assert(corresponding_check_stack == NULL); corresponding_check_stack = this_instr; |