forked from OSchip/llvm-project
tsan: simplify thread context setting
Currently we set thr->tctx after OnStarted callback taking thread registry mutex again and searching for the context. But OnStarted already runs under the thread registry mutex and has access to the context, so set it in the OnStarted. This makes code simpler and faster. Depends on D110132. Reviewed By: melver Differential Revision: https://reviews.llvm.org/D110133
This commit is contained in:
parent
908256b0ea
commit
9d7b7350c9
|
@ -169,10 +169,6 @@ void ThreadStart(ThreadState *thr, Tid tid, tid_t os_id,
|
|||
OnStartedArgs args = { thr, stk_addr, stk_size, tls_addr, tls_size };
|
||||
tr->StartThread(tid, os_id, thread_type, &args);
|
||||
|
||||
tr->Lock();
|
||||
thr->tctx = (ThreadContext*)tr->GetThreadLocked(tid);
|
||||
tr->Unlock();
|
||||
|
||||
while (!thr->tctx->trace.parts.Empty()) thr->tctx->trace.parts.PopBack();
|
||||
|
||||
#if !SANITIZER_GO
|
||||
|
@ -215,6 +211,7 @@ void ThreadContext::OnStarted(void *arg) {
|
|||
thr->fast_synch_epoch = epoch0;
|
||||
AcquireImpl(thr, 0, &sync);
|
||||
sync.Reset(&thr->proc()->clock_cache);
|
||||
thr->tctx = this;
|
||||
thr->is_inited = true;
|
||||
DPrintf(
|
||||
"#%d: ThreadStart epoch=%zu stk_addr=%zx stk_size=%zx "
|
||||
|
|
Loading…
Reference in New Issue