summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Liew <dan@su-root.co.uk>2018-12-21 21:22:27 +0000
committerDan Liew <dan@su-root.co.uk>2018-12-21 21:22:27 +0000
commit14e0d9ed89ac50b885ef6419aa3128090d85fe3c (patch)
tree66aa7324677b3f044c1b433004ff2b3b9fa1d56c
parent62ec024d3bc7a5788aa982b5b9d1ea4455598b53 (diff)
downloadbcm5719-llvm-14e0d9ed89ac50b885ef6419aa3128090d85fe3c.tar.gz
bcm5719-llvm-14e0d9ed89ac50b885ef6419aa3128090d85fe3c.zip
Introduce `AddressSpaceView` template parameter to `CombinedAllocator`.
Summary: This is a follow up to https://reviews.llvm.org/D55764 . For the ASan and LSan allocatorsthe type declarations have been modified so that it's possible to create a combined allocator type that consistently uses a different type of `AddressSpaceView`. We intend to use this in future patches. For the other sanitizers they just use `LocalAddressSpaceView` by default because we have no plans to use these allocators in an out-of-process manner. rdar://problem/45284065 Reviewers: kcc, dvyukov, vitalybuka, cryptoad, eugenis, kubamracek, george.karpenkov, yln Subscribers: #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D55766 llvm-svn: 349957
-rw-r--r--compiler-rt/lib/asan/asan_allocator.h18
-rw-r--r--compiler-rt/lib/lsan/lsan_allocator.cc3
-rw-r--r--compiler-rt/lib/lsan/lsan_allocator.h18
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h11
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h3
5 files changed, 42 insertions, 11 deletions
diff --git a/compiler-rt/lib/asan/asan_allocator.h b/compiler-rt/lib/asan/asan_allocator.h
index 209532e1fe4..c9b37dc7a6d 100644
--- a/compiler-rt/lib/asan/asan_allocator.h
+++ b/compiler-rt/lib/asan/asan_allocator.h
@@ -192,11 +192,21 @@ using PrimaryAllocator = PrimaryAllocatorASVT<LocalAddressSpaceView>;
#endif // SANITIZER_CAN_USE_ALLOCATOR64
static const uptr kNumberOfSizeClasses = SizeClassMap::kNumClasses;
-typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache;
-typedef LargeMmapAllocator<AsanMapUnmapCallback> SecondaryAllocator;
-typedef CombinedAllocator<PrimaryAllocator, AllocatorCache,
- SecondaryAllocator> AsanAllocator;
+template <typename AddressSpaceView>
+using AllocatorCacheASVT =
+ SizeClassAllocatorLocalCache<PrimaryAllocatorASVT<AddressSpaceView>>;
+using AllocatorCache = AllocatorCacheASVT<LocalAddressSpaceView>;
+template <typename AddressSpaceView>
+using SecondaryAllocatorASVT =
+ LargeMmapAllocator<AsanMapUnmapCallback, DefaultLargeMmapAllocatorPtrArray,
+ AddressSpaceView>;
+template <typename AddressSpaceView>
+using AsanAllocatorASVT =
+ CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>,
+ AllocatorCacheASVT<AddressSpaceView>,
+ SecondaryAllocatorASVT<AddressSpaceView>>;
+using AsanAllocator = AsanAllocatorASVT<LocalAddressSpaceView>;
struct AsanThreadLocalMallocStorage {
uptr quarantine_cache[16];
diff --git a/compiler-rt/lib/lsan/lsan_allocator.cc b/compiler-rt/lib/lsan/lsan_allocator.cc
index c58c3548002..1b338bd5973 100644
--- a/compiler-rt/lib/lsan/lsan_allocator.cc
+++ b/compiler-rt/lib/lsan/lsan_allocator.cc
@@ -34,9 +34,6 @@ static const uptr kMaxAllowedMallocSize = 4UL << 30;
#else
static const uptr kMaxAllowedMallocSize = 8UL << 30;
#endif
-typedef LargeMmapAllocator<> SecondaryAllocator;
-typedef CombinedAllocator<PrimaryAllocator, AllocatorCache,
- SecondaryAllocator> Allocator;
static Allocator allocator;
diff --git a/compiler-rt/lib/lsan/lsan_allocator.h b/compiler-rt/lib/lsan/lsan_allocator.h
index 29ea2b6d9c2..4c4e02fc090 100644
--- a/compiler-rt/lib/lsan/lsan_allocator.h
+++ b/compiler-rt/lib/lsan/lsan_allocator.h
@@ -96,7 +96,23 @@ template <typename AddressSpaceView>
using PrimaryAllocatorASVT = SizeClassAllocator64<AP64<AddressSpaceView>>;
using PrimaryAllocator = PrimaryAllocatorASVT<LocalAddressSpaceView>;
#endif
-typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache;
+
+template <typename AddressSpaceView>
+using AllocatorCacheASVT =
+ SizeClassAllocatorLocalCache<PrimaryAllocatorASVT<AddressSpaceView>>;
+using AllocatorCache = AllocatorCacheASVT<LocalAddressSpaceView>;
+
+template <typename AddressSpaceView>
+using SecondaryAllocatorASVT =
+ LargeMmapAllocator<NoOpMapUnmapCallback, DefaultLargeMmapAllocatorPtrArray,
+ AddressSpaceView>;
+
+template <typename AddressSpaceView>
+using AllocatorASVT =
+ CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>,
+ AllocatorCacheASVT<AddressSpaceView>,
+ SecondaryAllocatorASVT<AddressSpaceView>>;
+using Allocator = AllocatorASVT<LocalAddressSpaceView>;
AllocatorCache *GetAllocatorCache();
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h
index 1f874d60b92..2dec5d81b2b 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h
@@ -21,9 +21,11 @@
// PrimaryAllocator is used via a local AllocatorCache.
// SecondaryAllocator can allocate anything, but is not efficient.
template <class PrimaryAllocator, class AllocatorCache,
- class SecondaryAllocator> // NOLINT
+ class SecondaryAllocator,
+ typename AddressSpaceViewTy = LocalAddressSpaceView> // NOLINT
class CombinedAllocator {
public:
+ using AddressSpaceView = AddressSpaceViewTy;
void InitLinkerInitialized(s32 release_to_os_interval_ms) {
primary_.Init(release_to_os_interval_ms);
secondary_.InitLinkerInitialized();
@@ -31,6 +33,12 @@ class CombinedAllocator {
}
void Init(s32 release_to_os_interval_ms) {
+ 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");
primary_.Init(release_to_os_interval_ms);
secondary_.Init();
stats_.Init();
@@ -194,4 +202,3 @@ class CombinedAllocator {
SecondaryAllocator secondary_;
AllocatorGlobalStats stats_;
};
-
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h
index 455fcf3b4ee..e628a796471 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h
@@ -69,9 +69,10 @@ typedef LargeMmapAllocatorPtrArrayDynamic DefaultLargeMmapAllocatorPtrArray;
// sizes not covered by more efficient allocators (e.g. SizeClassAllocator64).
template <class MapUnmapCallback = NoOpMapUnmapCallback,
class PtrArrayT = DefaultLargeMmapAllocatorPtrArray,
- class AddressSpaceView = LocalAddressSpaceView>
+ class AddressSpaceViewTy = LocalAddressSpaceView>
class LargeMmapAllocator {
public:
+ using AddressSpaceView = AddressSpaceViewTy;
void InitLinkerInitialized() {
page_size_ = GetPageSizeCached();
chunks_ = reinterpret_cast<Header**>(ptr_array_.Init());
OpenPOWER on IntegriCloud