Skip to content

Commit 36ca9a2

Browse files
committed
[scudo] Use getMonotonicTimeFast for tryLock.
In tryLock, the Precedence value is set using the fast time function now. This should speed up tryLock calls slightly. This should be okay even though the value is used as a kind of random value in getTSDAndLockSlow. The fast time call still sets enough bits to avoid getting the same TSD on every call. Reviewed By: Chia-hungDuan Differential Revision: https://reviews.llvm.org/D154039
1 parent b4ff893 commit 36ca9a2

File tree

1 file changed

+3
-3
lines changed
  • compiler-rt/lib/scudo/standalone

1 file changed

+3
-3
lines changed

compiler-rt/lib/scudo/standalone/tsd.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ template <class Allocator> struct alignas(SCUDO_CACHE_LINE_SIZE) TSD {
4141
return true;
4242
}
4343
if (atomic_load_relaxed(&Precedence) == 0)
44-
atomic_store_relaxed(
45-
&Precedence,
46-
static_cast<uptr>(getMonotonicTime() >> FIRST_32_SECOND_64(16, 0)));
44+
atomic_store_relaxed(&Precedence,
45+
static_cast<uptr>(getMonotonicTimeFast() >>
46+
FIRST_32_SECOND_64(16, 0)));
4747
return false;
4848
}
4949
inline void lock() NO_THREAD_SAFETY_ANALYSIS {

0 commit comments

Comments
 (0)