< prev index next >

src/hotspot/share/services/threadService.cpp

Print this page
rev 56777 : See CR7-to-CR8-changes.

*** 206,224 **** // FIXME: JVMTI should call this function Handle ThreadService::get_current_contended_monitor(JavaThread* thread) { assert(thread != NULL, "should be non-NULL"); debug_only(Thread::check_for_dangling_thread_pointer(thread);) ! ObjectMonitor *wait_obj = thread->current_waiting_monitor(); oop obj = NULL; if (wait_obj != NULL) { // thread is doing an Object.wait() call obj = (oop) wait_obj->object(); assert(obj != NULL, "Object.wait() should have an object"); } else { ! ObjectMonitor *enter_obj = thread->current_pending_monitor(); if (enter_obj != NULL) { // thread is trying to enter() an ObjectMonitor. obj = (oop) enter_obj->object(); assert(obj != NULL, "ObjectMonitor should have an associated object!"); } --- 206,226 ---- // FIXME: JVMTI should call this function Handle ThreadService::get_current_contended_monitor(JavaThread* thread) { assert(thread != NULL, "should be non-NULL"); debug_only(Thread::check_for_dangling_thread_pointer(thread);) ! ObjectMonitorHandle omh; ! ObjectMonitor *wait_obj = thread->current_waiting_monitor(&omh); oop obj = NULL; if (wait_obj != NULL) { // thread is doing an Object.wait() call obj = (oop) wait_obj->object(); assert(obj != NULL, "Object.wait() should have an object"); } else { ! ObjectMonitorHandle omh; ! ObjectMonitor *enter_obj = thread->current_pending_monitor(&omh); if (enter_obj != NULL) { // thread is trying to enter() an ObjectMonitor. obj = (oop) enter_obj->object(); assert(obj != NULL, "ObjectMonitor should have an associated object!"); }
*** 360,369 **** --- 362,372 ---- DeadlockCycle* ThreadService::find_deadlocks_at_safepoint(ThreadsList * t_list, bool concurrent_locks) { assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); // This code was modified from the original Threads::find_deadlocks code. int globalDfn = 0, thisDfn; + ObjectMonitorHandle omh; ObjectMonitor* waitingToLockMonitor = NULL; JvmtiRawMonitor* waitingToLockRawMonitor = NULL; oop waitingToLockBlocker = NULL; bool blocked_on_monitor = false; JavaThread *currentThread, *previousThread;
*** 389,402 **** previousThread = jt; currentThread = jt; cycle->reset(); // When there is a deadlock, all the monitors involved in the dependency // cycle must be contended and heavyweight. So we only care about the // heavyweight monitor a thread is waiting to lock. ! waitingToLockMonitor = jt->current_pending_monitor(); // JVM TI raw monitors can also be involved in deadlocks, and we can be // waiting to lock both a raw monitor and ObjectMonitor at the same time. // It isn't clear how to make deadlock detection work correctly if that // happens. waitingToLockRawMonitor = jt->current_pending_raw_monitor(); --- 392,410 ---- previousThread = jt; currentThread = jt; cycle->reset(); + if (waitingToLockMonitor != NULL) { + // Done with the current waitingToLockMonitor value so release + // the ObjectMonitorHandle manually before we use it again: + omh.unset_om_ptr(); + } // When there is a deadlock, all the monitors involved in the dependency // cycle must be contended and heavyweight. So we only care about the // heavyweight monitor a thread is waiting to lock. ! waitingToLockMonitor = jt->current_pending_monitor(&omh); // JVM TI raw monitors can also be involved in deadlocks, and we can be // waiting to lock both a raw monitor and ObjectMonitor at the same time. // It isn't clear how to make deadlock detection work correctly if that // happens. waitingToLockRawMonitor = jt->current_pending_raw_monitor();
*** 483,493 **** last = cycle; cycle = new DeadlockCycle(); break; } previousThread = currentThread; ! waitingToLockMonitor = (ObjectMonitor*)currentThread->current_pending_monitor(); if (concurrent_locks) { waitingToLockBlocker = currentThread->current_park_blocker(); } } --- 491,506 ---- last = cycle; cycle = new DeadlockCycle(); break; } previousThread = currentThread; ! if (waitingToLockMonitor != NULL) { ! // Done with the current waitingToLockMonitor value so release ! // the ObjectMonitorHandle manually before we use it again: ! omh.unset_om_ptr(); ! } ! waitingToLockMonitor = (ObjectMonitor*)currentThread->current_pending_monitor(&omh); if (concurrent_locks) { waitingToLockBlocker = currentThread->current_park_blocker(); } }
*** 965,981 **** st->cr(); st->print_cr("Found one Java-level deadlock:"); st->print("============================="); JavaThread* currentThread; - ObjectMonitor* waitingToLockMonitor; JvmtiRawMonitor* waitingToLockRawMonitor; oop waitingToLockBlocker; int len = _threads->length(); for (int i = 0; i < len; i++) { currentThread = _threads->at(i); ! waitingToLockMonitor = currentThread->current_pending_monitor(); waitingToLockRawMonitor = currentThread->current_pending_raw_monitor(); waitingToLockBlocker = currentThread->current_park_blocker(); st->cr(); st->print_cr("\"%s\":", currentThread->get_thread_name()); const char* owner_desc = ",\n which is held by"; --- 978,994 ---- st->cr(); st->print_cr("Found one Java-level deadlock:"); st->print("============================="); JavaThread* currentThread; JvmtiRawMonitor* waitingToLockRawMonitor; oop waitingToLockBlocker; int len = _threads->length(); for (int i = 0; i < len; i++) { currentThread = _threads->at(i); ! ObjectMonitorHandle omh; ! ObjectMonitor* waitingToLockMonitor = currentThread->current_pending_monitor(&omh); waitingToLockRawMonitor = currentThread->current_pending_raw_monitor(); waitingToLockBlocker = currentThread->current_park_blocker(); st->cr(); st->print_cr("\"%s\":", currentThread->get_thread_name()); const char* owner_desc = ",\n which is held by";
< prev index next >