]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-117062: Make _JUMP_TO_TOP a general absolute jump (GH-120854)
authorBrandt Bucher <brandtbucher@microsoft.com>
Mon, 24 Jun 2024 15:35:10 +0000 (08:35 -0700)
committerGitHub <noreply@github.com>
Mon, 24 Jun 2024 15:35:10 +0000 (08:35 -0700)
Python/bytecodes.c
Python/executor_cases.c.h
Python/optimizer.c
Tools/jit/_stencils.py
Tools/jit/template.c

index a6fb862a6d476e99cd0db66f0204008d174e4071..c00de88fc70a6ee9b513814737f58058b1dc1661 100644 (file)
@@ -4149,9 +4149,7 @@ dummy_func(
         }
 
         op(_JUMP_TO_TOP, (--)) {
-#ifndef _Py_JIT
-            next_uop = &current_executor->trace[1];
-#endif
+            JUMP_TO_JUMP_TARGET();
         }
 
         tier2 op(_SET_IP, (instr_ptr/4 --)) {
index cdfffcdec9726ec9ecd74225bf14909202c16145..8de0309fa4dae03952f83228893236781ce78472 100644 (file)
         }
 
         case _JUMP_TO_TOP: {
-            #ifndef _Py_JIT
-            next_uop = &current_executor->trace[1];
-            #endif
+            JUMP_TO_JUMP_TARGET();
             break;
         }
 
index c9b187d2e108dd5c222452ddc73e095fc47c6fc7..0d7118cd9e336340009048dc116b308dd065e63e 100644 (file)
@@ -1059,6 +1059,11 @@ prepare_for_execution(_PyUOpInstruction *buffer, int length)
                 buffer[i].jump_target = 0;
             }
         }
+        if (opcode == _JUMP_TO_TOP) {
+            assert(buffer[0].opcode == _START_EXECUTOR);
+            buffer[i].format = UOP_FORMAT_JUMP;
+            buffer[i].jump_target = 1;
+        }
     }
     return next_spare;
 }
index c7c5ca1590d601965efc752af017ba1afebc0f92..755649dea54570cd0cee0a232eddf4da5324928f 100644 (file)
@@ -42,8 +42,6 @@ class HoleValue(enum.Enum):
     ERROR_TARGET = enum.auto()
     # The index of the exit to be jumped through (exposed as _JIT_EXIT_INDEX):
     EXIT_INDEX = enum.auto()
-    # The base address of the machine code for the first uop (exposed as _JIT_TOP):
-    TOP = enum.auto()
     # A hardcoded value of zero (used for symbol lookups):
     ZERO = enum.auto()
 
@@ -110,7 +108,6 @@ _HOLE_EXPRS = {
     HoleValue.JUMP_TARGET: "instruction_starts[instruction->jump_target]",
     HoleValue.ERROR_TARGET: "instruction_starts[instruction->error_target]",
     HoleValue.EXIT_INDEX: "instruction->exit_index",
-    HoleValue.TOP: "instruction_starts[1]",
     HoleValue.ZERO: "",
 }
 
index a81e866e9da4b3e8876271025bf7f0598a428a86..813e586bd3c03d05e00bf31600f3cfd5b8cbea88 100644 (file)
@@ -105,9 +105,6 @@ _JIT_ENTRY(_PyInterpreterFrame *frame, PyObject **stack_pointer, PyThreadState *
     UOP_STAT_INC(uopcode, execution_count);
 
     // The actual instruction definitions (only one will be used):
-    if (uopcode == _JUMP_TO_TOP) {
-        PATCH_JUMP(_JIT_TOP);
-    }
     switch (uopcode) {
 #include "executor_cases.c.h"
         default: