< prev index next >
src/hotspot/share/services/threadService.cpp
Print this page
rev 58110 : v2.09a with 8235795, 8235931 and 8236035 extracted; rebased to jdk-14+28; merge with 8236035.patch.cr1; merge with 8235795.patch.cr1; merge with 8236035.patch.cr2; merge with 8235795.patch.cr2; merge with 8235795.patch.cr3.
rev 58111 : See CR9-to-CR10-changes; merge with jdk-15+11.
*** 1,7 ****
/*
! * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 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,229 ----
// 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);)
! // This function can be called on a target JavaThread that is not
! // the caller and we are not at a safepoint. This ObjectMonitorHandle
! // keeps the ObjectMonitor from being async deflated so the object
! // reference we fetch remains non-NULL.
! 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 {
! 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 ****
--- 365,377 ----
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;
+ // This code is called at a safepoint so this ObjectMonitorHandle
+ // is not strictly necessary.
+ 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();
--- 397,415 ----
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();
}
}
--- 496,511 ----
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";
--- 983,1001 ----
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);
! // This code is called at a safepoint so this ObjectMonitorHandle
! // is not strictly necessary.
! 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 >