8000 GH-119726: Use LDR for AArch64 trampolines (GH-121001) · python/cpython@9662608 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9662608

Browse files
authored
GH-119726: Use LDR for AArch64 trampolines (GH-121001)
1 parent 1dc9a4f commit 9662608

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Improve the speed and memory use of C function calls from JIT code on AArch64.
2+
Patch by Diego Russo

Tools/jit/_stencils.py

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -204,33 +204,20 @@ def emit_aarch64_trampoline(self, hole: Hole, alignment: int) -> None:
204204
return
205205

206206
self.disassembly += [
207-
f"{base + 4 * 0:x}: d2800008 mov x8, #0x0",
208-
f"{base + 4 * 0:016x}: R_AARCH64_MOVW_UABS_G0_NC {hole.symbol}",
209-
f"{base + 4 * 1:x}: f2a00008 movk x8, #0x0, lsl #16",
210-
f"{base + 4 * 1:016x}: R_AARCH64_MOVW_UABS_G1_NC {hole.symbol}",
211-
f"{base + 4 * 2:x}: f2c00008 movk x8, #0x0, lsl #32",
212-
f"{base + 4 * 2:016x}: R_AARCH64_MOVW_UABS_G2_NC {hole.symbol}",
213-
f"{base + 4 * 3:x}: f2e00008 movk x8, #0x0, lsl #48",
214-
f"{base + 4 * 3:016x}: R_AARCH64_MOVW_UABS_G3 {hole.symbol}",
215-
f"{base + 4 * 4:x}: d61f0100 br x8",
207+
f"{base + 4 * 0:x}: 58000048 ldr x8, 8",
208+
f"{base + 4 * 1:x}: d61f0100 br x8",
209+
f"{base + 4 * 2:x}: 00000000",
210+
f"{base + 4 * 2:016x}: R_AARCH64_ABS64 {hole.symbol}",
211+
f"{base + 4 * 3:x}: 00000000",
216212
]
217213
for code in [
218-
0xD2800008.to_bytes(4, sys.byteorder),
219-
0xF2A00008.to_bytes(4, sys.byteorder),
220-
0xF2C00008.to_bytes(4, sys.byteorder),
221-
0xF2E00008.to_bytes(4, sys.byteorder),
214+
0x58000048.to_bytes(4, sys.byteorder),
222215
0xD61F0100.to_bytes(4, sys.byteorder),
216+
0x00000000.to_bytes(4, sys.byteorder),
217+
0x00000000.to_bytes(4, sys.byteorder),
223218
]:
224219
self.body.extend(code)
225-
for i, kind in enumerate(
226-
[
227-
"R_AARCH64_MOVW_UABS_G0_NC",
228-
"R_AARCH64_MOVW_UABS_G1_NC",
229-
"R_AARCH64_MOVW_UABS_G2_NC",
230-
"R_AARCH64_MOVW_UABS_G3",
231-
]
232-
):
233-
self.holes.append(hole.replace(offset=base + 4 * i, kind=kind))
220+
self.holes.append(hole.replace(offset=base + 8, kind="R_AARCH64_ABS64"))
234221
self.trampolines[hole.symbol] = base
235222

236223
def remove_jump(self, *, alignment: int = 1) -> None:

0 commit comments

Comments
 (0)
0