Skip to content

Commit 20c5676

Browse files
committedMay 1, 2019
[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 llvm-svn: 359719
1 parent 7780f51 commit 20c5676

9 files changed

+21
-45
lines changed
 

‎compiler-rt/lib/asan/asan_allocator.h

+1-7
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,9 @@ using PrimaryAllocator = PrimaryAllocatorASVT<LocalAddressSpaceView>;
185185

186186
static const uptr kNumberOfSizeClasses = SizeClassMap::kNumClasses;
187187

188-
template <typename AddressSpaceView>
189-
using SecondaryAllocatorASVT =
190-
LargeMmapAllocator<AsanMapUnmapCallback, DefaultLargeMmapAllocatorPtrArray,
191-
AddressSpaceView>;
192188
template <typename AddressSpaceView>
193189
using AsanAllocatorASVT =
194-
CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>,
195-
SecondaryAllocatorASVT<AddressSpaceView>,
196-
AddressSpaceView>;
190+
CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>>;
197191
using AsanAllocator = AsanAllocatorASVT<LocalAddressSpaceView>;
198192
using AllocatorCache = AsanAllocator::AllocatorCache;
199193

‎compiler-rt/lib/hwasan/hwasan_allocator.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ struct AP64 {
6161
static const uptr kFlags = 0;
6262
};
6363
typedef SizeClassAllocator64<AP64> PrimaryAllocator;
64-
typedef LargeMmapAllocator<HwasanMapUnmapCallback> SecondaryAllocator;
65-
typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
64+
typedef CombinedAllocator<PrimaryAllocator> Allocator;
6665
typedef Allocator::AllocatorCache AllocatorCache;
6766

6867
void AllocatorSwallowThreadLocalCache(AllocatorCache *cache);

‎compiler-rt/lib/lsan/lsan_allocator.h

+1-9
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,7 @@ using PrimaryAllocator = PrimaryAllocatorASVT<LocalAddressSpaceView>;
9090
#endif
9191

9292
template <typename AddressSpaceView>
93-
using SecondaryAllocatorASVT =
94-
LargeMmapAllocator<NoOpMapUnmapCallback, DefaultLargeMmapAllocatorPtrArray,
95-
AddressSpaceView>;
96-
97-
template <typename AddressSpaceView>
98-
using AllocatorASVT =
99-
CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>,
100-
SecondaryAllocatorASVT<AddressSpaceView>,
101-
AddressSpaceView>;
93+
using AllocatorASVT = CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>>;
10294
using Allocator = AllocatorASVT<LocalAddressSpaceView>;
10395
using AllocatorCache = Allocator::AllocatorCache;
10496

‎compiler-rt/lib/msan/msan_allocator.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ struct AP32 {
108108
};
109109
typedef SizeClassAllocator32<AP32> PrimaryAllocator;
110110
#endif
111-
typedef LargeMmapAllocator<MsanMapUnmapCallback> SecondaryAllocator;
112-
typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
111+
typedef CombinedAllocator<PrimaryAllocator> Allocator;
113112
typedef Allocator::AllocatorCache AllocatorCache;
114113

115114
static Allocator allocator;

‎compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h

+6-9
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,15 @@
1919
// When allocating 2^x bytes it should return 2^x aligned chunk.
2020
// PrimaryAllocator is used via a local AllocatorCache.
2121
// SecondaryAllocator can allocate anything, but is not efficient.
22-
template <class PrimaryAllocator, class SecondaryAllocator,
23-
typename AddressSpaceViewTy = LocalAddressSpaceView> // NOLINT
22+
template <class PrimaryAllocator,
23+
class LargeMmapAllocatorPtrArray = DefaultLargeMmapAllocatorPtrArray>
2424
class CombinedAllocator {
2525
public:
2626
using AllocatorCache = SizeClassAllocatorLocalCache<PrimaryAllocator>;
27-
using AddressSpaceView = AddressSpaceViewTy;
28-
static_assert(is_same<AddressSpaceView,
29-
typename PrimaryAllocator::AddressSpaceView>::value,
30-
"PrimaryAllocator is using wrong AddressSpaceView");
31-
static_assert(is_same<AddressSpaceView,
32-
typename SecondaryAllocator::AddressSpaceView>::value,
33-
"SecondaryAllocator is using wrong AddressSpaceView");
27+
using SecondaryAllocator =
28+
LargeMmapAllocator<typename PrimaryAllocator::MapUnmapCallback,
29+
LargeMmapAllocatorPtrArray,
30+
typename PrimaryAllocator::AddressSpaceView>;
3431

3532
void InitLinkerInitialized(s32 release_to_os_interval_ms) {
3633
stats_.InitLinkerInitialized();

‎compiler-rt/lib/sanitizer_common/sanitizer_allocator_internal.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,8 @@ struct AP32 {
3434
};
3535
typedef SizeClassAllocator32<AP32> PrimaryInternalAllocator;
3636

37-
typedef LargeMmapAllocator<NoOpMapUnmapCallback,
38-
LargeMmapAllocatorPtrArrayStatic>
39-
SecondaryInternalAllocator;
40-
41-
typedef CombinedAllocator<PrimaryInternalAllocator, SecondaryInternalAllocator>
37+
typedef CombinedAllocator<PrimaryInternalAllocator,
38+
LargeMmapAllocatorPtrArrayStatic>
4239
InternalAllocator;
4340
typedef InternalAllocator::AllocatorCache InternalAllocatorCache;
4441

‎compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc

+7-7
Original file line numberDiff line numberDiff line change
@@ -615,9 +615,9 @@ TEST(SanitizerCommon, LargeMmapAllocator) {
615615
a.Deallocate(&stats, p);
616616
}
617617

618-
template <class PrimaryAllocator, class SecondaryAllocator>
618+
template <class PrimaryAllocator>
619619
void TestCombinedAllocator() {
620-
typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
620+
typedef CombinedAllocator<PrimaryAllocator> Allocator;
621621
Allocator *a = new Allocator;
622622
a->Init(kReleaseToOSIntervalNever);
623623
std::mt19937 r;
@@ -683,26 +683,26 @@ void TestCombinedAllocator() {
683683

684684
#if SANITIZER_CAN_USE_ALLOCATOR64
685685
TEST(SanitizerCommon, CombinedAllocator64) {
686-
TestCombinedAllocator<Allocator64, LargeMmapAllocator<>>();
686+
TestCombinedAllocator<Allocator64>();
687687
}
688688

689689
TEST(SanitizerCommon, CombinedAllocator64Dynamic) {
690-
TestCombinedAllocator<Allocator64Dynamic, LargeMmapAllocator<>>();
690+
TestCombinedAllocator<Allocator64Dynamic>();
691691
}
692692

693693
#if !SANITIZER_ANDROID
694694
TEST(SanitizerCommon, CombinedAllocator64Compact) {
695-
TestCombinedAllocator<Allocator64Compact, LargeMmapAllocator<>>();
695+
TestCombinedAllocator<Allocator64Compact>();
696696
}
697697
#endif
698698

699699
TEST(SanitizerCommon, CombinedAllocator64VeryCompact) {
700-
TestCombinedAllocator<Allocator64VeryCompact, LargeMmapAllocator<>>();
700+
TestCombinedAllocator<Allocator64VeryCompact>();
701701
}
702702
#endif
703703

704704
TEST(SanitizerCommon, CombinedAllocator32Compact) {
705-
TestCombinedAllocator<Allocator32Compact, LargeMmapAllocator<>>();
705+
TestCombinedAllocator<Allocator32Compact>();
706706
}
707707

708708
template <class AllocatorCache>

‎compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ struct __AP64 {
4949
namespace {
5050

5151
typedef SizeClassAllocator64<__AP64> PrimaryAllocator;
52-
typedef LargeMmapAllocator<> SecondaryAllocator;
53-
typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
52+
typedef CombinedAllocator<PrimaryAllocator> Allocator;
5453
typedef Allocator::AllocatorCache AllocatorCache;
5554

5655
static Allocator allocator;

‎compiler-rt/lib/tsan/rtl/tsan_rtl.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ struct AP64 { // Allocator64 parameters. Deliberately using a short name.
7979
};
8080
typedef SizeClassAllocator64<AP64> PrimaryAllocator;
8181
#endif
82-
typedef LargeMmapAllocator<MapUnmapCallback> SecondaryAllocator;
83-
typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
82+
typedef CombinedAllocator<PrimaryAllocator> Allocator;
8483
typedef Allocator::AllocatorCache AllocatorCache;
8584
Allocator *allocator();
8685
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.