Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_size_class_map.h =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_size_class_map.h +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_size_class_map.h @@ -232,3 +232,8 @@ typedef SizeClassMap<3, 4, 8, 17, 128, 16> DefaultSizeClassMap; typedef SizeClassMap<3, 4, 8, 17, 64, 14> CompactSizeClassMap; typedef SizeClassMap<2, 5, 9, 16, 64, 14> VeryCompactSizeClassMap; + +// The following SizeClassMap only holds a way small number of cached entries, +// allowing for denser per-class arrays, smaller memory footprint and usually +// better performances in threaded environments. +typedef SizeClassMap<3, 4, 8, 17, 8, 10> DenseSizeClassMap; Index: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc +++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc @@ -89,11 +89,20 @@ static const uptr kFlags = 0; }; +struct AP64Dense { + static const uptr kSpaceBeg = kAllocatorSpace; + static const uptr kSpaceSize = kAllocatorSize; + static const uptr kMetadataSize = 16; + typedef DenseSizeClassMap SizeClassMap; + typedef NoOpMapUnmapCallback MapUnmapCallback; + static const uptr kFlags = 0; +}; typedef SizeClassAllocator64 Allocator64; typedef SizeClassAllocator64 Allocator64Dynamic; typedef SizeClassAllocator64 Allocator64Compact; typedef SizeClassAllocator64 Allocator64VeryCompact; +typedef SizeClassAllocator64 Allocator64Dense; #elif defined(__mips64) static const u64 kAddressSpaceSize = 1ULL << 40; #elif defined(__aarch64__) @@ -144,6 +153,10 @@ TestSizeClassMap(); } +TEST(SanitizerCommon, DenseSizeClassMap) { + TestSizeClassMap(); +} + template void TestSizeClassAllocator() { Allocator *a = new Allocator; @@ -234,6 +247,10 @@ TEST(SanitizerCommon, SizeClassAllocator64VeryCompact) { TestSizeClassAllocator(); } + +TEST(SanitizerCommon, SizeClassAllocator64Dense) { + TestSizeClassAllocator(); +} #endif #endif