[GR-59419] Implement compact constant pools. #11128
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 passingPoolConstant
s around, you must passConstantPool
+cpi
instead.I tried to avoid exposing the indices as much as I could e.g.
Symbol<Name> name = cp.className(classIndex)
instead ofint nameIndex = cp.classNameIndex(classIndex);
Additional metadata savings
I did some further cleanups like reducing the footprint of attributes, removed
LinkedMethod
and purged theUtfConstantTable
.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
.