Bug 1658374 - add spinning hint for aarch64 in Darwin mutexes; r=glandium

This change makes everything compile and presumably has some tiny effect on
performance.  We also take the opportunity to ensure that the compiler won't
optimize out our inline asm by making the asm volatile and indicating that
it touches memory.

Differential Revision: https://phabricator.services.mozilla.com/D86594
This commit is contained in:
Nathan Froyd 2020-08-13 11:36:08 +00:00
parent 51b1eb3e1e
commit 548da43ebd

View File

@ -163,7 +163,14 @@ void mozilla::detail::MutexImpl::lock() {
mutexLock();
break;
}
asm("pause"); // Hint to the processor that we're spinning.
// Hint to the processor that we're spinning.
#ifdef __x86_64__
# define SPIN_HINT "pause"
#elif defined(__aarch64__)
# define SPIN_HINT "yield"
#endif
asm volatile(SPIN_HINT ::: "memory");
#undef SPIN_HINT
count++;
} while (!mutexTryLock());