8231630: Optimize boot loader with no bootclasspath append entry.
Summary: Optimize SystemDictionary::load_instance_class for boot loader. Immediately return NULL if the requested class is either in the unnamed package or unnamed module, or in a module not defined to the boot loader, when there is no bootclasspath append entry.
Reviewed-by: martin, aeubanks, dthomson, redestad, lfoltan, iklam
--- a/src/hotspot/share/classfile/classLoader.hpp Mon Oct 07 17:12:22 2019 +0200
+++ b/src/hotspot/share/classfile/classLoader.hpp Mon Oct 07 11:29:10 2019 -0700
@@ -237,6 +237,8 @@
CDS_ONLY(static ClassPathEntry* app_classpath_entries() {return _app_classpath_entries;})
CDS_ONLY(static ClassPathEntry* module_path_entries() {return _module_path_entries;})
+ static bool has_bootclasspath_append() { return _first_append_entry != NULL; }
+
protected:
// Initialization:
// - setup the boot loader's system class path
--- a/src/hotspot/share/classfile/systemDictionary.cpp Mon Oct 07 17:12:22 2019 +0200
+++ b/src/hotspot/share/classfile/systemDictionary.cpp Mon Oct 07 11:29:10 2019 -0700
@@ -1432,6 +1432,11 @@
// a named package within the unnamed module. In all cases,
// limit visibility to search for the class only in the boot
// loader's append path.
+ if (!ClassLoader::has_bootclasspath_append()) {
+ // If there is no bootclasspath append entry, no need to continue
+ // searching.
+ return NULL;
+ }
search_only_bootloader_append = true;
}
}