diff --git a/compiler-rt/lib/scudo/standalone/combined.h b/compiler-rt/lib/scudo/standalone/combined.h --- a/compiler-rt/lib/scudo/standalone/combined.h +++ b/compiler-rt/lib/scudo/standalone/combined.h @@ -930,7 +930,7 @@ } private: - using SecondaryT = MapAllocator; + using SecondaryT = MapAllocator; typedef typename PrimaryT::SizeClassMap SizeClassMap; static const uptr MinAlignmentLog = SCUDO_MIN_ALIGNMENT_LOG; diff --git a/compiler-rt/lib/scudo/standalone/secondary.h b/compiler-rt/lib/scudo/standalone/secondary.h --- a/compiler-rt/lib/scudo/standalone/secondary.h +++ b/compiler-rt/lib/scudo/standalone/secondary.h @@ -245,7 +245,7 @@ atomic_s32 ReleaseToOsIntervalMs; }; -template class MapAllocator { +template class MapAllocator { public: void initLinkerInitialized(GlobalStats *S, s32 ReleaseToOsInterval = -1) { Cache.initLinkerInitialized(ReleaseToOsInterval); @@ -295,7 +295,7 @@ void releaseToOS() { Cache.releaseToOS(); } private: - CacheT Cache; + typename Config::SecondaryCache Cache; HybridMutex Mutex; DoublyLinkedList InUseBlocks; @@ -318,8 +318,8 @@ // For allocations requested with an alignment greater than or equal to a page, // the committed memory will amount to something close to Size - AlignmentHint // (pending rounding and headers). -template -void *MapAllocator::allocate(uptr Size, uptr AlignmentHint, +template +void *MapAllocator::allocate(uptr Size, uptr AlignmentHint, uptr *BlockEnd, FillContentsMode FillContents) { DCHECK_GE(Size, AlignmentHint); @@ -410,7 +410,7 @@ return reinterpret_cast(Ptr + LargeBlock::getHeaderSize()); } -template void MapAllocator::deallocate(void *Ptr) { +template void MapAllocator::deallocate(void *Ptr) { LargeBlock::Header *H = LargeBlock::getHeader(Ptr); const uptr Block = reinterpret_cast(H); const uptr CommitSize = H->BlockEnd - Block; @@ -430,8 +430,8 @@ unmap(Addr, Size, UNMAP_ALL, &Data); } -template -void MapAllocator::getStats(ScopedString *Str) const { +template +void MapAllocator::getStats(ScopedString *Str) const { Str->append( "Stats: MapAllocator: allocated %zu times (%zuK), freed %zu times " "(%zuK), remains %zu (%zuK) max %zuM\n", diff --git a/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp b/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp --- a/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp +++ b/compiler-rt/lib/scudo/standalone/tests/secondary_test.cpp @@ -19,7 +19,9 @@ #include #include -template static void testSecondaryBasic(void) { +template static void testSecondaryBasic(void) { + using SecondaryT = scudo::MapAllocator; + scudo::GlobalStats S; S.init(); std::unique_ptr L(new SecondaryT); @@ -55,7 +57,12 @@ Str.output(); } +struct NoCacheConfig { + typedef scudo::MapAllocatorNoCache SecondaryCache; +}; + struct TestConfig { + typedef scudo::MapAllocatorCache SecondaryCache; static const scudo::u32 SecondaryCacheEntriesArraySize = 128U; static const scudo::u32 SecondaryCacheDefaultMaxEntriesCount = 64U; static const scudo::uptr SecondaryCacheDefaultMaxEntrySize = 1UL << 20; @@ -64,15 +71,12 @@ }; TEST(ScudoSecondaryTest, SecondaryBasic) { - testSecondaryBasic>(); - testSecondaryBasic< - scudo::MapAllocator>>(); - testSecondaryBasic< - scudo::MapAllocator>>(); + testSecondaryBasic(); + testSecondaryBasic(); + testSecondaryBasic(); } -using LargeAllocator = - scudo::MapAllocator>; +using LargeAllocator = scudo::MapAllocator; // This exercises a variety of combinations of size and alignment for the // MapAllocator. The size computation done here mimic the ones done by the