From 0e93c4a5fd5825a16fd3c00f9f7942ec88412771 Mon Sep 17 00:00:00 2001 From: Fabio D'Urso Date: Fri, 30 Jun 2023 16:35:09 +0200 Subject: [PATCH] [scudo] SizeClassAllocator64: dispatch all the classes in init() This will make it easier to verify in a future patch that the ReservedMemory object has been fully dispatched. Reviewed By: Chia-hungDuan Differential Revision: https://reviews.llvm.org/D153019 --- compiler-rt/lib/scudo/standalone/primary64.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/compiler-rt/lib/scudo/standalone/primary64.h b/compiler-rt/lib/scudo/standalone/primary64.h index ab75f19..e6cd120 100644 --- a/compiler-rt/lib/scudo/standalone/primary64.h +++ b/compiler-rt/lib/scudo/standalone/primary64.h @@ -132,6 +132,10 @@ public: else Region->TryReleaseThreshold = PageSize; Region->ReleaseInfo.LastReleaseAtNs = Time; + + Region->MemMapInfo.MemMap = ReservedMemory.dispatch( + PrimaryBase + (I << Config::Primary::RegionSizeLog), RegionSize); + CHECK(Region->MemMapInfo.MemMap.isAllocated()); } shuffle(RegionInfoArray, NumClasses, &Seed); @@ -822,12 +826,6 @@ private: Region->Exhausted = true; return nullptr; } - // TODO: Consider allocating MemMap in init(). - if (!Region->MemMapInfo.MemMap.isAllocated()) { - Region->MemMapInfo.MemMap = ReservedMemory.dispatch( - getRegionBaseByClassId(ClassId), RegionSize); - } - DCHECK(Region->MemMapInfo.MemMap.isAllocated()); if (UNLIKELY(!Region->MemMapInfo.MemMap.remap( RegionBeg + MappedUser, MapSize, "scudo:primary", -- 2.7.4