[llvm-commits] [compiler-rt] r159516 - in /compiler-rt/trunk/lib/sanitizer_common: sanitizer_allocator64.h sanitizer_mutex.h
Dmitry Vyukov
dvyukov at google.com
Sun Jul 1 23:54:24 PDT 2012
Author: dvyukov
Date: Mon Jul 2 01:54:24 2012
New Revision: 159516
URL: http://llvm.org/viewvc/llvm-project?rev=159516&view=rev
Log:
tsan/asan: add mutex to 64-bit allocator
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator64.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_mutex.h
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator64.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator64.h?rev=159516&r1=159515&r2=159516&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator64.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator64.h Mon Jul 2 01:54:24 2012
@@ -20,6 +20,7 @@
#include "sanitizer_common.h"
#include "sanitizer_internal_defs.h"
#include "sanitizer_libc.h"
+#include "sanitizer_mutex.h"
namespace __sanitizer {
@@ -152,7 +153,7 @@
};
struct RegionInfo {
- uptr mutex; // FIXME
+ SpinMutex mutex;
LifoListNode *free_list;
uptr allocated_user; // Bytes allocated for user memory.
uptr allocated_meta; // Bytes allocated for metadata.
@@ -216,7 +217,7 @@
void *AllocateBySizeClass(uptr class_id) {
CHECK_LT(class_id, kNumClasses);
RegionInfo *region = GetRegionInfo(class_id);
- // FIXME: Lock region->mutex;
+ SpinMutexLock l(®ion->mutex);
if (!region->free_list) {
region->free_list = PopulateFreeList(class_id, region);
}
@@ -227,7 +228,7 @@
void DeallocateBySizeClass(void *p, uptr class_id) {
RegionInfo *region = GetRegionInfo(class_id);
- // FIXME: Lock region->mutex;
+ SpinMutexLock l(®ion->mutex);
PushLifoList(®ion->free_list, reinterpret_cast<LifoListNode*>(p));
}
};
@@ -250,7 +251,7 @@
Header *h = GetHeader(res);
h->size = size;
{
- // FIXME: lock
+ SpinMutexLock l(&mutex_);
h->next = list_;
h->prev = 0;
if (list_)
@@ -264,7 +265,7 @@
Header *h = GetHeader(p);
uptr map_size = RoundUpMapSize(h->size);
{
- // FIXME: lock
+ SpinMutexLock l(&mutex_);
Header *prev = h->prev;
Header *next = h->next;
if (prev)
@@ -278,7 +279,7 @@
}
uptr TotalMemoryUsed() {
- // FIXME: lock
+ SpinMutexLock l(&mutex_);
uptr res = 0;
for (Header *l = list_; l; l = l->next) {
res += RoundUpMapSize(l->size);
@@ -289,7 +290,7 @@
bool PointerIsMine(void *p) {
// Fast check.
if ((reinterpret_cast<uptr>(p) % kPageSize) != 0) return false;
- // FIXME: lock
+ SpinMutexLock l(&mutex_);
for (Header *l = list_; l; l = l->next) {
if (GetUser(l) == p) return true;
}
@@ -321,7 +322,7 @@
}
Header *list_;
- uptr lock_; // FIXME
+ SpinMutex mutex_;
};
// This class implements a complete memory allocator by using two
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_mutex.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_mutex.h?rev=159516&r1=159515&r2=159516&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_mutex.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_mutex.h Mon Jul 2 01:54:24 2012
@@ -79,6 +79,8 @@
void operator=(const GenericScopedReadLock&);
};
+typedef GenericScopedLock<SpinMutex> SpinMutexLock;
+
} // namespace __sanitizer
#endif // SANITIZER_MUTEX_H
More information about the llvm-commits
mailing list