[asan] use xchg instead of CAS in FakeStack::Allocate (5% faster for this case)

llvm-svn: 190589
This commit is contained in:
Kostya Serebryany 2013-09-12 07:28:42 +00:00
parent 729c8dc65b
commit e8f961e847
1 changed files with 2 additions and 3 deletions

View File

@ -31,10 +31,9 @@ FakeFrame *FakeStack::Allocate(uptr stack_size_log, uptr class_id,
for (int i = 0; i < num_iter; i++) {
uptr pos = ModuloNumberOfFrames(stack_size_log, class_id, hint_position++);
if (flags[pos]) continue;
u8 zero = 0;
// FIXME: this does not have to be thread-safe, just async-signal-safe.
if (atomic_compare_exchange_strong((atomic_uint8_t *)&flags[pos], &zero, 1,
memory_order_acquire)) {
if (0 == atomic_exchange((atomic_uint8_t *)&flags[pos], 1,
memory_order_relaxed)) {
FakeFrame *res = reinterpret_cast<FakeFrame *>(
GetFrame(stack_size_log, class_id, pos));
res->real_stack = real_stack;