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

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

Issue 2013173002: Lock CrossThreadPersistentRegion until end of weak processing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile fix Created 4 years, 7 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 2478a1d7abef5baa2833b6fe8f128a6f07dd5735..a6858409b70d38cba8cdd08c59b42752506a579b 100644
--- a/third_party/WebKit/Source/platform/heap/PersistentNode.h
+++ b/third_party/WebKit/Source/platform/heap/PersistentNode.h
@@ -197,9 +197,28 @@ public:
releaseStore(reinterpret_cast<void* volatile*>(&persistentNode), nullptr);
}
+ 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.
+#if ENABLE(ASSERT)
+ DCHECK(m_mutex.locked());
+#endif
m_persistentRegion->tracePersistentNodes(visitor, CrossThreadPersistentRegion::shouldTracePersistentNode);
}
@@ -208,6 +227,18 @@ public:
static bool shouldTracePersistentNode(Visitor*, PersistentNode*);
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