New faster interpreter based on instruction objects and operands.#2426
Draft
aardvark179 wants to merge 27 commits into
Draft
New faster interpreter based on instruction objects and operands.#2426aardvark179 wants to merge 27 commits into
aardvark179 wants to merge 27 commits into
Conversation
9d1fbcb to
65e41ce
Compare
65e41ce to
f61759b
Compare
f61759b to
7f70f9b
Compare
386c662 to
3699113
Compare
This was referenced Jun 18, 2026
9f5cb25 to
b81c666
Compare
b81c666 to
70c3b25
Compare
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.
This change implements a new interpreter based on
Instructionobjects rather than byte codes. Instructions generally have one or two operands which express where they get their data from (literal values, variables, or the stack). Currently all instructions that produce results put those results on the stack, but in the future the operands concept could be extended to where the result is placed and provide further improvements.This design provides significant performance improvements over the old interpreter (see benchmarks in #2416 ) in return for a slightly increased memory overhead. This overhead is less than might be expected because operand objects can be heavily reused, fewer instructions are usually required for the V2 interpreter, and the byte code itself is often only a portion of the overall foot print of interpreted functions compared to constants, metadata, etc.
While upstreaming this work I've taken the opportunity to remove a lot of duplication between the two interpreters as inconsistencies between these were the source of a few issues while rebasing this work.