From: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Date: Thu, 30 Oct 2025 18:26:37 +0000 (+0000) Subject: Remove dynamic exit for _FOR_ITER_TIER_TWO X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af9ea5750f859442ef4d39e14017f39c31d98c5f;p=thirdparty%2FPython%2Fcpython.git Remove dynamic exit for _FOR_ITER_TIER_TWO --- diff --git a/Include/internal/pycore_uop_metadata.h b/Include/internal/pycore_uop_metadata.h index c7fbfb0fafa2..148b3d9c1fc9 100644 --- a/Include/internal/pycore_uop_metadata.h +++ b/Include/internal/pycore_uop_metadata.h @@ -213,7 +213,7 @@ const uint16_t _PyUop_Flags[MAX_UOP_ID+1] = { [_MATCH_KEYS] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, [_GET_ITER] = HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, [_GET_YIELD_FROM_ITER] = HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, - [_FOR_ITER_TIER_TWO] = HAS_ARG_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, + [_FOR_ITER_TIER_TWO] = HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, [_ITER_CHECK_LIST] = HAS_EXIT_FLAG, [_GUARD_NOT_EXHAUSTED_LIST] = HAS_EXIT_FLAG, [_ITER_NEXT_LIST_TIER_TWO] = HAS_DEOPT_FLAG | HAS_ESCAPES_FLAG, diff --git a/Python/bytecodes.c b/Python/bytecodes.c index ba3b1df3d1ca..d62a7515963f 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -3251,8 +3251,7 @@ dummy_func( ERROR_NO_POP(); } /* iterator ended normally */ - /* This just sets the IP to what it expects (see normal _FOR_ITER) */ - frame->instr_ptr += (oparg + 2 + INLINE_CACHE_ENTRIES_FOR_ITER); + /* The translator sets the deopt target just past the matching END_FOR */ EXIT_IF(true); } next = item; diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 1534dd6995f6..88ef5a8656e0 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -4385,7 +4385,6 @@ _PyStackRef null_or_index; _PyStackRef iter; _PyStackRef next; - oparg = CURRENT_OPARG(); null_or_index = stack_pointer[-1]; iter = stack_pointer[-2]; _PyFrame_SetStackPointer(frame, stack_pointer); @@ -4395,7 +4394,6 @@ if (PyStackRef_IsError(item)) { JUMP_TO_ERROR(); } - frame->instr_ptr += (oparg + 2 + INLINE_CACHE_ENTRIES_FOR_ITER); if (true) { UOP_STAT_INC(uopcode, miss); JUMP_TO_JUMP_TARGET(); diff --git a/Python/optimizer.c b/Python/optimizer.c index d11108dcddfb..97b891ac97f3 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -1075,10 +1075,7 @@ prepare_for_execution(_PyUOpInstruction *buffer, int length) } int32_t jump_target = target; bool unique_target = false; - if (opcode == _FOR_ITER_TIER_TWO) { - exit_op = _DYNAMIC_EXIT; - } - else if ( + if ( opcode == _GUARD_IP__PUSH_FRAME || opcode == _GUARD_IP_RETURN_VALUE || opcode == _GUARD_IP_YIELD_VALUE ||