[compiler-rt] r332502 - [scudo] Quarantine optimization
Kostya Kortchinsky via llvm-commits
llvm-commits at lists.llvm.org
Wed May 16 11:12:32 PDT 2018
Author: cryptoad
Date: Wed May 16 11:12:31 2018
New Revision: 332502
URL: http://llvm.org/viewvc/llvm-project?rev=332502&view=rev
Log:
[scudo] Quarantine optimization
Summary:
It turns out that the previous code construct was not optimizing the allocation
and deallocation of batches. The class id was read as a class member (even
though a precomputed one) and nothing else was optimized. By changing the
construct this way, the compiler actually optimizes most of the allocation and
deallocation away to only work with a single class id, which not only saves some
CPU but also some code footprint.
Reviewers: alekseyshl, dvyukov
Reviewed By: dvyukov
Subscribers: dvyukov, delcypher, llvm-commits, #sanitizers
Differential Revision: https://reviews.llvm.org/D46961
Modified:
compiler-rt/trunk/lib/scudo/scudo_allocator.cpp
Modified: compiler-rt/trunk/lib/scudo/scudo_allocator.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/scudo_allocator.cpp?rev=332502&r1=332501&r2=332502&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/scudo_allocator.cpp (original)
+++ compiler-rt/trunk/lib/scudo/scudo_allocator.cpp Wed May 16 11:12:31 2018
@@ -197,16 +197,17 @@ struct QuarantineCallback {
// that the batches are indeed serviced by the Primary.
// TODO(kostyak): figure out the best way to protect the batches.
void *Allocate(uptr Size) {
+ const uptr BatchClassId = SizeClassMap::ClassID(sizeof(QuarantineBatch));
return getBackendAllocator().allocatePrimary(Cache_, BatchClassId);
}
void Deallocate(void *Ptr) {
+ const uptr BatchClassId = SizeClassMap::ClassID(sizeof(QuarantineBatch));
getBackendAllocator().deallocatePrimary(Cache_, Ptr, BatchClassId);
}
AllocatorCache *Cache_;
COMPILER_CHECK(sizeof(QuarantineBatch) < SizeClassMap::kMaxSize);
- const uptr BatchClassId = SizeClassMap::ClassID(sizeof(QuarantineBatch));
};
typedef Quarantine<QuarantineCallback, void> ScudoQuarantine;
More information about the llvm-commits
mailing list