[llvm-commits] [compiler-rt] r159139 - in /compiler-rt/trunk/lib/sanitizer_common: sanitizer_allocator64.h tests/sanitizer_allocator64_test.cc

Kostya Serebryany kcc at google.com
Mon Jun 25 07:53:50 PDT 2012


Author: kcc
Date: Mon Jun 25 09:53:49 2012
New Revision: 159139

URL: http://llvm.org/viewvc/llvm-project?rev=159139&view=rev
Log:
[tsan] minor changes in tsan allocator

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator64.h
    compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator64_test.cc

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=159139&r1=159138&r2=159139&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator64.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator64.h Mon Jun 25 09:53:49 2012
@@ -103,6 +103,7 @@
   }
   NOINLINE
   void Deallocate(void *p) {
+    CHECK(PointerIsMine(p));
     DeallocateBySizeClass(p, GetSizeClass(p));
   }
   bool PointerIsMine(void *p) {
@@ -119,7 +120,7 @@
         (1 + chunk_idx) * kMetadataSize;
   }
 
-  uptr TotalMemoryUsedIncludingFreeLists() {
+  uptr TotalMemoryUsed() {
     uptr res = 0;
     for (uptr i = 0; i < kNumClasses; i++)
       res += GetRegionInfo(i)->allocated_user;
@@ -153,7 +154,11 @@
   };
   COMPILER_CHECK(sizeof(RegionInfo) == kCacheLineSize);
 
-  uptr AdditionalSize() { return sizeof(RegionInfo) * kNumClasses; }
+  uptr AdditionalSize() { 
+    uptr res = sizeof(RegionInfo) * kNumClasses;
+    CHECK_EQ(res % kPageSize, 0);
+    return res;
+  }
   uptr AllocBeg()  { return kSpaceBeg  - AdditionalSize(); }
   uptr AllocSize() { return kSpaceSize + AdditionalSize(); }
 
@@ -170,7 +175,7 @@
 
   LifoListNode *PopLifoList(LifoListNode **list) {
     LifoListNode *res = *list;
-    *list = (*list)->next;
+    *list = res->next;
     return res;
   }
 

Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator64_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator64_test.cc?rev=159139&r1=159138&r2=159139&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator64_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator64_test.cc Mon Jun 25 09:53:49 2012
@@ -90,7 +90,7 @@
       a.Deallocate(x);
     }
     allocated.clear();
-    uptr total_allocated = a.TotalMemoryUsedIncludingFreeLists();
+    uptr total_allocated = a.TotalMemoryUsed();
     if (last_total_allocated == 0)
       last_total_allocated = total_allocated;
     CHECK_EQ(last_total_allocated, total_allocated);





More information about the llvm-commits mailing list