]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix a bug with where the executors get inserted during EXTENDED_ARG
authorKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Mon, 20 Oct 2025 23:52:56 +0000 (00:52 +0100)
committerKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Mon, 20 Oct 2025 23:52:56 +0000 (00:52 +0100)
Include/internal/pycore_uop.h
Python/bytecodes.c
Python/generated_cases.c.h
Python/generated_tracer_cases.c.h

index 86bea31204ca83388d88d3be7fb81cce3337e0f7..bccc0b00a4d210ff301425719e02da2b252d2d6c 100644 (file)
@@ -36,7 +36,7 @@ typedef struct _PyUOpInstruction{
 } _PyUOpInstruction;
 
 // This is the length of the trace we translate initially.
-#define UOP_MAX_TRACE_LENGTH 1400
+#define UOP_MAX_TRACE_LENGTH 1500
 #define UOP_BUFFER_SIZE (UOP_MAX_TRACE_LENGTH * sizeof(_PyUOpInstruction))
 
 /* Bloom filter with m = 256
index 0ba8286fc467d745e7c4133a83943afc4ed0c95e..7df899dc50e8d940c7d64d5c944be7e0e318866d 100644 (file)
@@ -2979,7 +2979,13 @@ dummy_func(
                 }
                 int _is_sys_tracing = (tstate->c_tracefunc != NULL) || (tstate->c_profilefunc != NULL);
                 if (!_is_sys_tracing) {
-                    _PyJIT_InitializeTracing(tstate, frame, this_instr, next_instr, STACK_LEVEL(), 0, NULL);
+                    /* Back up over EXTENDED_ARGs so executor is inserted at the corret place */
+                    _Py_CODEUNIT *insert_exec_at = this_instr;
+                    while (oparg > 255) {
+                        oparg >>= 8;
+                        insert_exec_at--;
+                    }
+                    _PyJIT_InitializeTracing(tstate, frame, insert_exec_at, next_instr, STACK_LEVEL(), 0, NULL);
                     ENTER_TRACING();
                 }
                 int _jump_taken = false;
index 28691b2c5c836d6dc6805b703ceb75dde02b4c79..5cd7142adb3314b17ae3742b0ca6c25784d51bc4 100644 (file)
                     }
                     int _is_sys_tracing = (tstate->c_tracefunc != NULL) || (tstate->c_profilefunc != NULL);
                     if (!_is_sys_tracing) {
-                        _PyJIT_InitializeTracing(tstate, frame, this_instr, next_instr, STACK_LEVEL(), 0, NULL);
+                        _Py_CODEUNIT *insert_exec_at = this_instr;
+                        while (oparg > 255) {
+                            oparg >>= 8;
+                            insert_exec_at--;
+                        }
+                        _PyJIT_InitializeTracing(tstate, frame, insert_exec_at, next_instr, STACK_LEVEL(), 0, NULL);
                         ENTER_TRACING();
                     }
                     int _jump_taken = false;
index 9d739dc00db983b6ccc761936025e44ffaa3dd49..759bfd13cb83dc9e9ebaa80fadd713f6186a6556 100644 (file)
                     }
                     int _is_sys_tracing = (tstate->c_tracefunc != NULL) || (tstate->c_profilefunc != NULL);
                     if (!_is_sys_tracing) {
-                        _PyJIT_InitializeTracing(tstate, frame, this_instr, next_instr, STACK_LEVEL(), 0, NULL);
+                        _Py_CODEUNIT *insert_exec_at = this_instr;
+                        while (oparg > 255) {
+                            oparg >>= 8;
+                            insert_exec_at--;
+                        }
+                        _PyJIT_InitializeTracing(tstate, frame, insert_exec_at, next_instr, STACK_LEVEL(), 0, NULL);
                         ENTER_TRACING();
                     }
                     int _jump_taken = false;