Skip to content

refactor(instr): carry call, local-write, and container-store as opcode flags - #198

Merged
siyul-park merged 1 commit into
mainfrom
refactor/instr-opcode-facets
Aug 16, 2026
Merged

siyul-park merged 1 commit into
mainfrom
refactor/instr-opcode-facets

Conversation

@siyul-park

Copy link
Copy Markdown
Owner

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:

  • is it a call — op == CALL || op == RETURN_CALL, written out in eight places across the planner, the lowerer, and the tracer
  • does it assign a local — LOCAL_SET, LOCAL_TEE
  • does it store into a heap container — ARRAY_SET, STRUCT_SET

instr.Type already carries an opcode's mnemonic, operand widths, and stack effect, so these belong there too. Added a Flags field with FlagCall, FlagLocalWrite, FlagContainerStore, and the predicates IsCall, 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 an if reads 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-563 consumes instr.Type.Pop/Push generically
  • interp/jit_plan.go:1421-1432 — applyStep has the same generic fallback at its tail
  • internal/cmd/geninterp/lower.go:653 reads instr.TypeOf(consumer).Push

All 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 escape instr.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-generated

Refs #164

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@siyul-park, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2066d0b2-10b2-482b-ba4c-6f19d2417f37

📥 Commits

Reviewing files that changed from the base of the PR and between 97d80d0 and 550ff75.

📒 Files selected for processing (4)
  • instr/type.go
  • interp/jit_arm64.go
  • interp/jit_plan.go
  • interp/trace.go

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…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>
@siyul-park
siyul-park force-pushed the refactor/instr-opcode-facets branch from 2232dc0 to 550ff75 Compare August 16, 2026 06:11
@siyul-park
siyul-park changed the base branch from fix/jit-selfcall-locals to main August 16, 2026 06:11
@siyul-park
siyul-park merged commit 05b50f5 into main Aug 16, 2026
2 of 3 checks passed
@siyul-park
siyul-park deleted the refactor/instr-opcode-facets branch November 7, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant