https://github.com/python/cpython/commit/a47abdb45d4f1c3195c324812c33b6ef1d9147da
commit: a47abdb45d4f1c3195c324812c33b6ef1d9147da
branch: main
author: Brandt Bucher <[email protected]>
committer: brandtbucher <[email protected]>
date: 2024-06-24T08:35:10-07:00
summary:

GH-117062: Make _JUMP_TO_TOP a general absolute jump (GH-120854)

files:
M Python/bytecodes.c
M Python/executor_cases.c.h
M Python/optimizer.c
M Tools/jit/_stencils.py
M Tools/jit/template.c

diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index a6fb862a6d476e..c00de88fc70a6e 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -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 --)) {
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index cdfffcdec9726e..8de0309fa4dae0 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -4302,9 +4302,7 @@
         }
 
         case _JUMP_TO_TOP: {
-            #ifndef _Py_JIT
-            next_uop = &current_executor->trace[1];
-            #endif
+            JUMP_TO_JUMP_TARGET();
             break;
         }
 
diff --git a/Python/optimizer.c b/Python/optimizer.c
index c9b187d2e108dd..0d7118cd9e3363 100644
--- a/Python/optimizer.c
+++ b/Python/optimizer.c
@@ -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;
 }
diff --git a/Tools/jit/_stencils.py b/Tools/jit/_stencils.py
index c7c5ca1590d601..755649dea54570 100644
--- a/Tools/jit/_stencils.py
+++ b/Tools/jit/_stencils.py
@@ -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 @@ class HoleValue(enum.Enum):
     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: "",
 }
 
diff --git a/Tools/jit/template.c b/Tools/jit/template.c
index a81e866e9da4b3..813e586bd3c03d 100644
--- a/Tools/jit/template.c
+++ b/Tools/jit/template.c
@@ -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:

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to