Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d145747
LLVM 20 bump
savannahostrowski Sep 18, 2025
d86b66e
Merge main
savannahostrowski Sep 19, 2025
9324b14
Add flags for testing
savannahostrowski Sep 19, 2025
f3bb6b9
Merge branch 'main' into llvm-20
savannahostrowski Sep 20, 2025
b6e7981
Merge main
savannahostrowski Oct 6, 2025
e867644
Fix windows
savannahostrowski Oct 6, 2025
13e9f5b
Merge main
savannahostrowski Oct 7, 2025
84781b4
Merge branch 'main' into llvm-20
savannahostrowski Oct 8, 2025
0034f14
Download binaries from GitHub releases
emmatyping Aug 6, 2025
cc98d30
Add hash checking
emmatyping Aug 7, 2025
76842eb
Apply Emma's commits for grabbing binaries from release artifacts
savannahostrowski Oct 8, 2025
a732cec
Merge branch 'main' into llvm-20
savannahostrowski Oct 11, 2025
e8395ce
Fix up LLVM via release artifacts
savannahostrowski Oct 11, 2025
d1e4363
Merge branch 'main' into llvm-20
savannahostrowski Oct 12, 2025
01aed67
Remove model flags for x86_64 darwin causing GOT relocation issues
savannahostrowski Oct 12, 2025
94f1a89
Clean up
savannahostrowski Oct 12, 2025
e6450de
Only patch x86_64 GOT relocations when relaxation succeeds
savannahostrowski Oct 13, 2025
1adf827
Revert "Only patch x86_64 GOT relocations when relaxation succeeds"
savannahostrowski Oct 13, 2025
b9bfacf
mcmodel=large
savannahostrowski Oct 14, 2025
57c44ee
Add macro to handle debug
savannahostrowski Oct 16, 2025
081ee86
fno-pic
savannahostrowski Oct 16, 2025
0b773f9
remove fno-pic
savannahostrowski Oct 16, 2025
c78af6f
remove hack
savannahostrowski Oct 18, 2025
d715cf2
Trampoline attempt
savannahostrowski Oct 18, 2025
38e11b9
Touch up and add better comments
savannahostrowski Oct 19, 2025
74eb9a4
Merge main
savannahostrowski Oct 19, 2025
ca95652
More clean up
savannahostrowski Oct 19, 2025
47153a5
📜🤖 Added by blurb_it.
blurb-it[bot] Oct 19, 2025
7b2df52
Redupe LLVM version reference from jit.yml
savannahostrowski Oct 21, 2025
3a5af39
Merge branch 'llvm-20' of https://github.com/savannahostrowski/cpytho…
savannahostrowski Oct 21, 2025
450dd09
Simplify fetching LLVM from bin-deps
savannahostrowski Oct 21, 2025
5da3349
Remove duplicate 20 reference in jit.yml
savannahostrowski Oct 21, 2025
620cd4f
Fix flags
savannahostrowski Oct 21, 2025
d1a68ab
Reduce DATA_ALIGN to 8 bytes
savannahostrowski Oct 21, 2025
f3d46bd
Merge branch 'main' into llvm-20
savannahostrowski Oct 21, 2025
4b35c2f
Update Devcontainer readme
savannahostrowski Oct 22, 2025
ffcb68e
Merge branch 'llvm-20' of https://github.com/savannahostrowski/cpytho…
savannahostrowski Oct 22, 2025
0540ba3
Merge branch 'main' into llvm-20
savannahostrowski Oct 30, 2025
618a4a6
Revert CI simplication and address comments for memcpy
savannahostrowski Oct 31, 2025
2e9ba92
Address comments about get_externals and trampoline helper
savannahostrowski Oct 31, 2025
a21cb31
Merge branch 'main' into llvm-20
savannahostrowski Oct 31, 2025
795f466
Restore get_externals
savannahostrowski Oct 31, 2025
b880f26
Fix spacing
savannahostrowski Oct 31, 2025
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
Next Next commit
Address comments about get_externals and trampoline helper
  • Loading branch information
savannahostrowski committed Oct 31, 2025
commit 2e9ba9272e65f86c4bffd4ce14c2a345d41fe743
25 changes: 8 additions & 17 deletions PCbuild/get_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,22 @@
import zipfile


def request_with_retry(request_func, *args, max_retries=7,
err_msg='Request failed.', **kwargs):
"""Make a request using request_func with exponential backoff"""
def retrieve_with_retries(download_location, output_path, reporthook, max_retries=7):
"""Download a file with retries."""
for attempt in range(max_retries + 1):
try:
resp = request_func(*args, **kwargs)
resp = urllib.request.urlretrieve(
download_location,
output_path,
reporthook,
)
except (urllib.error.URLError, ConnectionError) as ex:
if attempt == max_retries:
raise OSError(err_msg) from ex
raise OSError(f'Download from {download_location} failed.') from ex
time.sleep(2.25**attempt)
else:
return resp


def retrieve_with_retries(download_location, output_path, reporthook):
"""Download a file with retries."""
return request_with_retry(
urllib.request.urlretrieve,
download_location,
output_path,
reporthook,
err_msg=f'Download from {download_location} failed.',
)


def fetch_zip(commit_hash, zip_dir, *, org='python', binary=False, verbose=False):
repo = 'cpython-bin-deps' if binary else 'cpython-source-deps'
url = f'https://github.com/{org}/{repo}/archive/{commit_hash}.zip'
Expand Down
4 changes: 2 additions & 2 deletions PCbuild/get_externals.bat
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ for %%b in (%binaries%) do (
) else (
echo.Fetching %%b...
if "%%b"=="llvm-20.1.8.0" (
Comment thread
savannahostrowski marked this conversation as resolved.
%PYTHON% -E "%PCBUILD%\get_external.py" -r -O %ORG% -e "%EXTERNALS_DIR%" %%b
%PYTHON% -E "%PCBUILD%\get_external.py" --release --organization %ORG% --externals-dir "%EXTERNALS_DIR%" %%b
) else (
%PYTHON% -E "%PCBUILD%\get_external.py" -b -O %ORG% -e "%EXTERNALS_DIR%" %%b
%PYTHON% -E "%PCBUILD%\get_external.py" --binary --organization %ORG% --externals-dir "%EXTERNALS_DIR%" %%b
)
)
)
Expand Down
48 changes: 22 additions & 26 deletions Python/jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,25 @@ void patch_x86_64_trampoline(unsigned char *location, int ordinal, jit_state *st
#define DATA_ALIGN 1
#endif

// Get the trampoline memory location for a given symbol ordinal.
static unsigned char *
get_trampoline_slot(int ordinal, jit_state *state)
{
const uint32_t symbol_mask = 1 << (ordinal % 32);
const uint32_t trampoline_mask = state->trampolines.mask[ordinal / 32];
assert(symbol_mask & trampoline_mask);

// Count the number of set bits in the trampoline mask lower than ordinal
int index = _Py_popcount32(trampoline_mask & (symbol_mask - 1));
for (int i = 0; i < ordinal / 32; i++) {
index += _Py_popcount32(state->trampolines.mask[i]);
}

unsigned char *trampoline = state->trampolines.mem + index * TRAMPOLINE_SIZE;
assert((size_t)(index + 1) * TRAMPOLINE_SIZE <= state->trampolines.size);
return trampoline;
}

// Generate and patch AArch64 trampolines. The symbols to jump to are stored
// in the jit_stencils.h in the symbols_map.
void
Expand All @@ -477,20 +496,8 @@ patch_aarch64_trampoline(unsigned char *location, int ordinal, jit_state *state)
return;
}

// Masking is done modulo 32 as the mask is stored as an array of uint32_t
const uint32_t symbol_mask = 1 << (ordinal % 32);
const uint32_t trampoline_mask = state->trampolines.mask[ordinal / 32];
assert(symbol_mask & trampoline_mask);

// Count the number of set bits in the trampoline mask lower than ordinal,
// this gives the index into the array of trampolines.
int index = _Py_popcount32(trampoline_mask & (symbol_mask - 1));
for (int i = 0; i < ordinal / 32; i++) {
index += _Py_popcount32(state->trampolines.mask[i]);
}

uint32_t *p = (uint32_t*)(state->trampolines.mem + index * TRAMPOLINE_SIZE);
assert((size_t)(index + 1) * TRAMPOLINE_SIZE <= state->trampolines.size);
// Out of range - need a trampoline
uint32_t *p = (uint32_t *)get_trampoline_slot(ordinal, state);


/* Generate the trampoline
Expand Down Expand Up @@ -521,18 +528,7 @@ patch_x86_64_trampoline(unsigned char *location, int ordinal, jit_state *state)
}

// Out of range - need a trampoline
const uint32_t symbol_mask = 1 << (ordinal % 32);
const uint32_t trampoline_mask = state->trampolines.mask[ordinal / 32];
assert(symbol_mask & trampoline_mask);

// Count the number of set bits in the trampoline mask lower than ordinal
int index = _Py_popcount32(trampoline_mask & (symbol_mask - 1));
for (int i = 0; i < ordinal / 32; i++) {
index += _Py_popcount32(state->trampolines.mask[i]);
}

unsigned char *trampoline = state->trampolines.mem + index * TRAMPOLINE_SIZE;
assert((size_t)(index + 1) * TRAMPOLINE_SIZE <= state->trampolines.size);
unsigned char *trampoline = get_trampoline_slot(ordinal, state);

/* Generate the trampoline (14 bytes, padded to 16):
0: ff 25 00 00 00 00 jmp *(%rip)
Expand Down
Loading