Skip to content

New faster interpreter based on instruction objects and operands. - #2426

Draft
aardvark179 wants to merge 55 commits into
mozilla:masterfrom
aardvark179:aardvark179-interpreterv2
Draft

aardvark179 wants to merge 55 commits into
mozilla:masterfrom
aardvark179:aardvark179-interpreterv2

Conversation

@aardvark179

Copy link
Copy Markdown
Contributor

This change implements a new interpreter based on Instruction objects 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.

@aardvark179
aardvark179 force-pushed the aardvark179-interpreterv2 branch 2 times, most recently from 9d1fbcb to 65e41ce Compare June 6, 2026 21:02
@aardvark179
aardvark179 force-pushed the aardvark179-interpreterv2 branch from 65e41ce to f61759b Compare June 10, 2026 10:48
@aardvark179
aardvark179 force-pushed the aardvark179-interpreterv2 branch from f61759b to 7f70f9b Compare June 15, 2026 09:10
@aardvark179
aardvark179 force-pushed the aardvark179-interpreterv2 branch from 386c662 to 3699113 Compare June 17, 2026 09:56
@aardvark179
aardvark179 force-pushed the aardvark179-interpreterv2 branch 4 times, most recently from 9f5cb25 to b81c666 Compare June 24, 2026 13:38
@aardvark179
aardvark179 force-pushed the aardvark179-interpreterv2 branch from b81c666 to 70c3b25 Compare June 30, 2026 11:20
@aardvark179
aardvark179 force-pushed the aardvark179-interpreterv2 branch 3 times, most recently from fc7afed to 418d2c9 Compare July 21, 2026 17:15
@aardvark179
aardvark179 force-pushed the aardvark179-interpreterv2 branch 3 times, most recently from 29fa1d7 to f9ab208 Compare August 2, 2026 19:35
@aardvark179
aardvark179 force-pushed the aardvark179-interpreterv2 branch from f9ab208 to 301a01e Compare August 26, 2026 14:39
@aardvark179
aardvark179 force-pushed the aardvark179-interpreterv2 branch 3 times, most recently from 94f7455 to 2dc09ee Compare September 14, 2026 10:40
@aardvark179

Copy link
Copy Markdown
Contributor Author

So the test failure appears to be due to some refactoring in the V2 compiler just pushing it over the edge in terms of stack usage. It passes on my local machine, but increasing the size of the expression a little bit pushes it over the edge. I'm going to try a couple of approaches to refactoring the compiler to avoid this, but from some experimentation it's clear we've always been sailing close to the wind in terms of stack depth and this test.

@aardvark179
aardvark179 force-pushed the aardvark179-interpreterv2 branch from ad8ba09 to 8893380 Compare September 15, 2026 15:36
@aardvark179
aardvark179 force-pushed the aardvark179-interpreterv2 branch from 428a86c to cd2fd9c Compare September 28, 2026 16:23
@aardvark179
aardvark179 force-pushed the aardvark179-interpreterv2 branch from cd2fd9c to 73e8be5 Compare September 28, 2026 16:51

This branch has not been deployed

No deployments
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