< prev index next >

src/hotspot/share/jfr/recorder/storage/jfrStorageControl.cpp

Print this page




   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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "jfr/recorder/storage/jfrStorageControl.hpp"
  27 #include "runtime/atomic.hpp"
  28 #include "runtime/mutexLocker.hpp"
  29 #include "runtime/orderAccess.inline.hpp"
  30 
  31 // returns the updated value
  32 static jlong atomic_add(size_t value, size_t volatile* const dest) {
  33   size_t compare_value;
  34   size_t exchange_value;
  35   do {
  36     compare_value = OrderAccess::load_acquire(dest);
  37     exchange_value = compare_value + value;
  38   } while (Atomic::cmpxchg(exchange_value, dest, compare_value) != compare_value);
  39   return exchange_value;
  40 }
  41 
  42 static jlong atomic_dec(size_t volatile* const dest) {
  43   size_t compare_value;
  44   size_t exchange_value;
  45   do {
  46     compare_value = OrderAccess::load_acquire(dest);
  47     assert(compare_value >= 1, "invariant");
  48     exchange_value = compare_value - 1;
  49   } while (Atomic::cmpxchg(exchange_value, dest, compare_value) != compare_value);




   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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "jfr/recorder/storage/jfrStorageControl.hpp"
  27 #include "runtime/atomic.hpp"
  28 #include "runtime/mutexLocker.hpp"
  29 #include "runtime/orderAccess.hpp"
  30 
  31 // returns the updated value
  32 static jlong atomic_add(size_t value, size_t volatile* const dest) {
  33   size_t compare_value;
  34   size_t exchange_value;
  35   do {
  36     compare_value = OrderAccess::load_acquire(dest);
  37     exchange_value = compare_value + value;
  38   } while (Atomic::cmpxchg(exchange_value, dest, compare_value) != compare_value);
  39   return exchange_value;
  40 }
  41 
  42 static jlong atomic_dec(size_t volatile* const dest) {
  43   size_t compare_value;
  44   size_t exchange_value;
  45   do {
  46     compare_value = OrderAccess::load_acquire(dest);
  47     assert(compare_value >= 1, "invariant");
  48     exchange_value = compare_value - 1;
  49   } while (Atomic::cmpxchg(exchange_value, dest, compare_value) != compare_value);


< prev index next >