pyre-jit-trace: jitcode_dispatch follow-up — macro reflection + fbw/residual/inline/specialize extraction - #671
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (14)
WalkthroughThis PR modularizes Pyre’s JIT trace dispatcher into FBW state, residual-call, inline-call, and specialization modules. It adds concrete residual execution, recursive and user-call inlining, mutation journaling, abort/resume handling, walker-native folds, and float comparison routing. ChangesFBW JIT dispatch
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
🤖 Codex parity reviewStatic analysis of this diff vs the local RPython/PyPy sources (commit b411890). Files in the reviewed diff1. Regressions to PyPy parity introduced by this patchNone. 2. Other mismatches introduced by this patchNone. 3. Pre-existing mismatches (already present before this patch)
4. Structural adaptations
|
Add a binop_float_to_int_record family (float_lt/le/eq/ne/gt/ge) to regular_record_table!, so the six float-comparison arms dispatch from dispatch_regular_record instead of the per-opname match. These are part of the pyjitpl.py:284-292 exec-generated binary opimpl loop; their result lands in the int bank (ff>i). Consolidate the record-family parity citations (int/float arithmetic, the b1-is-b2 comparison fast path, float_mul-absent note, int-unary and ptr_eq/ptr_ne notes) into the table in arith.rs, and drop the orphaned comment block the arms left behind in mod.rs. Assisted-by: Claude
Relocate the 86 fbw_* / capture_fbw_* helpers — feature gates, the store / append / for-iter journals and rollback, executed-effect and residual counters, the finish-payload channel, and abort-resume carriers — from jitcode_dispatch/mod.rs into fbw_state.rs. Pure relocation; the two thread_local! blocks these functions own (FBW_FINISH_PAYLOAD and the SELFREC_CA_FOLD_ACTIVE / EXCEPTION_STRING_INLINE_ACTIVE gates) move with them, the latter two promoted to pub(crate) for the scoped-setter guards that stay in mod.rs. Assisted-by: Claude
Relocate the 17 residual-call helpers — the per-shape dispatchers
(dispatch_residual_call_{iRd,iIRd,iIRFd}_kind), the executor fast paths
(try_fold_pure_call_via_executor, try_execute_residual_call_via_executor),
opcode selection, arg binding, pre-call vable/vref sync, result writeback,
and the body classification helpers — from jitcode_dispatch/mod.rs into
residual_call.rs. Pure relocation; the residual_call_* opname arms stay in
handle and call into the moved dispatchers.
t3_audit_opname_gap_inventory now scans residual_call.rs alongside mod.rs
and arith.rs so the moved residual-call match arms stay in its
source-of-truth handler set.
Assisted-by: Claude
Relocate the 24 inline-call helpers — callee recognition and inlinability checks, active-box / call-stack reconstruction, callee register-bank allocation, the sub-jitcode walk driver, the self-recursive CALL_ASSEMBLER fold, the inline user-call / binop / compareop / exception-string specializers, and the dispatch_inline_call_* per-shape dispatchers — from jitcode_dispatch/mod.rs into inline_call.rs. Pure relocation; the inline_call_* opname arms stay in handle and call into the moved dispatchers. Assisted-by: Claude
Relocate the 31 try_walker_* specialization entry points (int/long/float arithmetic and comparisons, attribute and method loads, container builds and subscript, list-append, exception construction/raise, for-iter, slice, and the module/name cell folds) plus the three exclusive orthodox_list_append_* helpers from jitcode_dispatch/mod.rs into specialize.rs. Pure relocation; the shared walker_* primitives stay in mod.rs and the specialization opname arms stay in handle. Assisted-by: Claude
…unterpart The FBW jitcode walker has no single rpython/jit/metainterp/ file counterpart — the file-for-file parity mirror is the majit-metainterp crate (pyjitpl.rs, executor.rs, heapcache.rs, resume.rs, virtualizable.rs, blackhole.rs, ...). Document that in mod.rs and give every submodule header a Parity line naming the pyjitpl.py opimpl group / metainterp file it is the trace-side counterpart of, or declaring it pyre-specific where there is no upstream analogue (fbw_state, vstack_mirror, diag). Records the codewriter-level divergence in branch.rs: pyre emits an unfused goto_if_not/iL plus a separate compare_op, so PyPy's fused goto_if_not_int_lt family (pyjitpl.py:541) has no pyre opname. Comments only; no behaviour change. Assisted-by: Claude
Follow-up to #666 (merged), continuing the
jitcode_dispatchdecomposition. Five commits on top of the merged per-cluster split.Macro reflection
route float-comparison record arms via the macro table — adds a
binop_float_to_int_recordfamily (float_lt/le/eq/ne/gt/ge) toregular_record_table!, so the six float-comparison arms dispatch from the generated table instead of the per-opnamematch. These are part of thepyjitpl.py:284-292exec-generated binary opimpl loop (result in the int bank,ff>i). Consolidates the record-family parity citations into the table inarith.rsand drops the orphaned comment block the arms left inmod.rs.This completes the principle that pyre should generate what
pyjitpl.pygenerates and hand-port only what it hand-writes: an audit of all four exec-generated opimpl families found these six were the sole remaining hand-spelled uniform arms; everything else is already table-routed, has no pyre arm, or is a bank-crossing cast needing a bespoke helper.Relocations (pure behavior-preserving moves)
fbw_*/capture_fbw_*helpers (force-before-writeback state machine: feature gates, store/append/for-iter journals + rollback, executed-effect/residual counters, finish-payload channel, abort-resume carriers).try_walker_*specialization entry points + 3 exclusiveorthodox_list_append_*helpers. Sharedwalker_*primitives stay inmod.rs.The opname dispatch arms stay in
handle(mod.rs) throughout and call into the moved helpers.Result
mod.rsdrops from 21,780 → 8,497 lines (the dispatch core now holdshandle, the walk driver, and sharedwalker_*primitives). Each step verified withcargo testand both JIT backends; check.py dynasm 225/225 · cranelift 225/225.🤖 Generated with Claude Code
Summary by CodeRabbit