< prev index next >

src/hotspot/share/services/threadService.cpp

Print this page

 447     waitingToLockRawMonitor = jt->current_pending_raw_monitor();
 448 
 449     if (concurrent_locks) {
 450       waitingToLockBlocker = jt->current_park_blocker();
 451     }
 452 
 453     while (waitingToLockMonitor != nullptr ||
 454            waitingToLockRawMonitor != nullptr ||
 455            waitingToLockBlocker != nullptr) {
 456       cycle->add_thread(currentThread);
 457       // Give preference to the raw monitor
 458       if (waitingToLockRawMonitor != nullptr) {
 459         Thread* owner = waitingToLockRawMonitor->owner();
 460         if (owner != nullptr && // the raw monitor could be released at any time
 461             owner->is_Java_thread()) {
 462           currentThread = JavaThread::cast(owner);
 463         }
 464       } else if (waitingToLockMonitor != nullptr) {
 465         if (waitingToLockMonitor->has_owner()) {
 466           currentThread = Threads::owning_thread_from_monitor(t_list, waitingToLockMonitor);
 467           if (currentThread == nullptr) {
 468             // This function is called at a safepoint so the JavaThread
 469             // that owns waitingToLockMonitor should be findable, but
 470             // if it is not findable, then the previous currentThread is
 471             // blocked permanently. We record this as a deadlock.
 472             num_deadlocks++;
 473 
 474             // add this cycle to the deadlocks list
 475             if (deadlocks == nullptr) {
 476               deadlocks = cycle;
 477             } else {
 478               last->set_next(cycle);
 479             }
 480             last = cycle;
 481             cycle = new DeadlockCycle();
 482             break;
 483           }
 484         }
 485       } else {
 486         if (concurrent_locks) {
 487           if (waitingToLockBlocker->is_a(vmClasses::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass())) {
 488             oop threadObj = java_util_concurrent_locks_AbstractOwnableSynchronizer::get_owner_threadObj(waitingToLockBlocker);
 489             // This JavaThread (if there is one) is protected by the
 490             // ThreadsListSetter in VM_FindDeadlocks::doit().
 491             currentThread = threadObj != nullptr ? java_lang_Thread::thread(threadObj) : nullptr;
 492           } else {
 493             currentThread = nullptr;
 494           }
 495         }
 496       }
 497 
 498       if (currentThread == nullptr || is_virtual_or_carrier_thread(currentThread)) {
 499         // No dependency on another thread
 500         break;
 501       }
 502       if (currentThread->depth_first_number() < 0) {
 503         // First visit to this thread

 447     waitingToLockRawMonitor = jt->current_pending_raw_monitor();
 448 
 449     if (concurrent_locks) {
 450       waitingToLockBlocker = jt->current_park_blocker();
 451     }
 452 
 453     while (waitingToLockMonitor != nullptr ||
 454            waitingToLockRawMonitor != nullptr ||
 455            waitingToLockBlocker != nullptr) {
 456       cycle->add_thread(currentThread);
 457       // Give preference to the raw monitor
 458       if (waitingToLockRawMonitor != nullptr) {
 459         Thread* owner = waitingToLockRawMonitor->owner();
 460         if (owner != nullptr && // the raw monitor could be released at any time
 461             owner->is_Java_thread()) {
 462           currentThread = JavaThread::cast(owner);
 463         }
 464       } else if (waitingToLockMonitor != nullptr) {
 465         if (waitingToLockMonitor->has_owner()) {
 466           currentThread = Threads::owning_thread_from_monitor(t_list, waitingToLockMonitor);

















 467         }
 468       } else {
 469         if (concurrent_locks) {
 470           if (waitingToLockBlocker->is_a(vmClasses::java_util_concurrent_locks_AbstractOwnableSynchronizer_klass())) {
 471             oop threadObj = java_util_concurrent_locks_AbstractOwnableSynchronizer::get_owner_threadObj(waitingToLockBlocker);
 472             // This JavaThread (if there is one) is protected by the
 473             // ThreadsListSetter in VM_FindDeadlocks::doit().
 474             currentThread = threadObj != nullptr ? java_lang_Thread::thread(threadObj) : nullptr;
 475           } else {
 476             currentThread = nullptr;
 477           }
 478         }
 479       }
 480 
 481       if (currentThread == nullptr || is_virtual_or_carrier_thread(currentThread)) {
 482         // No dependency on another thread
 483         break;
 484       }
 485       if (currentThread->depth_first_number() < 0) {
 486         // First visit to this thread
< prev index next >