Lines Matching defs:thr
83 ThreadState *thr = cur_thread();
84 if (thr->proc())
101 ProcWire(gp->proc, thr);
106 ThreadState *thr = cur_thread();
107 if (thr->proc() != gp->proc)
109 ProcUnwire(gp->proc, thr);
135 static void SignalUnsafeCall(ThreadState *thr, uptr pc) {
136 if (atomic_load_relaxed(&thr->in_signal_handler) == 0 ||
140 ObtainCurrentStack(thr, pc, &stack);
146 OutputReport(thr, rep);
149 void *user_alloc(ThreadState *thr, uptr pc, uptr sz, uptr align, bool signal) {
152 void *p = allocator()->Allocate(&thr->proc()->alloc_cache, sz, align);
156 OnUserAlloc(thr, pc, (uptr)p, sz, true);
158 SignalUnsafeCall(thr, pc);
162 void *user_calloc(ThreadState *thr, uptr pc, uptr size, uptr n) {
165 void *p = user_alloc(thr, pc, n * size);
171 void user_free(ThreadState *thr, uptr pc, void *p, bool signal) {
174 OnUserFree(thr, pc, (uptr)p, true);
175 allocator()->Deallocate(&thr->proc()->alloc_cache, p);
177 SignalUnsafeCall(thr, pc);
180 void OnUserAlloc(ThreadState *thr, uptr pc, uptr p, uptr sz, bool write) {
181 DPrintf("#%d: alloc(%zu) = %p\n", thr->tid, sz, p);
182 ctx->metamap.AllocBlock(thr, pc, p, sz);
183 if (write && thr->ignore_reads_and_writes == 0)
184 MemoryRangeImitateWrite(thr, pc, (uptr)p, sz);
186 MemoryResetRange(thr, pc, (uptr)p, sz);
189 void OnUserFree(ThreadState *thr, uptr pc, uptr p, bool write) {
191 uptr sz = ctx->metamap.FreeBlock(thr->proc(), p);
192 DPrintf("#%d: free(%p, %zu)\n", thr->tid, p, sz);
193 if (write && thr->ignore_reads_and_writes == 0)
194 MemoryRangeFreed(thr, pc, (uptr)p, sz);
197 void *user_realloc(ThreadState *thr, uptr pc, void *p, uptr sz) {
202 p2 = user_alloc(thr, pc, sz);
211 user_free(thr, pc, p);
227 ThreadState *thr = cur_thread();
228 if (ctx == 0 || !ctx->initialized || thr->ignore_interceptors)
235 ThreadState *thr = cur_thread();
236 if (ctx == 0 || !ctx->initialized || thr->ignore_interceptors)
243 ThreadState *thr = cur_thread();
244 if (thr->nomalloc) {
245 thr->nomalloc = 0; // CHECK calls internal_malloc().
248 return InternalAlloc(sz, &thr->proc()->internal_alloc_cache);
252 ThreadState *thr = cur_thread();
253 if (thr->nomalloc) {
254 thr->nomalloc = 0; // CHECK calls internal_malloc().
257 InternalFree(p, &thr->proc()->internal_alloc_cache);
298 ThreadState *thr = cur_thread();
299 allocator()->SwallowCache(&thr->proc()->alloc_cache);
300 internal_allocator()->SwallowCache(&thr->proc()->internal_alloc_cache);
301 ctx->metamap.OnProcIdle(thr->proc());