summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorBrandt Bucher <brandtbucher@microsoft.com>2024-03-19 15:47:28 (GMT)
committerGitHub <noreply@github.com>2024-03-19 15:47:28 (GMT)
commit2c82592ab463f1f38237919a12145f34eaadda23 (patch)
tree34d68bdb788a2599fc80718e59f96a13aa9ac701 /Tools
parentf55e1880c1a13ab907070f05fedfbf674b6369e5 (diff)
downloadcpython-2c82592ab463f1f38237919a12145f34eaadda23.zip
cpython-2c82592ab463f1f38237919a12145f34eaadda23.tar.gz
cpython-2c82592ab463f1f38237919a12145f34eaadda23.tar.bz2
GH-116017: Put JIT code and data on the same page (GH-116845)
Diffstat (limited to 'Tools')
-rw-r--r--Tools/jit/_stencils.py7
-rw-r--r--Tools/jit/_targets.py2
2 files changed, 4 insertions, 5 deletions
diff --git a/Tools/jit/_stencils.py b/Tools/jit/_stencils.py
index 78c566d..05c4ce8 100644
--- a/Tools/jit/_stencils.py
+++ b/Tools/jit/_stencils.py
@@ -124,7 +124,7 @@ class Stencil:
):
self.holes.append(hole.replace(offset=base + 4 * i, kind=kind))
- def remove_jump(self) -> None:
+ def remove_jump(self, *, alignment: int = 1) -> None:
"""Remove a zero-length continuation jump, if it exists."""
hole = max(self.holes, key=lambda hole: hole.offset)
match hole:
@@ -170,7 +170,7 @@ class Stencil:
offset -= 2
case _:
return
- if self.body[offset:] == jump:
+ if self.body[offset:] == jump and offset % alignment == 0:
self.body = self.body[:offset]
self.holes.remove(hole)
@@ -199,9 +199,8 @@ class StencilGroup:
):
self.code.pad(alignment)
self.code.emit_aarch64_trampoline(hole)
- self.code.pad(alignment)
self.code.holes.remove(hole)
- self.code.remove_jump()
+ self.code.remove_jump(alignment=alignment)
self.code.pad(alignment)
self.data.pad(8)
for stencil in [self.code, self.data]:
diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py
index 417fdb5..66db358 100644
--- a/Tools/jit/_targets.py
+++ b/Tools/jit/_targets.py
@@ -89,7 +89,7 @@ class _Target(typing.Generic[_S, _R]):
if group.data.body:
line = f"0: {str(bytes(group.data.body)).removeprefix('b')}"
group.data.disassembly.append(line)
- group.process_relocations()
+ group.process_relocations(alignment=self.alignment)
return group
def _handle_section(self, section: _S, group: _stencils.StencilGroup) -> None: