Home | History | Annotate | Download | only in rtl

Lines Matching defs:thr

26 void ReportDeadlock(ThreadState *thr, uptr pc, DDReport *r);
29 ThreadState *thr;
32 Callback(ThreadState *thr, uptr pc)
33 : thr(thr)
35 DDCallback::pt = thr->dd_pt;
36 DDCallback::lt = thr->dd_lt;
40 return CurrentStackId(thr, pc);
43 return thr->unique_id;
47 void DDMutexInit(ThreadState *thr, uptr pc, SyncVar *s) {
48 Callback cb(thr, pc);
53 static void ReportMutexMisuse(ThreadState *thr, uptr pc, ReportType typ,
63 trace.ObtainCurrent(thr, pc);
66 OutputReport(thr, rep);
69 void MutexCreate(ThreadState *thr, uptr pc, uptr addr,
71 DPrintf("#%d: MutexCreate %zx\n", thr->tid, addr);
72 StatInc(thr, StatMutexCreate);
74 CHECK(!thr->is_freeing);
75 thr->is_freeing = true;
76 MemoryWrite(thr, pc, addr, kSizeLog1);
77 thr->is_freeing = false;
79 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true);
84 s->creation_stack_id = CurrentStackId(thr, pc);
88 void MutexDestroy(ThreadState *thr, uptr pc, uptr addr) {
89 DPrintf("#%d: MutexDestroy %zx\n", thr->tid, addr);
90 StatInc(thr, StatMutexDestroy);
98 CHECK(!thr->is_freeing);
99 thr->is_freeing = true;
100 MemoryWrite(thr, pc, addr, kSizeLog1);
101 thr->is_freeing = false;
107 Callback cb(thr, pc);
128 trace.ObtainCurrent(thr, pc);
134 OutputReport(thr, rep);
143 thr->mset.Remove(mid);
147 void MutexLock(ThreadState *thr, uptr pc, uptr addr, int rec, bool try_lock) {
148 DPrintf("#%d: MutexLock %zx rec=%d\n", thr->tid, addr, rec);
151 MemoryReadAtomic(thr, pc, addr, kSizeLog1);
152 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true);
153 thr->fast_state.IncrementEpoch();
154 TraceAddEvent(thr, thr->fast_state, EventTypeLock, s->GetId());
158 s->owner_tid = thr->tid;
159 s->last_lock = thr->fast_state.raw();
160 } else if (s->owner_tid == thr->tid) {
167 StatInc(thr, StatMutexLock);
168 AcquireImpl(thr, pc, &s->clock);
169 AcquireImpl(thr, pc, &s->read_clock);
171 StatInc(thr, StatMutexRecLock);
174 thr->mset.Add(s->GetId(), true, thr->fast_state.epoch());
176 Callback cb(thr, pc);
185 ReportMutexMisuse(thr, pc, ReportTypeMutexDoubleLock, addr, mid);
187 Callback cb(thr, pc);
188 ReportDeadlock(thr, pc, ctx->dd->GetReport(&cb));
192 int MutexUnlock(ThreadState *thr, uptr pc, uptr addr, bool all) {
193 DPrintf("#%d: MutexUnlock %zx all=%d\n", thr->tid, addr, all);
195 MemoryReadAtomic(thr, pc, addr, kSizeLog1);
196 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true);
197 thr->fast_state.IncrementEpoch();
198 TraceAddEvent(thr, thr->fast_state, EventTypeUnlock, s->GetId());
201 if (kCppMode && (s->recursion == 0 || s->owner_tid != thr->tid)) {
210 StatInc(thr, StatMutexUnlock);
212 ReleaseStoreImpl(thr, pc, &s->clock);
214 StatInc(thr, StatMutexRecUnlock);
217 thr->mset.Del(s->GetId(), true);
219 Callback cb(thr, pc);
226 ReportMutexMisuse(thr, pc, ReportTypeMutexBadUnlock, addr, mid);
228 Callback cb(thr, pc);
229 ReportDeadlock(thr, pc, ctx->dd->GetReport(&cb));
234 void MutexReadLock(ThreadState *thr, uptr pc, uptr addr, bool trylock) {
235 DPrintf("#%d: MutexReadLock %zx\n", thr->tid, addr);
236 StatInc(thr, StatMutexReadLock);
238 MemoryReadAtomic(thr, pc, addr, kSizeLog1);
239 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, false);
240 thr->fast_state.IncrementEpoch();
241 TraceAddEvent(thr, thr->fast_state, EventTypeRLock, s->GetId());
249 AcquireImpl(thr, pc, &s->clock);
250 s->last_lock = thr->fast_state.raw();
251 thr->mset.Add(s->GetId(), false, thr->fast_state.epoch());
253 Callback cb(thr, pc);
262 ReportMutexMisuse(thr, pc, ReportTypeMutexBadReadLock, addr, mid);
264 Callback cb(thr, pc);
265 ReportDeadlock(thr, pc, ctx->dd->GetReport(&cb));
269 void MutexReadUnlock(ThreadState *thr, uptr pc, uptr addr) {
270 DPrintf("#%d: MutexReadUnlock %zx\n", thr->tid, addr);
271 StatInc(thr, StatMutexReadUnlock);
273 MemoryReadAtomic(thr, pc, addr, kSizeLog1);
274 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true);
275 thr->fast_state.IncrementEpoch();
276 TraceAddEvent(thr, thr->fast_state, EventTypeRUnlock, s->GetId());
284 ReleaseImpl(thr, pc, &s->read_clock);
286 Callback cb(thr, pc);
292 thr->mset.Del(mid, false);
294 ReportMutexMisuse(thr, pc, ReportTypeMutexBadReadUnlock, addr, mid);
296 Callback cb(thr, pc);
297 ReportDeadlock(thr, pc, ctx->dd->GetReport(&cb));
301 void MutexReadOrWriteUnlock(ThreadState *thr, uptr pc, uptr addr) {
302 DPrintf("#%d: MutexReadOrWriteUnlock %zx\n", thr->tid, addr);
304 MemoryReadAtomic(thr, pc, addr, kSizeLog1);
305 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true);
311 StatInc(thr, StatMutexReadUnlock);
312 thr->fast_state.IncrementEpoch();
313 TraceAddEvent(thr, thr->fast_state, EventTypeRUnlock, s->GetId());
314 ReleaseImpl(thr, pc, &s->read_clock);
315 } else if (s->owner_tid == thr->tid) {
317 thr->fast_state.IncrementEpoch();
318 TraceAddEvent(thr, thr->fast_state, EventTypeUnlock, s->GetId());
322 StatInc(thr, StatMutexUnlock);
324 ReleaseImpl(thr, pc, &s->clock);
326 StatInc(thr, StatMutexRecUnlock);
332 thr->mset.Del(s->GetId(), write);
334 Callback cb(thr, pc);
341 ReportMutexMisuse(thr, pc, ReportTypeMutexBadUnlock, addr, mid);
343 Callback cb(thr, pc);
344 ReportDeadlock(thr, pc, ctx->dd->GetReport(&cb));
348 void MutexRepair(ThreadState *thr, uptr pc, uptr addr) {
349 DPrintf("#%d: MutexRepair %zx\n", thr->tid, addr);
350 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true);
356 void Acquire(ThreadState *thr, uptr pc, uptr addr) {
357 DPrintf("#%d: Acquire %zx\n", thr->tid, addr);
358 if (thr->ignore_sync)
360 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, false);
361 AcquireImpl(thr, pc, &s->clock);
366 ThreadState *thr = reinterpret_cast<ThreadState*>(arg);
369 thr->clock.set(tctx->tid, tctx->thr->fast_state.epoch());
371 thr->clock.set(tctx->tid, tctx->epoch1);
374 void AcquireGlobal(ThreadState *thr, uptr pc) {
375 DPrintf("#%d: AcquireGlobal\n", thr->tid);
376 if (thr->ignore_sync)
380 UpdateClockCallback, thr);
383 void Release(ThreadState *thr, uptr pc, uptr addr) {
384 DPrintf("#%d: Release %zx\n", thr->tid, addr);
385 if (thr->ignore_sync)
387 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true);
388 thr->fast_state.IncrementEpoch();
390 TraceAddEvent(thr, thr->fast_state, EventTypeMop, 0);
391 ReleaseImpl(thr, pc, &s->clock);
395 void ReleaseStore(ThreadState *thr, uptr pc, uptr addr) {
396 DPrintf("#%d: ReleaseStore %zx\n", thr->tid, addr);
397 if (thr->ignore_sync)
399 SyncVar *s = ctx->metamap.GetOrCreateAndLock(thr, pc, addr, true);
400 thr->fast_state.IncrementEpoch();
402 TraceAddEvent(thr, thr->fast_state, EventTypeMop, 0);
403 ReleaseStoreImpl(thr, pc, &s->clock);
409 ThreadState *thr = reinterpret_cast<ThreadState*>(arg);
412 thr->last_sleep_clock.set(tctx->tid, tctx->thr->fast_state.epoch());
414 thr->last_sleep_clock.set(tctx->tid, tctx->epoch1);
417 void AfterSleep(ThreadState *thr, uptr pc) {
418 DPrintf("#%d: AfterSleep %zx\n", thr->tid);
419 if (thr->ignore_sync)
421 thr->last_sleep_stack_id = CurrentStackId(thr, pc);
424 UpdateSleepClockCallback, thr);
428 void AcquireImpl(ThreadState *thr, uptr pc, SyncClock *c) {
429 if (thr->ignore_sync)
431 thr->clock.set(thr->fast_state.epoch());
432 thr->clock.acquire(c);
433 StatInc(thr, StatSyncAcquire);
436 void ReleaseImpl(ThreadState *thr, uptr pc, SyncClock *c) {
437 if (thr->ignore_sync)
439 thr->clock.set(thr->fast_state.epoch());
440 thr->fast_synch_epoch = thr->fast_state.epoch();
441 thr->clock.release(c);
442 StatInc(thr, StatSyncRelease);
445 void ReleaseStoreImpl(ThreadState *thr, uptr pc, SyncClock *c) {
446 if (thr->ignore_sync)
448 thr->clock.set(thr->fast_state.epoch());
449 thr->fast_synch_epoch = thr->fast_state.epoch();
450 thr->clock.ReleaseStore(c);
451 StatInc(thr, StatSyncRelease);
454 void AcquireReleaseImpl(ThreadState *thr, uptr pc, SyncClock *c) {
455 if (thr->ignore_sync)
457 thr->clock.set(thr->fast_state.epoch());
458 thr->fast_synch_epoch = thr->fast_state.epoch();
459 thr->clock.acq_rel(c);
460 StatInc(thr, StatSyncAcquire);
461 StatInc(thr, StatSyncRelease);
464 void ReportDeadlock(ThreadState *thr, uptr pc, DDReport *r) {
491 OutputReport(thr, rep);