tsan: don't release disabled clocks

llvm-svn: 167451
This commit is contained in:
Dmitry Vyukov 2012-11-06 13:16:25 +00:00
parent 2817639411
commit ba827dfdae
2 changed files with 8 additions and 1 deletions

View File

@ -58,6 +58,7 @@ namespace __tsan {
ThreadClock::ThreadClock() {
nclk_ = 0;
disabled_ = false;
for (uptr i = 0; i < (uptr)kMaxTidInClock; i++)
clk_[i] = 0;
}
@ -80,6 +81,8 @@ void ThreadClock::release(SyncClock *dst) const {
DCHECK(nclk_ <= kMaxTid);
DCHECK(dst->clk_.Size() <= kMaxTid);
if (disabled_)
return;
if (dst->clk_.Size() < nclk_)
dst->clk_.Resize(nclk_);
for (uptr i = 0; i < nclk_; i++) {
@ -92,6 +95,8 @@ void ThreadClock::ReleaseStore(SyncClock *dst) const {
DCHECK(nclk_ <= kMaxTid);
DCHECK(dst->clk_.Size() <= kMaxTid);
if (disabled_)
return;
if (dst->clk_.Size() < nclk_)
dst->clk_.Resize(nclk_);
for (uptr i = 0; i < nclk_; i++)
@ -106,6 +111,7 @@ void ThreadClock::acq_rel(SyncClock *dst) {
}
void ThreadClock::Disable(unsigned tid) {
disabled_ = true;
u64 c0 = clk_[tid];
for (uptr i = 0; i < kMaxTidInClock; i++)
clk_[i] = (u64)-1;

View File

@ -48,7 +48,7 @@ struct ThreadClock {
void set(unsigned tid, u64 v) {
DCHECK_LT(tid, kMaxTid);
DCHECK_GE(v, clk_[tid]);
DCHECK(v >= clk_[tid] || disabled_);
clk_[tid] = v;
if (nclk_ <= tid)
nclk_ = tid + 1;
@ -74,6 +74,7 @@ struct ThreadClock {
private:
uptr nclk_;
bool disabled_;
u64 clk_[kMaxTidInClock];
};