[sanitizer][NFC] Remove unneeded SizeClassAllocatorLocalCache

llvm-svn: 359729
This commit is contained in:
Vitaly Buka 2019-05-01 21:23:07 +00:00
parent 59bcb788ec
commit 9ef838761e
3 changed files with 17 additions and 29 deletions

View File

@ -23,7 +23,7 @@ template <class PrimaryAllocator,
class LargeMmapAllocatorPtrArray = DefaultLargeMmapAllocatorPtrArray>
class CombinedAllocator {
public:
using AllocatorCache = SizeClassAllocatorLocalCache<PrimaryAllocator>;
using AllocatorCache = typename PrimaryAllocator::AllocatorCache;
using SecondaryAllocator =
LargeMmapAllocator<typename PrimaryAllocator::MapUnmapCallback,
LargeMmapAllocatorPtrArray,

View File

@ -13,13 +13,6 @@
#error This file must be included inside sanitizer_allocator.h
#endif
// Objects of this type should be used as local caches for SizeClassAllocator64
// or SizeClassAllocator32. Since the typical use of this class is to have one
// object per thread in TLS, is has to be POD.
template<class SizeClassAllocator>
struct SizeClassAllocatorLocalCache
: SizeClassAllocator::AllocatorCache {};
// Cache used by SizeClassAllocator64.
template <class SizeClassAllocator>
struct SizeClassAllocator64LocalCache {

View File

@ -191,7 +191,7 @@ template <class Allocator>
void TestSizeClassAllocator() {
Allocator *a = new Allocator;
a->Init(kReleaseToOSIntervalNever);
SizeClassAllocatorLocalCache<Allocator> cache;
typename Allocator::AllocatorCache cache;
memset(&cache, 0, sizeof(cache));
cache.Init(0);
@ -315,7 +315,7 @@ template <class Allocator>
void SizeClassAllocatorMetadataStress() {
Allocator *a = new Allocator;
a->Init(kReleaseToOSIntervalNever);
SizeClassAllocatorLocalCache<Allocator> cache;
typename Allocator::AllocatorCache cache;
memset(&cache, 0, sizeof(cache));
cache.Init(0);
@ -369,7 +369,7 @@ template <class Allocator>
void SizeClassAllocatorGetBlockBeginStress(u64 TotalSize) {
Allocator *a = new Allocator;
a->Init(kReleaseToOSIntervalNever);
SizeClassAllocatorLocalCache<Allocator> cache;
typename Allocator::AllocatorCache cache;
memset(&cache, 0, sizeof(cache));
cache.Init(0);
@ -446,7 +446,7 @@ TEST(SanitizerCommon, SizeClassAllocator64MapUnmapCallback) {
Allocator64WithCallBack *a = new Allocator64WithCallBack;
a->Init(kReleaseToOSIntervalNever);
EXPECT_EQ(TestMapUnmapCallback::map_count, 1); // Allocator state.
SizeClassAllocatorLocalCache<Allocator64WithCallBack> cache;
typename Allocator64WithCallBack::AllocatorCache cache;
memset(&cache, 0, sizeof(cache));
cache.Init(0);
AllocatorStats stats;
@ -482,7 +482,7 @@ TEST(SanitizerCommon, SizeClassAllocator32MapUnmapCallback) {
Allocator32WithCallBack *a = new Allocator32WithCallBack;
a->Init(kReleaseToOSIntervalNever);
EXPECT_EQ(TestMapUnmapCallback::map_count, 0);
SizeClassAllocatorLocalCache<Allocator32WithCallBack> cache;
Allocator32WithCallBack::AllocatorCache cache;
memset(&cache, 0, sizeof(cache));
cache.Init(0);
AllocatorStats stats;
@ -516,7 +516,7 @@ TEST(SanitizerCommon, LargeMmapAllocatorMapUnmapCallback) {
TEST(SanitizerCommon, SizeClassAllocator64Overflow) {
Allocator64 a;
a.Init(kReleaseToOSIntervalNever);
SizeClassAllocatorLocalCache<Allocator64> cache;
Allocator64::AllocatorCache cache;
memset(&cache, 0, sizeof(cache));
cache.Init(0);
AllocatorStats stats;
@ -705,10 +705,10 @@ TEST(SanitizerCommon, CombinedAllocator32Compact) {
TestCombinedAllocator<Allocator32Compact>();
}
template <class AllocatorCache>
template <class Allocator>
void TestSizeClassAllocatorLocalCache() {
using AllocatorCache = typename Allocator::AllocatorCache;
AllocatorCache cache;
typedef typename AllocatorCache::Allocator Allocator;
Allocator *a = new Allocator();
a->Init(kReleaseToOSIntervalNever);
@ -744,35 +744,30 @@ void TestSizeClassAllocatorLocalCache() {
// to run them all at the same time. FIXME: Make them not flaky and reenable.
#if !SANITIZER_WINDOWS
TEST(SanitizerCommon, SizeClassAllocator64LocalCache) {
TestSizeClassAllocatorLocalCache<
SizeClassAllocatorLocalCache<Allocator64> >();
TestSizeClassAllocatorLocalCache<Allocator64>();
}
TEST(SanitizerCommon, SizeClassAllocator64DynamicLocalCache) {
TestSizeClassAllocatorLocalCache<
SizeClassAllocatorLocalCache<Allocator64Dynamic> >();
TestSizeClassAllocatorLocalCache<Allocator64Dynamic>();
}
#if !SANITIZER_ANDROID
TEST(SanitizerCommon, SizeClassAllocator64CompactLocalCache) {
TestSizeClassAllocatorLocalCache<
SizeClassAllocatorLocalCache<Allocator64Compact> >();
TestSizeClassAllocatorLocalCache<Allocator64Compact>();
}
#endif
TEST(SanitizerCommon, SizeClassAllocator64VeryCompactLocalCache) {
TestSizeClassAllocatorLocalCache<
SizeClassAllocatorLocalCache<Allocator64VeryCompact> >();
TestSizeClassAllocatorLocalCache<Allocator64VeryCompact>();
}
#endif
#endif
TEST(SanitizerCommon, SizeClassAllocator32CompactLocalCache) {
TestSizeClassAllocatorLocalCache<
SizeClassAllocatorLocalCache<Allocator32Compact> >();
TestSizeClassAllocatorLocalCache<Allocator32Compact>();
}
#if SANITIZER_CAN_USE_ALLOCATOR64
typedef SizeClassAllocatorLocalCache<Allocator64> AllocatorCache;
typedef Allocator64::AllocatorCache AllocatorCache;
static AllocatorCache static_allocator_cache;
void *AllocatorLeakTestWorker(void *arg) {
@ -891,7 +886,7 @@ template <class Allocator>
void TestSizeClassAllocatorIteration() {
Allocator *a = new Allocator;
a->Init(kReleaseToOSIntervalNever);
SizeClassAllocatorLocalCache<Allocator> cache;
typename Allocator::AllocatorCache cache;
memset(&cache, 0, sizeof(cache));
cache.Init(0);
@ -1034,7 +1029,7 @@ TEST(SanitizerCommon, SizeClassAllocator64PopulateFreeListOOM) {
kAllocatorSize / SpecialSizeClassMap::kNumClassesRounded;
SpecialAllocator64 *a = new SpecialAllocator64;
a->Init(kReleaseToOSIntervalNever);
SizeClassAllocatorLocalCache<SpecialAllocator64> cache;
SpecialAllocator64::AllocatorCache cache;
memset(&cache, 0, sizeof(cache));
cache.Init(0);