8231630: Optimize boot loader with no bootclasspath append entry

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
This commit is contained in:
Jiangli Zhou 2019-10-07 11:29:10 -07:00
parent 67a0aa7960
commit 874037d252
2 changed files with 7 additions and 0 deletions
src/hotspot/share/classfile

@ -237,6 +237,8 @@ class ClassLoader: AllStatic {
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

@ -1432,6 +1432,11 @@ InstanceKlass* SystemDictionary::load_instance_class(Symbol* class_name, Handle
// 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;
}
}