diff options
author | Vitaly Buka <vitalybuka@google.com> | 2019-05-01 19:30:49 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2019-05-01 19:30:49 +0000 |
commit | 8b0927fbbaa2dd437b3f189b357990dd3d06c694 (patch) | |
tree | 5a56d1ec74224ed1a140deadb37b906d447970d8 /lib/sanitizer_common | |
parent | cfcbff0d73bea1fece9c213fb7ed9eab27c125a6 (diff) | |
download | compiler-rt-8b0927fbbaa2dd437b3f189b357990dd3d06c694.tar.gz |
[sanitizer][NFC] Get type of AllocatorCache from CombinedAllocator
Reviewers: eugenis, cryptoad, kcc
Reviewed By: kcc
Subscribers: kcc, kubamracek, #sanitizers, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D61155
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359715 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common')
4 files changed, 15 insertions, 31 deletions
diff --git a/lib/sanitizer_common/sanitizer_allocator_combined.h b/lib/sanitizer_common/sanitizer_allocator_combined.h index d285df11f..e21d7a962 100644 --- a/lib/sanitizer_common/sanitizer_allocator_combined.h +++ b/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/lib/sanitizer_common/sanitizer_allocator_internal.h b/lib/sanitizer_common/sanitizer_allocator_internal.h index 214218a87..7d5b2f3c3 100644 --- a/lib/sanitizer_common/sanitizer_allocator_internal.h +++ b/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/lib/sanitizer_common/tests/sanitizer_allocator_test.cc b/lib/sanitizer_common/tests/sanitizer_allocator_test.cc index d19b37609..4c4ccb5fe 100644 --- a/lib/sanitizer_common/tests/sanitizer_allocator_test.cc +++ b/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/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc b/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc index bf09b0d55..34abbe615 100644 --- a/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc +++ b/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; |