Index: Source/platform/heap/ThreadState.cpp |
diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp |
index d3bc5cf73f62b1ae1a609758caa3d729b47f007e..2b0af09f013acf641b65558cb03cb778397ae506 100644 |
--- a/Source/platform/heap/ThreadState.cpp |
+++ b/Source/platform/heap/ThreadState.cpp |
@@ -1114,6 +1114,7 @@ void ThreadState::performPendingSweep() |
// Perform thread-specific weak processing. |
while (popAndInvokeWeakPointerCallback(Heap::s_markingVisitor)) { } |
} |
+ invokePreFinalizer(*Heap::s_markingVisitor); |
leaveNoAllocationScope(); |
// Perform sweeping and finalization. |
@@ -1247,6 +1248,25 @@ ThreadState::AttachedThreadStateSet& ThreadState::attachedThreads() |
return threads; |
} |
+void ThreadState::unregisterObjectWithPreFinalizerInternal(void* target) |
+{ |
+ if (isSweepInProgress()) |
+ return; |
+ auto it = m_objectsWithPreFinalizer.find(target); |
+ ASSERT(it != m_objectsWithPreFinalizer.end()); |
+ m_objectsWithPreFinalizer.remove(it); |
+} |
+ |
+void ThreadState::invokePreFinalizer(Visitor& visitor) |
+{ |
+ Vector<void*> deadObjects; |
+ for (auto& entry : m_objectsWithPreFinalizer) { |
+ if (entry.value(entry.key, visitor)) |
+ deadObjects.append(entry.key); |
+ } |
+ m_objectsWithPreFinalizer.removeAll(deadObjects); |
+} |
+ |
#if ENABLE(GC_PROFILE_MARKING) |
const GCInfo* ThreadState::findGCInfoFromAllThreads(Address address) |
{ |