https://github.com/python/cpython/commit/5d8db36bbbab166c4c221ee6e283f090475c5def
commit: 5d8db36bbbab166c4c221ee6e283f090475c5def
branch: main
author: Brandt Bucher <[email protected]>
committer: brandtbucher <[email protected]>
date: 2025-03-05T11:54:33-08:00
summary:
GH-115802: JIT using the "medium" code model on x86_64-unknown-linux-gnu
(GH-130097)
files:
A
Misc/NEWS.d/next/Core_and_Builtins/2025-02-13-12-31-53.gh-issue-115802.0kN4xM.rst
M Tools/jit/_stencils.py
M Tools/jit/_targets.py
diff --git
a/Misc/NEWS.d/next/Core_and_Builtins/2025-02-13-12-31-53.gh-issue-115802.0kN4xM.rst
b/Misc/NEWS.d/next/Core_and_Builtins/2025-02-13-12-31-53.gh-issue-115802.0kN4xM.rst
new file mode 100644
index 00000000000000..b645c6b9e1cf20
--- /dev/null
+++
b/Misc/NEWS.d/next/Core_and_Builtins/2025-02-13-12-31-53.gh-issue-115802.0kN4xM.rst
@@ -0,0 +1,2 @@
+Use the more efficient "medium" code model for JIT-compiled code on
+supported platforms.
diff --git a/Tools/jit/_stencils.py b/Tools/jit/_stencils.py
index 8b6957f8bdbdfc..4ddbe967438bd1 100644
--- a/Tools/jit/_stencils.py
+++ b/Tools/jit/_stencils.py
@@ -84,9 +84,8 @@ class HoleValue(enum.Enum):
"R_AARCH64_MOVW_UABS_G3": "patch_aarch64_16d",
# x86_64-unknown-linux-gnu:
"R_X86_64_64": "patch_64",
- "R_X86_64_GOTPCREL": "patch_32r",
"R_X86_64_GOTPCRELX": "patch_x86_64_32rx",
- "R_X86_64_PC32": "patch_32r",
+ "R_X86_64_PLT32": "patch_32r",
"R_X86_64_REX_GOTPCRELX": "patch_x86_64_32rx",
# x86_64-apple-darwin:
"X86_64_RELOC_BRANCH": "patch_32r",
@@ -226,11 +225,11 @@ def remove_jump(self, *, alignment: int = 1) -> None:
offset -= 3
case Hole(
offset=offset,
- kind="IMAGE_REL_I386_REL32" | "X86_64_RELOC_BRANCH",
+ kind="IMAGE_REL_I386_REL32" | "R_X86_64_PLT32" |
"X86_64_RELOC_BRANCH",
value=HoleValue.CONTINUE,
symbol=None,
- addend=-4,
- ) as hole:
+ addend=addend,
+ ) as hole if _signed(addend) == -4:
# jmp 5
jump = b"\xE9\x00\x00\x00\x00"
offset -= 1
@@ -243,17 +242,6 @@ def remove_jump(self, *, alignment: int = 1) -> None:
) as hole:
# b #4
jump = b"\x00\x00\x00\x14"
- case Hole(
- offset=offset,
- kind="R_X86_64_GOTPCRELX",
- value=HoleValue.GOT,
- symbol="_JIT_CONTINUE",
- addend=addend,
- ) as hole:
- assert _signed(addend) == -4
- # jmp qword ptr [rip]
- jump = b"\xFF\x25\x00\x00\x00\x00"
- offset -= 2
case _:
return
if self.body[offset:] == jump and offset % alignment == 0:
diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py
index 7eb433e2a5b207..84fa1a6ed25a18 100644
--- a/Tools/jit/_targets.py
+++ b/Tools/jit/_targets.py
@@ -522,7 +522,7 @@ def get_target(host: str) -> _COFF | _ELF | _MachO:
args = ["-fms-runtime-lib=dll"]
target = _COFF(host, args=args)
elif re.fullmatch(r"x86_64-.*-linux-gnu", host):
- args = ["-fpic"]
+ args = ["-fno-pic", "-mcmodel=medium", "-mlarge-data-threshold=0"]
target = _ELF(host, args=args)
else:
raise ValueError(host)
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]