Skip to content

[GR-59419] Implement compact constant pools. #11128

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

Merged
merged 1 commit into from
May 5, 2025

Conversation

graalvmbot
Copy link
Collaborator

@graalvmbot graalvmbot commented May 5, 2025

This PR implements compact constant pools which are shared by both Espresso and Crema.
It reduces the footprint of the .class metadata by avoiding wrapper objects for every CP entry, it saves ~6MB from the default libjavavm.so . It also removes a net ~1300 lines of code.

On AWFY, there's a 2.4% interpreter speedup and 7.6% RSS savings, note that metadata footprint is reduced by a larger factor, but it only accounts for a relatively small part of the RSS compared to Truffle/compiler and the memory used by applications.

Some history
The constant pool was introduced in the very first Espresso commit, by Doug, based on Maxine. At the time, the footprint of the metadata was already a concern, but we couldn't really measure it, so we postponed any (deemed premature) optimizations. This PR finally tackles the longstanding CP metadata overhead.

Main changes
PoolConstant and all its sub-classes are removed, the new CP provides methods to retrieve the metadata for every constant type. With the new design instead of passing PoolConstants around, you must pass ConstantPool + cpi instead.
I tried to avoid exposing the indices as much as I could e.g. Symbol<Name> name = cp.className(classIndex) instead of int nameIndex = cp.classNameIndex(classIndex);

Additional metadata savings
I did some further cleanups like reducing the footprint of attributes, removed LinkedMethod and purged the UtfConstantTable.

The PR is somehow disruptive, to make the review easier:
The Espresso JVMCI implementation uses RuntimeConstantPool#peekResolvedOrNull instead,
Thomas: this PR touches the verifier; the changes are minimal and it really helped that the verifier works mostly with the ImmutableConstantPool.
Allan: there are some minor changes in redefinition, in some places I had to obtain the CP from the declaring class and NOT from the MethodVersion.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label May 5, 2025
@graalvmbot graalvmbot closed this May 5, 2025
@graalvmbot graalvmbot deleted the a2p/crema-constant-pool branch May 5, 2025 15:44
@graalvmbot graalvmbot merged commit b871606 into master May 5, 2025
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants