Index: lib/asan/asan_allocator.h =================================================================== --- lib/asan/asan_allocator.h +++ lib/asan/asan_allocator.h @@ -147,7 +147,6 @@ const uptr kAllocatorSize = 0x40000000000ULL; // 4T. typedef DefaultSizeClassMap SizeClassMap; # endif -template struct AP64 { // Allocator64 parameters. Deliberately using a short name. static const uptr kSpaceBeg = kAllocatorSpace; static const uptr kSpaceSize = kAllocatorSize; @@ -155,11 +154,10 @@ typedef __asan::SizeClassMap SizeClassMap; typedef AsanMapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; - using AddressSpaceView = AddressSpaceViewTy; }; template -using PrimaryAllocatorASVT = SizeClassAllocator64>; +using PrimaryAllocatorASVT = SizeClassAllocator64; using PrimaryAllocator = PrimaryAllocatorASVT; #else // Fallback to SizeClassAllocator32. static const uptr kRegionSizeLog = 20; @@ -173,20 +171,19 @@ TwoLevelByteMap<(kNumRegions >> 12), 1 << 12, AddressSpaceView>; # endif typedef CompactSizeClassMap SizeClassMap; -template struct AP32 { static const uptr kSpaceBeg = 0; static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE; static const uptr kMetadataSize = 16; typedef __asan::SizeClassMap SizeClassMap; static const uptr kRegionSizeLog = __asan::kRegionSizeLog; - using AddressSpaceView = AddressSpaceViewTy; - using ByteMap = __asan::ByteMapASVT; + template + using ByteMapASVT = __asan::ByteMapASVT; typedef AsanMapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; }; template -using PrimaryAllocatorASVT = SizeClassAllocator32 >; +using PrimaryAllocatorASVT = SizeClassAllocator32; using PrimaryAllocator = PrimaryAllocatorASVT; #endif // SANITIZER_CAN_USE_ALLOCATOR64 Index: lib/lsan/lsan_allocator.h =================================================================== --- lib/lsan/lsan_allocator.h +++ lib/lsan/lsan_allocator.h @@ -57,20 +57,19 @@ using ByteMapASVT = TwoLevelByteMap<(kNumRegions >> 12), 1 << 12, AddressSpaceView>; -template struct AP32 { static const uptr kSpaceBeg = 0; static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE; static const uptr kMetadataSize = sizeof(ChunkMetadata); typedef __sanitizer::CompactSizeClassMap SizeClassMap; static const uptr kRegionSizeLog = __lsan::kRegionSizeLog; - using AddressSpaceView = AddressSpaceViewTy; - using ByteMap = __lsan::ByteMapASVT; + template + using ByteMapASVT = __lsan::ByteMapASVT; typedef NoOpMapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; }; template -using PrimaryAllocatorASVT = SizeClassAllocator32>; +using PrimaryAllocatorASVT = SizeClassAllocator32; using PrimaryAllocator = PrimaryAllocatorASVT; #elif defined(__x86_64__) || defined(__powerpc64__) # if defined(__powerpc64__) @@ -80,7 +79,6 @@ const uptr kAllocatorSpace = 0x600000000000ULL; const uptr kAllocatorSize = 0x40000000000ULL; // 4T. # endif -template struct AP64 { // Allocator64 parameters. Deliberately using a short name. static const uptr kSpaceBeg = kAllocatorSpace; static const uptr kSpaceSize = kAllocatorSize; @@ -88,11 +86,10 @@ typedef DefaultSizeClassMap SizeClassMap; typedef NoOpMapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; - using AddressSpaceView = AddressSpaceViewTy; }; template -using PrimaryAllocatorASVT = SizeClassAllocator64>; +using PrimaryAllocatorASVT = SizeClassAllocator64; using PrimaryAllocator = PrimaryAllocatorASVT; #endif Index: lib/msan/msan_allocator.cc =================================================================== --- lib/msan/msan_allocator.cc +++ lib/msan/msan_allocator.cc @@ -48,7 +48,9 @@ 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; + template + using ByteMapASVT = + TwoLevelByteMap<(kNumRegions >> 12), 1 << 12, AddressSpaceView>; struct AP32 { static const uptr kSpaceBeg = 0; @@ -56,8 +58,8 @@ static const uptr kMetadataSize = sizeof(Metadata); typedef __sanitizer::CompactSizeClassMap SizeClassMap; static const uptr kRegionSizeLog = __msan::kRegionSizeLog; - using AddressSpaceView = LocalAddressSpaceView; - using ByteMap = __msan::ByteMap; + template + using ByteMapASVT = __msan::ByteMapASVT; typedef MsanMapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; }; @@ -78,7 +80,6 @@ typedef DefaultSizeClassMap SizeClassMap; typedef MsanMapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; - using AddressSpaceView = LocalAddressSpaceView; }; typedef SizeClassAllocator64 PrimaryAllocator; @@ -93,7 +94,6 @@ typedef DefaultSizeClassMap SizeClassMap; typedef MsanMapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; - using AddressSpaceView = LocalAddressSpaceView; }; typedef SizeClassAllocator64 PrimaryAllocator; @@ -101,7 +101,9 @@ static const uptr kMaxAllowedMallocSize = 2UL << 30; // 2G static const uptr kRegionSizeLog = 20; static const uptr kNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kRegionSizeLog; - typedef TwoLevelByteMap<(kNumRegions >> 12), 1 << 12> ByteMap; + template + using ByteMapASVT = + TwoLevelByteMap<(kNumRegions >> 12), 1 << 12, AddressSpaceView>; struct AP32 { static const uptr kSpaceBeg = 0; @@ -109,8 +111,8 @@ static const uptr kMetadataSize = sizeof(Metadata); typedef __sanitizer::CompactSizeClassMap SizeClassMap; static const uptr kRegionSizeLog = __msan::kRegionSizeLog; - using AddressSpaceView = LocalAddressSpaceView; - using ByteMap = __msan::ByteMap; + template + using ByteMapASVT = __msan::ByteMapASVT; typedef MsanMapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; }; Index: lib/sanitizer_common/sanitizer_allocator_internal.h =================================================================== --- lib/sanitizer_common/sanitizer_allocator_internal.h +++ lib/sanitizer_common/sanitizer_allocator_internal.h @@ -26,9 +26,12 @@ static const uptr kInternalAllocatorNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kInternalAllocatorRegionSizeLog; #if SANITIZER_WORDSIZE == 32 -typedef FlatByteMap ByteMap; +template +using ByteMapASVT = FlatByteMap; #else -typedef TwoLevelByteMap<(kInternalAllocatorNumRegions >> 12), 1 << 12> ByteMap; +template +using ByteMapASVT = TwoLevelByteMap<(kInternalAllocatorNumRegions >> 12), + 1 << 12, AddressSpaceView>; #endif struct AP32 { static const uptr kSpaceBeg = 0; @@ -36,12 +39,12 @@ static const uptr kMetadataSize = 0; typedef InternalSizeClassMap SizeClassMap; static const uptr kRegionSizeLog = kInternalAllocatorRegionSizeLog; - using AddressSpaceView = LocalAddressSpaceView; - using ByteMap = __sanitizer::ByteMap; + template + using ByteMapASVT = __sanitizer::ByteMapASVT; typedef NoOpMapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; }; -typedef SizeClassAllocator32 PrimaryInternalAllocator; +using PrimaryInternalAllocator = SizeClassAllocator32; typedef SizeClassAllocatorLocalCache InternalAllocatorCache; Index: lib/sanitizer_common/sanitizer_allocator_primary32.h =================================================================== --- lib/sanitizer_common/sanitizer_allocator_primary32.h +++ lib/sanitizer_common/sanitizer_allocator_primary32.h @@ -44,16 +44,16 @@ }; }; -template +template class SizeClassAllocator32 { public: - using AddressSpaceView = typename Params::AddressSpaceView; + using AddressSpaceView = AddressSpaceViewTy; static const uptr kSpaceBeg = Params::kSpaceBeg; static const u64 kSpaceSize = Params::kSpaceSize; static const uptr kMetadataSize = Params::kMetadataSize; typedef typename Params::SizeClassMap SizeClassMap; static const uptr kRegionSizeLog = Params::kRegionSizeLog; - typedef typename Params::ByteMap ByteMap; + using ByteMap = typename Params::template ByteMapASVT; typedef typename Params::MapUnmapCallback MapUnmapCallback; static_assert( Index: lib/sanitizer_common/sanitizer_allocator_primary64.h =================================================================== --- lib/sanitizer_common/sanitizer_allocator_primary64.h +++ lib/sanitizer_common/sanitizer_allocator_primary64.h @@ -42,10 +42,10 @@ }; }; -template +template class SizeClassAllocator64 { public: - using AddressSpaceView = typename Params::AddressSpaceView; + using AddressSpaceView = AddressSpaceViewTy; static const uptr kSpaceBeg = Params::kSpaceBeg; static const uptr kSpaceSize = Params::kSpaceSize; static const uptr kMetadataSize = Params::kMetadataSize; Index: lib/sanitizer_common/tests/sanitizer_allocator_test.cc =================================================================== --- lib/sanitizer_common/tests/sanitizer_allocator_test.cc +++ lib/sanitizer_common/tests/sanitizer_allocator_test.cc @@ -52,7 +52,6 @@ typedef DefaultSizeClassMap SizeClassMap; #endif -template struct AP64 { // Allocator Params. Short name for shorter demangled names.. static const uptr kSpaceBeg = kAllocatorSpace; static const uptr kSpaceSize = kAllocatorSize; @@ -60,10 +59,8 @@ typedef ::SizeClassMap SizeClassMap; typedef NoOpMapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; - using AddressSpaceView = AddressSpaceViewTy; }; -template struct AP64Dyn { static const uptr kSpaceBeg = ~(uptr)0; static const uptr kSpaceSize = kAllocatorSize; @@ -71,10 +68,8 @@ typedef ::SizeClassMap SizeClassMap; typedef NoOpMapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; - using AddressSpaceView = AddressSpaceViewTy; }; -template struct AP64Compact { static const uptr kSpaceBeg = ~(uptr)0; static const uptr kSpaceSize = kAllocatorSize; @@ -82,10 +77,8 @@ typedef CompactSizeClassMap SizeClassMap; typedef NoOpMapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; - using AddressSpaceView = AddressSpaceViewTy; }; -template struct AP64VeryCompact { static const uptr kSpaceBeg = ~(uptr)0; static const uptr kSpaceSize = 1ULL << 37; @@ -93,10 +86,8 @@ typedef VeryCompactSizeClassMap SizeClassMap; typedef NoOpMapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; - using AddressSpaceView = AddressSpaceViewTy; }; -template struct AP64Dense { static const uptr kSpaceBeg = kAllocatorSpace; static const uptr kSpaceSize = kAllocatorSize; @@ -104,30 +95,29 @@ typedef DenseSizeClassMap SizeClassMap; typedef NoOpMapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; - using AddressSpaceView = AddressSpaceViewTy; }; template -using Allocator64ASVT = SizeClassAllocator64>; +using Allocator64ASVT = SizeClassAllocator64; using Allocator64 = Allocator64ASVT; template -using Allocator64DynamicASVT = SizeClassAllocator64>; +using Allocator64DynamicASVT = SizeClassAllocator64; using Allocator64Dynamic = Allocator64DynamicASVT; template using Allocator64CompactASVT = - SizeClassAllocator64>; + SizeClassAllocator64; using Allocator64Compact = Allocator64CompactASVT; template using Allocator64VeryCompactASVT = - SizeClassAllocator64>; + SizeClassAllocator64; using Allocator64VeryCompact = Allocator64VeryCompactASVT; template -using Allocator64DenseASVT = SizeClassAllocator64>; +using Allocator64DenseASVT = SizeClassAllocator64; using Allocator64Dense = Allocator64DenseASVT; #elif defined(__mips64) @@ -145,21 +135,20 @@ static const uptr kRegionSizeLog = FIRST_32_SECOND_64(20, 24); static const uptr kFlatByteMapSize = kAddressSpaceSize >> kRegionSizeLog; -template struct AP32Compact { static const uptr kSpaceBeg = 0; static const u64 kSpaceSize = kAddressSpaceSize; static const uptr kMetadataSize = 16; typedef CompactSizeClassMap SizeClassMap; static const uptr kRegionSizeLog = ::kRegionSizeLog; - using AddressSpaceView = AddressSpaceViewTy; - using ByteMap = FlatByteMap; + template + using ByteMapASVT = FlatByteMap; typedef NoOpMapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; }; template using Allocator32CompactASVT = - SizeClassAllocator32>; + SizeClassAllocator32; using Allocator32Compact = Allocator32CompactASVT; template @@ -291,22 +280,21 @@ TestSizeClassAllocator(); } -template struct AP32SeparateBatches { static const uptr kSpaceBeg = 0; static const u64 kSpaceSize = kAddressSpaceSize; static const uptr kMetadataSize = 16; typedef DefaultSizeClassMap SizeClassMap; static const uptr kRegionSizeLog = ::kRegionSizeLog; - using AddressSpaceView = AddressSpaceViewTy; - using ByteMap = FlatByteMap; + template + using ByteMapASVT = FlatByteMap; typedef NoOpMapUnmapCallback MapUnmapCallback; static const uptr kFlags = SizeClassAllocator32FlagMasks::kUseSeparateSizeClassForBatch; }; template using Allocator32SeparateBatchesASVT = - SizeClassAllocator32>; + SizeClassAllocator32; using Allocator32SeparateBatches = Allocator32SeparateBatchesASVT; @@ -466,15 +454,14 @@ #endif #endif -template struct AP32WithCallback { static const uptr kSpaceBeg = 0; static const u64 kSpaceSize = kAddressSpaceSize; static const uptr kMetadataSize = 16; typedef CompactSizeClassMap SizeClassMap; static const uptr kRegionSizeLog = ::kRegionSizeLog; - using AddressSpaceView = AddressSpaceViewTy; - using ByteMap = FlatByteMap; + template + using ByteMapASVT = FlatByteMap; typedef TestMapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; }; @@ -482,7 +469,7 @@ TEST(SanitizerCommon, SizeClassAllocator32MapUnmapCallback) { TestMapUnmapCallback::map_count = 0; TestMapUnmapCallback::unmap_count = 0; - typedef SizeClassAllocator32> Allocator32WithCallBack; + typedef SizeClassAllocator32 Allocator32WithCallBack; Allocator32WithCallBack *a = new Allocator32WithCallBack; a->Init(kReleaseToOSIntervalNever); EXPECT_EQ(TestMapUnmapCallback::map_count, 0); Index: lib/scudo/scudo_allocator.h =================================================================== --- lib/scudo/scudo_allocator.h +++ lib/scudo/scudo_allocator.h @@ -80,15 +80,17 @@ typedef NoOpMapUnmapCallback MapUnmapCallback; static const uptr kFlags = SizeClassAllocator64FlagMasks::kRandomShuffleChunks; - using AddressSpaceView = LocalAddressSpaceView; }; typedef SizeClassAllocator64 PrimaryT; #else static const uptr NumRegions = SANITIZER_MMAP_RANGE_SIZE >> RegionSizeLog; # if SANITIZER_WORDSIZE == 32 -typedef FlatByteMap ByteMap; +template +using ByteMapASVT = FlatByteMap; # elif SANITIZER_WORDSIZE == 64 -typedef TwoLevelByteMap<(NumRegions >> 12), 1 << 12> ByteMap; +template +using ByteMapASVT = + TwoLevelByteMap<(NumRegions >> 12), 1 << 12, AddressSpaceView>; # endif // SANITIZER_WORDSIZE struct AP32 { static const uptr kSpaceBeg = 0; @@ -96,8 +98,8 @@ static const uptr kMetadataSize = 0; typedef __scudo::SizeClassMap SizeClassMap; static const uptr kRegionSizeLog = RegionSizeLog; - using AddressSpaceView = LocalAddressSpaceView; - using ByteMap = __scudo::ByteMap; + template + using ByteMapASVT = __scudo::ByteMapASVT; typedef NoOpMapUnmapCallback MapUnmapCallback; static const uptr kFlags = SizeClassAllocator32FlagMasks::kRandomShuffleChunks | Index: lib/tsan/rtl/tsan_rtl.h =================================================================== --- lib/tsan/rtl/tsan_rtl.h +++ lib/tsan/rtl/tsan_rtl.h @@ -58,16 +58,17 @@ static const uptr kAllocatorRegionSizeLog = 20; static const uptr kAllocatorNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kAllocatorRegionSizeLog; -using ByteMap = TwoLevelByteMap<(kAllocatorNumRegions >> 12), 1 << 12, - LocalAddressSpaceView, MapUnmapCallback>; +template +using ByteMapASVT = TwoLevelByteMap<(kAllocatorNumRegions >> 12), 1 << 12, + AddressSpaceView, MapUnmapCallback>; struct AP32 { static const uptr kSpaceBeg = 0; static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE; static const uptr kMetadataSize = 0; typedef __sanitizer::CompactSizeClassMap SizeClassMap; static const uptr kRegionSizeLog = kAllocatorRegionSizeLog; - using AddressSpaceView = LocalAddressSpaceView; - using ByteMap = __tsan::ByteMap; + template + using ByteMapASVT = __tsan::ByteMapASVT; typedef __tsan::MapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; }; @@ -80,7 +81,6 @@ typedef DefaultSizeClassMap SizeClassMap; typedef __tsan::MapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; - using AddressSpaceView = LocalAddressSpaceView; }; typedef SizeClassAllocator64 PrimaryAllocator; #endif