[compiler-rt] [scudo] Support no-preserve-all-regions mode (PR #85149)

via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 27 14:43:25 PDT 2024


================
@@ -601,6 +593,35 @@ template <typename Config> class SizeClassAllocator64 {
     return BlockSize > PageSize;
   }
 
+  void initRegion(RegionInfo *Region, uptr ClassId, MemMapT MemMap,
+                  bool EnableRandomOffset) REQUIRES(Region->MMLock) {
+    DCHECK(!Region->MemMapInfo.MemMap.isAllocated());
+    DCHECK(MemMap.isAllocated());
+
+    const uptr PageSize = getPageSizeCached();
+    const uptr RegionBase = MemMap.getBase();
+
+    Region->MemMapInfo.MemMap = MemMap;
+
+    u32 Seed;
----------------
ChiaHungDuan wrote:

I was thinking of that but I preferred to make both cases (preserve region or not) be consistent, I left it as it is. Just think it over again, I think you're right, it's still better not to increase the calls to those functions even each region will only be initialized once. 

In the new approach, the seed is calculated for both modes in init() and stored in the RandState

https://github.com/llvm/llvm-project/pull/85149


More information about the llvm-commits mailing list