Field flattening and calling convention optimizations require that value classes that are going to be optimized are loaded at the time the optimization is computed (respectively at class load time and class link time). For this purpose, classes compiled with --enable-preview contain a new attribute called LoadableDescriptors listing classes that the JVM is allowed to load before attempting these optimizations.
Classes compiled without --enable-preview, which include most of the JDK classes even when the JVM/JDK is run with --enable-preview, lack the LoadableDescriptors attribute, and this causes missed opportunities of optimizing layouts and calling conventions. This issue is specific to classes using classes that have been migrated to become value classes.
Trying to load all referenced classes to check for possible optimizations is not an option as it would create a lot of unnecessary class loading, consuming time and memory, and night even trigger errors as some classes might not be loadable. A more reasonable option would be to simply check already loaded classes, which would not trigger additional class loading.
Boxing classes (java.lang.Integer and companions) are loaded early during the boot process of the JVM, so the JVM has access to their layouts and could optimize them even in classes lacking the LoadableDescriptors attribute. However, when loading or linking a class, the search of optimizable value classes is performed in the context of the current class loader, which might not have resolved entries for those boxing classes even if they have already been loaded by the bootstrap class loader.
Classes in java.* are special and user class loaders are not allowed to provide an alternate version of these classes. Adding entries for these classes in all class loaders at registration time would allow the JVM to optimize boxing classes even for classes lacking the LoadableDescriptors attribute.
Classes compiled without --enable-preview, which include most of the JDK classes even when the JVM/JDK is run with --enable-preview, lack the LoadableDescriptors attribute, and this causes missed opportunities of optimizing layouts and calling conventions. This issue is specific to classes using classes that have been migrated to become value classes.
Trying to load all referenced classes to check for possible optimizations is not an option as it would create a lot of unnecessary class loading, consuming time and memory, and night even trigger errors as some classes might not be loadable. A more reasonable option would be to simply check already loaded classes, which would not trigger additional class loading.
Boxing classes (java.lang.Integer and companions) are loaded early during the boot process of the JVM, so the JVM has access to their layouts and could optimize them even in classes lacking the LoadableDescriptors attribute. However, when loading or linking a class, the search of optimizable value classes is performed in the context of the current class loader, which might not have resolved entries for those boxing classes even if they have already been loaded by the bootstrap class loader.
Classes in java.* are special and user class loaders are not allowed to provide an alternate version of these classes. Adding entries for these classes in all class loaders at registration time would allow the JVM to optimize boxing classes even for classes lacking the LoadableDescriptors attribute.
- relates to
-
JDK-8364483 [lworld] Pre-register migrated classes in class loaders
-
- Open
-
- links to
-
Commit(lworld) openjdk/valhalla/57a9aef0
-
Review(lworld) openjdk/valhalla/1517