Skip to content

Introduce main V2 interpreter loop.#2439

Open
aardvark179 wants to merge 1 commit into
mozilla:masterfrom
aardvark179:aardvark179-interpreterv2-infra-2
Open

Introduce main V2 interpreter loop.#2439
aardvark179 wants to merge 1 commit into
mozilla:masterfrom
aardvark179:aardvark179-interpreterv2-infra-2

Conversation

@aardvark179

Copy link
Copy Markdown
Contributor

This PR is the next part #2426 and introduces the main interpreter v2 interpreter loop, error handling code, and utilitiy functions used by multiple instructions. This will be followed by PRs for the operands and instructions, and finally by the compiler itself.

@@ -0,0 +1,30 @@
package org.mozilla.javascript.interpreterv2.instruction;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have to always add the common header?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. If we should add it to every file then we've done a bad job of that for a while, even Slot.java doesn't have a licence header.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually are, I got lazy about that, I think that there must be a tool that can fix this for us.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe spotless can enforce this, and I can certainly produce a PR to fill in the missing ones.

import org.mozilla.javascript.interpreterv2.InstructionFormatter;

public abstract class JumpInstruction extends Instruction {
protected int offset;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it make sense to have a protected field and a getter/setter for this internal class

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I made it private and have changed the upcoming commits to remove direct references.

@aardvark179 aardvark179 force-pushed the aardvark179-interpreterv2-infra-2 branch from dd8cebd to 373de53 Compare July 1, 2026 11:26

@gbrail gbrail left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be an old fuddy-duddy but I see lots of opportunities for unit tests in here, simple stuff like the "formatter" but even the actual bits of the interpreter too. I will not lose sleep if they are written by AI as long as they have decent coverage. It would make me more confident if I were writing the code myself (or with a tool) to have those additional tests as well.

@aardvark179

Copy link
Copy Markdown
Contributor Author

That's reasonable, I'll see what I can do.

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.

3 participants