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

Unified Diff: Source/platform/heap/Heap.cpp

Issue 311263008: Make |Heap::findGCInfo()| threadsafe. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: change check to isAnyThreadInGC Created 6 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 | « no previous file | Source/platform/heap/ThreadState.h » ('j') | Source/platform/heap/ThreadState.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/Heap.cpp
diff --git a/Source/platform/heap/Heap.cpp b/Source/platform/heap/Heap.cpp
index f055df916d27a153d4ccc00a1fa90cbafe0dbb5b..17c6ddab553b3e43b5e8fa6fabad5b0c708ee837 100644
--- a/Source/platform/heap/Heap.cpp
+++ b/Source/platform/heap/Heap.cpp
@@ -1600,12 +1600,20 @@ Address Heap::checkAndMarkPointer(Visitor* visitor, Address address)
#if ENABLE(GC_TRACING)
const GCInfo* Heap::findGCInfo(Address address)
{
+ bool needLockForIteration = !ThreadState::isAnyThreadInGC();
+ if (needLockForIteration)
+ ThreadState::threadAttachMutex().lock();
+
ThreadState::AttachedThreadStateSet& threads = ThreadState::attachedThreads();
for (ThreadState::AttachedThreadStateSet::iterator it = threads.begin(), end = threads.end(); it != end; ++it) {
if (const GCInfo* gcInfo = (*it)->findGCInfo(address)) {
+ if (needLockForIteration)
+ ThreadState::threadAttachMutex().unlock();
Mads Ager (chromium) 2014/06/06 06:54:01 Do we have a scoped lock object that we could use
kouhei (in TOK) 2014/06/06 06:58:26 I tried to use MutexLocker, but it requires lock a
Mads Ager (chromium) 2014/06/06 07:03:30 Nah, don't bother for this change. This code is ne
return gcInfo;
}
}
+ if (needLockForIteration)
+ ThreadState::threadAttachMutex().unlock();
return 0;
}
« no previous file with comments | « no previous file | Source/platform/heap/ThreadState.h » ('j') | Source/platform/heap/ThreadState.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698