[sanitizer][NFC] Set LargeMmapAllocator type from PrimaryAllocator
authorVitaly Buka <vitalybuka@google.com>
Wed, 1 May 2019 19:41:54 +0000 (19:41 +0000)
committerVitaly Buka <vitalybuka@google.com>
Wed, 1 May 2019 19:41:54 +0000 (19:41 +0000)
They need to have same AddressSpaceView and MapUnmapCallback.

Reviewers: eugenis

Subscribers: kubamracek, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D61168

llvm-svn: 359719

compiler-rt/lib/asan/asan_allocator.h
compiler-rt/lib/hwasan/hwasan_allocator.h
compiler-rt/lib/lsan/lsan_allocator.h
compiler-rt/lib/msan/msan_allocator.cc
compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h
compiler-rt/lib/sanitizer_common/sanitizer_allocator_internal.h
compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc
compiler-rt/lib/tsan/rtl/tsan_rtl.h

index 63dbfd6..6add47b 100644 (file)
@@ -186,14 +186,8 @@ using PrimaryAllocator = PrimaryAllocatorASVT<LocalAddressSpaceView>;
 static const uptr kNumberOfSizeClasses = SizeClassMap::kNumClasses;
 
 template <typename AddressSpaceView>
-using SecondaryAllocatorASVT =
-    LargeMmapAllocator<AsanMapUnmapCallback, DefaultLargeMmapAllocatorPtrArray,
-                       AddressSpaceView>;
-template <typename AddressSpaceView>
 using AsanAllocatorASVT =
-    CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>,
-                      SecondaryAllocatorASVT<AddressSpaceView>,
-                      AddressSpaceView>;
+    CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>>;
 using AsanAllocator = AsanAllocatorASVT<LocalAddressSpaceView>;
 using AllocatorCache = AsanAllocator::AllocatorCache;
 
index 2070df1..3a50a11 100644 (file)
@@ -61,8 +61,7 @@ struct AP64 {
   static const uptr kFlags = 0;
 };
 typedef SizeClassAllocator64<AP64> PrimaryAllocator;
-typedef LargeMmapAllocator<HwasanMapUnmapCallback> SecondaryAllocator;
-typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
+typedef CombinedAllocator<PrimaryAllocator> Allocator;
 typedef Allocator::AllocatorCache AllocatorCache;
 
 void AllocatorSwallowThreadLocalCache(AllocatorCache *cache);
index bef7812..e139709 100644 (file)
@@ -90,15 +90,7 @@ using PrimaryAllocator = PrimaryAllocatorASVT<LocalAddressSpaceView>;
 #endif
 
 template <typename AddressSpaceView>
-using SecondaryAllocatorASVT =
-    LargeMmapAllocator<NoOpMapUnmapCallback, DefaultLargeMmapAllocatorPtrArray,
-                       AddressSpaceView>;
-
-template <typename AddressSpaceView>
-using AllocatorASVT =
-    CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>,
-                      SecondaryAllocatorASVT<AddressSpaceView>,
-                      AddressSpaceView>;
+using AllocatorASVT = CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>>;
 using Allocator = AllocatorASVT<LocalAddressSpaceView>;
 using AllocatorCache = Allocator::AllocatorCache;
 
index 59c39cb..1816840 100644 (file)
@@ -108,8 +108,7 @@ struct AP32 {
 };
 typedef SizeClassAllocator32<AP32> PrimaryAllocator;
 #endif
-typedef LargeMmapAllocator<MsanMapUnmapCallback> SecondaryAllocator;
-typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
+typedef CombinedAllocator<PrimaryAllocator> Allocator;
 typedef Allocator::AllocatorCache AllocatorCache;
 
 static Allocator allocator;
index e21d7a9..5b3dd15 100644 (file)
 //  When allocating 2^x bytes it should return 2^x aligned chunk.
 // PrimaryAllocator is used via a local AllocatorCache.
 // SecondaryAllocator can allocate anything, but is not efficient.
-template <class PrimaryAllocator, class SecondaryAllocator,
-          typename AddressSpaceViewTy = LocalAddressSpaceView>  // NOLINT
+template <class PrimaryAllocator,
+          class LargeMmapAllocatorPtrArray = DefaultLargeMmapAllocatorPtrArray>
 class CombinedAllocator {
  public:
   using AllocatorCache = SizeClassAllocatorLocalCache<PrimaryAllocator>;
-  using AddressSpaceView = AddressSpaceViewTy;
-  static_assert(is_same<AddressSpaceView,
-                        typename PrimaryAllocator::AddressSpaceView>::value,
-                "PrimaryAllocator is using wrong AddressSpaceView");
-  static_assert(is_same<AddressSpaceView,
-                        typename SecondaryAllocator::AddressSpaceView>::value,
-                "SecondaryAllocator is using wrong AddressSpaceView");
+  using SecondaryAllocator =
+      LargeMmapAllocator<typename PrimaryAllocator::MapUnmapCallback,
+                         LargeMmapAllocatorPtrArray,
+                         typename PrimaryAllocator::AddressSpaceView>;
 
   void InitLinkerInitialized(s32 release_to_os_interval_ms) {
     stats_.InitLinkerInitialized();
index 7d5b2f3..3284903 100644 (file)
@@ -34,11 +34,8 @@ struct AP32 {
 };
 typedef SizeClassAllocator32<AP32> PrimaryInternalAllocator;
 
-typedef LargeMmapAllocator<NoOpMapUnmapCallback,
-                           LargeMmapAllocatorPtrArrayStatic>
-    SecondaryInternalAllocator;
-
-typedef CombinedAllocator<PrimaryInternalAllocator, SecondaryInternalAllocator>
+typedef CombinedAllocator<PrimaryInternalAllocator,
+                          LargeMmapAllocatorPtrArrayStatic>
     InternalAllocator;
 typedef InternalAllocator::AllocatorCache InternalAllocatorCache;
 
index 4c4ccb5..790662d 100644 (file)
@@ -615,9 +615,9 @@ TEST(SanitizerCommon, LargeMmapAllocator) {
   a.Deallocate(&stats, p);
 }
 
-template <class PrimaryAllocator, class SecondaryAllocator>
+template <class PrimaryAllocator>
 void TestCombinedAllocator() {
-  typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
+  typedef CombinedAllocator<PrimaryAllocator> Allocator;
   Allocator *a = new Allocator;
   a->Init(kReleaseToOSIntervalNever);
   std::mt19937 r;
@@ -683,26 +683,26 @@ void TestCombinedAllocator() {
 
 #if SANITIZER_CAN_USE_ALLOCATOR64
 TEST(SanitizerCommon, CombinedAllocator64) {
-  TestCombinedAllocator<Allocator64, LargeMmapAllocator<>>();
+  TestCombinedAllocator<Allocator64>();
 }
 
 TEST(SanitizerCommon, CombinedAllocator64Dynamic) {
-  TestCombinedAllocator<Allocator64Dynamic, LargeMmapAllocator<>>();
+  TestCombinedAllocator<Allocator64Dynamic>();
 }
 
 #if !SANITIZER_ANDROID
 TEST(SanitizerCommon, CombinedAllocator64Compact) {
-  TestCombinedAllocator<Allocator64Compact, LargeMmapAllocator<>>();
+  TestCombinedAllocator<Allocator64Compact>();
 }
 #endif
 
 TEST(SanitizerCommon, CombinedAllocator64VeryCompact) {
-  TestCombinedAllocator<Allocator64VeryCompact, LargeMmapAllocator<>>();
+  TestCombinedAllocator<Allocator64VeryCompact>();
 }
 #endif
 
 TEST(SanitizerCommon, CombinedAllocator32Compact) {
-  TestCombinedAllocator<Allocator32Compact, LargeMmapAllocator<>>();
+  TestCombinedAllocator<Allocator32Compact>();
 }
 
 template <class AllocatorCache>
index 34abbe6..e7d482f 100644 (file)
@@ -49,8 +49,7 @@ struct __AP64 {
 namespace {
 
 typedef SizeClassAllocator64<__AP64> PrimaryAllocator;
-typedef LargeMmapAllocator<> SecondaryAllocator;
-typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
+typedef CombinedAllocator<PrimaryAllocator> Allocator;
 typedef Allocator::AllocatorCache AllocatorCache;
 
 static Allocator allocator;
index c37eab9..d58c1dc 100644 (file)
@@ -79,8 +79,7 @@ struct AP64 {  // Allocator64 parameters. Deliberately using a short name.
 };
 typedef SizeClassAllocator64<AP64> PrimaryAllocator;
 #endif
-typedef LargeMmapAllocator<MapUnmapCallback> SecondaryAllocator;
-typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
+typedef CombinedAllocator<PrimaryAllocator> Allocator;
 typedef Allocator::AllocatorCache AllocatorCache;
 Allocator *allocator();
 #endif