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

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

Issue 1477023003: Refactor the Heap into ThreadHeap to prepare for per thread heaps Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactored Created 4 years, 11 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 abd7a1264515f10cbda31c100d1ff52405b54007..6c6923fc2a8c84b4c7a3590f18effa2483ea8dfa 100644
--- a/third_party/WebKit/Source/platform/heap/PersistentNode.cpp
+++ b/third_party/WebKit/Source/platform/heap/PersistentNode.cpp
@@ -49,7 +49,7 @@ void PersistentRegion::ensurePersistentNodeSlots(void* self, TraceCallback trace
// a PersistentNodeSlot that contains only freed PersistentNodes,
// we delete the PersistentNodeSlot. This function rebuilds the free
// list of PersistentNodes.
-void PersistentRegion::tracePersistentNodes(Visitor* visitor)
+void PersistentRegion::tracePersistentNodes(Visitor* visitor, bool (*shouldTrace)(Visitor*, PersistentNode*))
{
m_freeListHead = nullptr;
int persistentCount = 0;
@@ -68,6 +68,8 @@ void PersistentRegion::tracePersistentNodes(Visitor* visitor)
freeListNext = node;
++freeCount;
} else {
+ if (shouldTrace && !shouldTrace(visitor, node))
+ return;
haraken 2016/01/28 15:52:50 Shouldn't this be 'continue'?
keishi 2016/02/29 06:02:33 Done.
node->tracePersistentNode(visitor);
++persistentCount;
}
@@ -98,6 +100,17 @@ public:
};
}
+bool CrossThreadPersistentRegion::shouldTracePersistentNode(Visitor* visitor, PersistentNode* node)
+{
haraken 2016/01/28 15:52:50 Add ASSERT(!node->isUnused()).
keishi 2016/02/29 06:02:33 Done.
+ CrossThreadPersistent<GCObject>* persistent = reinterpret_cast<CrossThreadPersistent<GCObject>*>(node->self());
+ ASSERT(persistent);
+ Address rawObject = reinterpret_cast<Address>(persistent->get());
+ // TODO: Why do we need to return true?
haraken 2016/01/28 15:52:50 I wonder why as well :) This should return false.
keishi 2016/02/29 06:02:33 Thanks, looks like it was.
+ if (!rawObject)
+ return true;
+ return visitor->gcData()->threadState()->gcGroup()->threads().contains(ThreadState::forObject(rawObject));
haraken 2016/01/28 15:52:50 forObject => fromAddress (for consistency with Hea
keishi 2016/02/29 06:02:33 Done.
+}
+
void CrossThreadPersistentRegion::prepareForThreadStateTermination(ThreadState* threadState)
{
// For heaps belonging to a thread that's detaching, any cross-thread persistents

Powered by Google App Engine
This is Rietveld 408576698