-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8360555: Archive all unnamed modules in CDS full module graph #26082
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
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back iklam! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
#if INCLUDE_CDS_JAVA_HEAP | ||
if (CDSConfig::is_using_full_module_graph()) { | ||
precond(unnamed_module == ClassLoaderDataShared::archived_boot_unnamed_module()); | ||
unnamed_module->restore_archived_oops(boot_loader_data); |
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.
If you're restoring the module oop from the archive, what is the module oop passed into this that the rest of the code is using?
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.
If you're storing the unnamed module oop in the archive should this method not be called? If it is, what are you saving by archiving the unnamed module?
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 callstack is:
jdk.internal.loader.BootLoader.setBootLoaderUnnamedModule0(java.base@26-internal/Native Method)
jdk.internal.loader.BootLoader.<clinit>(java.base@26-internal/BootLoader.java:71)
jdk.internal.module.ModuleBootstrap.boot(java.base@26-internal/ModuleBootstrap.java:162)
java.lang.System.initPhase2(java.base@26-internal/System.java:1932)
Both the Java code and the native code have a handle to this unnamed module oop. The precond
checks that they indeed are pointing the same oop.
Also, even though the oop is archived, we still need to set up some native states inside the unnamed_module->restore_archived_oops(boot_loader_data)
call. E.g., set up the OopHandle
that binds the oop to the ModuleEntry
.
what are you saving by archiving the unnamed module?
It's for JDK-8350550) -- I want to be able to reference the unnamed module before executing any Java code, so that archived classes can be loaded at the very beginning of vmClasses::resolve_all()
. See my draft PR: #26375
Currently, we still execute a lot of Java code when setting up the archived module graph (inside ModuleBootstrap.boot()
. I am working on a way to enable the archived module graph without executing any Java code (which will be a few REFs after JDK-8350550), so this call will eventually be gone.
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.
Ok, I see. At this point, you're just checking that what you've referred to before loading the unnamed module matches what you've previously saved in the shared archive. Did I get that right?
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.
Yes, it's checking that the Java and C++ code both found the same archived unnamed module.
UNNAMED_MODULE = archivedClassLoaders.unnamedModuleForBootLoader(); | ||
} else { | ||
UNNAMED_MODULE = jla.defineUnnamedModule(null); | ||
} | ||
jla.addEnableNativeAccess(UNNAMED_MODULE); | ||
setBootLoaderUnnamedModule0(UNNAMED_MODULE); |
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.
Here it's being called. Should this be called?
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 code looks good.
#if INCLUDE_CDS_JAVA_HEAP | ||
if (CDSConfig::is_using_full_module_graph()) { | ||
precond(unnamed_module == ClassLoaderDataShared::archived_boot_unnamed_module()); | ||
unnamed_module->restore_archived_oops(boot_loader_data); |
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.
Ok, I see. At this point, you're just checking that what you've referred to before loading the unnamed module matches what you've previously saved in the shared archive. Did I get that right?
@iklam this pull request can not be integrated into git checkout 8360555-archive-all-unnamed-modules
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
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.
The CDS full module graph is supposed to contain a snapshot of the boot layer, which has 3 unnamed modules for the boot, platform and system class loaders. Each unnamed module is represented by a
java.lang.Module
Java object and aModuleEntry
C++ object.Currently, we archive only the
java.lang.Module
for the platform and system loaders. The other 4 objects are dynamically created in the production run while executing Java bytecodes during VM bootstrap.With this PR, we archive all of the above 6 objects when
CDSConfig::is_dumping_full_module_graph()
is true.This is required for JDK-8350550, as we need the
java.lang.Module
object for archived classes in the unnamed module of the boot loader prior to executing any Java code.We also archive the
ModuleEntry
objects for the 3 unnamed modules for uniformity, as these objects are already archived for named modules.Progress
Warnings
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26082/head:pull/26082
$ git checkout pull/26082
Update a local copy of the PR:
$ git checkout pull/26082
$ git pull https://git.openjdk.org/jdk.git pull/26082/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26082
View PR using the GUI difftool:
$ git pr show -t 26082
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26082.diff
Using Webrev
Link to Webrev Comment