< prev index next >

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

Print this page

 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_RUNTIME_OBJECTMONITOR_INLINE_HPP
 26 #define SHARE_RUNTIME_OBJECTMONITOR_INLINE_HPP
 27 
 28 #include "runtime/objectMonitor.hpp"
 29 
 30 #include "logging/log.hpp"
 31 #include "oops/access.inline.hpp"
 32 #include "runtime/atomic.hpp"

 33 #include "runtime/synchronizer.hpp"
 34 
 35 inline intptr_t ObjectMonitor::is_entered(JavaThread* current) const {
 36   void* owner = owner_raw();
 37   if (current == owner || current->is_lock_owned((address)owner)) {
 38     return 1;








 39   }
 40   return 0;
 41 }
 42 
 43 inline markWord ObjectMonitor::header() const {
 44   return Atomic::load(&_header);
 45 }
 46 
 47 inline volatile markWord* ObjectMonitor::header_addr() {
 48   return &_header;
 49 }
 50 
 51 inline void ObjectMonitor::set_header(markWord hdr) {
 52   Atomic::store(&_header, hdr);
 53 }
 54 
 55 inline jint ObjectMonitor::waiters() const {
 56   return _waiters;
 57 }
 58 





 59 // Returns NULL if DEFLATER_MARKER is observed.
 60 inline void* ObjectMonitor::owner() const {
 61   void* owner = owner_raw();
 62   return owner != DEFLATER_MARKER ? owner : NULL;
 63 }
 64 
 65 inline void* ObjectMonitor::owner_raw() const {
 66   return Atomic::load(&_owner);
 67 }
 68 
 69 // Returns true if owner field == DEFLATER_MARKER and false otherwise.
 70 // This accessor is called when we really need to know if the owner
 71 // field == DEFLATER_MARKER and any non-NULL value won't do the trick.
 72 inline bool ObjectMonitor::owner_is_DEFLATER_MARKER() const {
 73   return owner_raw() == DEFLATER_MARKER;
 74 }
 75 
 76 // Returns true if 'this' is being async deflated and false otherwise.
 77 inline bool ObjectMonitor::is_being_async_deflated() {
 78   return contentions() < 0;

 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_RUNTIME_OBJECTMONITOR_INLINE_HPP
 26 #define SHARE_RUNTIME_OBJECTMONITOR_INLINE_HPP
 27 
 28 #include "runtime/objectMonitor.hpp"
 29 
 30 #include "logging/log.hpp"
 31 #include "oops/access.inline.hpp"
 32 #include "runtime/atomic.hpp"
 33 #include "runtime/lockStack.inline.hpp"
 34 #include "runtime/synchronizer.hpp"
 35 
 36 inline bool ObjectMonitor::is_entered(JavaThread* current) const {
 37   if (LockingMode == LM_LIGHTWEIGHT) {
 38     if (is_owner_anonymous()) {
 39       return current->lock_stack().contains(object());
 40     } else {
 41       return current == owner_raw();
 42     }
 43   } else {
 44     void* owner = owner_raw();
 45     if (current == owner || current->is_lock_owned((address)owner)) {
 46       return true;
 47     }
 48   }
 49   return false;
 50 }
 51 
 52 inline markWord ObjectMonitor::header() const {
 53   return Atomic::load(&_header);
 54 }
 55 
 56 inline volatile markWord* ObjectMonitor::header_addr() {
 57   return &_header;
 58 }
 59 
 60 inline void ObjectMonitor::set_header(markWord hdr) {
 61   Atomic::store(&_header, hdr);
 62 }
 63 
 64 inline jint ObjectMonitor::waiters() const {
 65   return _waiters;
 66 }
 67 
 68 inline bool ObjectMonitor::has_owner() const {
 69   void* owner = owner_raw();
 70   return owner != NULL && owner != DEFLATER_MARKER;
 71 }
 72 
 73 // Returns NULL if DEFLATER_MARKER is observed.
 74 inline void* ObjectMonitor::owner() const {
 75   void* owner = owner_raw();
 76   return owner != DEFLATER_MARKER ? owner : NULL;
 77 }
 78 
 79 inline void* ObjectMonitor::owner_raw() const {
 80   return Atomic::load(&_owner);
 81 }
 82 
 83 // Returns true if owner field == DEFLATER_MARKER and false otherwise.
 84 // This accessor is called when we really need to know if the owner
 85 // field == DEFLATER_MARKER and any non-NULL value won't do the trick.
 86 inline bool ObjectMonitor::owner_is_DEFLATER_MARKER() const {
 87   return owner_raw() == DEFLATER_MARKER;
 88 }
 89 
 90 // Returns true if 'this' is being async deflated and false otherwise.
 91 inline bool ObjectMonitor::is_being_async_deflated() {
 92   return contentions() < 0;
< prev index next >