[compiler-rt] r278163 - [sanitizer] minor refactoring in the allocator, NFC
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 9 13:54:50 PDT 2016
Author: kcc
Date: Tue Aug 9 15:54:50 2016
New Revision: 278163
URL: http://llvm.org/viewvc/llvm-project?rev=278163&view=rev
Log:
[sanitizer] minor refactoring in the allocator, NFC
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_local_cache.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary32.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_local_cache.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_local_cache.h?rev=278163&r1=278162&r2=278163&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_local_cache.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_local_cache.h Tue Aug 9 15:54:50 2016
@@ -140,8 +140,7 @@ struct SizeClassAllocatorLocalCache {
PerClass *c = &per_class_[class_id];
TransferBatch *b = allocator->AllocateBatch(&stats_, this, class_id);
CHECK_GT(b->Count(), 0);
- for (uptr i = 0; i < b->Count(); i++)
- c->batch[i] = b->Get(i);
+ b->CopyToArray(c->batch);
c->count = b->Count();
DestroyBatch(class_id, allocator, b);
}
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary32.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary32.h?rev=278163&r1=278162&r2=278163&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary32.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary32.h Tue Aug 9 15:54:50 2016
@@ -49,16 +49,16 @@ class SizeClassAllocator32 {
for (uptr i = 0; i < count; i++)
batch_[i] = batch[i];
}
- void *Get(uptr idx) {
- CHECK_LT(idx, count_);
- return batch_[idx];
- }
uptr Count() const { return count_; }
void Clear() { count_ = 0; }
void Add(void *ptr) {
batch_[count_++] = ptr;
CHECK_LE(count_, kMaxNumCached);
}
+ void CopyToArray(void *to_batch[]) {
+ for (uptr i = 0, n = Count(); i < n; i++)
+ to_batch[i] = batch_[i];
+ }
TransferBatch *next;
private:
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h?rev=278163&r1=278162&r2=278163&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary64.h Tue Aug 9 15:54:50 2016
@@ -50,9 +50,9 @@ class SizeClassAllocator64 {
for (uptr i = 0; i < count; i++)
batch_[i] = batch[i];
}
- void *Get(uptr idx) {
- CHECK_LT(idx, count_);
- return batch_[idx];
+ void CopyToArray(void *to_batch[]) {
+ for (uptr i = 0, n = Count(); i < n; i++)
+ to_batch[i] = batch_[i];
}
uptr Count() const { return count_; }
TransferBatch *next;
More information about the llvm-commits
mailing list