RFR: 8259068: Streamline class loader locking

Coleen Phillimore coleenp at openjdk.java.net
Fri Jan 15 00:03:12 UTC 2021


On Thu, 14 Jan 2021 22:51:51 GMT, Daniel D. Daugherty <dcubed at openjdk.org> wrote:

>> The system_loader_lock_object is never actually acquired when loading a class with a parallelCapable class loader, which includes the bootloader (class_loader == NULL), except in one place before restore_unshareable_info is called.  In this case, the per-class lock (BuiltinLoader.getClassLoadingLock) is held or the placeholder for LOAD_INSTANCE is present which implements mutual exclusion.  Ioi and I separately verified this while chasing down another bug.
>> This change removes the system_loader_lock_obj and extraneous code around compute_loader_lock_object to make it consistent.  This also removes the bool argument to ObjectLocker.  If the oop passed into ObjectLocker is null, we don't lock the object, which is consistent with the Mutex class.  This change also passes the class_loader to define_class to save an OopStorage.resolve() call.
>> Tested with tier1-8.
>
> src/hotspot/share/classfile/systemDictionaryShared.cpp line 1034:
> 
>> 1032:       Dictionary* dictionary = loader_data->dictionary();
>> 1033: 
>> 1034:       unsigned int d_hash = dictionary->compute_hash(name);
> 
> Is there a reason that `d_hash` was previously computed
> outside the `SystemDictionary_lock`?

I moved it closer to where it's used, but it can go back to outside the lock, to reduce what's computed inside the lock.

> src/hotspot/share/runtime/synchronizer.hpp line 189:
> 
>> 187:   // reenter reclaims lock with original recursion count
>> 188:   intx complete_exit(TRAPS)  { return ObjectSynchronizer::complete_exit(_obj, THREAD); }
>> 189:   void reenter(intx recursions, TRAPS)  { ObjectSynchronizer::reenter(_obj, recursions, CHECK); }
> 
> Nice cleanup.

thanks!

-------------

PR: https://git.openjdk.java.net/jdk/pull/2071


More information about the hotspot-dev mailing list