< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page
*** 87,24 ***
  #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/safepointVerifiers.hpp"
  #include "runtime/serviceThread.hpp"
  #include "runtime/sharedRuntime.hpp"
  #include "runtime/stackFrameStream.inline.hpp"
! #include "runtime/stackWatermarkSet.hpp"
  #include "runtime/statSampler.hpp"
  #include "runtime/task.hpp"
  #include "runtime/thread.inline.hpp"
  #include "runtime/threadCritical.hpp"
  #include "runtime/threadSMR.inline.hpp"
--- 87,25 ---
  #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"
  #include "runtime/safepointVerifiers.hpp"
  #include "runtime/serviceThread.hpp"
  #include "runtime/sharedRuntime.hpp"
  #include "runtime/stackFrameStream.inline.hpp"
! #include "runtime/stackWatermarkSet.inline.hpp"
  #include "runtime/statSampler.hpp"
  #include "runtime/task.hpp"
  #include "runtime/thread.inline.hpp"
  #include "runtime/threadCritical.hpp"
  #include "runtime/threadSMR.inline.hpp"

*** 147,10 ***
--- 148,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

*** 703,10 ***
--- 707,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: "

*** 1092,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) {
--- 1097,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) {

*** 1571,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;
    }
  
--- 1577,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;
    }
  

*** 2021,10 ***
--- 2028,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;

*** 2849,10 ***
--- 2860,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();
    }
  

*** 3738,10 ***
--- 3756,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

*** 3767,10 ***
--- 3786,41 ---
  
    // 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) {
+     // Need to start processing before accessing oops in the thread.
+     StackWatermark* watermark = StackWatermarkSet::get(q, StackWatermarkKind::gc);
+     if (watermark != nullptr) {
+       watermark->start_processing();
+     }
+ 
+     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 >