mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
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.
This commit is contained in:
parent
6fadd68da5
commit
981d172f7f
16 changed files with 238 additions and 184 deletions
|
@ -3075,7 +3075,12 @@ compiler_for(struct compiler *c, stmt_ty s)
|
|||
ADDOP_JUMP(c, NO_LOCATION, JUMP, start);
|
||||
|
||||
USE_LABEL(c, cleanup);
|
||||
/* It is important for instrumentation that the `END_FOR` comes first.
|
||||
* Iteration over a generator will jump to the first of these instructions,
|
||||
* but a non-generator will jump to a later instruction.
|
||||
*/
|
||||
ADDOP(c, NO_LOCATION, END_FOR);
|
||||
ADDOP(c, NO_LOCATION, POP_TOP);
|
||||
|
||||
compiler_pop_fblock(c, FOR_LOOP, start);
|
||||
|
||||
|
@ -5390,7 +5395,12 @@ compiler_sync_comprehension_generator(struct compiler *c, location loc,
|
|||
ADDOP_JUMP(c, elt_loc, JUMP, start);
|
||||
|
||||
USE_LABEL(c, anchor);
|
||||
/* It is important for instrumentation that the `END_FOR` comes first.
|
||||
* Iteration over a generator will jump to the first of these instructions,
|
||||
* but a non-generator will jump to a later instruction.
|
||||
*/
|
||||
ADDOP(c, NO_LOCATION, END_FOR);
|
||||
ADDOP(c, NO_LOCATION, POP_TOP);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue