Skip to content

interpreterv2 operands.#2446

Open
aardvark179 wants to merge 2 commits into
mozilla:masterfrom
aardvark179:aardvark179-interpreterv2-operands
Open

interpreterv2 operands.#2446
aardvark179 wants to merge 2 commits into
mozilla:masterfrom
aardvark179:aardvark179-interpreterv2-operands

Conversation

@aardvark179

Copy link
Copy Markdown
Contributor

This PR is the next part #2426 and introduces the operands used by the interpreter V2 instructions.

@aardvark179

Copy link
Copy Markdown
Contributor Author

@gbrail ir @rbri, could you kick the failed job off again? I think it's a transient infrastructure failure.

@gbrail

gbrail commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Just stylistic questions on this:

First, is there a good reason for all these classes to be "final"? I know that sometimes it affects performance but generally we don't make classes final unless we're really sure we need that and we're really sure that it helps with performance. (I do love to make private variables final but that's a different use of final IMO.)

Second, I see that some of the methods, like "retrieve," return boxed types like Double and Integer and other methods return double and int. Obviously we want to avoid boxing and unboxing until we no choice, and Java is pretty good these days at autoboxing in the compiler. Do we need it there? (Or is it a way to specify an "optional" result?")

@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.

Just a few more small things, thanks for reading!


@Override
public boolean isDouble(CallFrameV2 frame) {
return value == -1.0;

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 don't understand what this is supposed to do. Is an int ever a double?

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 don't understand this either. Yes, a double value (not a Double) can be compared to an int and will cause type promotion of the int side, but I'm not sure what it's intended to achieve here. @camnwalter, do you know what was intended? If you can't remember I'll change this to false.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe this is from something we check internally in our fork (for reasons I don't know), and when making interpreter v2, we wanted to copy the existing interpreter as closely as possible. I'm fairly sure we don't use it anywhere in this repo, so it should be fine to change it.


@Override
public boolean isDouble(CallFrameV2 frame) {
return value == -1.0;

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.

Same question here as for IntOperand.

if (!frame.useActivation) {
return frame.getVarAndWrap(index);
} else {
String name = frame.fnOrScript.getDescriptor().getParamOrVarName(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.

Other methods here use "index" as the parameter not "offset". Is this right? It confused by AI...

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