Ammar Askar <am...@ammaraskar.com> added the comment:
So I think this is a weird edge case with a set of opcode predictions (GET_ITER -> FOR_ITER -> POP_BLOCK) going outside of a line boundary. The disassembly of the reproducer above is: 4 0 SETUP_FINALLY 16 (to 18) 5 2 LOAD_CONST 1 (()) 4 GET_ITER >> 6 FOR_ITER 4 (to 12) 8 STORE_FAST 0 (i) 10 JUMP_ABSOLUTE 6 6 >> 12 POP_BLOCK 14 LOAD_CONST 2 (1) 16 RETURN_VALUE When computed gotos are disabled and there is a tracing function, instructions 0, 2, 4, 14 and 16 hit the `fast_next_opcode` label and have a chance to be traced as line hits. Note that `maybe_call_line_trace` will only cause a line hit if the instruction that starts a line (POP_BLOCK in this case) is being executed. When computed gotos are enabled, DISPATCH is a no-op and there is a special case for when tracing is enabled that causes every opcode to go through `fast_next_opcode`: https://github.com/python/cpython/blob/c3a651ad2544d7d1be389b63e9a4a58a92a31623/Python/ceval.c#L1054-L1059 When computed gotos are not enabled, there is no similar check for PREDICT (and might be too costly to add) causing this issue: https://github.com/python/cpython/blob/c3a651ad2544d7d1be389b63e9a4a58a92a31623/Python/ceval.c#L1131-L1141 ---------- title: Windows and Linux execute the same code differently -> ceval traces code differently based with USE_COMPUTED_GOTOS _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue41670> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com