]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
JIT: Rename trampoline.c to shim.c (#142974)
authorDiego Russo <diego.russo@arm.com>
Fri, 19 Dec 2025 14:39:41 +0000 (14:39 +0000)
committerGitHub <noreply@github.com>
Fri, 19 Dec 2025 14:39:41 +0000 (14:39 +0000)
Include/internal/pycore_ceval.h
Python/ceval.c
Python/jit.c
Python/pystate.c
Tools/jit/_targets.py
Tools/jit/_writer.py
Tools/jit/shim.c [moved from Tools/jit/trampoline.c with 100% similarity]

index af53f2e7d6f73eaf628803e988db7ed317d742e3..bf34c55cd783e474ed009a22b6ff07cb7a93dfcb 100644 (file)
@@ -123,7 +123,7 @@ _PyEval_EvalFrame(PyThreadState *tstate, _PyInterpreterFrame *frame, int throwfl
 
 #ifdef _Py_TIER2
 #ifdef _Py_JIT
-_Py_CODEUNIT *_Py_LazyJitTrampoline(
+_Py_CODEUNIT *_Py_LazyJitShim(
     struct _PyExecutorObject *current_executor, _PyInterpreterFrame *frame,
     _PyStackRef *stack_pointer, PyThreadState *tstate
 );
index 90ae0b022e39589faa005d873157c736aba0b8f8..cf86d5484f0d6ee34ecc572c18d4a999f15117d8 100644 (file)
@@ -1601,7 +1601,7 @@ early_exit:
 }
 #ifdef _Py_TIER2
 #ifdef _Py_JIT
-_PyJitEntryFuncPtr _Py_jit_entry = _Py_LazyJitTrampoline;
+_PyJitEntryFuncPtr _Py_jit_entry = _Py_LazyJitShim;
 #else
 _PyJitEntryFuncPtr _Py_jit_entry = _PyTier2Interpreter;
 #endif
@@ -1617,7 +1617,7 @@ _PyTier2Interpreter(
     const _PyUOpInstruction *next_uop;
     int oparg;
     /* Set up "jit" state after entry from tier 1.
-     * This mimics what the jit trampoline function does. */
+     * This mimics what the jit shim function does. */
     tstate->jit_exit = NULL;
     _PyStackRef _tos_cache0 = PyStackRef_ZERO_BITS;
     _PyStackRef _tos_cache1 = PyStackRef_ZERO_BITS;
index 7660f6f9beac890642994fbd7b81dde29b42b564..4ce90edf73a8cb8aacaa9afabc9405fb1d131ce8 100644 (file)
@@ -672,20 +672,20 @@ _PyJIT_Compile(_PyExecutorObject *executor, const _PyUOpInstruction trace[], siz
     return 0;
 }
 
-/* One-off compilation of the jit entry trampoline
+/* One-off compilation of the jit entry shim
  * We compile this once only as it effectively a normal
  * function, but we need to use the JIT because it needs
  * to understand the jit-specific calling convention.
  */
 static _PyJitEntryFuncPtr
-compile_trampoline(void)
+compile_shim(void)
 {
     _PyExecutorObject dummy;
     const StencilGroup *group;
     size_t code_size = 0;
     size_t data_size = 0;
     jit_state state = {0};
-    group = &trampoline;
+    group = &shim;
     code_size += group->code_size;
     data_size += group->data_size;
     combine_symbol_mask(group->trampoline_mask, state.trampolines.mask);
@@ -707,7 +707,7 @@ compile_trampoline(void)
     // Compile the shim, which handles converting between the native
     // calling convention and the calling convention used by jitted code
     // (which may be different for efficiency reasons).
-    group = &trampoline;
+    group = &shim;
     group->emit(code, data, &dummy, NULL, &state);
     code += group->code_size;
     data += group->data_size;
@@ -723,17 +723,17 @@ compile_trampoline(void)
 static PyMutex lazy_jit_mutex = { 0 };
 
 _Py_CODEUNIT *
-_Py_LazyJitTrampoline(
+_Py_LazyJitShim(
     _PyExecutorObject *executor, _PyInterpreterFrame *frame, _PyStackRef *stack_pointer, PyThreadState *tstate
 ) {
     PyMutex_Lock(&lazy_jit_mutex);
-    if (_Py_jit_entry == _Py_LazyJitTrampoline) {
-        _PyJitEntryFuncPtr trampoline = compile_trampoline();
-        if (trampoline == NULL) {
+    if (_Py_jit_entry == _Py_LazyJitShim) {
+        _PyJitEntryFuncPtr shim = compile_shim();
+        if (shim == NULL) {
             PyMutex_Unlock(&lazy_jit_mutex);
             Py_FatalError("Cannot allocate core JIT code");
         }
-        _Py_jit_entry = trampoline;
+        _Py_jit_entry = shim;
     }
     PyMutex_Unlock(&lazy_jit_mutex);
     return _Py_jit_entry(executor, frame, stack_pointer, tstate);
index 7ea8ef91f107a9bfda468057ff3a604bf8c3b141..cf55297cf8d94e8d28014ac99da608415d60aacd 100644 (file)
@@ -490,7 +490,7 @@ static inline int check_interpreter_whence(long);
 #endif
 
 extern _Py_CODEUNIT *
-_Py_LazyJitTrampoline(
+_Py_LazyJitShim(
     struct _PyExecutorObject *exec, _PyInterpreterFrame *frame, _PyStackRef *stack_pointer, PyThreadState *tstate
 );
 
index 5895e91c3c44ce77faf4165b7c27e1da97704017..39be353ec30858a3d074f793f18147a4a8639131 100644 (file)
@@ -204,8 +204,8 @@ class _Target(typing.Generic[_S, _R]):
         with tempfile.TemporaryDirectory() as tempdir:
             work = pathlib.Path(tempdir).resolve()
             async with asyncio.TaskGroup() as group:
-                coro = self._compile("trampoline", TOOLS_JIT / "trampoline.c", work)
-                tasks.append(group.create_task(coro, name="trampoline"))
+                coro = self._compile("shim", TOOLS_JIT / "shim.c", work)
+                tasks.append(group.create_task(coro, name="shim"))
                 template = TOOLS_JIT_TEMPLATE_C.read_text()
                 for case, opname in cases_and_opnames:
                     # Write out a copy of the template with *only* this case
index 3a59ffce7a2c45d283a1ef465972c4e99896d210..5fd9a2ee2d6e5825e63afa559355d798019b7894 100644 (file)
@@ -23,11 +23,11 @@ def _dump_footer(
     yield "    symbol_mask got_mask;"
     yield "} StencilGroup;"
     yield ""
-    yield f"static const StencilGroup trampoline = {groups['trampoline'].as_c('trampoline')};"
+    yield f"static const StencilGroup shim = {groups['shim'].as_c('shim')};"
     yield ""
     yield "static const StencilGroup stencil_groups[MAX_UOP_REGS_ID + 1] = {"
     for opname, group in sorted(groups.items()):
-        if opname == "trampoline":
+        if opname == "shim":
             continue
         yield f"    [{opname}] = {group.as_c(opname)},"
     yield "};"
similarity index 100%
rename from Tools/jit/trampoline.c
rename to Tools/jit/shim.c