Changeset View
Changeset View
Standalone View
Standalone View
compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cpp
Show First 20 Lines • Show All 423 Lines • ▼ Show 20 Lines | void AcquireGlobal(ThreadState *thr, uptr pc) { | ||||
DPrintf("#%d: AcquireGlobal\n", thr->tid); | DPrintf("#%d: AcquireGlobal\n", thr->tid); | ||||
if (thr->ignore_sync) | if (thr->ignore_sync) | ||||
return; | return; | ||||
ThreadRegistryLock l(ctx->thread_registry); | ThreadRegistryLock l(ctx->thread_registry); | ||||
ctx->thread_registry->RunCallbackForEachThreadLocked( | ctx->thread_registry->RunCallbackForEachThreadLocked( | ||||
UpdateClockCallback, thr); | UpdateClockCallback, thr); | ||||
} | } | ||||
void ReleaseAcquire(ThreadState *thr, uptr pc, uptr addr) { | |||||
DPrintf("#%d: ReleaseAcquire %zx\n", thr->tid, addr); | |||||
if (thr->ignore_sync) | |||||
return; | |||||
SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true); | |||||
thr->fast_state.IncrementEpoch(); | |||||
// Can't increment epoch w/o writing to the trace as well. | |||||
TraceAddEvent(thr, thr->fast_state, EventTypeMop, 0); | |||||
ReleaseAcquireImpl(thr, pc, &s->clock); | |||||
s->mtx.Unlock(); | |||||
} | |||||
void Release(ThreadState *thr, uptr pc, uptr addr) { | void Release(ThreadState *thr, uptr pc, uptr addr) { | ||||
DPrintf("#%d: Release %zx\n", thr->tid, addr); | DPrintf("#%d: Release %zx\n", thr->tid, addr); | ||||
if (thr->ignore_sync) | if (thr->ignore_sync) | ||||
return; | return; | ||||
SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true); | SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true); | ||||
thr->fast_state.IncrementEpoch(); | thr->fast_state.IncrementEpoch(); | ||||
// Can't increment epoch w/o writing to the trace as well. | // Can't increment epoch w/o writing to the trace as well. | ||||
TraceAddEvent(thr, thr->fast_state, EventTypeMop, 0); | TraceAddEvent(thr, thr->fast_state, EventTypeMop, 0); | ||||
Show All 37 Lines | |||||
void AcquireImpl(ThreadState *thr, uptr pc, SyncClock *c) { | void AcquireImpl(ThreadState *thr, uptr pc, SyncClock *c) { | ||||
if (thr->ignore_sync) | if (thr->ignore_sync) | ||||
return; | return; | ||||
thr->clock.set(thr->fast_state.epoch()); | thr->clock.set(thr->fast_state.epoch()); | ||||
thr->clock.acquire(&thr->proc()->clock_cache, c); | thr->clock.acquire(&thr->proc()->clock_cache, c); | ||||
StatInc(thr, StatSyncAcquire); | StatInc(thr, StatSyncAcquire); | ||||
} | } | ||||
void ReleaseAcquireImpl(ThreadState *thr, uptr pc, SyncClock *c) { | |||||
if (thr->ignore_sync) | |||||
return; | |||||
thr->clock.set(thr->fast_state.epoch()); | |||||
thr->fast_synch_epoch = thr->fast_state.epoch(); | |||||
thr->clock.releaseAcquire(&thr->proc()->clock_cache, c); | |||||
StatInc(thr, StatSyncReleaseAcquire); | |||||
} | |||||
void ReleaseImpl(ThreadState *thr, uptr pc, SyncClock *c) { | void ReleaseImpl(ThreadState *thr, uptr pc, SyncClock *c) { | ||||
if (thr->ignore_sync) | if (thr->ignore_sync) | ||||
return; | return; | ||||
thr->clock.set(thr->fast_state.epoch()); | thr->clock.set(thr->fast_state.epoch()); | ||||
thr->fast_synch_epoch = thr->fast_state.epoch(); | thr->fast_synch_epoch = thr->fast_state.epoch(); | ||||
thr->clock.release(&thr->proc()->clock_cache, c); | thr->clock.release(&thr->proc()->clock_cache, c); | ||||
StatInc(thr, StatSyncRelease); | StatInc(thr, StatSyncRelease); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |