Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8240258: SystemDictionary::quick_resolve need guarded by INCLUDE_CDS
Supplemental fix for 8236604 to guard SystemDictionary::quick_resolve with CDS

Reviewed-by: iklam, ccheung
  • Loading branch information
yminqi committed Feb 29, 2020
1 parent f176fae commit 5bfb8146e99531e943b9ff36101c9921e876776d
Showing with 34 additions and 32 deletions.
  1. +33 −31 src/hotspot/share/classfile/systemDictionary.cpp
  2. +1 −1 src/hotspot/share/classfile/systemDictionary.hpp
@@ -1378,6 +1378,37 @@ void SystemDictionary::load_shared_class_misc(InstanceKlass* ik, ClassLoaderData
}
}
}

void SystemDictionary::quick_resolve(InstanceKlass* klass, ClassLoaderData* loader_data, Handle domain, TRAPS) {
assert(!Universe::is_fully_initialized(), "We can make short cuts only during VM initialization");
assert(klass->is_shared(), "Must be shared class");
if (klass->class_loader_data() != NULL) {
return;
}

// add super and interfaces first
Klass* super = klass->super();
if (super != NULL && super->class_loader_data() == NULL) {
assert(super->is_instance_klass(), "Super should be instance klass");
quick_resolve(InstanceKlass::cast(super), loader_data, domain, CHECK);
}

Array<InstanceKlass*>* ifs = klass->local_interfaces();
for (int i = 0; i < ifs->length(); i++) {
InstanceKlass* ik = ifs->at(i);
if (ik->class_loader_data() == NULL) {
quick_resolve(ik, loader_data, domain, CHECK);
}
}

klass->restore_unshareable_info(loader_data, domain, THREAD);
load_shared_class_misc(klass, loader_data, CHECK);
Dictionary* dictionary = loader_data->dictionary();
unsigned int hash = dictionary->compute_hash(klass->name());
dictionary->add_klass(hash, klass->name(), klass);
add_to_hierarchy(klass, CHECK);
assert(klass->is_loaded(), "Must be in at least loaded state");
}
#endif // INCLUDE_CDS

InstanceKlass* SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) {
@@ -1918,43 +1949,13 @@ bool SystemDictionary::is_well_known_klass(Symbol* class_name) {
}
#endif

void SystemDictionary::quick_resolve(InstanceKlass* klass, ClassLoaderData* loader_data, Handle domain, TRAPS) {
assert(!Universe::is_fully_initialized(), "We can make short cuts only during VM initialization");
assert(klass->is_shared(), "Must be shared class");
if (klass->class_loader_data() != NULL) {
return;
}

// add super and interfaces first
Klass* super = klass->super();
if (super != NULL && super->class_loader_data() == NULL) {
assert(super->is_instance_klass(), "Super should be instance klass");
quick_resolve(InstanceKlass::cast(super), loader_data, domain, CHECK);
}

Array<InstanceKlass*>* ifs = klass->local_interfaces();
for (int i = 0; i < ifs->length(); i++) {
InstanceKlass* ik = ifs->at(i);
if (ik->class_loader_data() == NULL) {
quick_resolve(ik, loader_data, domain, CHECK);
}
}

klass->restore_unshareable_info(loader_data, domain, THREAD);
load_shared_class_misc(klass, loader_data, CHECK);
Dictionary* dictionary = loader_data->dictionary();
unsigned int hash = dictionary->compute_hash(klass->name());
dictionary->add_klass(hash, klass->name(), klass);
add_to_hierarchy(klass, CHECK);
assert(klass->is_loaded(), "Must be in at least loaded state");
}

bool SystemDictionary::resolve_wk_klass(WKID id, TRAPS) {
assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
int sid = wk_init_info[id - FIRST_WKID];
Symbol* symbol = vmSymbols::symbol_at((vmSymbols::SID)sid);
InstanceKlass** klassp = &_well_known_klasses[id];

#if INCLUDE_CDS
if (UseSharedSpaces && !JvmtiExport::should_post_class_prepare()) {
InstanceKlass* k = *klassp;
assert(k->is_shared_boot_class(), "must be");
@@ -1963,6 +1964,7 @@ bool SystemDictionary::resolve_wk_klass(WKID id, TRAPS) {
quick_resolve(k, loader_data, Handle(), CHECK_false);
return true;
}
#endif // INCLUDE_CDS

if (!is_wk_klass_loaded(*klassp)) {
Klass* k = resolve_or_fail(symbol, true, CHECK_false);
@@ -634,7 +634,7 @@ class SystemDictionary : AllStatic {
// Resolve well-known classes so they can be used like SystemDictionary::String_klass()
static void resolve_well_known_classes(TRAPS);
// quick resolve using CDS for well-known classes only.
static void quick_resolve(InstanceKlass* klass, ClassLoaderData* loader_data, Handle domain, TRAPS);
static void quick_resolve(InstanceKlass* klass, ClassLoaderData* loader_data, Handle domain, TRAPS) NOT_CDS_RETURN;

// Class loader constraints
static void check_constraints(unsigned int hash,

0 comments on commit 5bfb814

Please sign in to comment.