Index: third_party/WebKit/Source/platform/heap/PersistentNode.cpp |
diff --git a/third_party/WebKit/Source/platform/heap/PersistentNode.cpp b/third_party/WebKit/Source/platform/heap/PersistentNode.cpp |
index 329a0370df7d9394b8dc5fbec439def948f2ae43..f04607740e9eb5bf7774660a44243ba930e47d59 100644 |
--- a/third_party/WebKit/Source/platform/heap/PersistentNode.cpp |
+++ b/third_party/WebKit/Source/platform/heap/PersistentNode.cpp |
@@ -8,6 +8,15 @@ |
namespace blink { |
+namespace { |
+ |
+class DummyGCBase final : public GarbageCollected<DummyGCBase> { |
+public: |
+ DEFINE_INLINE_TRACE() { } |
+}; |
+ |
+} |
+ |
PersistentRegion::~PersistentRegion() |
{ |
PersistentNodeSlots* slots = m_slots; |
@@ -45,6 +54,21 @@ void PersistentRegion::ensurePersistentNodeSlots(void* self, TraceCallback trace |
m_slots = slots; |
} |
+void PersistentRegion::releasePersistentNode(PersistentNode* persistentNode, ThreadState::PersistentClearCallback callback) |
+{ |
+ ASSERT(!persistentNode->isUnused()); |
+ // 'self' is in use, containing the persistent wrapper object. |
+ void* self = persistentNode->self(); |
+ if (callback) { |
+ (*callback)(self); |
+ ASSERT(persistentNode->isUnused()); |
+ return; |
+ } |
+ Persistent<DummyGCBase>* persistent = reinterpret_cast<Persistent<DummyGCBase>*>(self); |
+ persistent->clear(); |
+ ASSERT(persistentNode->isUnused()); |
+} |
+ |
// This function traces all PersistentNodes. If we encounter |
// a PersistentNodeSlot that contains only freed PersistentNodes, |
// we delete the PersistentNodeSlot. This function rebuilds the free |
@@ -95,13 +119,6 @@ void PersistentRegion::tracePersistentNodes(Visitor* visitor) |
ASSERT(persistentCount == m_persistentCount); |
} |
-namespace { |
-class GCObject final : public GarbageCollected<GCObject> { |
-public: |
- DEFINE_INLINE_TRACE() { } |
-}; |
-} |
- |
void CrossThreadPersistentRegion::prepareForThreadStateTermination(ThreadState* threadState) |
{ |
// For heaps belonging to a thread that's detaching, any cross-thread persistents |
@@ -119,7 +136,7 @@ void CrossThreadPersistentRegion::prepareForThreadStateTermination(ThreadState* |
continue; |
// 'self' is in use, containing the cross-thread persistent wrapper object. |
- CrossThreadPersistent<GCObject>* persistent = reinterpret_cast<CrossThreadPersistent<GCObject>*>(slots->m_slot[i].self()); |
+ CrossThreadPersistent<DummyGCBase>* persistent = reinterpret_cast<CrossThreadPersistent<DummyGCBase>*>(slots->m_slot[i].self()); |
ASSERT(persistent); |
void* rawObject = persistent->atomicGet(); |
if (!rawObject) |