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
8293979: Resolve JVM_CONSTANT_Class references at CDS dump time #10330
8293979: Resolve JVM_CONSTANT_Class references at CDS dump time #10330
Conversation
👋 Welcome back iklam! A progress list of the required criteria for merging this PR into |
Webrevs
|
@iklam This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Ping - any reviewers? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have questions.
if (created) { | ||
InstanceKlass* super = ik->java_super(); | ||
if (super != NULL) { | ||
add_one_vm_class(super); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you care about order? Would it be better to add the superclasses before the instanceKlass?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order doesn't matter since this is a hashtable. Also, I am trying to avoid walking up the hierarchy if a class is already in the table.
} | ||
|
||
#if INCLUDE_CDS_JAVA_HEAP | ||
void ClassPrelinker::resolve_string(constantPoolHandle cp, int cp_index, TRAPS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this function only needed in this cpp file? Can you make it static and defined before its caller? Are there other functions where this is true? Does it need to be a member function of ClassPrelinker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to make such methods private, so it can access other private members of the same class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but this doesn't reference other private members of the class. The nice thing about it being a static non-member function is that you can easily see this without looking anywhere else. Also, it can be defined above the caller, which is where it's easy to find.
It's something that varies with developers but I like the style where you read a new file and see little function, little function, etc, leading up to the big function that calls them all.
|
||
CPKlassSlot kslot = cp->klass_slot_at(cp_index); | ||
int name_index = kslot.name_index(); | ||
Symbol* name = cp->symbol_at(name_index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this klass_name_at() ? I think these details should stay in constantPool.cpp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to use klass_name_at().
} | ||
} | ||
|
||
bool ClassPrelinker::can_archive_resolved_klass(ConstantPool* cp, int cp_index) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the other can_archive_resolved_klass be just above this one so we know why their names are the same? Also can_archive_vm_resolved_klass is too closely named.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the two can_archive_resolved_klass()
functions next to each other. I also folded can_archive_vm_resolved_klass
into can_archive_resolved_klass(InstanceKlass*, Klass*)
, simplified it and improved the comments.
|
||
Klass* ClassPrelinker::get_resolved_klass_or_null(ConstantPool* cp, int cp_index) { | ||
if (cp->tag_at(cp_index).is_klass()) { | ||
CPKlassSlot kslot = cp->klass_slot_at(cp_index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another place that CPKlassSlot leaks out. It would be nice if these were in constantPool. Maybe this function belongs in the constant pool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to use ConstantPool::resolved_klass_at() instead.
|
||
ClassPrelinker::ClassPrelinker() { | ||
assert(_singleton == NULL, "must be"); | ||
_singleton = this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why you have this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to put the states of the ClassPrelinker in its instance fields, but this is probably confusing. I'll change ClassPrelinker to AllStatic instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like you did this.
} | ||
|
||
#if INCLUDE_CDS_JAVA_HEAP | ||
void ClassPrelinker::resolve_string(constantPoolHandle cp, int cp_index, TRAPS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but this doesn't reference other private members of the class. The nice thing about it being a static non-member function is that you can easily see this without looking anywhere else. Also, it can be defined above the caller, which is where it's easy to find.
It's something that varies with developers but I like the style where you read a new file and see little function, little function, etc, leading up to the big function that calls them all.
|
||
ClassPrelinker::ClassPrelinker() { | ||
assert(_singleton == NULL, "must be"); | ||
_singleton = this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like you did this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the third read is the charm but this makes sense to me, and looks good.
@iklam This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 37 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just one nit in constantPool.cpp.
@@ -388,44 +373,69 @@ void ConstantPool::remove_unshareable_info() { | |||
resolved_references() != NULL ? resolved_references()->length() : 0); | |||
set_resolved_references(OopHandle()); | |||
|
|||
int num_klasses = 0; | |||
bool archived = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this declaration could be moved to line 392 since it is only used in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Thanks to @coleenp and @calvinccheung for the review. Passed tiers1-2. |
Going to push as commit aad81f2.
Your commit was automatically rebased without conflicts. |
Some
JVM_CONSTANT_Class
entries are guaranteed to resolve to the same value at both CDS dump time and run time:vmClasses::resolve_all()
. These classes cannot be replaced by JVMTI agents at run time.C
can be loaded from the CDS archive only if all ofC
's super types are also loaded from the CDS archive. Therefore, we know that aJVM_CONSTANT_Class
reference to a supertype ofC
must resolved to the same value at both CDS dump time and run time.By doing the resolution at dump time, we can speed up run time start-up by a little bit.
The
ClassPrelinker
class added by this PR will also be used in future REFs for pre-resolving other constant pool entries. The ultimate goal is to resolveinvokedynamic
andinvokehandle
so we can significantly improve the start-up time of features such as Lambda expressions and String concatenation. See JDK-8293336Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10330/head:pull/10330
$ git checkout pull/10330
Update a local copy of the PR:
$ git checkout pull/10330
$ git pull https://git.openjdk.org/jdk pull/10330/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 10330
View PR using the GUI difftool:
$ git pr show -t 10330
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10330.diff