summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorDiego Russo <diego.russo@arm.com>2024-07-03 13:22:21 (GMT)
committerGitHub <noreply@github.com>2024-07-03 13:22:21 (GMT)
commit84512c0e7f4441f060026f4fd9ddb7611fc10de4 (patch)
tree39b61e181af4ec1ccfa3d66caf4ae31ee723137f /Tools
parent26d24eeb90d781e381b97d64b4dcb1ee4dd891fe (diff)
downloadcpython-84512c0e7f4441f060026f4fd9ddb7611fc10de4.zip
cpython-84512c0e7f4441f060026f4fd9ddb7611fc10de4.tar.gz
cpython-84512c0e7f4441f060026f4fd9ddb7611fc10de4.tar.bz2
GH-119726: Emit AArch64 trampolines out-of-line (GH-121280)
Diffstat (limited to 'Tools')
-rw-r--r--Tools/jit/_stencils.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/Tools/jit/_stencils.py b/Tools/jit/_stencils.py
index 68eb1d1..1c6a9ed 100644
--- a/Tools/jit/_stencils.py
+++ b/Tools/jit/_stencils.py
@@ -184,7 +184,7 @@ class Stencil:
self.disassembly.append(f"{offset:x}: {' '.join(['00'] * padding)}")
self.body.extend([0] * padding)
- def emit_aarch64_trampoline(self, hole: Hole, alignment: int) -> None:
+ def emit_aarch64_trampoline(self, hole: Hole, alignment: int) -> Hole:
"""Even with the large code model, AArch64 Linux insists on 28-bit jumps."""
assert hole.symbol is not None
reuse_trampoline = hole.symbol in self.trampolines
@@ -194,14 +194,10 @@ class Stencil:
else:
self.pad(alignment)
base = len(self.body)
- where = slice(hole.offset, hole.offset + 4)
- instruction = int.from_bytes(self.body[where], sys.byteorder)
- instruction &= 0xFC000000
- instruction |= ((base - hole.offset) >> 2) & 0x03FFFFFF
- self.body[where] = instruction.to_bytes(4, sys.byteorder)
+ new_hole = hole.replace(addend=base, symbol=None, value=HoleValue.DATA)
if reuse_trampoline:
- return
+ return new_hole
self.disassembly += [
f"{base + 4 * 0:x}: 58000048 ldr x8, 8",
@@ -219,6 +215,7 @@ class Stencil:
self.body.extend(code)
self.holes.append(hole.replace(offset=base + 8, kind="R_AARCH64_ABS64"))
self.trampolines[hole.symbol] = base
+ return new_hole
def remove_jump(self, *, alignment: int = 1) -> None:
"""Remove a zero-length continuation jump, if it exists."""
@@ -294,8 +291,9 @@ class StencilGroup:
in {"R_AARCH64_CALL26", "R_AARCH64_JUMP26", "ARM64_RELOC_BRANCH26"}
and hole.value is HoleValue.ZERO
):
- self.code.emit_aarch64_trampoline(hole, alignment)
+ new_hole = self.data.emit_aarch64_trampoline(hole, alignment)
self.code.holes.remove(hole)
+ self.code.holes.append(new_hole)
self.code.remove_jump(alignment=alignment)
self.code.pad(alignment)
self.data.pad(8)