GH-89914: Make the oparg of the YIELD_VALUE instruction equal the stack depth. (GH-92960)

This commit is contained in:
Mark Shannon 2022-05-19 17:49:29 +01:00 committed by GitHub
parent 70aa1b9b91
commit 3fd8610002
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 35 additions and 26 deletions

View file

@ -1962,7 +1962,7 @@ compiler_add_yield_from(struct compiler *c, int await)
compiler_use_next_block(c, start);
ADDOP_JUMP(c, SEND, exit);
compiler_use_next_block(c, resume);
ADDOP(c, YIELD_VALUE);
ADDOP_I(c, YIELD_VALUE, 0);
ADDOP_I(c, RESUME, await ? 3 : 2);
ADDOP_JUMP(c, JUMP_NO_INTERRUPT, start);
compiler_use_next_block(c, exit);
@ -4193,7 +4193,7 @@ addop_yield(struct compiler *c) {
if (c->u->u_ste->ste_generator && c->u->u_ste->ste_coroutine) {
ADDOP(c, ASYNC_GEN_WRAP);
}
ADDOP(c, YIELD_VALUE);
ADDOP_I(c, YIELD_VALUE, 0);
ADDOP_I(c, RESUME, 1);
return 1;
}
@ -7152,6 +7152,9 @@ stackdepth(struct compiler *c, basicblock *entry)
next = NULL;
break;
}
if (instr->i_opcode == YIELD_VALUE) {
instr->i_oparg = depth;
}
}
if (next != NULL) {
assert(b->b_nofallthrough == 0);