8304743: Compile_lock and SystemDictionary updates
Reviewed-by: vlivanov, dholmes, dlong
This commit is contained in:
parent
df819cfa5a
commit
b062b1bd81
@ -508,25 +508,9 @@ ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass,
|
|||||||
return unloaded_klass;
|
return unloaded_klass;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle loader;
|
Klass* found_klass = SystemDictionary::find_constrained_or_local_klass(current, sym,
|
||||||
Handle domain;
|
(accessing_klass == nullptr) ? nullptr : accessing_klass->get_Klass(),
|
||||||
if (accessing_klass != nullptr) {
|
require_local);
|
||||||
loader = Handle(current, accessing_klass->loader());
|
|
||||||
domain = Handle(current, accessing_klass->protection_domain());
|
|
||||||
}
|
|
||||||
|
|
||||||
Klass* found_klass;
|
|
||||||
{
|
|
||||||
ttyUnlocker ttyul; // release tty lock to avoid ordering problems
|
|
||||||
MutexLocker ml(current, Compile_lock);
|
|
||||||
Klass* kls;
|
|
||||||
if (!require_local) {
|
|
||||||
kls = SystemDictionary::find_constrained_instance_or_array_klass(current, sym, loader);
|
|
||||||
} else {
|
|
||||||
kls = SystemDictionary::find_instance_or_array_klass(current, sym, loader, domain);
|
|
||||||
}
|
|
||||||
found_klass = kls;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we fail to find an array klass, look again for its element type.
|
// If we fail to find an array klass, look again for its element type.
|
||||||
// The element type may be available either locally or via constraints.
|
// The element type may be available either locally or via constraints.
|
||||||
|
@ -1353,11 +1353,7 @@ InstanceKlass* SystemDictionary::load_instance_class(Symbol* name,
|
|||||||
// before references to the initiating class loader.
|
// before references to the initiating class loader.
|
||||||
loader_data->record_dependency(loaded_class);
|
loader_data->record_dependency(loaded_class);
|
||||||
|
|
||||||
{ // Grabbing the Compile_lock prevents systemDictionary updates
|
|
||||||
// during compilations.
|
|
||||||
MutexLocker mu(THREAD, Compile_lock);
|
|
||||||
update_dictionary(THREAD, loaded_class, loader_data);
|
update_dictionary(THREAD, loaded_class, loader_data);
|
||||||
}
|
|
||||||
|
|
||||||
if (JvmtiExport::should_post_class_load()) {
|
if (JvmtiExport::should_post_class_load()) {
|
||||||
JvmtiExport::post_class_load(THREAD, loaded_class);
|
JvmtiExport::post_class_load(THREAD, loaded_class);
|
||||||
@ -1418,12 +1414,9 @@ void SystemDictionary::define_instance_class(InstanceKlass* k, Handle class_load
|
|||||||
// Add to class hierarchy, and do possible deoptimizations.
|
// Add to class hierarchy, and do possible deoptimizations.
|
||||||
k->add_to_hierarchy(THREAD);
|
k->add_to_hierarchy(THREAD);
|
||||||
|
|
||||||
{
|
|
||||||
MutexLocker mu_r(THREAD, Compile_lock);
|
|
||||||
// Add to systemDictionary - so other classes can see it.
|
// Add to systemDictionary - so other classes can see it.
|
||||||
// Grabs and releases SystemDictionary_lock
|
// Grabs and releases SystemDictionary_lock
|
||||||
update_dictionary(THREAD, k, loader_data);
|
update_dictionary(THREAD, k, loader_data);
|
||||||
}
|
|
||||||
|
|
||||||
// notify jvmti
|
// notify jvmti
|
||||||
if (JvmtiExport::should_post_class_load()) {
|
if (JvmtiExport::should_post_class_load()) {
|
||||||
@ -1684,19 +1677,16 @@ void SystemDictionary::check_constraints(InstanceKlass* k,
|
|||||||
void SystemDictionary::update_dictionary(JavaThread* current,
|
void SystemDictionary::update_dictionary(JavaThread* current,
|
||||||
InstanceKlass* k,
|
InstanceKlass* k,
|
||||||
ClassLoaderData* loader_data) {
|
ClassLoaderData* loader_data) {
|
||||||
// Compile_lock prevents systemDictionary updates during compilations
|
MonitorLocker mu1(SystemDictionary_lock);
|
||||||
assert_locked_or_safepoint(Compile_lock);
|
|
||||||
Symbol* name = k->name();
|
|
||||||
|
|
||||||
MutexLocker mu1(SystemDictionary_lock);
|
|
||||||
|
|
||||||
// Make a new dictionary entry.
|
// Make a new dictionary entry.
|
||||||
|
Symbol* name = k->name();
|
||||||
Dictionary* dictionary = loader_data->dictionary();
|
Dictionary* dictionary = loader_data->dictionary();
|
||||||
InstanceKlass* sd_check = dictionary->find_class(current, name);
|
InstanceKlass* sd_check = dictionary->find_class(current, name);
|
||||||
if (sd_check == nullptr) {
|
if (sd_check == nullptr) {
|
||||||
dictionary->add_klass(current, name, k);
|
dictionary->add_klass(current, name, k);
|
||||||
}
|
}
|
||||||
SystemDictionary_lock->notify_all();
|
mu1.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1742,6 +1732,22 @@ Klass* SystemDictionary::find_constrained_instance_or_array_klass(
|
|||||||
return klass;
|
return klass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Called by the compiler to find a loaded class directly or referenced in the loader constraint table.
|
||||||
|
Klass* SystemDictionary::find_constrained_or_local_klass(Thread* current, Symbol* sym,
|
||||||
|
Klass* accessing_klass,
|
||||||
|
bool require_local) {
|
||||||
|
HandleMark hm(current);
|
||||||
|
Handle loader;
|
||||||
|
Handle domain;
|
||||||
|
if (accessing_klass != nullptr) {
|
||||||
|
loader = Handle(current, accessing_klass->class_loader());
|
||||||
|
domain = Handle(current, accessing_klass->protection_domain());
|
||||||
|
}
|
||||||
|
|
||||||
|
return require_local ? find_instance_or_array_klass(current, sym, loader, domain) :
|
||||||
|
find_constrained_instance_or_array_klass(current, sym, loader);
|
||||||
|
}
|
||||||
|
|
||||||
bool SystemDictionary::add_loader_constraint(Symbol* class_name,
|
bool SystemDictionary::add_loader_constraint(Symbol* class_name,
|
||||||
Klass* klass_being_linked,
|
Klass* klass_being_linked,
|
||||||
Handle class_loader1,
|
Handle class_loader1,
|
||||||
|
@ -150,6 +150,7 @@ class SystemDictionary : AllStatic {
|
|||||||
Handle class_loader,
|
Handle class_loader,
|
||||||
Handle protection_domain);
|
Handle protection_domain);
|
||||||
|
|
||||||
|
private:
|
||||||
// Lookup an instance or array class that has already been loaded
|
// Lookup an instance or array class that has already been loaded
|
||||||
// either into the given class loader, or else into another class
|
// either into the given class loader, or else into another class
|
||||||
// loader that is constrained (via loader constraints) to produce
|
// loader that is constrained (via loader constraints) to produce
|
||||||
@ -175,6 +176,13 @@ class SystemDictionary : AllStatic {
|
|||||||
Symbol* class_name,
|
Symbol* class_name,
|
||||||
Handle class_loader);
|
Handle class_loader);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Called by the compiler to find a loaded class directly or referenced in the
|
||||||
|
// loader constraint table.
|
||||||
|
static Klass* find_constrained_or_local_klass(Thread* current, Symbol* sym,
|
||||||
|
Klass* accessing_klass,
|
||||||
|
bool require_local);
|
||||||
|
|
||||||
static void classes_do(MetaspaceClosure* it);
|
static void classes_do(MetaspaceClosure* it);
|
||||||
// Iterate over all methods in all klasses
|
// Iterate over all methods in all klasses
|
||||||
|
|
||||||
|
@ -1664,23 +1664,8 @@ Klass* JVMCIRuntime::get_klass_by_name_impl(Klass*& accessing_klass,
|
|||||||
return get_klass_by_name_impl(accessing_klass, cpool, strippedsym, require_local);
|
return get_klass_by_name_impl(accessing_klass, cpool, strippedsym, require_local);
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle loader;
|
Klass* found_klass = SystemDictionary::find_constrained_or_local_klass(THREAD, sym,
|
||||||
Handle domain;
|
accessing_klass, require_local);
|
||||||
if (accessing_klass != nullptr) {
|
|
||||||
loader = Handle(THREAD, accessing_klass->class_loader());
|
|
||||||
domain = Handle(THREAD, accessing_klass->protection_domain());
|
|
||||||
}
|
|
||||||
|
|
||||||
Klass* found_klass;
|
|
||||||
{
|
|
||||||
ttyUnlocker ttyul; // release tty lock to avoid ordering problems
|
|
||||||
MutexLocker ml(THREAD, Compile_lock);
|
|
||||||
if (!require_local) {
|
|
||||||
found_klass = SystemDictionary::find_constrained_instance_or_array_klass(THREAD, sym, loader);
|
|
||||||
} else {
|
|
||||||
found_klass = SystemDictionary::find_instance_or_array_klass(THREAD, sym, loader, domain);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we fail to find an array klass, look again for its element type.
|
// If we fail to find an array klass, look again for its element type.
|
||||||
// The element type may be available either locally or via constraints.
|
// The element type may be available either locally or via constraints.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user