diff options
author | Kostya Serebryany <kcc@google.com> | 2016-07-21 18:47:53 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2016-07-21 18:47:53 +0000 |
commit | 52ee88fd9cb9eaadfb9e8a6b460b57c2e25cb95d (patch) | |
tree | 53b75f77cfbcb754824b1bee3cc01a0934d72be1 /lib/sanitizer_common/sanitizer_allocator_size_class_map.h | |
parent | c8da6db25e5e82ea0ce79615cdffdc4966e2900f (diff) |
[sanitizer] allocator: remove kPopulateSize and only use SizeClassMap::MaxCached; ensure that TransferBatch size is a power of two, refactor TransferBatch creation/destruction into separate functions.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276318 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_allocator_size_class_map.h')
-rw-r--r-- | lib/sanitizer_common/sanitizer_allocator_size_class_map.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/sanitizer_common/sanitizer_allocator_size_class_map.h b/lib/sanitizer_common/sanitizer_allocator_size_class_map.h index 612064ec2..9d0566a84 100644 --- a/lib/sanitizer_common/sanitizer_allocator_size_class_map.h +++ b/lib/sanitizer_common/sanitizer_allocator_size_class_map.h @@ -87,14 +87,17 @@ class SizeClassMap { public: static const uptr kMaxNumCached = kMaxNumCachedT; + COMPILER_CHECK(((kMaxNumCached + 2) & (kMaxNumCached + 1)) == 0); // We transfer chunks between central and thread-local free lists in batches. // For small size classes we allocate batches separately. // For large size classes we use one of the chunks to store the batch. + // sizeof(TransferBatch) must be a power of 2 for more efficient allocation. struct TransferBatch { TransferBatch *next; uptr count; void *batch[kMaxNumCached]; }; + COMPILER_CHECK((sizeof(TransferBatch) & (sizeof(TransferBatch) - 1)) == 0); static const uptr kMaxSize = 1UL << kMaxSizeLog; static const uptr kNumClasses = @@ -180,7 +183,7 @@ class SizeClassMap { } }; -typedef SizeClassMap<17, 128, 16> DefaultSizeClassMap; -typedef SizeClassMap<17, 64, 14> CompactSizeClassMap; +typedef SizeClassMap<17, 126, 16> DefaultSizeClassMap; +typedef SizeClassMap<17, 62, 14> CompactSizeClassMap; template<class SizeClassAllocator> struct SizeClassAllocatorLocalCache; |