8382584: [lworld] Mandatory pre-loading still present in systemDictionary.cpp#2409
8382584: [lworld] Mandatory pre-loading still present in systemDictionary.cpp#2409caspernorrbin wants to merge 5 commits into
Conversation
|
👋 Welcome back cnorrbin! A progress list of the required criteria for merging this PR into |
|
@caspernorrbin 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 3 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@coleenp) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
| // A false return means that the class didn't load for other reasons than an exception. | ||
| bool check = preload_from_null_free_field(ik, class_loader, sig, field_index, CHECK_NULL); | ||
| if (!check) { | ||
| ik->set_shared_loading_failed(); |
There was a problem hiding this comment.
Can we safely drop this failure marking?
There was a problem hiding this comment.
It's used for regular shared class loading so I don't think we can drop this shared_loading_failed marker.
There was a problem hiding this comment.
Didn't realise that one was needed. I've re-added it, along with an edit to try_preload_from_loadable_descriptors so we can see if we failed or not. It now also has a new parameter that decides if failing means we call shared_loading_failed .
| // A false return means that the class didn't load for other reasons than an exception. | ||
| bool check = preload_from_null_free_field(ik, class_loader, sig, field_index, CHECK_NULL); | ||
| if (!check) { | ||
| ik->set_shared_loading_failed(); |
There was a problem hiding this comment.
It's used for regular shared class loading so I don't think we can drop this shared_loading_failed marker.
|
Following our offline discussions, I have now pushed a more robust version that:
|
| // Pre-load class referred to in non-static fields with archived inline field metadata. These fields | ||
| // must be checked against the resolved runtime class before the shared class can be used. | ||
| bool SystemDictionary::preload_from_required_inline_field(InstanceKlass* ik, Handle class_loader, Symbol* sig, int field_index, TRAPS) { | ||
| TempNewSymbol name = Signature::strip_envelope(sig); |
There was a problem hiding this comment.
This symbol is only used in logging, could it be possible to create it only when a message is logged?
There was a problem hiding this comment.
I have now wrapped the creation(s) inside if (is_log_enabled(...)).
| } else if (Signature::has_envelope(sig)) { | ||
| // Pending exceptions are cleared so we can fail silently | ||
| } else { | ||
| // Pending exceptions are cleared so we can fail silently. |
There was a problem hiding this comment.
Do we need this branch to attempt to preload? As long as we have the classes for the flattened fields, we should be OK. I would expect the other classes to be optional at this point
There was a problem hiding this comment.
This branch handles the speculative preloading from the LoadableDescriptors attribute for non-flat nullable fields, so it is not part of the required flat/null-restricted validation. I kept it to preserve the existing behavior where LoadableDescriptors can opportunistically load field classes. These loads are optional, failures are ignored and should not cause the shared loading to fail.
There was a problem hiding this comment.
I'm fine with leaving this for now but we should think further about this after the merge to mainline. With CDS, these field classes for non-flat fields will be loaded during ik->link_class() so this may be additional complexity we can simplify
|
|
||
| if (ik->has_inlined_fields()) { | ||
| for (AllFieldStream fs(ik); !fs.done(); fs.next()) { | ||
| if (fs.access_flags().is_static()) continue; |
There was a problem hiding this comment.
@fparain As per our discussion about nullresticted fields, this will need to be updated as well to not skip static fields
There was a problem hiding this comment.
Hmm, does this mean NR static fields may have non-reference layout?
There was a problem hiding this comment.
No, this is related to ensuring that NR fields at dump time and NR fields at restore time are consistent
There was a problem hiding this comment.
To @DanHeidinga , yes, null-restricted static fields should not be skipped, but this PR would need JDK-8384756 to be fixed before being able to implement this change.
coleenp
left a comment
There was a problem hiding this comment.
I guess I should un-review this since it's changed since my review.
Hi everyone,
This change removes the remaining mandatory preloading path for null-restricted instance fields when loading classes from CDS. JDK-8380053 already changed normal class loading so null-restricted field types are no longer loaded just because the field is null-restriced. Instead, the preloading is speculative and driven by the
LoadableDescriptorattribute. The CDS path still had the older special case inSystemDictionary::preload_from_null_free_field, which could force loading of null-restricted field types.This fix removes that CDS-only preload helper and routes non-static field signatures through the existing
LoadableDescriptorpath instead. This makes loading follow the same model as inClassFileParser::fetch_field_classes()with speculative loading.Testing:
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/2409/head:pull/2409$ git checkout pull/2409Update a local copy of the PR:
$ git checkout pull/2409$ git pull https://git.openjdk.org/valhalla.git pull/2409/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2409View PR using the GUI difftool:
$ git pr show -t 2409Using diff file
Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/2409.diff
Using Webrev
Link to Webrev Comment