GH-128375: Better instrument for FOR_ITER (GH-128445)

This commit is contained in:
Mark Shannon 2025-01-06 17:54:47 +00:00 committed by GitHub
parent b9c693dcca
commit f826beca0c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 827 additions and 544 deletions

View file

@ -409,7 +409,7 @@ codegen_addop_j(instr_sequence *seq, location loc,
if (_PyInstructionSequence_Addop(seq, opcode, target.id, loc) != SUCCESS) {
return ERROR;
}
if (IS_CONDITIONAL_JUMP_OPCODE(opcode) || opcode == FOR_ITER) {
if (IS_CONDITIONAL_JUMP_OPCODE(opcode)) {
return _PyInstructionSequence_Addop(seq, NOT_TAKEN, 0, NO_LOCATION);
}
return SUCCESS;
@ -2018,7 +2018,7 @@ codegen_for(compiler *c, stmt_ty s)
* but a non-generator will jump to a later instruction.
*/
ADDOP(c, NO_LOCATION, END_FOR);
ADDOP(c, NO_LOCATION, POP_TOP);
ADDOP(c, NO_LOCATION, POP_ITER);
_PyCompile_PopFBlock(c, COMPILE_FBLOCK_FOR_LOOP, start);
@ -4283,7 +4283,7 @@ codegen_sync_comprehension_generator(compiler *c, location loc,
* but a non-generator will jump to a later instruction.
*/
ADDOP(c, NO_LOCATION, END_FOR);
ADDOP(c, NO_LOCATION, POP_TOP);
ADDOP(c, NO_LOCATION, POP_ITER);
}
return SUCCESS;