< prev index next >

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

Print this page
rev 60098 : 8246476: remove AsyncDeflateIdleMonitors option and the safepoint based deflation mechanism
Reviewed-by: dholmes, pchilanomate, coleenp
rev 60099 : coleenp CR


 107 }
 108 
 109 inline void ObjectMonitor::set_object(void* obj) {
 110   _object = obj;
 111 }
 112 
 113 // Return number of threads contending for this monitor.
 114 inline jint ObjectMonitor::contentions() const {
 115   return Atomic::load(&_contentions);
 116 }
 117 
 118 // Add value to the contentions field.
 119 inline void ObjectMonitor::add_to_contentions(jint value) {
 120   Atomic::add(&_contentions, value);
 121 }
 122 
 123 // Clear _owner field; current value must match old_value.
 124 inline void ObjectMonitor::release_clear_owner(void* old_value) {
 125 #ifdef ASSERT
 126   void* prev = Atomic::load(&_owner);
 127 #endif
 128   assert(prev == old_value, "unexpected prev owner=" INTPTR_FORMAT
 129          ", expected=" INTPTR_FORMAT, p2i(prev), p2i(old_value));

 130   Atomic::release_store(&_owner, (void*)NULL);
 131   log_trace(monitorinflation, owner)("release_clear_owner(): mid="
 132                                      INTPTR_FORMAT ", old_value=" INTPTR_FORMAT,
 133                                      p2i(this), p2i(old_value));
 134 }
 135 
 136 // Simply set _owner field to new_value; current value must match old_value.
 137 // (Simple means no memory sync needed.)
 138 inline void ObjectMonitor::set_owner_from(void* old_value, void* new_value) {
 139 #ifdef ASSERT
 140   void* prev = Atomic::load(&_owner);
 141 #endif
 142   assert(prev == old_value, "unexpected prev owner=" INTPTR_FORMAT
 143          ", expected=" INTPTR_FORMAT, p2i(prev), p2i(old_value));

 144   Atomic::store(&_owner, new_value);
 145   log_trace(monitorinflation, owner)("set_owner_from(): mid="
 146                                      INTPTR_FORMAT ", old_value=" INTPTR_FORMAT
 147                                      ", new_value=" INTPTR_FORMAT, p2i(this),
 148                                      p2i(old_value), p2i(new_value));
 149 }
 150 
 151 // Simply set _owner field to new_value; current value must match old_value1 or old_value2.
 152 // (Simple means no memory sync needed.)
 153 inline void ObjectMonitor::set_owner_from(void* old_value1, void* old_value2, void* new_value) {
 154   void* prev = Atomic::load(&_owner);
 155   assert(prev == old_value1 || prev == old_value2,
 156          "unexpected prev owner=" INTPTR_FORMAT ", expected1="
 157          INTPTR_FORMAT " or expected2=" INTPTR_FORMAT, p2i(prev),
 158          p2i(old_value1), p2i(old_value2));
 159   _owner = new_value;
 160   log_trace(monitorinflation, owner)("set_owner_from(old1=" INTPTR_FORMAT
 161                                      ", old2=" INTPTR_FORMAT "): mid="
 162                                      INTPTR_FORMAT ", prev=" INTPTR_FORMAT
 163                                      ", new=" INTPTR_FORMAT, p2i(old_value1),
 164                                      p2i(old_value2), p2i(this), p2i(prev),
 165                                      p2i(new_value));
 166 }
 167 
 168 // Simply set _owner field to self; current value must match basic_lock_p.
 169 inline void ObjectMonitor::set_owner_from_BasicLock(void* basic_lock_p, Thread* self) {
 170 #ifdef ASSERT
 171   void* prev = Atomic::load(&_owner);
 172 #endif
 173   assert(prev == basic_lock_p, "unexpected prev owner=" INTPTR_FORMAT
 174          ", expected=" INTPTR_FORMAT, p2i(prev), p2i(basic_lock_p));

 175   // Non-null owner field to non-null owner field is safe without
 176   // cmpxchg() as long as all readers can tolerate either flavor.
 177   Atomic::store(&_owner, self);
 178   log_trace(monitorinflation, owner)("set_owner_from_BasicLock(): mid="
 179                                      INTPTR_FORMAT ", basic_lock_p="
 180                                      INTPTR_FORMAT ", new_value=" INTPTR_FORMAT,
 181                                      p2i(this), p2i(basic_lock_p), p2i(self));
 182 }
 183 
 184 // Try to set _owner field to new_value if the current value matches
 185 // old_value. Otherwise, does not change the _owner field. Returns
 186 // the prior value of the _owner field.
 187 inline void* ObjectMonitor::try_set_owner_from(void* old_value, void* new_value) {
 188   void* prev = Atomic::cmpxchg(&_owner, old_value, new_value);
 189   if (prev == old_value) {
 190     log_trace(monitorinflation, owner)("try_set_owner_from(): mid="
 191                                        INTPTR_FORMAT ", prev=" INTPTR_FORMAT
 192                                        ", new=" INTPTR_FORMAT, p2i(this),
 193                                        p2i(prev), p2i(new_value));
 194   }




 107 }
 108 
 109 inline void ObjectMonitor::set_object(void* obj) {
 110   _object = obj;
 111 }
 112 
 113 // Return number of threads contending for this monitor.
 114 inline jint ObjectMonitor::contentions() const {
 115   return Atomic::load(&_contentions);
 116 }
 117 
 118 // Add value to the contentions field.
 119 inline void ObjectMonitor::add_to_contentions(jint value) {
 120   Atomic::add(&_contentions, value);
 121 }
 122 
 123 // Clear _owner field; current value must match old_value.
 124 inline void ObjectMonitor::release_clear_owner(void* old_value) {
 125 #ifdef ASSERT
 126   void* prev = Atomic::load(&_owner);

 127   assert(prev == old_value, "unexpected prev owner=" INTPTR_FORMAT
 128          ", expected=" INTPTR_FORMAT, p2i(prev), p2i(old_value));
 129 #endif
 130   Atomic::release_store(&_owner, (void*)NULL);
 131   log_trace(monitorinflation, owner)("release_clear_owner(): mid="
 132                                      INTPTR_FORMAT ", old_value=" INTPTR_FORMAT,
 133                                      p2i(this), p2i(old_value));
 134 }
 135 
 136 // Simply set _owner field to new_value; current value must match old_value.
 137 // (Simple means no memory sync needed.)
 138 inline void ObjectMonitor::set_owner_from(void* old_value, void* new_value) {
 139 #ifdef ASSERT
 140   void* prev = Atomic::load(&_owner);

 141   assert(prev == old_value, "unexpected prev owner=" INTPTR_FORMAT
 142          ", expected=" INTPTR_FORMAT, p2i(prev), p2i(old_value));
 143 #endif
 144   Atomic::store(&_owner, new_value);
 145   log_trace(monitorinflation, owner)("set_owner_from(): mid="
 146                                      INTPTR_FORMAT ", old_value=" INTPTR_FORMAT
 147                                      ", new_value=" INTPTR_FORMAT, p2i(this),
 148                                      p2i(old_value), p2i(new_value));
 149 }
 150 
 151 // Simply set _owner field to new_value; current value must match old_value1 or old_value2.
 152 // (Simple means no memory sync needed.)
 153 inline void ObjectMonitor::set_owner_from(void* old_value1, void* old_value2, void* new_value) {
 154   void* prev = Atomic::load(&_owner);
 155   assert(prev == old_value1 || prev == old_value2,
 156          "unexpected prev owner=" INTPTR_FORMAT ", expected1="
 157          INTPTR_FORMAT " or expected2=" INTPTR_FORMAT, p2i(prev),
 158          p2i(old_value1), p2i(old_value2));
 159   _owner = new_value;
 160   log_trace(monitorinflation, owner)("set_owner_from(old1=" INTPTR_FORMAT
 161                                      ", old2=" INTPTR_FORMAT "): mid="
 162                                      INTPTR_FORMAT ", prev=" INTPTR_FORMAT
 163                                      ", new=" INTPTR_FORMAT, p2i(old_value1),
 164                                      p2i(old_value2), p2i(this), p2i(prev),
 165                                      p2i(new_value));
 166 }
 167 
 168 // Simply set _owner field to self; current value must match basic_lock_p.
 169 inline void ObjectMonitor::set_owner_from_BasicLock(void* basic_lock_p, Thread* self) {
 170 #ifdef ASSERT
 171   void* prev = Atomic::load(&_owner);

 172   assert(prev == basic_lock_p, "unexpected prev owner=" INTPTR_FORMAT
 173          ", expected=" INTPTR_FORMAT, p2i(prev), p2i(basic_lock_p));
 174 #endif
 175   // Non-null owner field to non-null owner field is safe without
 176   // cmpxchg() as long as all readers can tolerate either flavor.
 177   Atomic::store(&_owner, self);
 178   log_trace(monitorinflation, owner)("set_owner_from_BasicLock(): mid="
 179                                      INTPTR_FORMAT ", basic_lock_p="
 180                                      INTPTR_FORMAT ", new_value=" INTPTR_FORMAT,
 181                                      p2i(this), p2i(basic_lock_p), p2i(self));
 182 }
 183 
 184 // Try to set _owner field to new_value if the current value matches
 185 // old_value. Otherwise, does not change the _owner field. Returns
 186 // the prior value of the _owner field.
 187 inline void* ObjectMonitor::try_set_owner_from(void* old_value, void* new_value) {
 188   void* prev = Atomic::cmpxchg(&_owner, old_value, new_value);
 189   if (prev == old_value) {
 190     log_trace(monitorinflation, owner)("try_set_owner_from(): mid="
 191                                        INTPTR_FORMAT ", prev=" INTPTR_FORMAT
 192                                        ", new=" INTPTR_FORMAT, p2i(this),
 193                                        p2i(prev), p2i(new_value));
 194   }


< prev index next >