Skip to content

Move cold opcode bodies out of the VM dispatch loop#193

Open
hadashiA wants to merge 1 commit into
mainfrom
claude/vm-hot-cold-split
Open

Move cold opcode bodies out of the VM dispatch loop#193
hadashiA wants to merge 1 commit into
mainfrom
claude/vm-hot-cold-split

Conversation

@hadashiA

Copy link
Copy Markdown
Owner

Summary

Shrinks the interpreter's giant dispatch method by moving cold opcode bodies into [MethodImpl(NoInlining)] local functions, following the extraction pattern already used for Class/Module/Exec/Rescue/RaiseIf etc.

Extracted

  • OP_ARGARY — whole body
  • OP_KARG — whole body
  • OP_HASH / OP_HASHADD — literal-building loops
  • SendInternal's method-visibility validation (the check stays inline; raise-path arg building moves out)
  • EnterSlowPath — was an un-annotated local function; now pinned NoInlining so the JIT can never inline its ~150 lines back into the dispatch loop

Execute IL: 13,220 → 12,235 bytes; Tier1 native code: 26.5KB → 24.1KB (−9%).

Numbers (order-alternated pairs, within-pair comparison, vs #191)

benchmark before after
optcarrot 23.9–24.0 fps 24.4–24.5 fps (+2.2%), checksum 59662
bm_ao_render ~2735 ms ~2597 ms (−5.1%)
bm_ivar neutral
bm_so_mandelbrot ~815 ms ~888 ms (+9%) — known regression

The mandelbrot regression is a code-placement effect on the Float fast path of Add..Div, not an execution-path change: bisecting showed even extracting only OP_ARGARY (which never executes in mandelbrot) reproduces it, and four different extraction combinations all land at the same ~+9%. optcarrot and ao improve consistently across all rounds. Mandelbrot-style float loops are the workload where the mrb2cs AOT path already delivers ~16x, so the interpreter trade-off favors the real workloads.

Tests

157 passed; all TFMs build; optcarrot video checksum identical.

🤖 Generated with Claude Code

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