< prev index next >

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

Print this page

  1 /*
  2  * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 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  *

 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;
 93 }
 94 
 95 // Return number of threads contending for this monitor.
 96 inline int ObjectMonitor::contentions() const {
 97   return Atomic::load(&_contentions);
 98 }
 99 
100 // Add value to the contentions field.
101 inline void ObjectMonitor::add_to_contentions(int value) {
102   Atomic::add(&_contentions, value);
103 }
104 






105 // Clear _owner field; current value must match old_value.
106 inline void ObjectMonitor::release_clear_owner(void* old_value) {
107 #ifdef ASSERT
108   void* prev = Atomic::load(&_owner);
109   assert(prev == old_value, "unexpected prev owner=" INTPTR_FORMAT
110          ", expected=" INTPTR_FORMAT, p2i(prev), p2i(old_value));
111 #endif
112   Atomic::release_store(&_owner, (void*)nullptr);
113   log_trace(monitorinflation, owner)("release_clear_owner(): mid="
114                                      INTPTR_FORMAT ", old_value=" INTPTR_FORMAT,
115                                      p2i(this), p2i(old_value));
116 }
117 
118 // Simply set _owner field to new_value; current value must match old_value.
119 // (Simple means no memory sync needed.)
120 inline void ObjectMonitor::set_owner_from(void* old_value, void* new_value) {
121 #ifdef ASSERT
122   void* prev = Atomic::load(&_owner);
123   assert(prev == old_value, "unexpected prev owner=" INTPTR_FORMAT
124          ", expected=" INTPTR_FORMAT, p2i(prev), p2i(old_value));

  1 /*
  2  * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 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  *

 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;
 93 }
 94 
 95 // Return number of threads contending for this monitor.
 96 inline int ObjectMonitor::contentions() const {
 97   return Atomic::load(&_contentions);
 98 }
 99 
100 // Add value to the contentions field.
101 inline void ObjectMonitor::add_to_contentions(int value) {
102   Atomic::add(&_contentions, value);
103 }
104 
105 inline void ObjectMonitor::set_recursions(size_t recursions) {
106   assert(_recursions == 0, "must be");
107   assert(has_owner(), "must be owned");
108   _recursions = checked_cast<intx>(recursions);
109 }
110 
111 // Clear _owner field; current value must match old_value.
112 inline void ObjectMonitor::release_clear_owner(void* old_value) {
113 #ifdef ASSERT
114   void* prev = Atomic::load(&_owner);
115   assert(prev == old_value, "unexpected prev owner=" INTPTR_FORMAT
116          ", expected=" INTPTR_FORMAT, p2i(prev), p2i(old_value));
117 #endif
118   Atomic::release_store(&_owner, (void*)nullptr);
119   log_trace(monitorinflation, owner)("release_clear_owner(): mid="
120                                      INTPTR_FORMAT ", old_value=" INTPTR_FORMAT,
121                                      p2i(this), p2i(old_value));
122 }
123 
124 // Simply set _owner field to new_value; current value must match old_value.
125 // (Simple means no memory sync needed.)
126 inline void ObjectMonitor::set_owner_from(void* old_value, void* new_value) {
127 #ifdef ASSERT
128   void* prev = Atomic::load(&_owner);
129   assert(prev == old_value, "unexpected prev owner=" INTPTR_FORMAT
130          ", expected=" INTPTR_FORMAT, p2i(prev), p2i(old_value));
< prev index next >