-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8298601: Refactor archiving of java.lang.Module objects #11715
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
8298601: Refactor archiving of java.lang.Module objects #11715
Conversation
👋 Welcome back iklam! A progress list of the required criteria for merging this PR into |
Webrevs
|
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 suggested some name changes that might be helpful to people who don't already know this code, but the movement seems fine.
} | ||
|
||
#ifndef PRODUCT | ||
void ModuleEntry::validate_archived_module_entries() { |
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 this have a check_module_entries name since it's called by a similarly sounding function name in Modules? It doesn't actually validate anything in the module entries except the count.
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 renamed it to ModuleEntry::verify_archived_module_entries()
to be consistent with Modules::verify_archived_modules()
.
|
||
if (log_is_enabled(Info, cds, module)) { | ||
ResourceMark rm; | ||
log_info(cds, module)("Restored archived %s", debug_info()); |
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 don't know if stringStream needs a resource mark so if it doesn't, you can just have one log line for these.
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 used StringStream::as_string(bool c_heap = false)
to return from debug_info()
, so the result is resource allocated.
Anyway, I can see that this style may be confusing. I'll rewrite it to follow the print_on(st)
style that's more common where the semantics are well understood. This will make the logging a little more tedious but I think it's OK.
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 a few minor comments.
@@ -53,8 +53,12 @@ class Modules : AllStatic { | |||
static void define_module(Handle module, jboolean is_open, jstring version, | |||
jstring location, jobjectArray packages, TRAPS); | |||
|
|||
static bool check_module_oop(oop orig_module_obj); |
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 needs NOT_CDS_JAVA_HEAP_RETURN_(false)
at the end.
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.
ModuleEntry* ModuleEntry::allocate_archived_entry() const { | ||
assert(is_named(), "unnamed packages/modules are not archived"); | ||
ModuleEntry* archived_entry = (ModuleEntry*)ArchiveBuilder::rw_region_alloc(sizeof(ModuleEntry)); | ||
memcpy((void*)archived_entry, (void*)this, sizeof(ModuleEntry)); | ||
archived_entry->_archived_module_index = -2; |
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.
Why not use -1 as the initial value?
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.
if (loader_data()->is_boot_class_loader_data()) { | ||
info.print("boot"); | ||
} else if (SystemDictionary::is_platform_class_loader(loader_data()->class_loader())) { | ||
info.print("platform"); | ||
} else if (SystemDictionary::is_system_class_loader(loader_data()->class_loader())) { | ||
info.print("system"); | ||
} |
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 could be simplified to
info.print(loader_data()->loader_name());
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 the code to use ModuleEntry::print()
instead, which internally calls loader_data()->loader_name_and_id()
.
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.
Updates look good. Thanks.
@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 no new commits pushed to the ➡️ 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.
Thanks @calvinccheung and @coleenp for the review. |
Going to push as commit 82deb5c.
Your commit was automatically rebased without conflicts. |
This RFE is a prerequisite for JDK-8296344: Remove dependency on G1 for writing the CDS archive heap.
The main change of this RFE is in
HeapShared::archive_reachable_objects_from()
. We avoid the use of "archived objects" in the interface between CDS and the module system, and use integer "root indices" instead. (See note [1] in JDK-8298600.)Also, for better encapsulation, the module-specific code has been moved from
HeapShared::check_module_oop()
to the three new functions in modules.cpp.Besides the refactoring, this RFE also tightens up the code that deals with
java.lang.Module
oops and the corresponding C++ModuleEntry
objects.As this is admittedly an obscured area of the CDS archive heap, I've added the following:
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/11715/head:pull/11715
$ git checkout pull/11715
Update a local copy of the PR:
$ git checkout pull/11715
$ git pull https://git.openjdk.org/jdk pull/11715/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 11715
View PR using the GUI difftool:
$ git pr show -t 11715
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/11715.diff