RFR: 8298601: Refactor archiving of java.lang.Module objects
Calvin Cheung
ccheung at openjdk.org
Thu Dec 22 03:06:51 UTC 2022
On Mon, 19 Dec 2022 05:28:39 GMT, Ioi Lam <iklam at openjdk.org> wrote:
> This RFE is a prerequisite for [JDK-8296344: Remove dependency on G1 for writing the CDS archive heap](https://bugs.openjdk.org/browse/JDK-8296344).
>
> 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](https://bugs.openjdk.org/browse/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:
>
> - Assertions to make sure that when an oop is archived, the corresponding C++ object is also archived, and vice-versa.
> - More comments
I have a few minor comments.
src/hotspot/share/classfile/moduleEntry.cpp line 399:
> 397: ModuleEntry* archived_entry = (ModuleEntry*)ArchiveBuilder::rw_region_alloc(sizeof(ModuleEntry));
> 398: memcpy((void*)archived_entry, (void*)this, sizeof(ModuleEntry));
> 399: archived_entry->_archived_module_index = -2;
Why not use -1 as the initial value?
src/hotspot/share/classfile/moduleEntry.cpp line 516:
> 514: } else if (SystemDictionary::is_system_class_loader(loader_data()->class_loader())) {
> 515: info.print("system");
> 516: }
I think this could be simplified to
`info.print(loader_data()->loader_name());`
src/hotspot/share/classfile/modules.hpp line 56:
> 54: jstring location, jobjectArray packages, TRAPS);
> 55:
> 56: static bool check_module_oop(oop orig_module_obj);
I think this needs `NOT_CDS_JAVA_HEAP_RETURN_(false)` at the end.
-------------
PR: https://git.openjdk.org/jdk/pull/11715
More information about the hotspot-runtime-dev
mailing list