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

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: Created 4 years, 10 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 fcb060ca55e80643beaec9ba133fc81e5b72332e..896c0658130f276299b0b4d6623ea6d600d34e0c 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, ShouldTraceCallback shouldTrace)
{
m_freeListHead = nullptr;
int persistentCount = 0;
@@ -68,6 +68,8 @@ void PersistentRegion::tracePersistentNodes(Visitor* visitor)
freeListNext = node;
++freeCount;
} else {
+ if (shouldTrace && !shouldTrace(visitor, node))
haraken 2016/02/29 11:17:45 Nit: Or you can implement PersistentRegion::should
keishi 2016/03/02 06:01:03 Done.
+ continue;
node->tracePersistentNode(visitor);
++persistentCount;
}
@@ -88,7 +90,6 @@ void PersistentRegion::tracePersistentNodes(Visitor* visitor)
slots = slots->m_next;
}
}
- ASSERT(persistentCount == m_persistentCount);
haraken 2016/02/29 11:17:45 Can we keep this assert by incrementing persistent
keishi 2016/03/02 06:01:03 Done.
}
namespace {
@@ -98,6 +99,16 @@ public:
};
}
+bool CrossThreadPersistentRegion::shouldTracePersistentNode(Visitor* visitor, PersistentNode* node)
+{
+ CrossThreadPersistent<GCObject>* persistent = reinterpret_cast<CrossThreadPersistent<GCObject>*>(node->self());
+ ASSERT(persistent);
+ Address rawObject = reinterpret_cast<Address>(persistent->get());
+ if (!rawObject)
+ return false;
+ return visitor->visitorScope()->heap().threads().contains(ThreadState::fromObject(rawObject));
+}
+
void CrossThreadPersistentRegion::prepareForThreadStateTermination(ThreadState* threadState)
{
// For heaps belonging to a thread that's detaching, any cross-thread persistents
@@ -126,7 +137,7 @@ void CrossThreadPersistentRegion::prepareForThreadStateTermination(ThreadState*
// but not invalidate its CrossThreadPersistent<>s.
if (page->orphaned())
continue;
- if (page->heap()->threadState() == threadState)
+ if (page->arena()->threadState() == threadState)
persistent->clear();
}
slots = slots->m_next;

Powered by Google App Engine
This is Rietveld 408576698