https://github.com/python/cpython/commit/c7dcb2652083a702a023881bc328ecaa5f1f2ac5
commit: c7dcb2652083a702a023881bc328ecaa5f1f2ac5
branch: main
author: Mark Shannon <[email protected]>
committer: markshannon <[email protected]>
date: 2025-12-17T12:07:07Z
summary:
GH-142621: JIT: Avoid memory load for symbols within 4GB on AArch64 (GH-142820)
files:
M Python/jit.c
diff --git a/Python/jit.c b/Python/jit.c
index 602d7a519bd3fc..ccafe0ce497f43 100644
--- a/Python/jit.c
+++ b/Python/jit.c
@@ -432,6 +432,15 @@ patch_aarch64_33rx(unsigned char *location, uint64_t value)
loc32[1] = 0xF2A00000 | (get_bits(relaxed, 16, 16) << 5) | reg;
return;
}
+ int64_t page_delta = (relaxed >> 12) - ((uintptr_t)location >> 12);
+ if (page_delta >= -(1L << 20) &&
+ page_delta < (1L << 20))
+ {
+ // adrp reg, AAA; ldr reg, [reg + BBB] -> adrp reg, AAA; add reg, reg,
BBB
+ patch_aarch64_21rx(location, relaxed);
+ loc32[1] = 0x91000000 | get_bits(relaxed, 0, 12) << 10 | reg << 5 |
reg;
+ return;
+ }
relaxed = value - (uintptr_t)location;
if ((relaxed & 0x3) == 0 &&
(int64_t)relaxed >= -(1L << 19) &&
_______________________________________________
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]