Commit add5a7ae authored by Scott Wolchok's avatar Scott Wolchok Committed by Facebook Github Bot 0

Use yield, not wfe, for asm_volatile_pause on ARM and ARM64

Summary:Found this hunting down LockFreeRingBuffer iOS perf problems. `wfe` and `yield` are similar, but `yield` is the instruction meant for "hey, I'm doing a spinlock", whereas `wfe` tries to wait for certain processor events. See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cjafcggi.html

Conveniently, it's the same instruction on 32-bit and 64-bit ARM.

Reviewed By: yfeldblum

Differential Revision: D2986160

fb-gh-sync-id: 34671256112e605bf857f9db54a56cf6bb6f1ee2
shipit-source-id: 34671256112e605bf857f9db54a56cf6bb6f1ee2
parent a7d7c07c
...@@ -430,8 +430,8 @@ inline void asm_volatile_pause() { ...@@ -430,8 +430,8 @@ inline void asm_volatile_pause() {
::_mm_pause(); ::_mm_pause();
#elif defined(__i386__) || FOLLY_X64 #elif defined(__i386__) || FOLLY_X64
asm volatile ("pause"); asm volatile ("pause");
#elif FOLLY_A64 #elif FOLLY_A64 || defined(__arm__)
asm volatile ("wfe"); asm volatile ("yield");
#elif FOLLY_PPC64 #elif FOLLY_PPC64
asm volatile("or 27,27,27"); asm volatile("or 27,27,27");
#endif #endif
...@@ -441,8 +441,8 @@ inline void asm_pause() { ...@@ -441,8 +441,8 @@ inline void asm_pause() {
::_mm_pause(); ::_mm_pause();
#elif defined(__i386__) || FOLLY_X64 #elif defined(__i386__) || FOLLY_X64
asm ("pause"); asm ("pause");
#elif FOLLY_A64 #elif FOLLY_A64 || defined(__arm__)
asm ("wfe"); asm ("yield");
#elif FOLLY_PPC64 #elif FOLLY_PPC64
asm ("or 31,31,31"); asm ("or 31,31,31");
#endif #endif
......
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