diff options
author | Mark Shannon <mark@hotpy.org> | 2025-01-06 17:54:47 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-06 17:54:47 +0000 |
commit | f826beca0cedb8e4b92896544c75fd0d9dcb0446 (patch) | |
tree | 87630b6e28e141a0e687e04d2f66d8e4cde21b99 /Python/optimizer.c | |
parent | b9c693dcca01537eee1ef716ffebc632be37594b (diff) | |
download | cpython-f826beca0cedb8e4b92896544c75fd0d9dcb0446.tar.gz cpython-f826beca0cedb8e4b92896544c75fd0d9dcb0446.zip |
GH-128375: Better instrument for `FOR_ITER` (GH-128445)
Diffstat (limited to 'Python/optimizer.c')
-rw-r--r-- | Python/optimizer.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Python/optimizer.c b/Python/optimizer.c index 6a4d20fad76..52b3f0a84af 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -622,8 +622,14 @@ translate_bytecode_to_trace( goto done; } assert(opcode != ENTER_EXECUTOR && opcode != EXTENDED_ARG); - RESERVE_RAW(2, "_CHECK_VALIDITY_AND_SET_IP"); - ADD_TO_TRACE(_CHECK_VALIDITY_AND_SET_IP, 0, (uintptr_t)instr, target); + if (OPCODE_HAS_NO_SAVE_IP(opcode)) { + RESERVE_RAW(2, "_CHECK_VALIDITY"); + ADD_TO_TRACE(_CHECK_VALIDITY, 0, 0, target); + } + else { + RESERVE_RAW(2, "_CHECK_VALIDITY_AND_SET_IP"); + ADD_TO_TRACE(_CHECK_VALIDITY_AND_SET_IP, 0, (uintptr_t)instr, target); + } /* Special case the first instruction, * so that we can guarantee forward progress */ @@ -771,7 +777,7 @@ translate_bytecode_to_trace( uint32_t next_inst = target + 1 + INLINE_CACHE_ENTRIES_FOR_ITER + (oparg > 255); uint32_t jump_target = next_inst + oparg; assert(_Py_GetBaseCodeUnit(code, jump_target).op.code == END_FOR); - assert(_Py_GetBaseCodeUnit(code, jump_target+1).op.code == POP_TOP); + assert(_Py_GetBaseCodeUnit(code, jump_target+1).op.code == POP_ITER); } #endif break; |