summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/scudo/scudo_allocator.cpp
diff options
context:
space:
mode:
authorKostya Kortchinsky <kostyak@google.com>2016-12-15 18:06:55 +0000
committerKostya Kortchinsky <kostyak@google.com>2016-12-15 18:06:55 +0000
commit47be0edfa3015e5812a65bc2a01c23dafd3731ac (patch)
treefba7adf03c9f8b9ec376803be59a1709235ffded /compiler-rt/lib/scudo/scudo_allocator.cpp
parenta0d8a278a71ff3176ad1ab39ab2948b06ef11022 (diff)
downloadbcm5719-llvm-47be0edfa3015e5812a65bc2a01c23dafd3731ac.tar.gz
bcm5719-llvm-47be0edfa3015e5812a65bc2a01c23dafd3731ac.zip
[scudo] Use DefaultSizeClassMap for 32-bit
Summary: With the recent changes to the Secondary, we use less bits for UnusedBytes, which allows us in return to increase the bits used for Offset. That means that we can use a Primary SizeClassMap allowing for a larger maximum size. Reviewers: kcc, alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D27816 llvm-svn: 289838
Diffstat (limited to 'compiler-rt/lib/scudo/scudo_allocator.cpp')
-rw-r--r--compiler-rt/lib/scudo/scudo_allocator.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler-rt/lib/scudo/scudo_allocator.cpp b/compiler-rt/lib/scudo/scudo_allocator.cpp
index 4f3b05ffbee..96cfbdbc1af 100644
--- a/compiler-rt/lib/scudo/scudo_allocator.cpp
+++ b/compiler-rt/lib/scudo/scudo_allocator.cpp
@@ -68,7 +68,7 @@ typedef FlatByteMap<NumRegions> ByteMap;
# elif SANITIZER_WORDSIZE == 64
typedef TwoLevelByteMap<(NumRegions >> 12), 1 << 12> ByteMap;
# endif // SANITIZER_WORDSIZE
-typedef SizeClassMap<3, 4, 8, 16, 64, 14> SizeClassMap;
+typedef DefaultSizeClassMap SizeClassMap;
typedef SizeClassAllocator32<0, SANITIZER_MMAP_RANGE_SIZE, 0, SizeClassMap,
RegionSizeLog, ByteMap> PrimaryAllocator;
#endif // SANITIZER_CAN_USE_ALLOCATOR64
@@ -354,11 +354,11 @@ struct Allocator {
"header\n");
}
// Verify that we can fit the maximum amount of unused bytes in the header.
- // The worst case scenario would be when allocating 1 byte on a MaxAlignment
- // alignment. Since the combined allocator currently rounds the size up to
- // the alignment before passing it to the secondary, we end up with
- // MaxAlignment - 1 extra bytes.
- uptr MaxUnusedBytes = MaxAlignment - 1;
+ // Given that the Secondary fits the allocation to a page, the worst case
+ // scenario happens in the Primary. It will depend on the second to last
+ // and last class sizes, as well as the dynamic base for the Primary. The
+ // following is an over-approximation that works for our needs.
+ uptr MaxUnusedBytes = SizeClassMap::kMaxSize - 1 - AlignedChunkHeaderSize;
Header.UnusedBytes = MaxUnusedBytes;
if (Header.UnusedBytes != MaxUnusedBytes) {
dieWithMessage("ERROR: the maximum possible unused bytes doesn't fit in "
OpenPOWER on IntegriCloud