Skip to content

jit: precompute symbol offsets, add x86-64 GOT relaxation, and include lightweight JIT benchmark tool#123

Draft
methane wants to merge 2 commits into
mainfrom
codex/jit
Draft

jit: precompute symbol offsets, add x86-64 GOT relaxation, and include lightweight JIT benchmark tool#123
methane wants to merge 2 commits into
mainfrom
codex/jit

Conversation

@methane

@methane methane commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Reduce emit-time overhead by avoiding repeated popcount walks when resolving GOT/trampoline slots.
  • Improve generated code quality by enabling an x86-64 relaxation that can replace RIP-relative loads with immediates when safe.
  • Provide a lightweight local benchmark to quickly smoke-test JIT changes before running larger suites.

Description

  • Added an offsets array to symbol_state and implemented initialize_symbol_state to precompute ordinal-to-slot indices and region sizes.
  • Replaced the popcount-based slot index calculation in get_symbol_slot with a direct lookup using state->offsets[ordinal].
  • Replaced manual size accumulation loops with calls to initialize_symbol_state and simplified padding/alignment arithmetic for code/data/GOT regions.
  • Extended patch_x86_64_32rx to relax certain mov reg, [rip + AAA] sequences into immediate mov reg, imm using the C7 /0 encoding while preserving REX.W handling.
  • Updated Tools/jit/README.md with a "Measuring JIT performance" section and added Tools/jit/benchmark.py as a small JIT-focused benchmark driver.

Testing

  • Built CPython with --enable-experimental-jit and the build completed successfully.
  • Ran the new benchmark smoke test via Tools/jit/benchmark.py to validate jit_available/jit_enabled reporting and collected timings, which completed without error.
  • Ran the project's test suite focusing on JIT-related tests with make test, and the executed tests passed.

Codex Task

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9975c054-3ac2-4896-9174-d26cf5f0d9e4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/jit

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant