Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Revert changes for Linux x86-64
  • Loading branch information
diegorusso committed Apr 8, 2026
commit 67149067417cac6d5b1ce00723180dead5af16c1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Improve JIT code generation on Linux targets by reducing the indirect call to external symbols. Patch by Diego Russo.
Improve JIT code generation on Linux AArch64 by reducing the indirect call to external symbols. Patch by Diego Russo.
15 changes: 4 additions & 11 deletions Python/jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,25 +316,18 @@ patch_32(unsigned char *location, uint64_t value)
memcpy(location, &final_value, sizeof(final_value));
}

// 32-bit absolute address, sign-extended by the instruction.
// 32-bit relative address.
void
patch_32s(unsigned char *location, uint64_t value)
patch_32r(unsigned char *location, uint64_t value)
{
value -= (uintptr_t)location;
// Check that we're not out of range of 32 signed bits:
assert((int64_t)value >= -(1LL << 31));
assert((int64_t)value < (1LL << 31));
int32_t final_value = (int32_t)value;
uint32_t final_value = (uint32_t)value;
memcpy(location, &final_value, sizeof(final_value));
}

// 32-bit relative address.
void
patch_32r(unsigned char *location, uint64_t value)
{
value -= (uintptr_t)location;
patch_32s(location, value);
}

// 64-bit absolute address.
void
patch_64(unsigned char *location, uint64_t value)
Expand Down
1 change: 0 additions & 1 deletion Tools/jit/_stencils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class HoleValue(enum.Enum):
"R_AARCH64_MOVW_UABS_G2_NC": "patch_aarch64_16c",
"R_AARCH64_MOVW_UABS_G3": "patch_aarch64_16d",
# x86_64-unknown-linux-gnu:
"R_X86_64_32S": "patch_32s",
"R_X86_64_64": "patch_64",
"R_X86_64_GOTPCRELX": "patch_x86_64_32rx",
"R_X86_64_PLT32": "patch_32r",
Expand Down
2 changes: 1 addition & 1 deletion Tools/jit/_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ def get_target(host: str) -> _COFF32 | _COFF64 | _ELF | _MachO:
elif re.fullmatch(r"x86_64-.*-linux-gnu", host):
host = "x86_64-unknown-linux-gnu"
condition = "defined(__x86_64__) && defined(__linux__)"
args = ["-fno-pic", "-mcmodel=medium", "-mlarge-data-threshold=0"]
args = ["-fno-pic", "-mcmodel=medium", "-mlarge-data-threshold=0", "-fno-plt"]
optimizer = _optimizers.OptimizerX86
target = _ELF(
host, condition, args=args, optimizer=optimizer, frame_pointers=True
Expand Down
Loading