summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/scudo/scudo_allocator_secondary.h
diff options
context:
space:
mode:
authorKostya Kortchinsky <kostyak@google.com>2018-02-27 16:14:49 +0000
committerKostya Kortchinsky <kostyak@google.com>2018-02-27 16:14:49 +0000
commitbeeea6227b4e9c56b995891708e258c2b78e611d (patch)
tree73f0eaa51b3eea9fb1226a34f32249845cdc6410 /compiler-rt/lib/scudo/scudo_allocator_secondary.h
parent6e066350d8dcfac70e8a038e9ea580dacb56d08d (diff)
downloadbcm5719-llvm-beeea6227b4e9c56b995891708e258c2b78e611d.tar.gz
bcm5719-llvm-beeea6227b4e9c56b995891708e258c2b78e611d.zip
[scudo] Introduce Chunk::getHeaderSize
Summary: Instead of using `AlignedChunkHeaderSize`, introduce a `constexpr` function `getHeaderSize` in the `Chunk` namespace. Switch `RoundUpTo` to a `constexpr` as well (so we can use it in `constexpr` declarations). Mark a few variables in the areas touched as `const`. Overall this has no functional change, and is mostly to make things a bit more consistent. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D43772 llvm-svn: 326206
Diffstat (limited to 'compiler-rt/lib/scudo/scudo_allocator_secondary.h')
-rw-r--r--compiler-rt/lib/scudo/scudo_allocator_secondary.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler-rt/lib/scudo/scudo_allocator_secondary.h b/compiler-rt/lib/scudo/scudo_allocator_secondary.h
index 2415b3f1de2..119b149257d 100644
--- a/compiler-rt/lib/scudo/scudo_allocator_secondary.h
+++ b/compiler-rt/lib/scudo/scudo_allocator_secondary.h
@@ -28,7 +28,7 @@ class ScudoLargeMmapAllocator {
}
void *Allocate(AllocatorStats *Stats, uptr Size, uptr Alignment) {
- const uptr UserSize = Size - AlignedChunkHeaderSize;
+ const uptr UserSize = Size - Chunk::getHeaderSize();
// The Scudo frontend prevents us from allocating more than
// MaxAllowedMallocSize, so integer overflow checks would be superfluous.
uptr MapSize = Size + AlignedReservedAddressRangeSize;
@@ -80,7 +80,7 @@ class ScudoLargeMmapAllocator {
// Actually mmap the memory, preserving the guard pages on either side
CHECK_EQ(MapBeg + PageSize,
AddressRange.Map(MapBeg + PageSize, MapSize - 2 * PageSize));
- const uptr Ptr = UserBeg - AlignedChunkHeaderSize;
+ const uptr Ptr = UserBeg - Chunk::getHeaderSize();
ReservedAddressRange *StoredRange = getReservedAddressRange(Ptr);
*StoredRange = AddressRange;
@@ -129,9 +129,9 @@ class ScudoLargeMmapAllocator {
}
static constexpr uptr AlignedReservedAddressRangeSize =
- (sizeof(ReservedAddressRange) + MinAlignment - 1) & ~(MinAlignment - 1);
+ RoundUpTo(sizeof(ReservedAddressRange), MinAlignment);
static constexpr uptr HeadersSize =
- AlignedReservedAddressRangeSize + AlignedChunkHeaderSize;
+ AlignedReservedAddressRangeSize + Chunk::getHeaderSize();
uptr PageSizeCached;
SpinMutex StatsMutex;
OpenPOWER on IntegriCloud