Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Unified Diff: third_party/WebKit/Source/platform/heap/PersistentNode.cpp

Issue 1919663002: Unify and generalize thread static persistent finalization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)
« no previous file with comments | « third_party/WebKit/Source/platform/heap/PersistentNode.h ('k') | third_party/WebKit/Source/platform/heap/ThreadState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698