diff options
11 files changed, 28 insertions, 56 deletions
diff --git a/compiler-rt/lib/asan/asan_allocator.h b/compiler-rt/lib/asan/asan_allocator.h index a3c3cda8ed5..63dbfd60473 100644 --- a/compiler-rt/lib/asan/asan_allocator.h +++ b/compiler-rt/lib/asan/asan_allocator.h @@ -184,10 +184,6 @@ using PrimaryAllocator = PrimaryAllocatorASVT<LocalAddressSpaceView>; #endif // SANITIZER_CAN_USE_ALLOCATOR64 static const uptr kNumberOfSizeClasses = SizeClassMap::kNumClasses; -template <typename AddressSpaceView> -using AllocatorCacheASVT = - SizeClassAllocatorLocalCache<PrimaryAllocatorASVT<AddressSpaceView>>; -using AllocatorCache = AllocatorCacheASVT<LocalAddressSpaceView>; template <typename AddressSpaceView> using SecondaryAllocatorASVT = @@ -196,10 +192,10 @@ using SecondaryAllocatorASVT = template <typename AddressSpaceView> using AsanAllocatorASVT = CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>, - AllocatorCacheASVT<AddressSpaceView>, SecondaryAllocatorASVT<AddressSpaceView>, AddressSpaceView>; using AsanAllocator = AsanAllocatorASVT<LocalAddressSpaceView>; +using AllocatorCache = AsanAllocator::AllocatorCache; struct AsanThreadLocalMallocStorage { uptr quarantine_cache[16]; diff --git a/compiler-rt/lib/hwasan/hwasan_allocator.h b/compiler-rt/lib/hwasan/hwasan_allocator.h index fca22da6c09..2070df1502f 100644 --- a/compiler-rt/lib/hwasan/hwasan_allocator.h +++ b/compiler-rt/lib/hwasan/hwasan_allocator.h @@ -61,10 +61,9 @@ struct AP64 { static const uptr kFlags = 0; }; typedef SizeClassAllocator64<AP64> PrimaryAllocator; -typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache; typedef LargeMmapAllocator<HwasanMapUnmapCallback> SecondaryAllocator; -typedef CombinedAllocator<PrimaryAllocator, AllocatorCache, - SecondaryAllocator> Allocator; +typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator; +typedef Allocator::AllocatorCache AllocatorCache; void AllocatorSwallowThreadLocalCache(AllocatorCache *cache); diff --git a/compiler-rt/lib/lsan/lsan_allocator.h b/compiler-rt/lib/lsan/lsan_allocator.h index eda5f0e3aac..bef78128d40 100644 --- a/compiler-rt/lib/lsan/lsan_allocator.h +++ b/compiler-rt/lib/lsan/lsan_allocator.h @@ -90,11 +90,6 @@ using PrimaryAllocator = PrimaryAllocatorASVT<LocalAddressSpaceView>; #endif template <typename AddressSpaceView> -using AllocatorCacheASVT = - SizeClassAllocatorLocalCache<PrimaryAllocatorASVT<AddressSpaceView>>; -using AllocatorCache = AllocatorCacheASVT<LocalAddressSpaceView>; - -template <typename AddressSpaceView> using SecondaryAllocatorASVT = LargeMmapAllocator<NoOpMapUnmapCallback, DefaultLargeMmapAllocatorPtrArray, AddressSpaceView>; @@ -102,12 +97,12 @@ using SecondaryAllocatorASVT = template <typename AddressSpaceView> using AllocatorASVT = CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>, - AllocatorCacheASVT<AddressSpaceView>, SecondaryAllocatorASVT<AddressSpaceView>, AddressSpaceView>; using Allocator = AllocatorASVT<LocalAddressSpaceView>; +using AllocatorCache = Allocator::AllocatorCache; -AllocatorCache *GetAllocatorCache(); +Allocator::AllocatorCache *GetAllocatorCache(); int lsan_posix_memalign(void **memptr, uptr alignment, uptr size, const StackTrace &stack); diff --git a/compiler-rt/lib/msan/msan_allocator.cc b/compiler-rt/lib/msan/msan_allocator.cc index 8bf8fda061c..59c39cbef95 100644 --- a/compiler-rt/lib/msan/msan_allocator.cc +++ b/compiler-rt/lib/msan/msan_allocator.cc @@ -108,10 +108,9 @@ struct AP32 { }; typedef SizeClassAllocator32<AP32> PrimaryAllocator; #endif -typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache; typedef LargeMmapAllocator<MsanMapUnmapCallback> SecondaryAllocator; -typedef CombinedAllocator<PrimaryAllocator, AllocatorCache, - SecondaryAllocator> Allocator; +typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator; +typedef Allocator::AllocatorCache AllocatorCache; static Allocator allocator; static AllocatorCache fallback_allocator_cache; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h index d285df11f23..e21d7a9623b 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h @@ -19,11 +19,11 @@ // 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 AllocatorCache, - class SecondaryAllocator, +template <class PrimaryAllocator, class SecondaryAllocator, typename AddressSpaceViewTy = LocalAddressSpaceView> // NOLINT class CombinedAllocator { public: + using AllocatorCache = SizeClassAllocatorLocalCache<PrimaryAllocator>; using AddressSpaceView = AddressSpaceViewTy; static_assert(is_same<AddressSpaceView, typename PrimaryAllocator::AddressSpaceView>::value, diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_internal.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_internal.h index 214218a8740..7d5b2f3c34f 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_internal.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_internal.h @@ -34,15 +34,13 @@ struct AP32 { }; typedef SizeClassAllocator32<AP32> PrimaryInternalAllocator; -typedef SizeClassAllocatorLocalCache<PrimaryInternalAllocator> - InternalAllocatorCache; - typedef LargeMmapAllocator<NoOpMapUnmapCallback, LargeMmapAllocatorPtrArrayStatic> SecondaryInternalAllocator; -typedef CombinedAllocator<PrimaryInternalAllocator, InternalAllocatorCache, - SecondaryInternalAllocator> InternalAllocator; +typedef CombinedAllocator<PrimaryInternalAllocator, SecondaryInternalAllocator> + InternalAllocator; +typedef InternalAllocator::AllocatorCache InternalAllocatorCache; void *InternalAlloc(uptr size, InternalAllocatorCache *cache = nullptr, uptr alignment = 0); diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc index d19b37609d6..4c4ccb5fe79 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc @@ -615,17 +615,14 @@ TEST(SanitizerCommon, LargeMmapAllocator) { a.Deallocate(&stats, p); } -template -<class PrimaryAllocator, class SecondaryAllocator, class AllocatorCache> +template <class PrimaryAllocator, class SecondaryAllocator> void TestCombinedAllocator() { - typedef - CombinedAllocator<PrimaryAllocator, AllocatorCache, SecondaryAllocator> - Allocator; + typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator; Allocator *a = new Allocator; a->Init(kReleaseToOSIntervalNever); std::mt19937 r; - AllocatorCache cache; + typename Allocator::AllocatorCache cache; memset(&cache, 0, sizeof(cache)); a->InitCache(&cache); @@ -686,36 +683,26 @@ void TestCombinedAllocator() { #if SANITIZER_CAN_USE_ALLOCATOR64 TEST(SanitizerCommon, CombinedAllocator64) { - TestCombinedAllocator<Allocator64, - LargeMmapAllocator<>, - SizeClassAllocatorLocalCache<Allocator64> > (); + TestCombinedAllocator<Allocator64, LargeMmapAllocator<>>(); } TEST(SanitizerCommon, CombinedAllocator64Dynamic) { - TestCombinedAllocator<Allocator64Dynamic, - LargeMmapAllocator<>, - SizeClassAllocatorLocalCache<Allocator64Dynamic> > (); + TestCombinedAllocator<Allocator64Dynamic, LargeMmapAllocator<>>(); } #if !SANITIZER_ANDROID TEST(SanitizerCommon, CombinedAllocator64Compact) { - TestCombinedAllocator<Allocator64Compact, - LargeMmapAllocator<>, - SizeClassAllocatorLocalCache<Allocator64Compact> > (); + TestCombinedAllocator<Allocator64Compact, LargeMmapAllocator<>>(); } #endif TEST(SanitizerCommon, CombinedAllocator64VeryCompact) { - TestCombinedAllocator<Allocator64VeryCompact, - LargeMmapAllocator<>, - SizeClassAllocatorLocalCache<Allocator64VeryCompact> > (); + TestCombinedAllocator<Allocator64VeryCompact, LargeMmapAllocator<>>(); } #endif TEST(SanitizerCommon, CombinedAllocator32Compact) { - TestCombinedAllocator<Allocator32Compact, - LargeMmapAllocator<>, - SizeClassAllocatorLocalCache<Allocator32Compact> > (); + TestCombinedAllocator<Allocator32Compact, LargeMmapAllocator<>>(); } template <class AllocatorCache> diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc index bf09b0d5506..34abbe61539 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc @@ -49,10 +49,9 @@ struct __AP64 { namespace { typedef SizeClassAllocator64<__AP64> PrimaryAllocator; -typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache; typedef LargeMmapAllocator<> SecondaryAllocator; -typedef CombinedAllocator<PrimaryAllocator, AllocatorCache, - SecondaryAllocator> Allocator; +typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator; +typedef Allocator::AllocatorCache AllocatorCache; static Allocator allocator; static bool global_inited; diff --git a/compiler-rt/lib/scudo/scudo_allocator.h b/compiler-rt/lib/scudo/scudo_allocator.h index 59225b681d8..7a92e41423c 100644 --- a/compiler-rt/lib/scudo/scudo_allocator.h +++ b/compiler-rt/lib/scudo/scudo_allocator.h @@ -102,9 +102,9 @@ typedef SizeClassAllocator32<AP32> PrimaryT; #include "scudo_allocator_secondary.h" #include "scudo_allocator_combined.h" -typedef SizeClassAllocatorLocalCache<PrimaryT> AllocatorCacheT; typedef LargeMmapAllocator SecondaryT; -typedef CombinedAllocator<PrimaryT, AllocatorCacheT, SecondaryT> BackendT; +typedef CombinedAllocator<PrimaryT, SecondaryT> BackendT; +typedef BackendT::AllocatorCache AllocatorCacheT; void initScudo(); diff --git a/compiler-rt/lib/scudo/scudo_allocator_combined.h b/compiler-rt/lib/scudo/scudo_allocator_combined.h index d750b995ffb..4e9217cddbe 100644 --- a/compiler-rt/lib/scudo/scudo_allocator_combined.h +++ b/compiler-rt/lib/scudo/scudo_allocator_combined.h @@ -18,10 +18,10 @@ # error "This file must be included inside scudo_allocator.h." #endif -template <class PrimaryAllocator, class AllocatorCache, - class SecondaryAllocator> +template <class PrimaryAllocator, class SecondaryAllocator> class CombinedAllocator { public: + using AllocatorCache = typename PrimaryAllocator::AllocatorCache; void init(s32 ReleaseToOSIntervalMs) { Primary.Init(ReleaseToOSIntervalMs); Secondary.Init(); diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h index 2c8ae29f3e9..c37eab9dac1 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h @@ -79,10 +79,9 @@ struct AP64 { // Allocator64 parameters. Deliberately using a short name. }; typedef SizeClassAllocator64<AP64> PrimaryAllocator; #endif -typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache; typedef LargeMmapAllocator<MapUnmapCallback> SecondaryAllocator; -typedef CombinedAllocator<PrimaryAllocator, AllocatorCache, - SecondaryAllocator> Allocator; +typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator; +typedef Allocator::AllocatorCache AllocatorCache; Allocator *allocator(); #endif |