< prev index next >

src/hotspot/share/runtime/objectMonitor.inline.hpp

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 1998, 2021, 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) 1998, 2024, 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.

*** 28,18 ***
  #include "runtime/objectMonitor.hpp"
  
  #include "logging/log.hpp"
  #include "oops/access.inline.hpp"
  #include "runtime/atomic.hpp"
  #include "runtime/synchronizer.hpp"
  
! inline intptr_t ObjectMonitor::is_entered(JavaThread* current) const {
!   void* owner = owner_raw();
!   if (current == owner || current->is_lock_owned((address)owner)) {
!     return 1;
    }
!   return 0;
  }
  
  inline markWord ObjectMonitor::header() const {
    return Atomic::load(&_header);
  }
--- 28,27 ---
  #include "runtime/objectMonitor.hpp"
  
  #include "logging/log.hpp"
  #include "oops/access.inline.hpp"
  #include "runtime/atomic.hpp"
+ #include "runtime/lockStack.inline.hpp"
  #include "runtime/synchronizer.hpp"
  
! inline bool ObjectMonitor::is_entered(JavaThread* current) const {
!   if (LockingMode == LM_LIGHTWEIGHT) {
!     if (is_owner_anonymous()) {
!       return current->lock_stack().contains(object());
+     } else {
+       return current == owner_raw();
+     }
+   } else {
+     void* owner = owner_raw();
+     if (current == owner || current->is_lock_owned((address)owner)) {
+       return true;
+     }
    }
!   return false;
  }
  
  inline markWord ObjectMonitor::header() const {
    return Atomic::load(&_header);
  }

*** 54,10 ***
--- 63,15 ---
  
  inline jint ObjectMonitor::waiters() const {
    return _waiters;
  }
  
+ inline bool ObjectMonitor::has_owner() const {
+   void* owner = owner_raw();
+   return owner != NULL && owner != DEFLATER_MARKER;
+ }
+ 
  // Returns NULL if DEFLATER_MARKER is observed.
  inline void* ObjectMonitor::owner() const {
    void* owner = owner_raw();
    return owner != DEFLATER_MARKER ? owner : NULL;
  }

*** 86,10 ***
--- 100,16 ---
  // Add value to the contentions field.
  inline void ObjectMonitor::add_to_contentions(jint value) {
    Atomic::add(&_contentions, value);
  }
  
+ inline void ObjectMonitor::set_recursions(size_t recursions) {
+   assert(_recursions == 0, "must be");
+   assert(has_owner(), "must be owned");
+   _recursions = checked_cast<intx>(recursions);
+ }
+ 
  // Clear _owner field; current value must match old_value.
  inline void ObjectMonitor::release_clear_owner(void* old_value) {
  #ifdef ASSERT
    void* prev = Atomic::load(&_owner);
    assert(prev == old_value, "unexpected prev owner=" INTPTR_FORMAT
< prev index next >