Changeset View
Changeset View
Standalone View
Standalone View
compiler-rt/lib/tsan/rtl/tsan_clock.cpp
Show All 24 Lines | |||||
// clock[i] = max(clock[i], src->clock[i]); | // clock[i] = max(clock[i], src->clock[i]); | ||||
// } | // } | ||||
// | // | ||||
// void ThreadClock::release(SyncClock *dst) const { | // void ThreadClock::release(SyncClock *dst) const { | ||||
// for (int i = 0; i < kMaxThreads; i++) | // for (int i = 0; i < kMaxThreads; i++) | ||||
// dst->clock[i] = max(dst->clock[i], clock[i]); | // dst->clock[i] = max(dst->clock[i], clock[i]); | ||||
// } | // } | ||||
// | // | ||||
// void ThreadClock::releaseStoreAcquire(SyncClock *sc) const { | |||||
// for (int i = 0; i < kMaxThreads; i++) { | |||||
// tmp = clock[i]; | |||||
// clock[i] = max(clock[i], sc->clock[i]); | |||||
// sc->clock[i] = tmp; | |||||
dvyukov: So this is effectively releaseStore.
There is a somewhat mismatching terminology we use in tsan… | |||||
// } | |||||
// } | |||||
// | |||||
// void ThreadClock::ReleaseStore(SyncClock *dst) const { | // void ThreadClock::ReleaseStore(SyncClock *dst) const { | ||||
// for (int i = 0; i < kMaxThreads; i++) | // for (int i = 0; i < kMaxThreads; i++) | ||||
// dst->clock[i] = clock[i]; | // dst->clock[i] = clock[i]; | ||||
// } | // } | ||||
// | // | ||||
// void ThreadClock::acq_rel(SyncClock *dst) { | // void ThreadClock::acq_rel(SyncClock *dst) { | ||||
// acquire(dst); | // acquire(dst); | ||||
// release(dst); | // release(dst); | ||||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | void ThreadClock::acquire(ClockCache *c, SyncClock *src) { | ||||
if (acquired) { | if (acquired) { | ||||
CPP_STAT_INC(StatClockAcquiredSomething); | CPP_STAT_INC(StatClockAcquiredSomething); | ||||
last_acquire_ = clk_[tid_]; | last_acquire_ = clk_[tid_]; | ||||
ResetCached(c); | ResetCached(c); | ||||
} | } | ||||
} | } | ||||
void ThreadClock::releaseStoreAcquire(ClockCache *c, SyncClock *sc) { | |||||
DCHECK_LE(nclk_, kMaxTid); | |||||
DCHECK_LE(dst->size_, kMaxTid); | |||||
if (sc->size_ == 0) { | |||||
// ReleaseStore will correctly set release_store_tid_, | |||||
// which can be important for future operations. | |||||
ReleaseStore(c, sc); | |||||
return; | |||||
} | |||||
// Check if we need to resize dst. | |||||
if (sc->size_ < nclk_) | |||||
sc->Resize(c, nclk_); | |||||
sc->Unshare(c); | |||||
// Update sc->clk_. | |||||
sc->FlushDirty(); | |||||
Not Done ReplyInline ActionsThis acquired is not used (other than for stats). dvyukov: This acquired is not used (other than for stats).
We either need to remove this, or do just… | |||||
uptr i = 0; | |||||
for (ClockElem &ce : *sc) { | |||||
u64 tmp = clk_[i]; | |||||
clk_[i] = max(ce.epoch, clk_[i]); | |||||
ce.epoch = tmp; | |||||
ce.reused = 0; | |||||
i++; | |||||
} | |||||
sc->release_store_tid_ = kInvalidTid; | |||||
sc->release_store_reused_ = 0; | |||||
} | |||||
void ThreadClock::release(ClockCache *c, SyncClock *dst) { | void ThreadClock::release(ClockCache *c, SyncClock *dst) { | ||||
DCHECK_LE(nclk_, kMaxTid); | DCHECK_LE(nclk_, kMaxTid); | ||||
DCHECK_LE(dst->size_, kMaxTid); | DCHECK_LE(dst->size_, kMaxTid); | ||||
if (dst->size_ == 0) { | if (dst->size_ == 0) { | ||||
// ReleaseStore will correctly set release_store_tid_, | // ReleaseStore will correctly set release_store_tid_, | ||||
// which can be important for future operations. | // which can be important for future operations. | ||||
ReleaseStore(c, dst); | ReleaseStore(c, dst); | ||||
▲ Show 20 Lines • Show All 408 Lines • Show Last 20 Lines |
So this is effectively releaseStore.
There is a somewhat mismatching terminology we use in tsan runtime vs Go api.
If Go api these are called releaseMerge and release, which corresponds to release and releaseStore terminology in tsan runtime. So more complete name would be something like releaseStoreAcquire.