]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix _CHECK_PERIODIC insertion
authorKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Sun, 19 Oct 2025 14:51:26 +0000 (15:51 +0100)
committerKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Sun, 19 Oct 2025 14:51:26 +0000 (15:51 +0100)
Python/bytecodes.c
Python/generated_cases.c.h
Python/generated_tracer_cases.c.h
Python/optimizer.c

index 38ac989e6652fb42a3d6d1d79f9e02fd2ebeabdf..e75f1d05a4849a09a3897141515114ac41db3ca5 100644 (file)
@@ -2981,8 +2981,10 @@ dummy_func(
                     _PyJIT_InitializeTracing(tstate, frame, this_instr, STACK_LEVEL(), 0, NULL);
                     ENTER_TRACING();
                 }
-                // Don't add the JUMP_BACKWARD_JIT instruction to the trace.
-                DISPATCH();
+                int _jump_taken = false;
+                PyCodeObject *old_code = _PyFrame_GetCode(frame);
+                PyFunctionObject *old_func = (PyFunctionObject *)PyStackRef_AsPyObjectBorrow(frame->f_funcobj);
+                TRACING_DISPATCH();
             }
             else {
                 ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
index 5080df123dc00a9d40d0346b12b9c67a653a6f38..7b7d10e526505dcd0b6dcbae341c34319fe90ed3 100644 (file)
                         _PyJIT_InitializeTracing(tstate, frame, this_instr, STACK_LEVEL(), 0, NULL);
                         ENTER_TRACING();
                     }
-                    DISPATCH();
+                    int _jump_taken = false;
+                    PyCodeObject *old_code = _PyFrame_GetCode(frame);
+                    PyFunctionObject *old_func = (PyFunctionObject *)PyStackRef_AsPyObjectBorrow(frame->f_funcobj);
+                    TRACING_DISPATCH();
                 }
                 else {
                     ADVANCE_ADAPTIVE_COUNTER(this_instr[1].counter);
index 67c240669b9dd8432c549962fd8c24c5dea24f3f..3feeb0d05362fd8898303bb3f2058edb4b057b90 100644 (file)
                         _PyJIT_InitializeTracing(tstate, frame, this_instr, STACK_LEVEL(), 0, NULL);
                         ENTER_TRACING();
                     }
+                    int _jump_taken = false;
+                    PyCodeObject *old_code = _PyFrame_GetCode(frame);
+                    PyFunctionObject *old_func = (PyFunctionObject *)PyStackRef_AsPyObjectBorrow(frame->f_funcobj);
                     TRACING_DISPATCH();
                 }
                 else {
index a6d9c7904ee6380eb90390a4f31897c2946ae8a9..18b7d1d5aa29ff28b1d1243cd98cbff342a62af9 100644 (file)
@@ -673,7 +673,6 @@ _PyJIT_translate_single_bytecode_to_trace(
 
     // Loop back to the start
     if (is_first_instr && tstate->interp->jit_state.jit_tracer_code_curr_size > 2) {
-        ADD_TO_TRACE(_CHECK_PERIODIC, 0, 0, target);
         ADD_TO_TRACE(_JUMP_TO_TOP, 0, 0, 0);
         goto done;
     }
@@ -705,19 +704,7 @@ _PyJIT_translate_single_bytecode_to_trace(
             break;
         }
         case JUMP_BACKWARD_JIT:
-            // This is possible as the JIT might have re-activated after it was disabled.                // if (next_uop->opcode != _START_EXECUTOR) {
-            //     if (next_uop->format == UOP_FORMAT_TARGET) {
-            //         _Py_CODEUNIT *aim = _PyFrame_GetBytecode(frame) + next_uop->target;
-            //         printf("    aim=[%s]\n", _PyOpcode_OpName[aim->op.code]);
-            //     }
-            //     else if (next_uop->format == UOP_FORMAT_JUMP) {
-            //         _PyUOpInstruction *aim_uop =  current_executor->trace + next_uop->jump_target;
-            //         if (aim_uop->format == UOP_FORMAT_TARGET) {
-            //             _Py_CODEUNIT *aim = _PyFrame_GetBytecode(frame) + aim_uop->target;
-            //             printf("    aim=[%s]\n", _PyOpcode_OpName[aim->op.code]);
-            //         }
-            //     }
-            // }
+            // This is possible as the JIT might have re-activated after it was disabled
         case JUMP_BACKWARD_NO_JIT:
         case JUMP_BACKWARD:
             ADD_TO_TRACE(_CHECK_PERIODIC, 0, 0, target);