Skip to content

Commit 7ff1857

Browse files
committed
JIT: Avoid memory load for symbols within 4GB on AArch64
1 parent ba587ed commit 7ff1857

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Python/jit.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,15 @@ patch_aarch64_33rx(unsigned char *location, uint64_t value)
432432
loc32[1] = 0xF2A00000 | (get_bits(relaxed, 16, 16) << 5) | reg;
433433
return;
434434
}
435+
int64_t page_delta = (relaxed >> 12) - ((uintptr_t)location >> 12);
436+
if (page_delta >= -(1L << 20) &&
437+
page_delta < (1L << 20))
438+
{
439+
// adrp reg, AAA; ldr reg, [reg + BBB] -> adrp reg, AAA; add reg, reg, BBB
440+
patch_aarch64_21rx(location, relaxed);
441+
loc32[1] = 0x91000000 | get_bits(relaxed, 0, 12) << 10 | reg << 5 | reg;
442+
return;
443+
}
435444
relaxed = value - (uintptr_t)location;
436445
if ((relaxed & 0x3) == 0 &&
437446
(int64_t)relaxed >= -(1L << 19) &&

0 commit comments

Comments
 (0)