Repository navigation
feat(interp): add array set fusion - #181
Conversation
Keep the threaded array.set implementation shared by fused and standalone paths. Restrict native array.set lowering to proven constant containers and deopt other shapes to the threaded handler. This removes duplicate generated mutation logic and keeps the JIT fast path conservative.
Keep array.set fusion on compile-time constant containers so the generator and ARM64 backend share one specialization boundary. Remove the unused dynamic-container path and inline the single-use value producer selection.
|
Warning Review limit reached
Next review available in: 48 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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThe PR adds constant-backed ChangesARRAY_SET JIT support
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CONST_GET
participant resolve
participant element
participant storeArray
participant Interpreter.setArrayElem
CONST_GET->>resolve: supply constant array, index, and value
resolve->>element: build fused ARRAY_SET
element->>storeArray: convert and store typed value
element->>Interpreter.setArrayElem: handle standalone or fallback write
Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
interp/jit_arm64.go (1)
3318-3347: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winReject constant generic arrays from native
ARRAY_SET.
backingConstproves only constant provenance. It does not prove a typed-array representation. Thetypes.KindRefarm selectsheapArrayRef, so a constant*types.Arraycan still reach native mutation.Restrict the native path to
heapArrayI1,heapArrayI8,heapArrayI32,heapArrayI64,heapArrayF32, andheapArrayF64. Deopt generic arrays to the threaded handler.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@interp/jit_arm64.go` around lines 3318 - 3347, Update the native ARRAY_SET path around the kind switch to reject generic constant arrays: allow only the six typed-array backing kinds heapArrayI1, heapArrayI8, heapArrayI32, heapArrayI64, heapArrayF32, and heapArrayF64. Remove or bypass the types.KindRef/heapArrayRef case so generic arrays deopt to the threaded handler instead of reaching native mutation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/cmd/geninterp/lower.go`:
- Around line 2333-2351: Restore caller-before-callee declaration order by
moving storeArray in internal/cmd/geninterp/lower.go below element, which calls
it; also move releaseFrameRefs in interp/jit_arm64.go below stitch and ret,
which call it. Make no other behavioral changes.
In `@interp/jit_arm64.go`:
- Around line 2689-2710: Refactor arm64Lowerer.releaseFrameRefs to preflight-box
all reference locals before emitting any instructions, returning false without
mutating IR if boxing fails; then perform full reference release using the
existing zero-count release or side-exit mechanism rather than an unconditional
decrement/store. Preserve the native frame cleanup and returned-reference retain
sequence, and document that JIT contract in docs/jit-internals.md.
---
Outside diff comments:
In `@interp/jit_arm64.go`:
- Around line 3318-3347: Update the native ARRAY_SET path around the kind switch
to reject generic constant arrays: allow only the six typed-array backing kinds
heapArrayI1, heapArrayI8, heapArrayI32, heapArrayI64, heapArrayF32, and
heapArrayF64. Remove or bypass the types.KindRef/heapArrayRef case so generic
arrays deopt to the threaded handler instead of reaching native mutation.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6e3949b2-9679-4f87-b643-e5fbfc2793d5
📒 Files selected for processing (6)
docs/jit-internals.mdinternal/cmd/geninterp/lower.gointernal/cmd/geninterp/pattern.gointerp/interp.gointerp/jit_arm64.gointerp/threaded.go
siyul-park
left a comment
There was a problem hiding this comment.
Reviewed all current CodeRabbit findings against the updated branch.
- Caller-before-callee ordering: fixed in b558552 by moving
releaseFrameRefsbelowstitch/ret; the existingstoreArrayordering already matches the guideline. - Frame ref cleanup: fixed in b558552. Ref locals are collected/boxed before the release sequence, and each release uses the normal
guardRCpath so a final owner deoptimizes instead of being unconditionally decremented. The contract is documented indocs/jit-internals.md. - Generic constant arrays in native
ARRAY_SET: fixed by removing theKindRef/heapArrayRefnative case; ref-element arrays now deopt to the threaded handler. The existing terminal-fallback parity test passes.
I also checked analogous ref-release sites (ARRAY_SET, STRUCT_SET, reads, releaseRef) for the same unconditional-final-owner pattern; existing mutation/read paths already use the guarded release contract.
Validation: focused ARM64 tests and all non-ARM64 packages pass. The known self-tail-call deferred-ref case remains the only expected failure and is tracked in #179.
Summary
ARRAY_SETfusion lowering for constant typed arraysarrayGet/arraySetValidation
make check-generatedgit diff --checkgo test ./internal/cmd/geninterp ./instr ./types ./program ./interpKnown issue
ARM64 self-tail-call deferred-ref imbalance remains tracked separately in #179; this PR does not mask or weaken that ownership test.
Summary by CodeRabbit
New Features
Bug Fixes