summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2019-05-01 21:23:07 +0000
committerVitaly Buka <vitalybuka@google.com>2019-05-01 21:23:07 +0000
commit3aad8d0cb76ad2cbaecd363597a0125b6f8b0b6e (patch)
tree51af32aea5a2b91e70b7e79fb7c6875e37031aaa
parentde399a3fb6500f2a0893190ff625a55a9d70cf4d (diff)
downloadcompiler-rt-3aad8d0cb76ad2cbaecd363597a0125b6f8b0b6e.tar.gz
[sanitizer][NFC] Remove unneeded SizeClassAllocatorLocalCache
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359729 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/sanitizer_common/sanitizer_allocator_combined.h2
-rw-r--r--lib/sanitizer_common/sanitizer_allocator_local_cache.h7
-rw-r--r--lib/sanitizer_common/tests/sanitizer_allocator_test.cc37
3 files changed, 17 insertions, 29 deletions
diff --git a/lib/sanitizer_common/sanitizer_allocator_combined.h b/lib/sanitizer_common/sanitizer_allocator_combined.h
index 5b3dd15df..33f89d6d4 100644
--- a/lib/sanitizer_common/sanitizer_allocator_combined.h
+++ b/lib/sanitizer_common/sanitizer_allocator_combined.h
@@ -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,
diff --git a/lib/sanitizer_common/sanitizer_allocator_local_cache.h b/lib/sanitizer_common/sanitizer_allocator_local_cache.h
index b3b764f8f..108dfc231 100644
--- a/lib/sanitizer_common/sanitizer_allocator_local_cache.h
+++ b/lib/sanitizer_common/sanitizer_allocator_local_cache.h
@@ -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 {
diff --git a/lib/sanitizer_common/tests/sanitizer_allocator_test.cc b/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
index 790662d99..5d99bf458 100644
--- a/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
+++ b/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
@@ -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);