| Index: Source/heap/ThreadState.cpp
|
| diff --git a/Source/heap/ThreadState.cpp b/Source/heap/ThreadState.cpp
|
| index 853e412593526c2389c9893399f105be4b3d2fac..4bd7a10b5e29644b1ba2894aee1a793d2309d9a0 100644
|
| --- a/Source/heap/ThreadState.cpp
|
| +++ b/Source/heap/ThreadState.cpp
|
| @@ -327,6 +327,14 @@ void ThreadState::detach()
|
|
|
| void ThreadState::visitRoots(Visitor* visitor)
|
| {
|
| + {
|
| + // All threads are at safepoints so this is not strictly necessary.
|
| + // However we acquire the mutex to make mutation and traversal of this
|
| + // list symmetrical.
|
| + MutexLocker locker(globalRootsMutex());
|
| + globalRoots()->trace(visitor);
|
| + }
|
| +
|
| AttachedThreadStateSet& threads = attachedThreads();
|
| for (AttachedThreadStateSet::iterator it = threads.begin(), end = threads.end(); it != end; ++it)
|
| (*it)->trace(visitor);
|
| @@ -358,9 +366,7 @@ void ThreadState::visitStack(Visitor* visitor)
|
|
|
| void ThreadState::visitPersistents(Visitor* visitor)
|
| {
|
| - for (PersistentNode* current = m_persistents->m_next; current != m_persistents; current = current->m_next) {
|
| - current->trace(visitor);
|
| - }
|
| + m_persistents->trace(visitor);
|
| }
|
|
|
| void ThreadState::trace(Visitor* visitor)
|
| @@ -387,6 +393,18 @@ bool ThreadState::checkAndMarkPointer(Visitor* visitor, Address address)
|
| return false;
|
| }
|
|
|
| +PersistentNode* ThreadState::globalRoots()
|
| +{
|
| + AtomicallyInitializedStatic(PersistentNode*, anchor = new PersistentAnchor);
|
| + return anchor;
|
| +}
|
| +
|
| +Mutex& ThreadState::globalRootsMutex()
|
| +{
|
| + AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
|
| + return mutex;
|
| +}
|
| +
|
| // Trigger garbage collection on a 50% increase in size, but not for
|
| // less than 2 pages.
|
| static bool increasedEnoughToGC(size_t newSize, size_t oldSize)
|
|
|