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;
|
||||
}
|
||||
|
||||
Handle loader;
|
||||
Handle domain;
|
||||
if (accessing_klass != nullptr) {
|
||||
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;
|
||||
}
|
||||
Klass* found_klass = SystemDictionary::find_constrained_or_local_klass(current, sym,
|
||||
(accessing_klass == nullptr) ? nullptr : accessing_klass->get_Klass(),
|
||||
require_local);
|
||||
|
||||
// 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.
|
||||
|
@ -1353,11 +1353,7 @@ InstanceKlass* SystemDictionary::load_instance_class(Symbol* name,
|
||||
// before references to the initiating class loader.
|
||||
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);
|
||||
}
|
||||
|
||||
if (JvmtiExport::should_post_class_load()) {
|
||||
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.
|
||||
k->add_to_hierarchy(THREAD);
|
||||
|
||||
{
|
||||
MutexLocker mu_r(THREAD, Compile_lock);
|
||||
// Add to systemDictionary - so other classes can see it.
|
||||
// Grabs and releases SystemDictionary_lock
|
||||
update_dictionary(THREAD, k, loader_data);
|
||||
}
|
||||
|
||||
// notify jvmti
|
||||
if (JvmtiExport::should_post_class_load()) {
|
||||
@ -1684,19 +1677,16 @@ void SystemDictionary::check_constraints(InstanceKlass* k,
|
||||
void SystemDictionary::update_dictionary(JavaThread* current,
|
||||
InstanceKlass* k,
|
||||
ClassLoaderData* loader_data) {
|
||||
// Compile_lock prevents systemDictionary updates during compilations
|
||||
assert_locked_or_safepoint(Compile_lock);
|
||||
Symbol* name = k->name();
|
||||
|
||||
MutexLocker mu1(SystemDictionary_lock);
|
||||
MonitorLocker mu1(SystemDictionary_lock);
|
||||
|
||||
// Make a new dictionary entry.
|
||||
Symbol* name = k->name();
|
||||
Dictionary* dictionary = loader_data->dictionary();
|
||||
InstanceKlass* sd_check = dictionary->find_class(current, name);
|
||||
if (sd_check == nullptr) {
|
||||
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;
|
||||
}
|
||||
|
||||
// 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,
|
||||
Klass* klass_being_linked,
|
||||
Handle class_loader1,
|
||||
|
@ -150,6 +150,7 @@ class SystemDictionary : AllStatic {
|
||||
Handle class_loader,
|
||||
Handle protection_domain);
|
||||
|
||||
private:
|
||||
// Lookup an instance or array class that has already been loaded
|
||||
// either into the given class loader, or else into another class
|
||||
// loader that is constrained (via loader constraints) to produce
|
||||
@ -175,6 +176,13 @@ class SystemDictionary : AllStatic {
|
||||
Symbol* class_name,
|
||||
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);
|
||||
// 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);
|
||||
}
|
||||
|
||||
Handle loader;
|
||||
Handle domain;
|
||||
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);
|
||||
}
|
||||
}
|
||||
Klass* found_klass = SystemDictionary::find_constrained_or_local_klass(THREAD, sym,
|
||||
accessing_klass, require_local);
|
||||
|
||||
// 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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user