diff options
Diffstat (limited to 'compiler-rt/lib/tsan/rtl/tsan_clock.h')
-rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_clock.h | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/compiler-rt/lib/tsan/rtl/tsan_clock.h b/compiler-rt/lib/tsan/rtl/tsan_clock.h index a57a0e4f791..931fde80b07 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_clock.h +++ b/compiler-rt/lib/tsan/rtl/tsan_clock.h @@ -18,7 +18,10 @@ namespace __tsan { -const u64 kClkMask = (1ULL << kClkBits) - 1; +struct ClockElem { + u64 epoch : kClkBits; + u64 reused : 64 - kClkBits; +}; // The clock that lives in sync variables (mutexes, atomics, etc). class SyncClock { @@ -31,7 +34,7 @@ class SyncClock { u64 get(unsigned tid) const { DCHECK_LT(tid, clk_.Size()); - return clk_[tid] & kClkMask; + return clk_[tid].epoch; } void Reset(); @@ -39,34 +42,33 @@ class SyncClock { void DebugDump(int(*printf)(const char *s, ...)); private: - u64 release_seq_; unsigned release_store_tid_; + unsigned release_store_reused_; static const uptr kDirtyTids = 2; unsigned dirty_tids_[kDirtyTids]; - mutable Vector<u64> clk_; + mutable Vector<ClockElem> clk_; friend struct ThreadClock; }; // The clock that lives in threads. struct ThreadClock { public: - explicit ThreadClock(unsigned tid); + explicit ThreadClock(unsigned tid, unsigned reused = 0); u64 get(unsigned tid) const { DCHECK_LT(tid, kMaxTidInClock); - DCHECK_EQ(clk_[tid], clk_[tid] & kClkMask); - return clk_[tid]; + return clk_[tid].epoch; } void set(unsigned tid, u64 v); void set(u64 v) { - DCHECK_GE(v, clk_[tid_]); - clk_[tid_] = v; + DCHECK_GE(v, clk_[tid_].epoch); + clk_[tid_].epoch = v; } void tick() { - clk_[tid_]++; + clk_[tid_].epoch++; } uptr size() const { @@ -78,14 +80,16 @@ struct ThreadClock { void acq_rel(SyncClock *dst); void ReleaseStore(SyncClock *dst) const; + void DebugReset(); void DebugDump(int(*printf)(const char *s, ...)); private: static const uptr kDirtyTids = SyncClock::kDirtyTids; const unsigned tid_; + const unsigned reused_; u64 last_acquire_; uptr nclk_; - u64 clk_[kMaxTidInClock]; + ClockElem clk_[kMaxTidInClock]; bool IsAlreadyAcquired(const SyncClock *src) const; void UpdateCurrentThread(SyncClock *dst) const; |