summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2019-05-01 19:30:49 +0000
committerVitaly Buka <vitalybuka@google.com>2019-05-01 19:30:49 +0000
commit8b0927fbbaa2dd437b3f189b357990dd3d06c694 (patch)
tree5a56d1ec74224ed1a140deadb37b906d447970d8
parentcfcbff0d73bea1fece9c213fb7ed9eab27c125a6 (diff)
downloadcompiler-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
-rw-r--r--lib/asan/asan_allocator.h6
-rw-r--r--lib/hwasan/hwasan_allocator.h5
-rw-r--r--lib/lsan/lsan_allocator.h9
-rw-r--r--lib/msan/msan_allocator.cc5
-rw-r--r--lib/sanitizer_common/sanitizer_allocator_combined.h4
-rw-r--r--lib/sanitizer_common/sanitizer_allocator_internal.h8
-rw-r--r--lib/sanitizer_common/tests/sanitizer_allocator_test.cc29
-rw-r--r--lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc5
-rw-r--r--lib/scudo/scudo_allocator.h4
-rw-r--r--lib/scudo/scudo_allocator_combined.h4
-rw-r--r--lib/tsan/rtl/tsan_rtl.h5
11 files changed, 28 insertions, 56 deletions
diff --git a/lib/asan/asan_allocator.h b/lib/asan/asan_allocator.h
index a3c3cda8e..63dbfd604 100644
--- a/lib/asan/asan_allocator.h
+++ b/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/lib/hwasan/hwasan_allocator.h b/lib/hwasan/hwasan_allocator.h
index fca22da6c..2070df150 100644
--- a/lib/hwasan/hwasan_allocator.h
+++ b/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/lib/lsan/lsan_allocator.h b/lib/lsan/lsan_allocator.h
index eda5f0e3a..bef78128d 100644
--- a/lib/lsan/lsan_allocator.h
+++ b/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/lib/msan/msan_allocator.cc b/lib/msan/msan_allocator.cc
index 8bf8fda06..59c39cbef 100644
--- a/lib/msan/msan_allocator.cc
+++ b/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/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;
diff --git a/lib/scudo/scudo_allocator.h b/lib/scudo/scudo_allocator.h
index 59225b681..7a92e4142 100644
--- a/lib/scudo/scudo_allocator.h
+++ b/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/lib/scudo/scudo_allocator_combined.h b/lib/scudo/scudo_allocator_combined.h
index d750b995f..4e9217cdd 100644
--- a/lib/scudo/scudo_allocator_combined.h
+++ b/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/lib/tsan/rtl/tsan_rtl.h b/lib/tsan/rtl/tsan_rtl.h
index 2c8ae29f3..c37eab9da 100644
--- a/lib/tsan/rtl/tsan_rtl.h
+++ b/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