JDK-8240245 : Avoid calling is_shared_class_visible() in SystemDictionary::load_shared_class()
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 15
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-02-28
  • Updated: 2024-10-17
  • Resolved: 2020-06-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15 JDK 16
15 b27Fixed 16Fixed
Related Reports
Relates :  
Relates :  
Description
http://hg.openjdk.java.net/jdk/jdk/file/7ef41e83066b/src/hotspot/share/classfile/systemDictionary.cpp#l1268

is_shared_class_visible() might be time consuming because it needs to look up PackageEntry and ModuleEntry. However, if we are running the JVM without any of the following:

    bootclasspath append
    --limit-modules
    --upgrade-module-path

is_shared_class_visible() will always return true, so we can skip the call to improve start-up time.

Comments
Changeset: 96fadefa Author: Yumin Qi <minqi@openjdk.org> Date: 2020-06-10 23:16:27 +0000 URL: https://git.openjdk.java.net/lanai/commit/96fadefa
02-07-2020

URL: https://hg.openjdk.java.net/jdk/jdk/rev/3c69cce3c041 User: minqi Date: 2020-06-11 06:16:42 +0000
11-06-2020

--module-path if not specified, skip the check. If specified at runtime, if it is same as dump time, we do not need check visibility further, but we have to since we did not archive this property("jdk.module.path"). For --limit-modules and --upgrade-module-path, if they specified for run time, CDS will be disabled, so don't need check them.
22-05-2020

To cache PackageEntry span the functions seems complicated. In SystemDictionary::is_shared_class_visible, the get entry in fact is in SystemDictionaryShared::is_shared_class_visible_for_classloader, but that check is for checking if the entry can be found from platform loader or system class loader. Some return path will skip the check.
21-05-2020

We actually seem to look up the PackageEntry twice in the scope of SystemDictionary::load_shared_class. Once in SystemDictionary::is_shared_class_visible and once in IK::set_package. So an alternative optimization might be to hold on to the looked up PackageEntry and pass it on so that InstanceKlass::restore_unshareable_info can avoid calling (or call an alternate, simplified) InstanceKlass::set_package.
19-03-2020