Move cold opcode bodies out of the VM dispatch loop#193
Open
hadashiA wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Shrinks the interpreter's giant dispatch method by moving cold opcode bodies into
[MethodImpl(NoInlining)]local functions, following the extraction pattern already used forClass/Module/Exec/Rescue/RaiseIfetc.Extracted
OP_ARGARY— whole bodyOP_KARG— whole bodyOP_HASH/OP_HASHADD— literal-building loopsSendInternal's method-visibility validation (the check stays inline; raise-path arg building moves out)EnterSlowPath— was an un-annotated local function; now pinnedNoInliningso the JIT can never inline its ~150 lines back into the dispatch loopExecuteIL: 13,220 → 12,235 bytes; Tier1 native code: 26.5KB → 24.1KB (−9%).Numbers (order-alternated pairs, within-pair comparison, vs #191)
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 onlyOP_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