Skip to content

wasm: streamline hot JIT paths - #1192

Merged
youknowone merged 1 commit into
mainfrom
agent/wasm-intmul-fastpath
Aug 13, 2026
Merged

wasm: streamline hot JIT paths#1192
youknowone merged 1 commit into
mainfrom
agent/wasm-intmul-fastpath

Conversation

@youknowone

Copy link
Copy Markdown
Owner

Summary

  • move Wasm guard recovery spills out of the hot trace into a shared cold dispatcher
  • fast-path signed-32 IntMulOvf while retaining the full-width overflow fallback
  • remove redundant recursive CALL_ASSEMBLER nursery-frame clearing
  • invert fused integer guard comparisons directly and direct-call five exact uniform-i64 blackhole helpers in the guest

Why

Profiling showed software 64x64 overflow checks in nested_loop, duplicate 1064-byte frame clears in recursive calls, inline cold fail-arg spill blocks in fannkuch, and 44,678 exact-ABI blackhole helper calls reflecting guest→host→guest. The changes preserve PyPy/backend structure and retain generic fallbacks for ambiguous ABIs.

Results

  • nested_loop: ~0.66s → ~0.45s
  • fib_recursive: ~2.39s → ~1.98s
  • fannkuch host jit_calls: 44,692 → 14
  • full benchmark suite: dynasm 17/17, cranelift 17/17, wasm 14/14

Validation

  • cargo check --features dynasm
  • cargo test --workspace --exclude pyrex --features dynasm
  • cargo test -p majit-backend-wasm --test codegen_test
  • cargo test -p majit-backend-wasm --test codegen_test -- --ignored
  • python3 pyre/check.py --no-synthetic --no-cpython-suite

Note: the unexcluded workspace test reaches a pre-existing user-only PYRE_WASM_CALL_HIST worktree diagnostic and fails its gate-triage completeness check; that unrelated file is not included in this PR.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@youknowone, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 38 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fd09c9ab-a7dc-4fa9-8f8a-bc6e2c836790

📥 Commits

Reviewing files that changed from the base of the PR and between 0d83827 and c3234c3.

📒 Files selected for processing (3)
  • majit/majit-backend-wasm/src/codegen.rs
  • majit/majit-backend-wasm/tests/codegen_test.rs
  • pyre/pyre-wasm/src/lib.rs

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.

@youknowone
youknowone marked this pull request as ready for review August 13, 2026 04:56
@youknowone
youknowone merged commit 2482351 into main Aug 13, 2026
16 of 18 checks passed
@youknowone
youknowone deleted the agent/wasm-intmul-fastpath branch August 13, 2026 04:57
@github-actions

Copy link
Copy Markdown

🤖 Codex parity review

Static analysis of this diff vs the local RPython/PyPy sources (commit c3234c3).
Updated: 2026-08-13T04:59:56.780Z

Files in the reviewed diff
majit/majit-backend-wasm/src/codegen.rs
majit/majit-backend-wasm/tests/codegen_test.rs
pyre/pyre-wasm/src/lib.rs

1. Regressions to PyPy parity introduced by this patch

None.

2. Other mismatches introduced by this patch

None.

3. Pre-existing mismatches (already present before this patch)

None.

4. Structural adaptations

  • majit/majit-backend-wasm/src/codegen.rs:2078 ↔ rpython/jit/backend/x86/assembler.py:835 — Wasm uses a structured hot-exit block and br_table cold dispatcher; x86 appends per-guard recovery stubs to linear machine code. The patch preserves positional fail-argument recovery while adapting to structured Wasm control flow.

  • majit/majit-backend-wasm/src/codegen.rs:5531 ↔ rpython/jit/backend/x86/assembler.py:1869 — Wasm lacks x86 overflow flags, so INT_MUL_OVF uses an exact signed-32 fast-path proof plus a software full-width high-word fallback, rather than imul plus NO condition flags.

  • majit/majit-backend-wasm/src/codegen.rs:3591 ↔ rpython/memory/gc/incminimark.py:1345 — The removed per-frame memory.fill relies on the wasm nursery’s target-specific full-arena zeroing on reset. This is a wasm GC-layout adaptation; frame metadata and Ref homes are still explicitly initialized.

  • pyre/pyre-wasm/src/lib.rs:181 ↔ rpython/jit/backend/x86/assembler.py:2272 — The exact-function wasm ABI allow-list directly invokes known uniform-i64 helpers instead of reflecting through the host trampoline. This replaces a wasm guest→host→guest call with an in-module call while retaining the generic path for all other signatures.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant