diff options
author | Kostya Kortchinsky <kostyak@google.com> | 2018-05-16 18:12:31 +0000 |
---|---|---|
committer | Kostya Kortchinsky <kostyak@google.com> | 2018-05-16 18:12:31 +0000 |
commit | 30125cf033926a1120fc9f274e6f1d8097bcd079 (patch) | |
tree | ceef5e17907e6e919ee17f9a0e660026e4ed1edf | |
parent | f59108d344969204009cc9de26dacc8043c908b8 (diff) |
[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
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@332502 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/scudo/scudo_allocator.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/scudo/scudo_allocator.cpp b/lib/scudo/scudo_allocator.cpp index c72ac8601..5a9315e08 100644 --- a/lib/scudo/scudo_allocator.cpp +++ b/lib/scudo/scudo_allocator.cpp @@ -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; |