mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Conformance cache] Add allocated extended-storage for entries to the free list
This memory is part of the conformance cache concurrent hash map, so when we clear the conformance cache, record each of the allocated pointers within the concurrent map's free list. This way, it'll be freed with the rest of the concurrent map when it's safe to do so.
This commit is contained in:
@@ -750,7 +750,12 @@ public:
|
||||
|
||||
/// Clear the hash table, freeing (when safe) all memory currently used for
|
||||
/// indices and elements.
|
||||
void clear() {
|
||||
///
|
||||
/// - addFreedNodes: if nonempty, this function will be called with the head
|
||||
/// of the free list. The function may add additional nodes to the free
|
||||
/// list, which will be freed when it is safe to do so.
|
||||
void clear(std::function<void(ConcurrentFreeListNode *&)> addFreedNodes
|
||||
= nullptr) {
|
||||
typename MutexTy::ScopedLock guard(WriterLock);
|
||||
|
||||
IndexStorage indices = Indices.load(std::memory_order_relaxed);
|
||||
@@ -766,6 +771,9 @@ public:
|
||||
ConcurrentFreeListNode::add(&FreeList, ptr);
|
||||
ConcurrentFreeListNode::add(&FreeList, elements);
|
||||
|
||||
if (addFreedNodes)
|
||||
addFreedNodes(FreeList);
|
||||
|
||||
deallocateFreeListIfSafe();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user