[PATCH] D27816: [scudo] Use DefaultSizeClassMap for 32-bit
Kostya Kortchinsky via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 15 10:17:30 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289838: [scudo] Use DefaultSizeClassMap for 32-bit (authored by cryptoad).
Changed prior to commit:
https://reviews.llvm.org/D27816?vs=81599&id=81612#toc
Repository:
rL LLVM
https://reviews.llvm.org/D27816
Files:
compiler-rt/trunk/lib/scudo/scudo_allocator.cpp
compiler-rt/trunk/lib/scudo/scudo_allocator.h
Index: compiler-rt/trunk/lib/scudo/scudo_allocator.cpp
===================================================================
--- compiler-rt/trunk/lib/scudo/scudo_allocator.cpp
+++ compiler-rt/trunk/lib/scudo/scudo_allocator.cpp
@@ -68,7 +68,7 @@
# 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 @@
"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 "
Index: compiler-rt/trunk/lib/scudo/scudo_allocator.h
===================================================================
--- compiler-rt/trunk/lib/scudo/scudo_allocator.h
+++ compiler-rt/trunk/lib/scudo/scudo_allocator.h
@@ -44,10 +44,10 @@
typedef u64 PackedHeader;
struct UnpackedHeader {
u64 Checksum : 16;
- u64 UnusedBytes : 24; // Needed for reallocation purposes.
+ u64 UnusedBytes : 20; // Needed for reallocation purposes.
u64 State : 2; // available, allocated, or quarantined
u64 AllocType : 2; // malloc, new, new[], or memalign
- u64 Offset : 12; // Offset from the beginning of the backend
+ u64 Offset : 16; // Offset from the beginning of the backend
// allocation to the beginning of the chunk itself,
// in multiples of MinAlignment. See comment about
// its maximum value and test in init().
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27816.81612.patch
Type: text/x-patch
Size: 2583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161215/156dc3d4/attachment.bin>
More information about the llvm-commits
mailing list