Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a dynamic linker that understands consts #1686

Merged
merged 1 commit into from
Oct 12, 2024

Conversation

gbrail
Copy link
Collaborator

@gbrail gbrail commented Oct 7, 2024

This is an optimization that plugs in to the dynamic linking framework to make bytecode operations that should result in constant values efficiently return a const and avoid a whole bunch of hash table lookup operations. It can make scripts much faster IF and only if they use the "const" keyword.

@p-bakker
Copy link
Collaborator

p-bakker commented Oct 8, 2024

Awesome!

Question though: Rhino currently only supports function & scope-level consts, not block-level. While attempting to add block-level const support, I so far just focused on interpreted mode, but I assume already or otherwise due to this change, changes would be required on the bytecode generation side as well?

@gbrail
Copy link
Collaborator Author

gbrail commented Oct 8, 2024

This works at a much lower level -- when it comes time to look up a property or a value on the current scope, that's when this code gets activated, and it checks to see whether that property was marked as a constant. So, whatever happens at the higher levels, this code is unaffected.

If you're having to make changes to the "interpreter" to make scope-level consts work (as opposed to the AST or the IR), then yes, we'll probably have to make similar changes to the bytecode generation. Once you have an idea of what those changes are I can look at the bytecode generation if you'd like.

The ConstAwareLinker turns invocations to look up object properties and
variables that are truly constant into constants in the JVM. This makes
constants massively faster -- when people use them.
@gbrail gbrail merged commit 66f978c into mozilla:master Oct 12, 2024
1 check passed
@gbrail gbrail deleted the indy-9-add-constants branch October 12, 2024 00:09
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.

2 participants