jit: PR#457 parity-review follow-ups — built_as_portal fold gate; callee-locals shadow TLS→WalkContext#500
Conversation
…etadata The strict inline fold resolved the callee portal frame register behind a walk-time read of the PYRE_ALWAYS_PORTAL env var (fbw_always_portal_enabled). The jitcode's input shape is fixed at build time and recorded in its built_as_portal metadata, so read that instead: add built_as_portal_at to state.rs and filter the callee jitcode index through it before portal_red_regs_at. Non-portal callees keep yielding u16::MAX (fold inert). Remove the now-unused fbw_always_portal_enabled; the build-time env read in codewriter.rs stays. check.py 161/161 on dynasm, cranelift, wasm. Assisted-by: Claude
FBW_CALLEE_LOCALS_CONCRETE, FBW_CALLEE_LOCALS_OPREF and
FBW_STRICT_FOLD_FRAME_REG were thread-local Vec-stacks whose every access
touched only the innermost entry — per-inline-level state emulated through
ambient TLS. Move it onto the walking frame itself: a new
CalleeLocalsShadow { opref, concrete, fold_frame_reg } owned by
WalkContext.callee_shadow, matching MIFrame-owned per-frame state
(pyjitpl.py:177-234 registers_i/r/f). The field is Some only for the two
inlined-callee sub-walks that pushed the TLS stacks
(try_walker_inline_user_call, drive_bridge_carrier_subwalk); None elsewhere
preserves the empty-stack no-op semantics. The Vec-stacks, their helper
functions and the InlineRecursionGuard push/pop of them are deleted; nesting
is carried by the call stack. A guard-less sub-walk can no longer alias the
caller's innermost maps. FBW_INLINE_CODE_STACK stays (genuine cross-level
recursion-depth scan).
check.py 161/161 on dynasm, cranelift, wasm; cargo test -p pyre-jit-trace 265
passed.
Assisted-by: Claude
|
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 (2)
WalkthroughPer-walk callee-local shadowing replaces thread-local strict-fold state during inline traversal. ChangesStrict inline folding
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CallerWalk
participant InlineWalk
participant CalleeLocalsShadow
participant JitMetadata
CallerWalk->>JitMetadata: read built_as_portal_at(jitcode_index)
CallerWalk->>InlineWalk: create WalkContext with callee_shadow
InlineWalk->>CalleeLocalsShadow: seed reconstructed slots and parameters
InlineWalk->>CalleeLocalsShadow: read and update local OpRef/concrete state
CalleeLocalsShadow-->>InlineWalk: provide strict fold frame register
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 2350a54). 1. 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
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0f32240831
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| let (callee_outcome, _callee_end_pc) = { | ||
| let mut sub_wc = WalkContext { | ||
| callee_shadow: None, |
There was a problem hiding this comment.
Preserve callee shadow across inline_call sub-walks
When an FBW-inlined Python callee reaches an inline_call_* helper, this sub-WalkContext now drops the active callee locals shadow. Before this change, run_sub_jitcode_walk did not push a new TLS shadow frame, so helper sub-walks inside the inlined callee still saw the current frame's fold/concrete maps; with callee_shadow: None, any vable reads/writes in those helper jitcodes lose the fresh-frame fold and concrete fallback, leading to VableBoxNotSeeded aborts or stale local/stack shadows for callees whose body contains helper inline_call_* plus getarrayitem_vable/setarrayitem_vable.
Useful? React with 👍 / 👎.
Follow-ups to the parity review on #457 (review comment: #457 (comment)). Both flagged orthodox gaps are fixed.
1. Gate strict fresh-frame fold on callee jitcode
built_as_portalmetadata (10a3e209aab)Review §2: a mutable env var (
PYRE_ALWAYS_PORTAL) was read at walk time to decide how a jitcode is interpreted. A JitCode's shape must come from the JitCode artifact itself.built_as_portalmetadata (stamped at build time in codewriter fromframe_is_portal) via a newstate::built_as_portal_at()accessor.fbw_always_portal_enabled()(the walk-time env read, single call site) is deleted. The build-time env read in codewriter stays — that is where the shape is legitimately decided and recorded.2. Move the FBW inline-callee locals shadow from TLS onto
WalkContext(0f32240831e)Review §1: per-inlined-callee locals lived in TLS
Vec-stacks (FBW_CALLEE_LOCALS_CONCRETE/_OPREF,FBW_STRICT_FOLD_FRAME_REG). RPython keeps per-callee state onMIFrame.registers_i/r/f(pyjitpl.py:177-234); pyre's MIFrame analog isWalkContext, which already ownsregisters_r/i/f.WalkContext. They are replaced by acallee_shadow: Option<CalleeLocalsShadow>field onWalkContext(slot-keyed OpRef/concrete maps + fold frame reg).Someonly at the two inlined-callee sub-walk constructions (try_walker_inline_user_call,drive_bridge_carrier_subwalk);Noneeverywhere else, preserving the previous empty-stack no-op semantics for top-level walks.InlineRecursionGuardpush/pop plumbing are deleted — nesting is now carried by the Rust call stack itself. This also structurally removes a latent hazard where a guard-less sub-walk could observe the caller's innermost maps through TLS.FBW_INLINE_CODE_STACKstays (genuine cross-level recursion-depth scan).Verification
python3 pyre/check.py: 161/161 on dynasm, cranelift, wasm (run for each commit).cargo test -p pyre-jit-trace --release --no-default-features --features dynasm: 265 passed.calls_closures.pyoutput unchanged.Out of scope
The review's deeper point — callee locals absent from resume data inside an inlined callee (currently handled by CALL-boundary replay) — belongs to the ongoing exact-resume epics (#467/#126/#215-P2) and is not touched here.
FBW_INLINE_CALLEE_CONSTSfollows the same TLS pattern and is a candidate for the same migration as a follow-up.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes