Replace folly::asm_pause with folly::asm_volatile_pause v2017.07.03.00
authorChristopher Dykes <cdykes@fb.com>
Mon, 3 Jul 2017 04:20:10 +0000 (21:20 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Mon, 3 Jul 2017 04:34:44 +0000 (21:34 -0700)
Summary: There is no difference, as the statements are already implicitly volatile.

Reviewed By: yfeldblum

Differential Revision: D5363491

fbshipit-source-id: ab5bb878f5ca72aa0de96f82e345213729c071e2

folly/MicroLock.cpp
folly/SharedMutex.h
folly/detail/AtomicHashUtils.h
folly/portability/Asm.h
folly/test/SmallLocksTest.cpp
folly/test/SpinLockTest.cpp

index 06e8de08768bb01bbb69636dffed07b198738108..ac587ca066429b0a8d488fde1cb8054e97ab79db 100644 (file)
@@ -51,7 +51,7 @@ retry:
       // sched_yield(), but more portable
       std::this_thread::yield();
     } else {
-      folly::asm_pause();
+      folly::asm_volatile_pause();
     }
     oldWord = wordPtr->load(std::memory_order_relaxed);
     goto retry;
index 24d8051c4d5e81780610a4d5c83b8084298f6766..163382ab34b8155dc7e0b60cd95f23ef4af76ce5 100644 (file)
@@ -991,7 +991,7 @@ class SharedMutexImpl {
           return;
         }
       }
-      asm_pause();
+      asm_volatile_pause();
       if (UNLIKELY(++spinCount >= kMaxSpinCount)) {
         applyDeferredReaders(state, ctx, slot);
         return;
index 70d30ac2c62f32339a997c99975ed677c3d98784..e9ca9d0be289ac04e7d0c4ce388e0871a4cbd619 100644 (file)
@@ -29,7 +29,7 @@ void atomic_hash_spin_wait(Cond condition) {
   constexpr size_t kPauseLimit = 10000;
   for (size_t i = 0; condition(); ++i) {
     if (i < kPauseLimit) {
-      folly::asm_pause();
+      folly::asm_volatile_pause();
     } else {
       std::this_thread::yield();
     }
index f3343649715edb695ef17329921fb5aa51e69ee5..f7b7ebba86d0b52f933ca31ee43e198a5cee8f2e 100644 (file)
@@ -42,16 +42,4 @@ inline void asm_volatile_pause() {
   asm volatile("or 27,27,27");
 #endif
 }
-
-inline void asm_pause() {
-#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
-  ::_mm_pause();
-#elif defined(__i386__) || FOLLY_X64
-  asm("pause");
-#elif FOLLY_A64 || defined(__arm__)
-  asm("yield");
-#elif FOLLY_PPC64
-  asm("or 31,31,31");
-#endif
-}
 }
index 9da8b2bd098c223e7cec110878fd0b41b8199a50..77f42db7d32d32d9bebf857c726e418843fb0871 100644 (file)
@@ -71,7 +71,7 @@ void splock_test() {
   const int max = 1000;
   auto rng = folly::ThreadLocalPRNG();
   for (int i = 0; i < max; i++) {
-    folly::asm_pause();
+    folly::asm_volatile_pause();
     MSLGuard g(v.lock);
 
     int first = v.ar[0];
index 67279a700f82367151b122f673fcb118616c2617..1f53d76f33f447c557649d3237afec08ae751f52 100644 (file)
@@ -42,7 +42,7 @@ void spinlockTestThread(LockedVal<LOCK>* v) {
   const int max = 1000;
   auto rng = folly::ThreadLocalPRNG();
   for (int i = 0; i < max; i++) {
-    folly::asm_pause();
+    folly::asm_volatile_pause();
     SpinLockGuardImpl<LOCK> g(v->lock);
 
     int first = v->ar[0];
@@ -67,7 +67,7 @@ struct TryLockState {
 template <typename LOCK>
 void trylockTestThread(TryLockState<LOCK>* state, size_t count) {
   while (true) {
-    folly::asm_pause();
+    folly::asm_volatile_pause();
     bool ret = state->lock2.try_lock();
     SpinLockGuardImpl<LOCK> g(state->lock1);
     if (state->obtained >= count) {
@@ -89,7 +89,7 @@ void trylockTestThread(TryLockState<LOCK>* state, size_t count) {
       auto oldFailed = state->failed;
       while (state->failed == oldFailed && state->obtained < count) {
         state->lock1.unlock();
-        folly::asm_pause();
+        folly::asm_volatile_pause();
         state->lock1.lock();
       }