summaryrefslogtreecommitdiffstats
path: root/Python/jit.c
diff options
context:
space:
mode:
authorDiego Russo <diego.russo@arm.com>2025-03-19 19:19:21 (GMT)
committerGitHub <noreply@github.com>2025-03-19 19:19:21 (GMT)
commit8a33034d82314e2a5a8f39f9348e93135f94807d (patch)
treedb738d9601ed907591e9de5f789623bc6d29a02f /Python/jit.c
parent63a638c43f821e9c8b3256e7122c06e539dc585d (diff)
downloadcpython-8a33034d82314e2a5a8f39f9348e93135f94807d.zip
cpython-8a33034d82314e2a5a8f39f9348e93135f94807d.tar.gz
cpython-8a33034d82314e2a5a8f39f9348e93135f94807d.tar.bz2
GH-130956: Only emit AArch64 trampolines for long jumps (GH-131041)
Diffstat (limited to 'Python/jit.c')
-rw-r--r--Python/jit.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/Python/jit.c b/Python/jit.c
index 092b873..95b5a1b 100644
--- a/Python/jit.c
+++ b/Python/jit.c
@@ -430,6 +430,17 @@ void patch_aarch64_trampoline(unsigned char *location, int ordinal, jit_state *s
void
patch_aarch64_trampoline(unsigned char *location, int ordinal, jit_state *state)
{
+
+ uint64_t value = (uintptr_t)symbols_map[ordinal];
+ int64_t range = value - (uintptr_t)location;
+
+ // If we are in range of 28 signed bits, we patch the instruction with
+ // the address of the symbol.
+ if (range >= -(1 << 27) && range < (1 << 27)) {
+ patch_aarch64_26r(location, (uintptr_t)value);
+ return;
+ }
+
// Masking is done modulo 32 as the mask is stored as an array of uint32_t
const uint32_t symbol_mask = 1 << (ordinal % 32);
const uint32_t trampoline_mask = state->trampolines.mask[ordinal / 32];
@@ -445,7 +456,6 @@ patch_aarch64_trampoline(unsigned char *location, int ordinal, jit_state *state)
uint32_t *p = (uint32_t*)(state->trampolines.mem + index * TRAMPOLINE_SIZE);
assert((size_t)(index + 1) * TRAMPOLINE_SIZE <= state->trampolines.size);
- uint64_t value = (uintptr_t)symbols_map[ordinal];
/* Generate the trampoline
0: 58000048 ldr x8, 8