From: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Date: Sat, 25 Oct 2025 22:49:49 +0000 (+0100) Subject: up the trace length X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e132f01e32504316a449e7b6181514c925748fe;p=thirdparty%2FPython%2Fcpython.git up the trace length --- diff --git a/Include/internal/pycore_uop.h b/Include/internal/pycore_uop.h index bccc0b00a4d2..4e1b15af42ca 100644 --- a/Include/internal/pycore_uop.h +++ b/Include/internal/pycore_uop.h @@ -36,7 +36,7 @@ typedef struct _PyUOpInstruction{ } _PyUOpInstruction; // This is the length of the trace we translate initially. -#define UOP_MAX_TRACE_LENGTH 1500 +#define UOP_MAX_TRACE_LENGTH 3000 #define UOP_BUFFER_SIZE (UOP_MAX_TRACE_LENGTH * sizeof(_PyUOpInstruction)) /* Bloom filter with m = 256 diff --git a/Python/optimizer.c b/Python/optimizer.c index 38fccafeda49..d39156a41afd 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -544,9 +544,6 @@ add_to_trace( goto full; \ } -// Reserve space for N uops, plus 3 for _SET_IP, _CHECK_VALIDITY and _EXIT_TRACE -#define RESERVE(needed) RESERVE_RAW((needed) + 3, _PyUOpName(opcode)) - /* Returns 1 on success (added to trace), 0 on trace end. */ @@ -688,19 +685,13 @@ _PyJit_translate_single_bytecode_to_trace( } // One for possible _DEOPT, one because _CHECK_VALIDITY itself might _DEOPT - max_length -= 2; + max_length -= 1; const struct opcode_macro_expansion *expansion = &_PyOpcode_macro_expansion[opcode]; - ADD_TO_TRACE(_CHECK_VALIDITY, 0, 0, target); - assert(opcode != ENTER_EXECUTOR && opcode != EXTENDED_ARG); assert(!_PyErr_Occurred(tstate)); - if (!OPCODE_HAS_NO_SAVE_IP(opcode)) { - ADD_TO_TRACE(_SET_IP, 0, (uintptr_t)target_instr, target); - } - /* Special case the first instruction, * so that we can guarantee forward progress */ if (progress_needed && tstate->interp->jit_state.code_curr_size <= 2) { @@ -720,7 +711,13 @@ _PyJit_translate_single_bytecode_to_trace( max_length--; } - RESERVE_RAW(expansion->nuops + needs_guard_ip + 4, "uop and various checks"); + RESERVE_RAW(expansion->nuops + needs_guard_ip + 3 + (!OPCODE_HAS_NO_SAVE_IP(opcode)), "uop and various checks"); + + ADD_TO_TRACE(_CHECK_VALIDITY, 0, 0, target); + + if (!OPCODE_HAS_NO_SAVE_IP(opcode)) { + ADD_TO_TRACE(_SET_IP, 0, (uintptr_t)target_instr, target); + } switch (opcode) { @@ -780,7 +777,6 @@ _PyJit_translate_single_bytecode_to_trace( goto unsupported; } assert(nuops > 0); - RESERVE(nuops + 1); /* One extra for exit */ uint32_t orig_oparg = oparg; // For OPARG_TOP/BOTTOM uint32_t orig_target = target; for (int i = 0; i < nuops; i++) {