]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix ENTER_EXECUTOR bug
authorKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Sun, 21 Sep 2025 10:23:50 +0000 (11:23 +0100)
committerKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Sun, 21 Sep 2025 10:23:50 +0000 (11:23 +0100)
Python/bytecodes.c
Python/ceval_macros.h
Python/generated_cases.c.h

index a377bb5a385f2b2c60a206bfd21a8cbc69a65907..98ff74b0d6afb1dfc41a792e4200ace8c70df322 100644 (file)
@@ -3045,8 +3045,13 @@ dummy_func(
             assert(executor != tstate->interp->cold_executor);
             tstate->jit_exit = NULL;
             if (IS_JIT_TRACING()) {
-                RECORD_TRACE();
-                BAIL_TRACING_NO_DISPATCH();
+                int old_opcode = executor->vm_data.opcode;
+                int old_oparg = (oparg & ~255) | executor->vm_data.oparg;
+                RECORD_TRACE_NO_DISPATCH();
+                opcode = old_opcode;
+                oparg = old_oparg;
+                next_instr = this_instr;
+                DISPATCH_GOTO();
             }
             TIER1_TO_TIER2(executor, 1);
             #else
index 47da165924536fe355b016aaf91a9fee00bd130d..a13c9427804485bdd578cab4e889b60fcdde8a5d 100644 (file)
 #  define BAIL_TRACING_NO_DISPATCH() \
     LEAVE_TRACING(); \
     int err = _PyOptimizer_Optimize(frame, tstate); \
-    tstate->interp->jit_tracer_code_curr_size = 0; \
     if (err < 0) { \
         JUMP_TO_LABEL(error); \
     }
             BAIL_TRACING(); \
         } \
     } while (0);
+#  define RECORD_TRACE_NO_DISPATCH() do { \
+        frame->instr_ptr = next_instr; \
+        if (add_to_code_trace(tstate, frame, old_code, this_instr, next_instr, opcode, oparg, _jump_taken)) { \
+            BAIL_TRACING_NO_DISPATCH(); \
+        } \
+    } while (0);
 #endif
 
 
index 4183e23cdf1802b743684b5c0293c9f8f85ea0c0..9551acb4d64bb918afdb2f8fc1724e08d954a7ae 100644 (file)
             assert(executor != tstate->interp->cold_executor);
             tstate->jit_exit = NULL;
             if (IS_JIT_TRACING()) {
-                RECORD_TRACE();
-                BAIL_TRACING_NO_DISPATCH();
+                int old_opcode = executor->vm_data.opcode;
+                int old_oparg = (oparg & ~255) | executor->vm_data.oparg;
+                RECORD_TRACE_NO_DISPATCH();
+                opcode = old_opcode;
+                oparg = old_oparg;
+                next_instr = this_instr;
+                DISPATCH_GOTO();
             }
             TIER1_TO_TIER2(executor, 1);
             #else
             assert(executor != tstate->interp->cold_executor);
             tstate->jit_exit = NULL;
             if (IS_JIT_TRACING()) {
-                RECORD_TRACE();
-                BAIL_TRACING_NO_DISPATCH();
+                int old_opcode = executor->vm_data.opcode;
+                int old_oparg = (oparg & ~255) | executor->vm_data.oparg;
+                RECORD_TRACE_NO_DISPATCH();
+                opcode = old_opcode;
+                oparg = old_oparg;
+                next_instr = this_instr;
+                DISPATCH_GOTO();
             }
             TIER1_TO_TIER2(executor, 1);
             #else