fix(interp): make recursive trace boundary explicit - #185
Open
siyul-park wants to merge 2 commits into
Open
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe tracer now terminates non-entry recursive calls as partial trace cuts. Function-entry self-calls retain native lowering. The JIT internals documentation describes both behaviors. ChangesRecursive call trace cuts
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
siyul-park
marked this pull request as ready for review
August 10, 2026 14:40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #184.
The Fannkuch compare benchmark could produce incorrect results in
defaultandjitmodes whilethreadedremained correct.Root cause
The trace recorder used
skipCallwhen it encountered a recursiveCALL. That is only sound when the recorder can model the call's effects.skipCallsupplies placeholder return values and does not reproduce the callee's heap mutations.A recursive call encountered inside a non-entry loop trace could therefore leave the recorder with a speculative VM/heap state that never existed. Fannkuch exposes this because its recursive permutation routine mutates a shared array and continues execution after the call.
Fix
Treat recursive calls in non-entry loop traces as a trace boundary. The native prefix is retained, the real recursive call executes through the threaded path, and the post-call continuation can be captured from the actual frame and heap state.
Function-entry self-recursion keeps the existing native
selfCallpath, so the fix does not disable native recursive-call lowering globally or reject heap mutation from JIT plans.The JIT trace contract documentation is updated to describe the boundary explicitly.
Validation
go test -race ./...go vet ./...go test -tags=compare -run='^$' -bench='^BenchmarkCall_Fannkuch$' -benchtime=1x -count=5git diff --checkThe Fannkuch compare benchmark passes for
default,threaded,jit,native,gpython, andcpythonon the ARM64 development machine.Summary by CodeRabbit
Bug Fixes
Documentation