Repository navigation
refactor(interp): resolve typed array element layout from one table - #200
Conversation
|
Warning Review limit reached
Next review available in: 21 minutes Limit details: You’ve used all 1 included review currently available under your plan. 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 (2)
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 |
daa922c to
08bb211
Compare
The element storage layout - which heap itab a container must carry, where its element data starts, how wide an element is, and whether a loaded element is an unboxed payload - was written out longhand in four places: arrayGet and arraySet each carried the full kind switch, arrayLen carried the itab set with its base offsets, and the planner's hoist eligibility carried the itab set again to mean "primitive typed array". elemShapes is now the one place that layout is written down, with elemShapeOf resolving by element kind and elemShapeByItab by concrete container itab. A new element kind is one row instead of an edit to each site, and the four sites can no longer disagree about a kind's width or base offset. hoistable's rule reads directly now: it hoists a container only when the shape resolves and its elements are raw, because a ref array's elements carry ownership that a cached slice header cannot account for. That was previously expressed by listing six itabs and omitting the seventh. No behavior change: the table reproduces the same kind and itab sets, with the same base offsets and scales, that the four copies named. The guard preamble shared by arrayGet/arraySet and structGet/structSet was evaluated for the same treatment and left alone. The sequences look alike but differ in the number and kind of side exits they queue, in whether a hoisted fast path runs before the guards, and in return arity; a combinator covering them would take more parameters than it removes, in the code where the refcount invariants live. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
f1f81b4 to
540c799
Compare
* refactor(interp): reject a self callee instead of falling through The BLR slot path cannot serve a call to the function currently being emitted: it has published no slot yet. A self callee that selfCall turns down was falling through to that path with the call marker pushed back onto the operand stack, so ctx.sp() counted one slot too many and the callee frame base landed one slot high. Nothing reaches it - instrumenting the branch across the interp suite and all 18 benchmark kernels recorded zero hits - so this removes an untested path rather than fixing an observed failure. Rejecting matches what the code did before the marker handling moved. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(interp): build the element shape table on every architecture jit_plan.go resolves a container's element layout through elemShapeByItab, but that table and the itabs it names lived in jit_arm64.go, whose name constrains it to one GOARCH. The planner is portable and compiles for architectures with no native backend at all, so every non-arm64 build failed on an undefined symbol. Move the heap itabs, the element shape table, and the ref-array element offset the table names into the portable JIT core. Nothing changes for arm64; the architecture file keeps only lowering detail. Regression from #200, where the table was introduced. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * build: baseline coverage against what CI can actually measure The gate compares one number across two architectures with very different compiled surfaces. CI runs on amd64, where the arm64 JIT backend is not compiled but the portable planner, tracer, and JIT core are - and every test that exercises them skips, so they count as uncovered. 72.8 was recorded in #146, before the JIT grew. It has not been measurable since: non-arm64 builds have failed outright, so the job never reached the gate. With the build fixed, the honest amd64 number is 63.6. Raising it again needs portable tests for the planner and tracer, not a different threshold. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Stage 3 (second half) of the JIT lowering rework. Stacked on #199.
Change
The element storage layout — which heap itab a container must carry, where its element data starts, how wide an element is, and whether a loaded element is an unboxed payload — was written out longhand in four places:
arrayGetkind → (itab, base, scale, raw)switcharraySetrawarrayLenhoistable(planner)elemShapesis now the one place that layout is written down, withelemShapeOfresolving by element kind andelemShapeByItabby concrete container itab. A new element kind is one row instead of an edit to each site, and the four sites can no longer disagree about a kind's width or base offset.hoistable's rule also reads directly now — it hoists only when the shape resolves and its elements are raw, because a ref array's elements carry ownership a cached slice header cannot account for. That was previously expressed by listing six itabs and omitting the seventh, leaving the reason implicit.No behavior change: the table reproduces the same kind and itab sets, with the same base offsets and scales, that the four copies named.
The guard combinator was evaluated and rejected
The plan called for a second extraction here — one guarded-access combinator for
arrayGet/arraySetandstructGet/structSet. I looked at it and did not do it, deliberately:arraySetqueues three side exits (shape, bounds, value);arrayGetqueues a different setarraySetruns a hoisted fast path before the guards and returns early from inside it(bool, bool)vsboolA combinator covering all of that would take more parameters than it removes, in the code where a mistake is a use-after-free rather than a style problem. The repetition here is real but shallow; the abstraction would be deep and speculative.
arrayGetKnownandarrayKindare also left alone — both dispatch on the concrete Go type of a live heap value rather than on an itab, which is a different mechanism.Test plan
go test -race ./...make lint,make check-generatedRefs #164
🤖 Generated with Claude Code