forked from OSchip/llvm-project
tsan: minor MetaMap tweaks
1. Add some comments. 2. Use kInvalidStackID instead of literal 0. 3. Add more LIKELY/UNLIKELY. Reviewed By: vitalybuka, melver Differential Revision: https://reviews.llvm.org/D107371
This commit is contained in:
parent
6f8c4340c2
commit
d3faecbb7c
|
@ -26,7 +26,7 @@ void SyncVar::Init(ThreadState *thr, uptr pc, uptr addr, u64 uid,
|
|||
this->uid = uid;
|
||||
this->next = 0;
|
||||
|
||||
creation_stack_id = 0;
|
||||
creation_stack_id = kInvalidStackID;
|
||||
if (save_stack && !SANITIZER_GO) // Go does not use them
|
||||
creation_stack_id = CurrentStackId(thr, pc);
|
||||
if (common_flags()->detect_deadlocks)
|
||||
|
@ -35,7 +35,7 @@ void SyncVar::Init(ThreadState *thr, uptr pc, uptr addr, u64 uid,
|
|||
|
||||
void SyncVar::Reset(Processor *proc) {
|
||||
uid = 0;
|
||||
creation_stack_id = 0;
|
||||
creation_stack_id = kInvalidStackID;
|
||||
owner_tid = kInvalidTid;
|
||||
last_lock = 0;
|
||||
recursion = 0;
|
||||
|
@ -212,12 +212,12 @@ SyncVar *MetaMap::GetSync(ThreadState *thr, uptr pc, uptr addr, bool create,
|
|||
}
|
||||
if (!create)
|
||||
return nullptr;
|
||||
if (*meta != idx0) {
|
||||
if (UNLIKELY(*meta != idx0)) {
|
||||
idx0 = *meta;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (myidx == 0) {
|
||||
if (LIKELY(myidx == 0)) {
|
||||
const u64 uid = atomic_fetch_add(&uid_gen_, 1, memory_order_relaxed);
|
||||
myidx = sync_alloc_.Alloc(&thr->proc()->sync_cache);
|
||||
mys = sync_alloc_.Map(myidx);
|
||||
|
|
|
@ -46,6 +46,8 @@ enum MutexFlags {
|
|||
MutexFlagNotStatic,
|
||||
};
|
||||
|
||||
// SyncVar is a descriptor of a user synchronization object
|
||||
// (mutex or an atomic variable).
|
||||
struct SyncVar {
|
||||
SyncVar();
|
||||
|
||||
|
@ -101,10 +103,8 @@ struct SyncVar {
|
|||
}
|
||||
};
|
||||
|
||||
/* MetaMap allows to map arbitrary user pointers onto various descriptors.
|
||||
Currently it maps pointers to heap block descriptors and sync var descs.
|
||||
It uses 1/2 direct shadow, see tsan_platform.h.
|
||||
*/
|
||||
// MetaMap maps app addresses to heap block (MBlock) and sync var (SyncVar)
|
||||
// descriptors. It uses 1/2 direct shadow, see tsan_platform.h for the mapping.
|
||||
class MetaMap {
|
||||
public:
|
||||
MetaMap();
|
||||
|
|
Loading…
Reference in New Issue