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

Unified Diff: Source/platform/heap/ThreadState.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
« Source/platform/heap/ThreadState.h ('K') | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/ThreadState.cpp
diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp
index 87d0c40e847b614df6ebce10370292c8826cf9dc..3761aea84af0a8873aeb7c48d5c2525ed57d9275 100644
--- a/Source/platform/heap/ThreadState.cpp
+++ b/Source/platform/heap/ThreadState.cpp
@@ -96,7 +96,7 @@ uint8_t ThreadState::s_mainThreadStateStorage[sizeof(ThreadState)];
SafePointBarrier* ThreadState::s_safePointBarrier = 0;
bool ThreadState::s_inGC = false;
-static Mutex& threadAttachMutex()
+Mutex& ThreadState::threadAttachMutex()
{
AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
return mutex;
@@ -123,7 +123,7 @@ public:
ASSERT(ThreadState::current()->isAtSafePoint());
// Lock threadAttachMutex() to prevent threads from attaching.
- threadAttachMutex().lock();
+ ThreadState::threadAttachMutex().lock();
ThreadState::AttachedThreadStateSet& threads = ThreadState::attachedThreads();
@@ -182,7 +182,7 @@ public:
interruptors[i]->clearInterrupt();
}
- threadAttachMutex().unlock();
+ ThreadState::threadAttachMutex().unlock();
ASSERT(ThreadState::current()->isAtSafePoint());
}
@@ -315,7 +315,7 @@ void ThreadState::shutdown()
void ThreadState::attachMainThread()
{
RELEASE_ASSERT(!Heap::s_shutdownCalled);
- MutexLocker locker(threadAttachMutex());
+ MutexLocker locker(ThreadState::threadAttachMutex());
ThreadState* state = new(s_mainThreadStateStorage) ThreadState();
attachedThreads().add(state);
}
@@ -331,7 +331,7 @@ void ThreadState::detachMainThread()
state->enterSafePointWithoutPointers();
{
- MutexLocker locker(threadAttachMutex());
+ MutexLocker locker(ThreadState::threadAttachMutex());
state->leaveSafePoint();
ASSERT(attachedThreads().contains(state));
attachedThreads().remove(state);
@@ -345,7 +345,7 @@ void ThreadState::shutdownHeapIfNecessary()
// We don't need to enter a safe point before acquiring threadAttachMutex
// because this thread is already detached.
- MutexLocker locker(threadAttachMutex());
+ MutexLocker locker(ThreadState::threadAttachMutex());
// We start shutting down the heap if there is no running thread
// and Heap::shutdown() is already called.
if (!attachedThreads().size() && Heap::s_shutdownCalled)
@@ -355,7 +355,7 @@ void ThreadState::shutdownHeapIfNecessary()
void ThreadState::attach()
{
RELEASE_ASSERT(!Heap::s_shutdownCalled);
- MutexLocker locker(threadAttachMutex());
+ MutexLocker locker(ThreadState::threadAttachMutex());
ThreadState* state = new ThreadState();
attachedThreads().add(state);
}
@@ -397,7 +397,7 @@ void ThreadState::detach()
state->enterSafePointWithoutPointers();
{
- MutexLocker locker(threadAttachMutex());
+ MutexLocker locker(ThreadState::threadAttachMutex());
state->leaveSafePoint();
ASSERT(attachedThreads().contains(state));
attachedThreads().remove(state);
@@ -860,7 +860,7 @@ void ThreadState::addInterruptor(Interruptor* interruptor)
SafePointScope scope(HeapPointersOnStack, SafePointScope::AllowNesting);
{
- MutexLocker locker(threadAttachMutex());
+ MutexLocker locker(ThreadState::threadAttachMutex());
m_interruptors.append(interruptor);
}
}
@@ -870,7 +870,7 @@ void ThreadState::removeInterruptor(Interruptor* interruptor)
SafePointScope scope(HeapPointersOnStack, SafePointScope::AllowNesting);
{
- MutexLocker locker(threadAttachMutex());
+ MutexLocker locker(ThreadState::threadAttachMutex());
size_t index = m_interruptors.find(interruptor);
RELEASE_ASSERT(index >= 0);
m_interruptors.remove(index);
« Source/platform/heap/ThreadState.h ('K') | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698