remove assymetric load_acquires JEP-349-branch
authormgronlun
Sun, 15 Sep 2019 20:23:40 +0200
branchJEP-349-branch
changeset 58159 892527a70da9
parent 58158 369ebc2a11c2
child 58160 c17888eb0d03
remove assymetric load_acquires
src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp
src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.cpp
src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp
src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp
src/hotspot/share/jfr/recorder/repository/jfrChunk.cpp
src/hotspot/share/jfr/recorder/service/jfrPostBox.cpp
src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp
src/hotspot/share/jfr/recorder/storage/jfrBuffer.cpp
src/hotspot/share/jfr/recorder/storage/jfrBuffer.hpp
src/hotspot/share/jfr/recorder/storage/jfrStorageControl.cpp
src/hotspot/share/jfr/recorder/storage/jfrVirtualMemory.cpp
src/hotspot/share/jfr/utilities/jfrAllocation.cpp
--- a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp	Sun Sep 15 15:31:04 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp	Sun Sep 15 20:23:40 2019 +0200
@@ -168,7 +168,7 @@
 }
 
 bool JfrCheckpointManager::use_epoch_transition_mspace(const Thread* thread) const {
-  return _service_thread != thread && OrderAccess::load_acquire(&_checkpoint_epoch_state) != JfrTraceIdEpoch::epoch();
+  return _service_thread != thread && _checkpoint_epoch_state != JfrTraceIdEpoch::epoch();
 }
 
 static const size_t lease_retry = 10;
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.cpp	Sun Sep 15 15:31:04 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.cpp	Sun Sep 15 20:23:40 2019 +0200
@@ -33,7 +33,6 @@
 #include "oops/method.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/atomic.hpp"
-#include "runtime/orderAccess.hpp"
 #include "runtime/vm_version.hpp"
 #include "runtime/jniHandles.inline.hpp"
 #include "runtime/thread.inline.hpp"
@@ -45,7 +44,7 @@
   traceid compare_value;
   traceid exchange_value;
   do {
-    compare_value = OrderAccess::load_acquire(dest);
+    compare_value = Atomic::load(dest);
     exchange_value = compare_value + 1;
   } while (Atomic::cmpxchg(exchange_value, dest, compare_value) != compare_value);
   return exchange_value;
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp	Sun Sep 15 15:31:04 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp	Sun Sep 15 20:23:40 2019 +0200
@@ -31,7 +31,6 @@
 #include "jfr/recorder/checkpoint/types/traceid/jfrTraceId.hpp"
 #include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdBits.inline.hpp"
 #include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp"
-#include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdMacros.hpp"
 #include "jfr/support/jfrKlassExtension.hpp"
 #include "oops/arrayKlass.hpp"
 #include "oops/klass.hpp"
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp	Sun Sep 15 15:31:04 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp	Sun Sep 15 20:23:40 2019 +0200
@@ -25,18 +25,19 @@
 #ifndef SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDEPOCH_HPP
 #define SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDEPOCH_HPP
 
+#include "jfr/utilities/jfrTypes.hpp"
 #include "memory/allocation.hpp"
 #include "runtime/orderAccess.hpp"
 
-#define USED_BIT 1
-#define METHOD_USED_BIT (USED_BIT << 2)
-#define EPOCH_1_SHIFT 0
-#define EPOCH_2_SHIFT 1
-#define USED_EPOCH_1_BIT (USED_BIT << EPOCH_1_SHIFT)
-#define USED_EPOCH_2_BIT (USED_BIT << EPOCH_2_SHIFT)
-#define METHOD_USED_EPOCH_1_BIT (METHOD_USED_BIT << EPOCH_1_SHIFT)
-#define METHOD_USED_EPOCH_2_BIT (METHOD_USED_BIT << EPOCH_2_SHIFT)
-#define METHOD_AND_CLASS_IN_USE_BITS (METHOD_USED_BIT | USED_BIT)
+#define USED_BIT                             1
+#define METHOD_USED_BIT                      (USED_BIT << 2)
+#define EPOCH_1_SHIFT                        0
+#define EPOCH_2_SHIFT                        1
+#define USED_EPOCH_1_BIT                     (USED_BIT << EPOCH_1_SHIFT)
+#define USED_EPOCH_2_BIT                     (USED_BIT << EPOCH_2_SHIFT)
+#define METHOD_USED_EPOCH_1_BIT              (METHOD_USED_BIT << EPOCH_1_SHIFT)
+#define METHOD_USED_EPOCH_2_BIT              (METHOD_USED_BIT << EPOCH_2_SHIFT)
+#define METHOD_AND_CLASS_IN_USE_BITS         (METHOD_USED_BIT | USED_BIT)
 #define METHOD_AND_CLASS_IN_USE_EPOCH_1_BITS (METHOD_AND_CLASS_IN_USE_BITS << EPOCH_1_SHIFT)
 #define METHOD_AND_CLASS_IN_USE_EPOCH_2_BITS (METHOD_AND_CLASS_IN_USE_BITS << EPOCH_2_SHIFT)
 
--- a/src/hotspot/share/jfr/recorder/repository/jfrChunk.cpp	Sun Sep 15 15:31:04 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/repository/jfrChunk.cpp	Sun Sep 15 20:23:40 2019 +0200
@@ -25,6 +25,7 @@
 #include "precompiled.hpp"
 #include "jfr/recorder/repository/jfrChunk.hpp"
 #include "jfr/recorder/service/jfrOptionSet.hpp"
+#include "jfr/utilities/jfrTime.hpp"
 #include "jfr/utilities/jfrTimeConverter.hpp"
 #include "jfr/utilities/jfrTypes.hpp"
 #include "runtime/os.inline.hpp"
--- a/src/hotspot/share/jfr/recorder/service/jfrPostBox.cpp	Sun Sep 15 15:31:04 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/service/jfrPostBox.cpp	Sun Sep 15 20:23:40 2019 +0200
@@ -26,7 +26,6 @@
 #include "jfr/recorder/service/jfrPostBox.hpp"
 #include "jfr/utilities/jfrTryLock.hpp"
 #include "runtime/atomic.hpp"
-#include "runtime/orderAccess.hpp"
 #include "runtime/thread.inline.hpp"
 
 #define MSG_IS_SYNCHRONOUS ( (MSGBIT(MSG_ROTATE)) |          \
@@ -86,7 +85,7 @@
 
 void JfrPostBox::deposit(int new_messages) {
   while (true) {
-    const int current_msgs = OrderAccess::load_acquire(&_messages);
+    const int current_msgs = Atomic::load(&_messages);
     // OR the new message
     const int exchange_value = current_msgs | new_messages;
     const int result = Atomic::cmpxchg(exchange_value, &_messages, current_msgs);
@@ -116,7 +115,7 @@
   deposit(msg);
   // serial_id is used to check when what we send in has been processed.
   // _msg_read_serial is read under JfrMsg_lock protection.
-  const uintptr_t serial_id = OrderAccess::load_acquire(&_msg_read_serial) + 1;
+  const uintptr_t serial_id = Atomic::load(&_msg_read_serial) + 1;
   msg_lock.notify_all();
   while (!is_message_processed(serial_id)) {
     msg_lock.wait();
@@ -131,12 +130,12 @@
  */
 bool JfrPostBox::is_message_processed(uintptr_t serial_id) const {
   assert(JfrMsg_lock->owned_by_self(), "_msg_handled_serial must be read under JfrMsg_lock protection");
-  return serial_id <= OrderAccess::load_acquire(&_msg_handled_serial);
+  return serial_id <= Atomic::load(&_msg_handled_serial);
 }
 
 bool JfrPostBox::is_empty() const {
   assert(JfrMsg_lock->owned_by_self(), "not holding JfrMsg_lock!");
-  return OrderAccess::load_acquire(&_messages) == 0;
+  return Atomic::load(&_messages) == 0;
 }
 
 int JfrPostBox::collect() {
--- a/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp	Sun Sep 15 15:31:04 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp	Sun Sep 15 20:23:40 2019 +0200
@@ -59,7 +59,7 @@
 // set data iff *dest == NULL
 static bool try_set(void* const data, void** dest, bool clear) {
   assert(data != NULL, "invariant");
-  const void* const current = OrderAccess::load_acquire(dest);
+  const void* const current = Atomic::load(dest);
   if (current != NULL) {
     if (current != data) {
       // already set
--- a/src/hotspot/share/jfr/recorder/storage/jfrBuffer.cpp	Sun Sep 15 15:31:04 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/storage/jfrBuffer.cpp	Sun Sep 15 20:23:40 2019 +0200
@@ -88,7 +88,7 @@
 const u1* JfrBuffer::stable_top() const {
   const u1* current_top;
   do {
-    current_top = OrderAccess::load_acquire(&_top);
+    current_top = Atomic::load(&_top);
   } while (MUTEX_CLAIM == current_top);
   return current_top;
 }
@@ -115,7 +115,8 @@
   assert(new_top <= end(), "invariant");
   assert(new_top >= start(), "invariant");
   assert(top() == MUTEX_CLAIM, "invariant");
-  OrderAccess::release_store(&_top, new_top);
+  OrderAccess::storestore();
+  _top = new_top;
 }
 
 size_t JfrBuffer::unflushed_size() const {
@@ -126,18 +127,19 @@
   assert(id != NULL, "invariant");
   const void* current_id;
   do {
-    current_id = OrderAccess::load_acquire(&_identity);
+    current_id = Atomic::load(&_identity);
   } while (current_id != NULL || Atomic::cmpxchg(id, &_identity, current_id) != current_id);
 }
 
 bool JfrBuffer::try_acquire(const void* id) {
   assert(id != NULL, "invariant");
-  const void* const current_id = OrderAccess::load_acquire(&_identity);
+  const void* const current_id = Atomic::load(&_identity);
   return current_id == NULL && Atomic::cmpxchg(id, &_identity, current_id) == current_id;
 }
 
 void JfrBuffer::release() {
-  OrderAccess::release_store(&_identity, (const void*)NULL);
+  OrderAccess::storestore();
+  _identity = NULL;
 }
 
 bool JfrBuffer::acquired_by(const void* id) const {
@@ -241,32 +243,24 @@
 
 void JfrBuffer::clear_excluded() {
   if (excluded()) {
+    OrderAccess::storestore();
     _flags ^= (u1)EXCLUDED;
   }
   assert(!excluded(), "invariant");
 }
 
-static u2 load_acquire_flags(const u2* const flags) {
-  return OrderAccess::load_acquire(flags);
-}
-
-static void release_store_flags(u2* const flags, u2 new_flags) {
-  OrderAccess::release_store(flags, new_flags);
-}
-
 bool JfrBuffer::retired() const {
-  return (u1)RETIRED == (load_acquire_flags(&_flags) & (u1)RETIRED);
+  return (_flags & (u1)RETIRED) == (u1)RETIRED;
 }
 
 void JfrBuffer::set_retired() {
-  const u2 new_flags = load_acquire_flags(&_flags) | (u1)RETIRED;
-  release_store_flags(&_flags, new_flags);
+  OrderAccess::storestore();
+  _flags |= (u1)RETIRED;
 }
 
 void JfrBuffer::clear_retired() {
-  u2 new_flags = load_acquire_flags(&_flags);
-  if ((u1)RETIRED == (new_flags & (u1)RETIRED)) {
-    new_flags ^= (u1)RETIRED;
-    release_store_flags(&_flags, new_flags);
+  if (retired()) {
+    OrderAccess::storestore();
+    _flags ^= (u1)RETIRED;
   }
 }
--- a/src/hotspot/share/jfr/recorder/storage/jfrBuffer.hpp	Sun Sep 15 15:31:04 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/storage/jfrBuffer.hpp	Sun Sep 15 20:23:40 2019 +0200
@@ -169,13 +169,11 @@
   bool excluded() const;
   void set_excluded();
   void clear_excluded();
-
 };
 
 class JfrAgeNode : public JfrBuffer {
  private:
   JfrBuffer* _retired;
-
  public:
   JfrAgeNode() : _retired(NULL) {}
   void set_retired_buffer(JfrBuffer* retired) {
--- a/src/hotspot/share/jfr/recorder/storage/jfrStorageControl.cpp	Sun Sep 15 15:31:04 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/storage/jfrStorageControl.cpp	Sun Sep 15 20:23:40 2019 +0200
@@ -26,14 +26,13 @@
 #include "jfr/recorder/storage/jfrStorageControl.hpp"
 #include "runtime/atomic.hpp"
 #include "runtime/mutexLocker.hpp"
-#include "runtime/orderAccess.hpp"
 
 // returns the updated value
 static jlong atomic_add(size_t value, size_t volatile* const dest) {
   size_t compare_value;
   size_t exchange_value;
   do {
-    compare_value = OrderAccess::load_acquire(dest);
+    compare_value = Atomic::load(dest);
     exchange_value = compare_value + value;
   } while (Atomic::cmpxchg(exchange_value, dest, compare_value) != compare_value);
   return exchange_value;
@@ -43,7 +42,7 @@
   size_t compare_value;
   size_t exchange_value;
   do {
-    compare_value = OrderAccess::load_acquire(dest);
+    compare_value = Atomic::load(dest);
     assert(compare_value >= 1, "invariant");
     exchange_value = compare_value - 1;
   } while (Atomic::cmpxchg(exchange_value, dest, compare_value) != compare_value);
@@ -102,7 +101,7 @@
 // concurrent with accuracy requirement
 
 size_t JfrStorageControl::global_lease_count() const {
-  return OrderAccess::load_acquire(&_global_lease_count);
+  return Atomic::load(&_global_lease_count);
 }
 
 size_t JfrStorageControl::increment_leased() {
--- a/src/hotspot/share/jfr/recorder/storage/jfrVirtualMemory.cpp	Sun Sep 15 15:31:04 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/storage/jfrVirtualMemory.cpp	Sun Sep 15 20:23:40 2019 +0200
@@ -26,7 +26,6 @@
 #include "jfr/recorder/storage/jfrVirtualMemory.hpp"
 #include "memory/virtualspace.hpp"
 #include "runtime/globals.hpp"
-#include "runtime/orderAccess.hpp"
 #include "runtime/os.hpp"
 #include "services/memTracker.hpp"
 #include "utilities/globalDefinitions.hpp"
--- a/src/hotspot/share/jfr/utilities/jfrAllocation.cpp	Sun Sep 15 15:31:04 2019 +0200
+++ b/src/hotspot/share/jfr/utilities/jfrAllocation.cpp	Sun Sep 15 20:23:40 2019 +0200
@@ -28,7 +28,6 @@
 #include "logging/log.hpp"
 #include "memory/allocation.inline.hpp"
 #include "runtime/atomic.hpp"
-#include "runtime/orderAccess.hpp"
 #include "runtime/vm_version.hpp"
 #include "utilities/debug.hpp"
 #include "utilities/macros.hpp"
@@ -40,7 +39,7 @@
   jlong compare_value;
   jlong exchange_value;
   do {
-    compare_value = OrderAccess::load_acquire(dest);
+    compare_value = Atomic::load(dest);
     exchange_value = compare_value + value;
   } while (Atomic::cmpxchg(exchange_value, dest, compare_value) != compare_value);
   return exchange_value;