< prev index next > src/hotspot/share/runtime/thread.cpp
Print this page
#include "runtime/interfaceSupport.inline.hpp"
#include "runtime/java.hpp"
#include "runtime/javaCalls.hpp"
#include "runtime/jniHandles.inline.hpp"
#include "runtime/jniPeriodicChecker.hpp"
#include "runtime/monitorDeflationThread.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/nonJavaThread.hpp"
! #include "runtime/objectMonitor.hpp"
#include "runtime/orderAccess.hpp"
#include "runtime/osThread.hpp"
#include "runtime/prefetch.inline.hpp"
#include "runtime/safepoint.hpp"
#include "runtime/safepointMechanism.inline.hpp"
#include "runtime/interfaceSupport.inline.hpp"
#include "runtime/java.hpp"
#include "runtime/javaCalls.hpp"
#include "runtime/jniHandles.inline.hpp"
#include "runtime/jniPeriodicChecker.hpp"
+ #include "runtime/lockStack.inline.hpp"
#include "runtime/monitorDeflationThread.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/nonJavaThread.hpp"
! #include "runtime/objectMonitor.inline.hpp"
#include "runtime/orderAccess.hpp"
#include "runtime/osThread.hpp"
#include "runtime/prefetch.inline.hpp"
#include "runtime/safepoint.hpp"
#include "runtime/safepointMechanism.inline.hpp"
// However, there is a note in JavaThread::is_lock_owned() about the VM threads not being
// used for compilation in the future. If that change is made, the need for these methods
// should be revisited, and they should be removed if possible.
bool Thread::is_lock_owned(address adr) const {
+ assert(!UseFastLocking, "maybe not call that?");
return is_in_full_stack(adr);
}
bool Thread::set_as_starting_thread() {
assert(_starting_thread == NULL, "already initialized: "
_parker(),
_cached_monitor_info(nullptr),
_class_to_be_initialized(nullptr),
! _SleepEvent(ParkEvent::Allocate(this))
{
set_jni_functions(jni_functions());
#if INCLUDE_JVMCI
assert(_jvmci._implicit_exception_pc == nullptr, "must be");
_parker(),
_cached_monitor_info(nullptr),
_class_to_be_initialized(nullptr),
! _SleepEvent(ParkEvent::Allocate(this)),
+ _lock_stack()
{
set_jni_functions(jni_functions());
#if INCLUDE_JVMCI
assert(_jvmci._implicit_exception_pc == nullptr, "must be");
return ret;
}
}
bool JavaThread::is_lock_owned(address adr) const {
! if (Thread::is_lock_owned(adr)) return true;
for (MonitorChunk* chunk = monitor_chunks(); chunk != NULL; chunk = chunk->next()) {
if (chunk->contains(adr)) return true;
}
return ret;
}
}
bool JavaThread::is_lock_owned(address adr) const {
! assert(!UseFastLocking, "should not be called with fast-locking");
+ if (Thread::is_lock_owned(adr)) return true;
for (MonitorChunk* chunk = monitor_chunks(); chunk != NULL; chunk = chunk->next()) {
if (chunk->contains(adr)) return true;
}
#endif
if (jvmti_thread_state() != NULL) {
jvmti_thread_state()->oops_do(f, cf);
}
+
+ if (!UseHeavyMonitors && UseFastLocking) {
+ lock_stack().oops_do(f);
+ }
}
void JavaThread::oops_do_frames(OopClosure* f, CodeBlobClosure* cf) {
if (!has_last_Java_frame()) {
return;
}
JavaThread *Threads::owning_thread_from_monitor_owner(ThreadsList * t_list,
address owner) {
+ assert(!UseFastLocking, "only with stack-locking");
// NULL owner means not locked so we can skip the search
if (owner == NULL) return NULL;
DO_JAVA_THREADS(t_list, p) {
// first, see if owner is the address of a Java thread
// cannot assert on lack of success here; see above comment
return the_owner;
}
+ JavaThread* Threads::owning_thread_from_object(ThreadsList * t_list, oop obj) {
+ assert(UseFastLocking, "Only with fast-locking");
+ DO_JAVA_THREADS(t_list, q) {
+ if (q->lock_stack().contains(obj)) {
+ return q;
+ }
+ }
+ return NULL;
+ }
+
+ JavaThread* Threads::owning_thread_from_monitor(ThreadsList* t_list, ObjectMonitor* monitor) {
+ if (UseFastLocking) {
+ void* raw_owner = monitor->owner_raw();
+ if (raw_owner == ANONYMOUS_OWNER) {
+ return owning_thread_from_object(t_list, monitor->object());
+ } else if (raw_owner == DEFLATER_MARKER) {
+ return NULL;
+ } else {
+ Thread* owner = reinterpret_cast<Thread*>(raw_owner);
+ #ifdef ASSERT
+ if (owner != NULL) {
+ bool found = false;
+ DO_JAVA_THREADS(t_list, q) {
+ if (q == owner) {
+ found = true;;
+ break;
+ }
+ }
+ assert(found, "owner is not a thread: " PTR_FORMAT, p2i(owner));
+ }
+ #endif
+ assert(owner == NULL || owner->is_Java_thread(), "only JavaThreads own monitors");
+ return reinterpret_cast<JavaThread*>(owner);
+ }
+ } else {
+ return owning_thread_from_monitor_owner(t_list, (address)monitor->owner());
+ }
+ }
+
class PrintOnClosure : public ThreadClosure {
private:
outputStream* _st;
public:
< prev index next >