< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page
*** 87,14 ***
  #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"
--- 87,15 ---
  #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"

*** 146,10 ***
--- 147,13 ---
  #include "runtime/rtmLocking.hpp"
  #endif
  #if INCLUDE_JFR
  #include "jfr/jfr.hpp"
  #endif
+ #if INCLUDE_VM_STRUCTS
+ #include "runtime/vmStructs.hpp"
+ #endif
  
  // Initialization after module runtime initialization
  void universe_post_module_init();  // must happen after call_initPhase2
  
  #ifdef DTRACE_ENABLED

*** 700,10 ***
--- 704,11 ---
  // 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(LockingMode != LM_LIGHTWEIGHT, "should not be called with new lightweight locking");
    return is_in_full_stack(adr);
  }
  
  bool Thread::set_as_starting_thread() {
    assert(_starting_thread == NULL, "already initialized: "

*** 1089,12 ***
    _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");
    if (JVMCICounterSize > 0) {
--- 1094,13 ---
    _parker(),
    _cached_monitor_info(nullptr),
  
    _class_to_be_initialized(nullptr),
  
!   _SleepEvent(ParkEvent::Allocate(this)),
! 
+   _lock_stack(this) {
    set_jni_functions(jni_functions());
  
  #if INCLUDE_JVMCI
    assert(_jvmci._implicit_exception_pc == nullptr, "must be");
    if (JVMCICounterSize > 0) {

*** 1567,11 ***
      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;
    }
  
--- 1573,12 ---
      return ret;
    }
  }
  
  bool JavaThread::is_lock_owned(address adr) const {
!   assert(LockingMode != LM_LIGHTWEIGHT, "should not be called with new lightweight 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;
    }
  

*** 2017,10 ***
--- 2024,14 ---
  #endif
  
    if (jvmti_thread_state() != NULL) {
      jvmti_thread_state()->oops_do(f, cf);
    }
+ 
+   if (LockingMode == LM_LIGHTWEIGHT) {
+     lock_stack().oops_do(f);
+   }
  }
  
  void JavaThread::oops_do_frames(OopClosure* f, CodeBlobClosure* cf) {
    if (!has_last_Java_frame()) {
      return;

*** 2822,10 ***
--- 2833,17 ---
    // Must be before create_vm_init_agents()
    if (Arguments::init_libraries_at_startup()) {
      convert_vm_init_libraries_to_agents();
    }
  
+   // Should happen before any agent attaches and pokes into vmStructs
+ #if INCLUDE_VM_STRUCTS
+   if (UseCompactObjectHeaders) {
+     VMStructs::compact_headers_overrides();
+   }
+ #endif
+ 
    // Launch -agentlib/-agentpath and converted -Xrun agents
    if (Arguments::init_agents_at_startup()) {
      create_vm_init_agents();
    }
  

*** 3707,10 ***
--- 3725,11 ---
  }
  
  
  JavaThread *Threads::owning_thread_from_monitor_owner(ThreadsList * t_list,
                                                        address owner) {
+   assert(LockingMode != LM_LIGHTWEIGHT, "Not with new lightweight 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

*** 3736,10 ***
--- 3755,35 ---
  
    // 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(LockingMode == LM_LIGHTWEIGHT, "Only with new lightweight 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 (LockingMode == LM_LIGHTWEIGHT) {
+     if (monitor->is_owner_anonymous()) {
+       return owning_thread_from_object(t_list, monitor->object());
+     } else {
+       Thread* owner = reinterpret_cast<Thread*>(monitor->owner());
+       assert(owner == NULL || owner->is_Java_thread(), "only JavaThreads own monitors");
+       return reinterpret_cast<JavaThread*>(owner);
+     }
+   } else {
+     address owner = (address)monitor->owner();
+     return owning_thread_from_monitor_owner(t_list, owner);
+   }
+ }
+ 
  class PrintOnClosure : public ThreadClosure {
  private:
    outputStream* _st;
  
  public:
< prev index next >