]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - heap/GCThread.cpp
JavaScriptCore-7600.1.4.16.1.tar.gz
[apple/javascriptcore.git] / heap / GCThread.cpp
index aa868f1b348814d80e7d41239fb3a142ae366aee..cf496a1b67f5e3134cb923004e2ef458cc4a99be 100644 (file)
@@ -29,6 +29,7 @@
 #include "CopyVisitor.h"
 #include "CopyVisitorInlines.h"
 #include "GCThreadSharedData.h"
 #include "CopyVisitor.h"
 #include "CopyVisitorInlines.h"
 #include "GCThreadSharedData.h"
+#include "JSCInlines.h"
 #include "SlotVisitor.h"
 #include <wtf/MainThread.h>
 #include <wtf/PassOwnPtr.h>
 #include "SlotVisitor.h"
 #include <wtf/MainThread.h>
 #include <wtf/PassOwnPtr.h>
@@ -69,16 +70,14 @@ CopyVisitor* GCThread::copyVisitor()
 
 GCPhase GCThread::waitForNextPhase()
 {
 
 GCPhase GCThread::waitForNextPhase()
 {
-    MutexLocker locker(m_shared.m_phaseLock);
-    while (m_shared.m_gcThreadsShouldWait)
-        m_shared.m_phaseCondition.wait(m_shared.m_phaseLock);
+    std::unique_lock<std::mutex> lock(m_shared.m_phaseMutex);
+    m_shared.m_phaseConditionVariable.wait(lock, [this] { return !m_shared.m_gcThreadsShouldWait; });
 
     m_shared.m_numberOfActiveGCThreads--;
     if (!m_shared.m_numberOfActiveGCThreads)
 
     m_shared.m_numberOfActiveGCThreads--;
     if (!m_shared.m_numberOfActiveGCThreads)
-        m_shared.m_activityCondition.signal();
+        m_shared.m_activityConditionVariable.notify_one();
 
 
-    while (m_shared.m_currentPhase == NoPhase)
-        m_shared.m_phaseCondition.wait(m_shared.m_phaseLock);
+    m_shared.m_phaseConditionVariable.wait(lock, [this] { return m_shared.m_currentPhase != NoPhase; });
     m_shared.m_numberOfActiveGCThreads++;
     return m_shared.m_currentPhase;
 }
     m_shared.m_numberOfActiveGCThreads++;
     return m_shared.m_currentPhase;
 }
@@ -92,7 +91,7 @@ void GCThread::gcThreadMain()
     // Wait for the main thread to finish creating and initializing us. The main thread grabs this lock before 
     // creating this thread. We aren't guaranteed to have a valid threadID until the main thread releases this lock.
     {
     // Wait for the main thread to finish creating and initializing us. The main thread grabs this lock before 
     // creating this thread. We aren't guaranteed to have a valid threadID until the main thread releases this lock.
     {
-        MutexLocker locker(m_shared.m_phaseLock);
+        std::lock_guard<std::mutex> lock(m_shared.m_phaseMutex);
     }
     {
         ParallelModeEnabler enabler(*m_slotVisitor);
     }
     {
         ParallelModeEnabler enabler(*m_slotVisitor);