[llvm] [ORC] Add opt-in per-JITDylib colocating slab allocator (PR #207970)

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 29 05:41:46 PDT 2026


================
@@ -136,6 +193,13 @@ void MapperJITLinkMemoryManager::allocate(const JITLinkDylib *JD, LinkGraph &G,
   }
 
   if (SelectedRange.empty()) { // no already reserved range was found
+    // A reservation is needed. If this pool already owns one, reserving another
+    // ("second slab") may place its objects out of range, so consult the
+    // growth policy first.
+    if (!ReservedKeys.insert(PoolKey).second) {
+      if (auto Err = OnSecondSlab())
+        return CompleteAllocation(std::move(Err));
+    }
     auto TotalAllocation = alignTo(TotalSize, ReservationUnits);
     Mapper->reserve(TotalAllocation, std::move(CompleteAllocation));
----------------
lhames wrote:

I think the mutex locked on line 180 above is guarding, but I haven't read closely -- worth a double check.

Side note: We should try to refactor all of this to make the locking clearer, but that's another patch.

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


More information about the llvm-commits mailing list