Ignore:
Timestamp:
Jan 20, 2014, 9:10:36 AM (12 years ago)
Author:
[email protected]
Message:

Convert GCThreadSharedData over to STL threading primitives
https://bugs.webkit.org/show_bug.cgi?id=127256

Reviewed by Andreas Kling.

  • heap/GCThread.cpp:

(JSC::GCThread::waitForNextPhase):
(JSC::GCThread::gcThreadMain):

  • heap/GCThreadSharedData.cpp:

(JSC::GCThreadSharedData::GCThreadSharedData):
(JSC::GCThreadSharedData::~GCThreadSharedData):
(JSC::GCThreadSharedData::startNextPhase):
(JSC::GCThreadSharedData::endCurrentPhase):
(JSC::GCThreadSharedData::didStartMarking):
(JSC::GCThreadSharedData::didFinishMarking):

  • heap/GCThreadSharedData.h:
  • heap/SlotVisitor.cpp:

(JSC::SlotVisitor::donateKnownParallel):
(JSC::SlotVisitor::drainFromShared):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/heap/GCThreadSharedData.cpp

    r162017 r162352  
    8484#if ENABLE(PARALLEL_GC)
    8585    // Grab the lock so the new GC threads can be properly initialized before they start running.
    86     MutexLocker locker(m_phaseLock);
     86    std::unique_lock<std::mutex> lock(m_phaseMutex);
    8787    for (unsigned i = 1; i < Options::numberOfGCMarkers(); ++i) {
    8888        m_numberOfActiveGCThreads++;
     
    9696
    9797    // Wait for all the GCThreads to get to the right place.
    98     while (m_numberOfActiveGCThreads)
    99         m_activityCondition.wait(m_phaseLock);
     98    m_activityConditionVariable.wait(lock, [this] { return !m_numberOfActiveGCThreads; });
    10099#endif
    101100}
     
    106105    // Destroy our marking threads.
    107106    {
    108         MutexLocker markingLocker(m_markingLock);
    109         MutexLocker phaseLocker(m_phaseLock);
     107        std::lock_guard<std::mutex> markingLock(m_markingMutex);
     108        std::lock_guard<std::mutex> phaseLock(m_phaseMutex);
    110109        ASSERT(m_currentPhase == NoPhase);
    111110        m_parallelMarkersShouldExit = true;
    112111        m_gcThreadsShouldWait = false;
    113112        m_currentPhase = Exit;
    114         m_phaseCondition.broadcast();
     113        m_phaseConditionVariable.notify_all();
    115114    }
    116115    for (unsigned i = 0; i < m_gcThreads.size(); ++i) {
     
    140139void GCThreadSharedData::startNextPhase(GCPhase phase)
    141140{
    142     MutexLocker phaseLocker(m_phaseLock);
     141    std::lock_guard<std::mutex> lock(m_phaseMutex);
    143142    ASSERT(!m_gcThreadsShouldWait);
    144143    ASSERT(m_currentPhase == NoPhase);
    145144    m_gcThreadsShouldWait = true;
    146145    m_currentPhase = phase;
    147     m_phaseCondition.broadcast();
     146    m_phaseConditionVariable.notify_all();
    148147}
    149148
     
    151150{
    152151    ASSERT(m_gcThreadsShouldWait);
    153     MutexLocker locker(m_phaseLock);
     152    std::unique_lock<std::mutex> lock(m_phaseMutex);
    154153    m_currentPhase = NoPhase;
    155154    m_gcThreadsShouldWait = false;
    156     m_phaseCondition.broadcast();
    157     while (m_numberOfActiveGCThreads)
    158         m_activityCondition.wait(m_phaseLock);
     155    m_phaseConditionVariable.notify_all();
     156    m_activityConditionVariable.wait(lock, [this] { return !m_numberOfActiveGCThreads; });
    159157}
    160158
    161159void GCThreadSharedData::didStartMarking()
    162160{
    163     MutexLocker markingLocker(m_markingLock);
     161    std::lock_guard<std::mutex> lock(m_markingMutex);
    164162    m_parallelMarkersShouldExit = false;
    165163    startNextPhase(Mark);
     
    169167{
    170168    {
    171         MutexLocker markingLocker(m_markingLock);
     169        std::lock_guard<std::mutex> lock(m_markingMutex);
    172170        m_parallelMarkersShouldExit = true;
    173         m_markingCondition.broadcast();
     171        m_markingConditionVariable.notify_all();
    174172    }
    175173
Note: See TracChangeset for help on using the changeset viewer.