From: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Date: Thu, 6 Nov 2025 20:45:17 +0000 (+0000) Subject: move code to correcdt places X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7b3c2309b74b7f86bae225ae993b0393182baa2;p=thirdparty%2FPython%2Fcpython.git move code to correcdt places --- diff --git a/Python/optimizer.c b/Python/optimizer.c index b31b4ddfefe2..601f249e9c4c 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -605,6 +605,24 @@ _PyJit_translate_single_bytecode_to_trace( int old_stack_level = tstate->interp->jit_state.prev_instr_stacklevel; + // Strange control-flow + bool has_dynamic_jump_taken = OPCODE_HAS_UNPREDICTABLE_JUMP(opcode) && + (next_instr != this_instr + 1 + _PyOpcode_Caches[_PyOpcode_Deopt[opcode]]); + if (has_dynamic_jump_taken) { + DPRINTF(2, "Unsupported: dynamic jump taken\n"); + goto unsupported; + } + + /* Special case the first instruction, + * so that we can guarantee forward progress */ + if (progress_needed && tstate->interp->jit_state.code_curr_size <= 3) { + if (OPCODE_HAS_EXIT(opcode) || OPCODE_HAS_DEOPT(opcode)) { + opcode = _PyOpcode_Deopt[opcode]; + } + assert(!OPCODE_HAS_EXIT(opcode)); + assert(!OPCODE_HAS_DEOPT(opcode)); + } + bool needs_guard_ip = _PyOpcode_NeedsGuardIp[opcode]; DPRINTF(2, "%p %d: %s(%d) %d %d\n", old_code, target, _PyOpcode_OpName[opcode], oparg, needs_guard_ip, old_stack_level); @@ -628,24 +646,6 @@ _PyJit_translate_single_bytecode_to_trace( goto done; } - // Strange control-flow - bool has_dynamic_jump_taken = OPCODE_HAS_UNPREDICTABLE_JUMP(opcode) && - (next_instr != this_instr + 1 + _PyOpcode_Caches[_PyOpcode_Deopt[opcode]]); - if (has_dynamic_jump_taken) { - DPRINTF(2, "Unsupported: dynamic jump taken\n"); - goto unsupported; - } - - /* Special case the first instruction, - * so that we can guarantee forward progress */ - if (progress_needed && tstate->interp->jit_state.code_curr_size <= 2) { - if (OPCODE_HAS_EXIT(opcode) || OPCODE_HAS_DEOPT(opcode)) { - opcode = _PyOpcode_Deopt[opcode]; - } - assert(!OPCODE_HAS_EXIT(opcode)); - assert(!OPCODE_HAS_DEOPT(opcode)); - } - // This happens when a recursive call happens that we can't trace. Such as Python -> C -> Python calls // If we haven't guarded the IP, then it's untraceable. if (frame != tstate->interp->jit_state.prev_instr_frame && !needs_guard_ip) {