[llvm-commits] [compiler-rt] r171055 - in /compiler-rt/trunk/lib/sanitizer_common: sanitizer_allocator.h tests/sanitizer_allocator_test.cc

Kostya Serebryany kcc at google.com
Mon Dec 24 23:50:35 PST 2012


Author: kcc
Date: Tue Dec 25 01:50:35 2012
New Revision: 171055

URL: http://llvm.org/viewvc/llvm-project?rev=171055&view=rev
Log:
[sanitizer] increase the maximum size class of the fast allocator. This should save quite a bit of memory in tsan/msan (and later in asan). This also puts more stress on the large allocator. Add a couple of checks

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h
    compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h?rev=171055&r1=171054&r2=171055&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h Tue Dec 25 01:50:35 2012
@@ -153,7 +153,7 @@
   }
 };
 
-typedef SizeClassMap<21, 256, 16> DefaultSizeClassMap;
+typedef SizeClassMap<15, 256, 16> DefaultSizeClassMap;
 typedef SizeClassMap<15, 64, 14> CompactSizeClassMap;
 
 
@@ -323,9 +323,9 @@
   COMPILER_CHECK((kRegionSize) >= (1ULL << (SANITIZER_WORDSIZE / 2)));
   // Populate the free list with at most this number of bytes at once
   // or with one element if its size is greater.
-  static const uptr kPopulateSize = 1 << 18;
+  static const uptr kPopulateSize = 1 << 15;
   // Call mmap for user memory with at least this size.
-  static const uptr kUserMapSize = 1 << 18;
+  static const uptr kUserMapSize = 1 << 15;
   // Call mmap for metadata memory with at least this size.
   static const uptr kMetaMapSize = 1 << 16;
 
@@ -715,6 +715,7 @@
     {
       SpinMutexLock l(&mutex_);
       uptr idx = n_chunks_++;
+      CHECK_LT(idx, kMaxNumChunks);
       h->chunk_idx = idx;
       chunks_[idx] = h;
     }
@@ -757,6 +758,8 @@
 
   // At least page_size_/2 metadata bytes is available.
   void *GetMetaData(void *p) {
+    // Too slow: CHECK_EQ(p, GetBlockBegin(p));
+    CHECK(IsAligned(reinterpret_cast<uptr>(p), page_size_));
     return GetHeader(p) + 1;
   }
 

Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc?rev=171055&r1=171054&r2=171055&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc Tue Dec 25 01:50:35 2012
@@ -44,7 +44,7 @@
 template <class SizeClassMap>
 void TestSizeClassMap() {
   typedef SizeClassMap SCMap;
-  SCMap::Print();
+  // SCMap::Print();
   SCMap::Validate();
 }
 





More information about the llvm-commits mailing list