diff options
author | Kostya Serebryany <kcc@google.com> | 2016-08-09 23:30:22 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2016-08-09 23:30:22 +0000 |
commit | 98935353f1d437aa081a8e702f4cebd0b807a002 (patch) | |
tree | e1d7f7d0f8b6af5a17b3b9f99c5e689415c89fa7 /lib/sanitizer_common/sanitizer_allocator_local_cache.h | |
parent | 874f0c1907e38e3553c17d84a2920d418b8ba785 (diff) |
[sanitizer] use 32-bit offset instead of 64-bit pointers in the 64-bit allocator's transfer batches. This saves 2x memory for the transfer batches (up to ~1.5% overall in some cases)
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@278179 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_allocator_local_cache.h')
-rw-r--r-- | lib/sanitizer_common/sanitizer_allocator_local_cache.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/sanitizer_common/sanitizer_allocator_local_cache.h b/lib/sanitizer_common/sanitizer_allocator_local_cache.h index 38d63a555..0ad22bae3 100644 --- a/lib/sanitizer_common/sanitizer_allocator_local_cache.h +++ b/lib/sanitizer_common/sanitizer_allocator_local_cache.h @@ -74,7 +74,7 @@ struct SizeClassAllocatorLocalCache { struct PerClass { uptr count; uptr max_count; - void *batch[2 * SizeClassMap::kMaxNumCached]; + void *batch[2 * TransferBatch::kMaxNumCached]; }; PerClass per_class_[kNumClasses]; AllocatorStats stats_; @@ -84,7 +84,7 @@ struct SizeClassAllocatorLocalCache { return; for (uptr i = 0; i < kNumClasses; i++) { PerClass *c = &per_class_[i]; - c->max_count = 2 * SizeClassMap::MaxCached(i); + c->max_count = 2 * TransferBatch::MaxCached(i); } } @@ -109,9 +109,8 @@ struct SizeClassAllocatorLocalCache { ? 0 : SizeClassMap::kBatchClassID; if (Allocator::ClassIdToSize(class_id) < - sizeof(TransferBatch) - - sizeof(uptr) * (SizeClassMap::kMaxNumCached - - SizeClassMap::MaxCached(class_id))) + TransferBatch::AllocationSizeRequiredForNElements( + TransferBatch::MaxCached(class_id))) return SizeClassMap::ClassID(sizeof(TransferBatch)); return 0; } @@ -152,7 +151,8 @@ struct SizeClassAllocatorLocalCache { uptr first_idx_to_drain = c->count - cnt; TransferBatch *b = CreateBatch( class_id, allocator, (TransferBatch *)c->batch[first_idx_to_drain]); - b->SetFromArray(&c->batch[first_idx_to_drain], cnt); + b->SetFromArray(allocator->GetRegionBeginBySizeClass(class_id), + &c->batch[first_idx_to_drain], cnt); c->count -= cnt; allocator->DeallocateBatch(&stats_, class_id, b); } |