diff options
author | Vitaly Buka <vitalybuka@google.com> | 2019-05-01 19:41:54 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2019-05-01 19:41:54 +0000 |
commit | 99cd89c106a10f18ccbaeda9a920d28ae3e943cf (patch) | |
tree | 39c548447e8063d0259feef75a4b031f00580395 | |
parent | 602be703dd35567968f1c4567332eade87e93597 (diff) | |
download | compiler-rt-99cd89c106a10f18ccbaeda9a920d28ae3e943cf.tar.gz |
[sanitizer][NFC] Set LargeMmapAllocator type from PrimaryAllocator
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
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359719 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/asan/asan_allocator.h | 8 | ||||
-rw-r--r-- | lib/hwasan/hwasan_allocator.h | 3 | ||||
-rw-r--r-- | lib/lsan/lsan_allocator.h | 10 | ||||
-rw-r--r-- | lib/msan/msan_allocator.cc | 3 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_allocator_combined.h | 15 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_allocator_internal.h | 7 | ||||
-rw-r--r-- | lib/sanitizer_common/tests/sanitizer_allocator_test.cc | 14 | ||||
-rw-r--r-- | lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc | 3 | ||||
-rw-r--r-- | lib/tsan/rtl/tsan_rtl.h | 3 |
9 files changed, 21 insertions, 45 deletions
diff --git a/lib/asan/asan_allocator.h b/lib/asan/asan_allocator.h index 63dbfd604..6add47be2 100644 --- a/lib/asan/asan_allocator.h +++ b/lib/asan/asan_allocator.h @@ -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; diff --git a/lib/hwasan/hwasan_allocator.h b/lib/hwasan/hwasan_allocator.h index 2070df150..3a50a11f3 100644 --- a/lib/hwasan/hwasan_allocator.h +++ b/lib/hwasan/hwasan_allocator.h @@ -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); diff --git a/lib/lsan/lsan_allocator.h b/lib/lsan/lsan_allocator.h index bef78128d..e13970997 100644 --- a/lib/lsan/lsan_allocator.h +++ b/lib/lsan/lsan_allocator.h @@ -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; diff --git a/lib/msan/msan_allocator.cc b/lib/msan/msan_allocator.cc index 59c39cbef..181684001 100644 --- a/lib/msan/msan_allocator.cc +++ b/lib/msan/msan_allocator.cc @@ -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; diff --git a/lib/sanitizer_common/sanitizer_allocator_combined.h b/lib/sanitizer_common/sanitizer_allocator_combined.h index e21d7a962..5b3dd15df 100644 --- a/lib/sanitizer_common/sanitizer_allocator_combined.h +++ b/lib/sanitizer_common/sanitizer_allocator_combined.h @@ -19,18 +19,15 @@ // 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(); diff --git a/lib/sanitizer_common/sanitizer_allocator_internal.h b/lib/sanitizer_common/sanitizer_allocator_internal.h index 7d5b2f3c3..32849036f 100644 --- a/lib/sanitizer_common/sanitizer_allocator_internal.h +++ b/lib/sanitizer_common/sanitizer_allocator_internal.h @@ -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; diff --git a/lib/sanitizer_common/tests/sanitizer_allocator_test.cc b/lib/sanitizer_common/tests/sanitizer_allocator_test.cc index 4c4ccb5fe..790662d99 100644 --- a/lib/sanitizer_common/tests/sanitizer_allocator_test.cc +++ b/lib/sanitizer_common/tests/sanitizer_allocator_test.cc @@ -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> diff --git a/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc b/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc index 34abbe615..e7d482fec 100644 --- a/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc +++ b/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc @@ -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; diff --git a/lib/tsan/rtl/tsan_rtl.h b/lib/tsan/rtl/tsan_rtl.h index c37eab9da..d58c1dca4 100644 --- a/lib/tsan/rtl/tsan_rtl.h +++ b/lib/tsan/rtl/tsan_rtl.h @@ -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 |