GH-116017: Put JIT code and data on the same page (GH-116845)

This commit is contained in:
Brandt Bucher 2024-03-19 08:47:28 -07:00 committed by GitHub
parent f55e1880c1
commit 2c82592ab4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 34 deletions

View file

@ -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]: