Lines Matching refs:thr

27   , thr()
49 ThreadState *thr;
54 thr = 0;
58 if (!args->thr) // GCD workers don't have a parent thread.
60 args->thr->fast_state.IncrementEpoch();
62 TraceAddEvent(args->thr, args->thr->fast_state, EventTypeMop, 0);
63 ReleaseImpl(args->thr, 0, &sync);
64 creation_stack_id = CurrentStackId(args->thr, args->pc);
66 StatInc(args->thr, StatThreadMaxTid);
81 ThreadState *thr;
90 thr = args->thr;
95 new(thr) ThreadState(ctx, tid, unique_id, epoch0, reuse_count,
98 thr->shadow_stack = &ThreadTrace(thr->tid)->shadow_stack[0];
99 thr->shadow_stack_pos = thr->shadow_stack;
100 thr->shadow_stack_end = thr->shadow_stack + kShadowStackSize;
104 thr->shadow_stack = (uptr*)internal_alloc(MBlockShadowStack,
106 thr->shadow_stack_pos = thr->shadow_stack;
107 thr->shadow_stack_end = thr->shadow_stack + kInitStackSize;
110 AllocatorThreadStart(thr);
113 thr->dd_pt = ctx->dd->CreatePhysicalThread();
114 thr->dd_lt = ctx->dd->CreateLogicalThread(unique_id);
116 thr->fast_state.SetHistorySize(flags()->history_size);
119 TraceAddEvent(thr, thr->fast_state, EventTypeMop, 0);
121 thr->fast_synch_epoch = epoch0;
122 AcquireImpl(thr, 0, &sync);
123 StatInc(thr, StatSyncAcquire);
124 sync.Reset(&thr->clock_cache);
125 thr->is_inited = true;
134 thr->fast_state.IncrementEpoch();
136 TraceAddEvent(thr, thr->fast_state, EventTypeMop, 0);
137 ReleaseImpl(thr, 0, &sync);
139 epoch1 = thr->fast_state.epoch();
142 ctx->dd->DestroyPhysicalThread(thr->dd_pt);
143 ctx->dd->DestroyLogicalThread(thr->dd_lt);
145 ctx->clock_alloc.FlushCache(&thr->clock_cache);
146 ctx->metamap.OnThreadIdle(thr);
148 AllocatorThreadFinish(thr);
150 thr->~ThreadState();
152 StatAggregate(ctx->stat, thr->stat);
154 thr = 0;
197 static void ThreadCheckIgnore(ThreadState *thr) {
200 if (thr->ignore_reads_and_writes)
201 ReportIgnoresEnabled(thr->tctx, &thr->mop_ignore_set);
202 if (thr->ignore_sync)
203 ReportIgnoresEnabled(thr->tctx, &thr->sync_ignore_set);
206 static void ThreadCheckIgnore(ThreadState *thr) {}
209 void ThreadFinalize(ThreadState *thr) {
210 ThreadCheckIgnore(thr);
222 OutputReport(thr, rep);
227 int ThreadCount(ThreadState *thr) {
233 int ThreadCreate(ThreadState *thr, uptr pc, uptr uid, bool detached) {
234 StatInc(thr, StatThreadCreate);
235 OnCreatedArgs args = { thr, pc };
236 u32 parent_tid = thr ? thr->tid : kInvalidTid; // No parent for GCD workers.
240 StatSet(thr, StatThreadMaxAlive, ctx->thread_registry->GetMaxAliveThreads());
244 void ThreadStart(ThreadState *thr, int tid, uptr os_id) {
254 MemoryRangeImitateWrite(thr, /*pc=*/ 1, stk_addr, stk_size);
257 // Check that the thr object is in tls;
258 const uptr thr_beg = (uptr)thr;
259 const uptr thr_end = (uptr)thr + sizeof(*thr);
264 // Since the thr object is huge, skip it.
265 MemoryRangeImitateWrite(thr, /*pc=*/ 2, tls_addr, thr_beg - tls_addr);
266 MemoryRangeImitateWrite(thr, /*pc=*/ 2,
273 OnStartedArgs args = { thr, stk_addr, stk_size, tls_addr, tls_size };
277 thr->tctx = (ThreadContext*)tr->GetThreadLocked(tid);
282 thr->ignore_interceptors++;
283 ThreadIgnoreBegin(thr, 0);
284 ThreadIgnoreSyncBegin(thr, 0);
289 void ThreadFinish(ThreadState *thr) {
290 ThreadCheckIgnore(thr);
291 StatInc(thr, StatThreadFinish);
292 if (thr->stk_addr && thr->stk_size)
293 DontNeedShadowFor(thr->stk_addr, thr->stk_size);
294 if (thr->tls_addr && thr->tls_size)
295 DontNeedShadowFor(thr->tls_addr, thr->tls_size);
296 thr->is_dead = true;
297 ctx->thread_registry->FinishThread(thr->tid);
309 int ThreadTid(ThreadState *thr, uptr pc, uptr uid) {
311 DPrintf("#%d: ThreadTid uid=%zu tid=%d\n", thr->tid, uid, res);
315 void ThreadJoin(ThreadState *thr, uptr pc, int tid) {
318 DPrintf("#%d: ThreadJoin tid=%d\n", thr->tid, tid);
319 ctx->thread_registry->JoinThread(tid, thr);
322 void ThreadDetach(ThreadState *thr, uptr pc, int tid) {
325 ctx->thread_registry->DetachThread(tid, thr);
328 void ThreadSetName(ThreadState *thr, const char *name) {
329 ctx->thread_registry->SetThreadName(thr->tid, name);
332 void MemoryAccessRange(ThreadState *thr, uptr pc, uptr addr,
339 thr->tid, (void*)pc, (void*)addr,
362 StatInc(thr, StatMopRange);
367 StatInc(thr, StatMopRangeRodata);
371 FastState fast_state = thr->fast_state;
376 thr->fast_state = fast_state;
377 TraceAddEvent(thr, fast_state, EventTypeMop, pc);
387 MemoryAccessImpl(thr, addr, kAccessSizeLog, is_write, false,
398 MemoryAccessImpl(thr, addr, kAccessSizeLog, is_write, false,
408 MemoryAccessImpl(thr, addr, kAccessSizeLog, is_write, false,