Repository navigation
refactor(instr): carry call, local-write, and container-store as opcode flags - #198
Conversation
|
Warning Review limit reached
Next review available in: 22 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 (4)
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 |
…de flags Three static facts about an opcode were re-derived from inline opcode lists at every use site: whether it calls, whether it assigns a local, and whether it stores into a heap container. The call test alone appeared in eight places across the planner, the lowerer, and the tracer, each spelling out `op == CALL || op == RETURN_CALL`. instr.Type already carries an opcode's mnemonic, operand widths, and stack effect, so these belong there too. Add a Flags field with FlagCall, FlagLocalWrite, and FlagContainerStore, and the predicates IsCall, WritesLocal, and StoresContainer that read it. callFree, noSpill, hoistable, carried, the static planner's call-target tracking, the lowerer's leaf detection and call fusion, and two tracer sites now share those predicates. Adding an opcode that calls or stores no longer means finding every list that should have mentioned it. Multi-way switches that dispatch on the opcode keep their `case CALL, RETURN_CALL:` arms - those select behaviour per opcode rather than asking a yes/no question, and an if would read worse inside them. No behavior change: the flags reproduce exactly the opcode sets the inline lists named. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2232dc0 to
550ff75
Compare
Stage 1 of the JIT lowering rework. Stacked on #197.
Change
Three static facts about an opcode were re-derived from inline opcode lists at every use site:
op == CALL || op == RETURN_CALL, written out in eight places across the planner, the lowerer, and the tracerLOCAL_SET, LOCAL_TEEARRAY_SET, STRUCT_SETinstr.Typealready carries an opcode's mnemonic, operand widths, and stack effect, so these belong there too. Added aFlagsfield withFlagCall,FlagLocalWrite,FlagContainerStore, and the predicatesIsCall,WritesLocal,StoresContainer.callFree,noSpill,hoistable,carried, the static planner's call-target tracking, the lowerer's leaf detection and call fusion, and two tracer sites now share them. Adding an opcode that calls or stores no longer means finding every list that should have mentioned it.Multi-way switches that dispatch on the opcode keep their
case CALL, RETURN_CALL:arms — those select behaviour per opcode rather than asking a yes/no question, and anifreads worse inside them.No behavior change: the flags reproduce exactly the opcode sets the inline lists named.
A correction to the plan this came from
The audit behind this work claimed "stack effects are implemented three times" and that a follow-up stage should unify them. That is wrong, and I am recording it rather than acting on it:
program/verify.go:551-563consumesinstr.Type.Pop/Pushgenericallyinterp/jit_plan.go:1421-1432—applyStephas the same generic fallback at its tailinternal/cmd/geninterp/lower.go:653readsinstr.TypeOf(consumer).PushAll three already read the table.
applyStep's 22 bespoke cases are exactly the provenance-tracking (backing,slot, declared struct/array type, known constant) and dynamic-arity opcodes — which is precisely the escapeinstr.Type's own doc carves out: "When both Pop and Push are nil the opcode has no statically fixed effect."So there is no third implementation to remove, and that stage is dropped.
Test plan
go test -race ./...make lint,make check-generatedRefs #164
🤖 Generated with Claude Code