diff --git a/compiler-rt/lib/msan/msan_allocator.cc b/compiler-rt/lib/msan/msan_allocator.cc --- a/compiler-rt/lib/msan/msan_allocator.cc +++ b/compiler-rt/lib/msan/msan_allocator.cc @@ -44,23 +44,24 @@ } }; +struct DefaultMsanAllocatorParams : public DefaultAllocatorParams { + static const uptr kMetadataSize = sizeof(Metadata); + using MapUnmapCallback = MsanMapUnmapCallback; + using AddressSpaceView = LocalAddressSpaceView; +}; + #if defined(__mips64) static const uptr kMaxAllowedMallocSize = 2UL << 30; static const uptr kRegionSizeLog = 20; static const uptr kNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kRegionSizeLog; typedef TwoLevelByteMap<(kNumRegions >> 12), 1 << 12> ByteMap; -struct AP32 { +struct AP32 : public DefaultMsanAllocatorParams { static const uptr kSpaceBeg = 0; static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE; - static const uptr kMetadataSize = sizeof(Metadata); typedef __sanitizer::CompactSizeClassMap SizeClassMap; static const uptr kRegionSizeLog = __msan::kRegionSizeLog; - using AddressSpaceView = LocalAddressSpaceView; using ByteMap = __msan::ByteMap; - typedef MsanMapUnmapCallback MapUnmapCallback; - using PtrArray = DefaultLargeMmapAllocatorPtrArray; - static const uptr kFlags = 0; }; typedef SizeClassAllocator32 PrimaryAllocator; #elif defined(__x86_64__) @@ -72,15 +73,10 @@ #endif static const uptr kMaxAllowedMallocSize = 8UL << 30; -struct AP64 { // Allocator64 parameters. Deliberately using a short name. +struct AP64 : public DefaultMsanAllocatorParams { static const uptr kSpaceBeg = kAllocatorSpace; static const uptr kSpaceSize = 0x40000000000; // 4T. - static const uptr kMetadataSize = sizeof(Metadata); typedef DefaultSizeClassMap SizeClassMap; - typedef MsanMapUnmapCallback MapUnmapCallback; - using PtrArray = DefaultLargeMmapAllocatorPtrArray; - static const uptr kFlags = 0; - using AddressSpaceView = LocalAddressSpaceView; }; typedef SizeClassAllocator64 PrimaryAllocator; @@ -88,15 +84,10 @@ #elif defined(__powerpc64__) static const uptr kMaxAllowedMallocSize = 2UL << 30; // 2G -struct AP64 { // Allocator64 parameters. Deliberately using a short name. +struct AP64 : public DefaultMsanAllocatorParams { static const uptr kSpaceBeg = 0x300000000000; static const uptr kSpaceSize = 0x020000000000; // 2T. - static const uptr kMetadataSize = sizeof(Metadata); typedef DefaultSizeClassMap SizeClassMap; - typedef MsanMapUnmapCallback MapUnmapCallback; - using PtrArray = DefaultLargeMmapAllocatorPtrArray; - static const uptr kFlags = 0; - using AddressSpaceView = LocalAddressSpaceView; }; typedef SizeClassAllocator64 PrimaryAllocator; @@ -106,17 +97,12 @@ static const uptr kNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kRegionSizeLog; typedef TwoLevelByteMap<(kNumRegions >> 12), 1 << 12> ByteMap; -struct AP32 { +struct AP32 : public DefaultMsanAllocatorParams { static const uptr kSpaceBeg = 0; static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE; - static const uptr kMetadataSize = sizeof(Metadata); typedef __sanitizer::CompactSizeClassMap SizeClassMap; static const uptr kRegionSizeLog = __msan::kRegionSizeLog; - using AddressSpaceView = LocalAddressSpaceView; using ByteMap = __msan::ByteMap; - typedef MsanMapUnmapCallback MapUnmapCallback; - using PtrArray = DefaultLargeMmapAllocatorPtrArray; - static const uptr kFlags = 0; }; typedef SizeClassAllocator32 PrimaryAllocator; #endif diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h --- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h @@ -13,6 +13,11 @@ #error This file must be included inside sanitizer_allocator.h #endif +struct DefaultAllocatorParams { + using PtrArray = DefaultLargeMmapAllocatorPtrArray; + static const uptr kFlags = 0; +}; + // This class implements a complete memory allocator by using two // internal allocators: // PrimaryAllocator is efficient, but may not allocate some sizes (alignments).