< prev index next >

src/share/vm/classfile/systemDictionary.cpp

Print this page




 479 // lockObject must be held.
 480 // Complicated dance due to lock ordering:
 481 // Must first release the classloader object lock to
 482 // allow initial definer to complete the class definition
 483 // and to avoid deadlock
 484 // Reclaim classloader lock object with same original recursion count
 485 // Must release SystemDictionary_lock after notify, since
 486 // class loader lock must be claimed before SystemDictionary_lock
 487 // to prevent deadlocks
 488 //
 489 // The notify allows applications that did an untimed wait() on
 490 // the classloader object lock to not hang.
 491 void SystemDictionary::double_lock_wait(Handle lockObject, TRAPS) {
 492   assert_lock_strong(SystemDictionary_lock);
 493 
 494   bool calledholdinglock
 495       = ObjectSynchronizer::current_thread_holds_lock((JavaThread*)THREAD, lockObject);
 496   assert(calledholdinglock,"must hold lock for notify");
 497   assert((!(lockObject() == _system_loader_lock_obj) && !is_parallelCapable(lockObject)), "unexpected double_lock_wait");
 498   ObjectSynchronizer::notifyall(lockObject, THREAD);
 499   intptr_t recursions =  ObjectSynchronizer::complete_exit(lockObject, THREAD);

 500   SystemDictionary_lock->wait();
 501   SystemDictionary_lock->unlock();
 502   ObjectSynchronizer::reenter(lockObject, recursions, THREAD);
 503   SystemDictionary_lock->lock();
 504 }
 505 
 506 // If the class in is in the placeholder table, class loading is in progress
 507 // For cases where the application changes threads to load classes, it
 508 // is critical to ClassCircularity detection that we try loading
 509 // the superclass on the same thread internally, so we do parallel
 510 // super class loading here.
 511 // This also is critical in cases where the original thread gets stalled
 512 // even in non-circularity situations.
 513 // Note: must call resolve_super_or_fail even if null super -
 514 // to force placeholder entry creation for this class for circularity detection
 515 // Caller must check for pending exception
 516 // Returns non-null Klass* if other thread has completed load
 517 // and we are done,
 518 // If return null Klass* and no pending exception, the caller must load the class
 519 instanceKlassHandle SystemDictionary::handle_parallel_super_load(
 520     Symbol* name, Symbol* superclassname, Handle class_loader,
 521     Handle protection_domain, Handle lockObject, TRAPS) {
 522 




 479 // lockObject must be held.
 480 // Complicated dance due to lock ordering:
 481 // Must first release the classloader object lock to
 482 // allow initial definer to complete the class definition
 483 // and to avoid deadlock
 484 // Reclaim classloader lock object with same original recursion count
 485 // Must release SystemDictionary_lock after notify, since
 486 // class loader lock must be claimed before SystemDictionary_lock
 487 // to prevent deadlocks
 488 //
 489 // The notify allows applications that did an untimed wait() on
 490 // the classloader object lock to not hang.
 491 void SystemDictionary::double_lock_wait(Handle lockObject, TRAPS) {
 492   assert_lock_strong(SystemDictionary_lock);
 493 
 494   bool calledholdinglock
 495       = ObjectSynchronizer::current_thread_holds_lock((JavaThread*)THREAD, lockObject);
 496   assert(calledholdinglock,"must hold lock for notify");
 497   assert((!(lockObject() == _system_loader_lock_obj) && !is_parallelCapable(lockObject)), "unexpected double_lock_wait");
 498   ObjectSynchronizer::notifyall(lockObject, THREAD);
 499   intptr_t saved_recursions, saved_trace_exit_stack;
 500   ObjectSynchronizer::complete_exit(lockObject, &saved_recursions, &saved_trace_exit_stack, THREAD);
 501   SystemDictionary_lock->wait();
 502   SystemDictionary_lock->unlock();
 503   ObjectSynchronizer::reenter(lockObject, saved_recursions, saved_trace_exit_stack, THREAD);
 504   SystemDictionary_lock->lock();
 505 }
 506 
 507 // If the class in is in the placeholder table, class loading is in progress
 508 // For cases where the application changes threads to load classes, it
 509 // is critical to ClassCircularity detection that we try loading
 510 // the superclass on the same thread internally, so we do parallel
 511 // super class loading here.
 512 // This also is critical in cases where the original thread gets stalled
 513 // even in non-circularity situations.
 514 // Note: must call resolve_super_or_fail even if null super -
 515 // to force placeholder entry creation for this class for circularity detection
 516 // Caller must check for pending exception
 517 // Returns non-null Klass* if other thread has completed load
 518 // and we are done,
 519 // If return null Klass* and no pending exception, the caller must load the class
 520 instanceKlassHandle SystemDictionary::handle_parallel_super_load(
 521     Symbol* name, Symbol* superclassname, Handle class_loader,
 522     Handle protection_domain, Handle lockObject, TRAPS) {
 523 


< prev index next >