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 233fbc348b44764092038b2208cfbaa4e7b64927..563f0fd7844b861ff5180cb20983623f600bd929 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 |
@@ -97,16 +121,9 @@ void PersistentRegion::tracePersistentNodes(Visitor* visitor, ShouldTraceCallbac |
ASSERT(persistentCount == m_persistentCount); |
} |
-namespace { |
-class GCObject final : public GarbageCollected<GCObject> { |
-public: |
- DEFINE_INLINE_TRACE() { } |
-}; |
-} |
- |
bool CrossThreadPersistentRegion::shouldTracePersistentNode(Visitor* visitor, PersistentNode* node) |
{ |
- CrossThreadPersistent<GCObject>* persistent = reinterpret_cast<CrossThreadPersistent<GCObject>*>(node->self()); |
+ CrossThreadPersistent<DummyGCBase>* persistent = reinterpret_cast<CrossThreadPersistent<DummyGCBase>*>(node->self()); |
ASSERT(persistent); |
Address rawObject = reinterpret_cast<Address>(persistent->get()); |
if (!rawObject) |
@@ -131,7 +148,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) |