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

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

Issue 2065343002: Lock CrossThreadPersistentRegion until end of weak processing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 6 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
« no previous file with comments | « third_party/WebKit/Source/platform/heap/Heap.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/heap/PersistentNode.h
diff --git a/third_party/WebKit/Source/platform/heap/PersistentNode.h b/third_party/WebKit/Source/platform/heap/PersistentNode.h
index ebaf0604edc31cd3090c6accc3988d1193c62ec1..41d9c1941fba17863f62749ac8d229597a70373a 100644
--- a/third_party/WebKit/Source/platform/heap/PersistentNode.h
+++ b/third_party/WebKit/Source/platform/heap/PersistentNode.h
@@ -180,15 +180,44 @@ public:
m_persistentRegion->freePersistentNode(persistentNode);
}
+ class LockScope final {
+ STACK_ALLOCATED();
+ public:
+ LockScope(CrossThreadPersistentRegion& persistentRegion)
+ : m_persistentRegion(persistentRegion)
+ {
+ m_persistentRegion.lock();
+ }
+ ~LockScope()
+ {
+ m_persistentRegion.unlock();
+ }
+ private:
+ CrossThreadPersistentRegion& m_persistentRegion;
+ };
+
void tracePersistentNodes(Visitor* visitor)
{
- MutexLocker lock(m_mutex);
+ // If this assert triggers, you're tracing without being in a LockScope.
+ ASSERT(m_mutex.locked());
m_persistentRegion->tracePersistentNodes(visitor);
}
void prepareForThreadStateTermination(ThreadState*);
private:
+ friend class LockScope;
+
+ void lock()
+ {
+ m_mutex.lock();
+ }
+
+ void unlock()
+ {
+ m_mutex.unlock();
+ }
+
// We don't make CrossThreadPersistentRegion inherit from PersistentRegion
// because we don't want to virtualize performance-sensitive methods
// such as PersistentRegion::allocate/freePersistentNode.
« no previous file with comments | « third_party/WebKit/Source/platform/heap/Heap.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698