src/hotspot/share/runtime/objectMonitor.inline.hpp
changeset 57777 90ead0febf56
parent 57734 18f4d3d46d54
child 58679 9c3209ff7550
child 59156 14fa9e70ae71
--- a/src/hotspot/share/runtime/objectMonitor.inline.hpp	Fri Aug 16 09:18:41 2019 +0200
+++ b/src/hotspot/share/runtime/objectMonitor.inline.hpp	Tue Aug 06 10:48:21 2019 +0200
@@ -25,6 +25,8 @@
 #ifndef SHARE_RUNTIME_OBJECTMONITOR_INLINE_HPP
 #define SHARE_RUNTIME_OBJECTMONITOR_INLINE_HPP
 
+#include "runtime/atomic.hpp"
+
 inline intptr_t ObjectMonitor::is_entered(TRAPS) const {
   if (THREAD == _owner || THREAD->is_lock_owned((address) _owner)) {
     return 1;
@@ -32,17 +34,17 @@
   return 0;
 }
 
-inline markOop ObjectMonitor::header() const {
-  return _header;
+inline markWord ObjectMonitor::header() const {
+  return Atomic::load(&_header);
 }
 
-inline volatile markOop* ObjectMonitor::header_addr() {
+inline volatile markWord* ObjectMonitor::header_addr() {
   assert((intptr_t)this == (intptr_t)&_header, "sync code expects this");
   return &_header;
 }
 
-inline void ObjectMonitor::set_header(markOop hdr) {
-  _header = hdr;
+inline void ObjectMonitor::set_header(markWord hdr) {
+  Atomic::store(hdr, &_header);
 }
 
 inline jint ObjectMonitor::waiters() const {
@@ -54,14 +56,14 @@
 }
 
 inline void ObjectMonitor::clear() {
-  assert(_header != NULL, "must be non-NULL");
+  assert(Atomic::load(&_header).value() != 0, "must be non-zero");
   assert(_contentions == 0, "must be 0: contentions=%d", _contentions);
   assert(_waiters == 0, "must be 0: waiters=%d", _waiters);
   assert(_recursions == 0, "must be 0: recursions=" INTPTR_FORMAT, _recursions);
   assert(_object != NULL, "must be non-NULL");
   assert(_owner == NULL, "must be NULL: owner=" INTPTR_FORMAT, p2i(_owner));
 
-  _header = NULL;
+  Atomic::store(markWord::zero(), &_header);
   _object = NULL;
 }