gh-111354: Simplify _PyGen_yf by moving some of its work to the compiler and frame state (#111648)

This commit is contained in:
Irit Katriel 2023-11-03 10:01:36 +00:00 committed by GitHub
parent 7810b6981a
commit d49aba5a7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 342 additions and 338 deletions

View file

@ -1549,7 +1549,7 @@ compiler_add_yield_from(struct compiler *c, location loc, int await)
// Set up a virtual try/except to handle when StopIteration is raised during
// a close or throw call. The only way YIELD_VALUE raises if they do!
ADDOP_JUMP(c, loc, SETUP_FINALLY, fail);
ADDOP(c, loc, YIELD_VALUE);
ADDOP_I(c, loc, YIELD_VALUE, 1);
ADDOP(c, NO_LOCATION, POP_BLOCK);
ADDOP_I(c, loc, RESUME, await ? RESUME_AFTER_AWAIT : RESUME_AFTER_YIELD_FROM);
ADDOP_JUMP(c, loc, JUMP_NO_INTERRUPT, send);
@ -4159,7 +4159,7 @@ addop_yield(struct compiler *c, location loc) {
if (c->u->u_ste->ste_generator && c->u->u_ste->ste_coroutine) {
ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_ASYNC_GEN_WRAP);
}
ADDOP(c, loc, YIELD_VALUE);
ADDOP_I(c, loc, YIELD_VALUE, 0);
ADDOP_I(c, loc, RESUME, RESUME_AFTER_YIELD);
return SUCCESS;
}