< prev index next >

src/hotspot/share/services/threadService.cpp

Print this page
rev 59470 : 8153224.v2.1[12].patch merged with 8153224.v2.13.patch.

*** 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,228 **** // 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!"); } } Handle h(Thread::current(), obj); return h; --- 206,236 ---- // 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. So it is possible for + // the waiting or pending condition to be over/stale and for the + // first stage of async deflation to clear the object field in + // the ObjectMonitor. It is also possible for the object to be + // inflated again and to be associated with a completely different + // ObjectMonitor by the time this object reference is processed + // by the caller. 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(AsyncDeflateIdleMonitors || 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(AsyncDeflateIdleMonitors || obj != NULL, "ObjectMonitor should have an associated object!"); } } Handle h(Thread::current(), obj); return h;
*** 389,398 **** --- 397,407 ---- previousThread = jt; currentThread = jt; cycle->reset(); + // The ObjectMonitor* can't be async deflated since we are at a safepoint. // 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
*** 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"; --- 974,990 ---- 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); ! // The ObjectMonitor* can't be async deflated since we are at a safepoint. ! ObjectMonitor* 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";
< prev index next >