Commit dedaae98 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Replace folly::asm_pause with folly::asm_volatile_pause

Summary: There is no difference, as the statements are already implicitly volatile.

Reviewed By: yfeldblum

Differential Revision: D5363491

fbshipit-source-id: ab5bb878f5ca72aa0de96f82e345213729c071e2
parent 8b7d44fb
......@@ -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;
......
......@@ -991,7 +991,7 @@ class SharedMutexImpl {
return;
}
}
asm_pause();
asm_volatile_pause();
if (UNLIKELY(++spinCount >= kMaxSpinCount)) {
applyDeferredReaders(state, ctx, slot);
return;
......
......@@ -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();
}
......
......@@ -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
}
}
......@@ -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];
......
......@@ -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();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment