Changeset 190217 in webkit


Ignore:
Timestamp:
Sep 24, 2015 1:13:07 PM (9 years ago)
Author:
fpizlo@apple.com
Message:

Remove special case code for the no-parallel-GC case
https://bugs.webkit.org/show_bug.cgi?id=149512

Reviewed by Mark Lam.

Make serial GC just a parallel GC where the helper threads don't do anything. Also make the
idle thread calculation a bit more explicit.

The main outcome is that we no longer use Options::numberOfGCMarkers() as much, so the code is
resilient against the number of GC markers changing.

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

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

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r190215 r190217  
     12015-09-23  Filip Pizlo  <fpizlo@apple.com>
     2
     3        Remove special case code for the no-parallel-GC case
     4        https://bugs.webkit.org/show_bug.cgi?id=149512
     5
     6        Reviewed by Mark Lam.
     7
     8        Make serial GC just a parallel GC where the helper threads don't do anything. Also make the
     9        idle thread calculation a bit more explicit.
     10
     11        The main outcome is that we no longer use Options::numberOfGCMarkers() as much, so the code is
     12        resilient against the number of GC markers changing.
     13
     14        * heap/Heap.h:
     15        * heap/SlotVisitor.cpp:
     16        (JSC::SlotVisitor::donateKnownParallel):
     17        (JSC::SlotVisitor::drain):
     18        (JSC::SlotVisitor::drainFromShared):
     19
    1202015-09-23  Filip Pizlo  <fpizlo@apple.com>
    221
  • trunk/Source/JavaScriptCore/heap/Heap.h

    r190179 r190217  
    429429    MarkStackArray m_sharedMarkStack;
    430430    unsigned m_numberOfActiveParallelMarkers { 0 };
     431    unsigned m_numberOfWaitingParallelMarkers { 0 };
    431432    bool m_parallelMarkersShouldExit { false };
    432433
  • trunk/Source/JavaScriptCore/heap/SlotVisitor.cpp

    r190151 r190217  
    148148    m_stack.donateSomeCellsTo(m_heap.m_sharedMarkStack);
    149149
    150     if (m_heap.m_numberOfActiveParallelMarkers < Options::numberOfGCMarkers())
    151         m_heap.m_markingConditionVariable.notifyAll();
     150    m_heap.m_markingConditionVariable.notifyAll();
    152151}
    153152
     
    157156    ASSERT(m_isInParallelMode);
    158157   
    159     if (Options::numberOfGCMarkers() > 1) {
    160         while (!m_stack.isEmpty()) {
    161             m_stack.refill();
    162             for (unsigned countdown = Options::minimumNumberOfScansBetweenRebalance(); m_stack.canRemoveLast() && countdown--;)
    163                 visitChildren(*this, m_stack.removeLast());
    164             donateKnownParallel();
    165         }
    166        
    167         mergeOpaqueRootsIfNecessary();
    168         return;
    169     }
    170    
    171158    while (!m_stack.isEmpty()) {
    172159        m_stack.refill();
    173         while (m_stack.canRemoveLast())
     160        for (unsigned countdown = Options::minimumNumberOfScansBetweenRebalance(); m_stack.canRemoveLast() && countdown--;)
    174161            visitChildren(*this, m_stack.removeLast());
    175     }
     162        donateKnownParallel();
     163    }
     164   
     165    mergeOpaqueRootsIfNecessary();
    176166}
    177167
     
    183173    ASSERT(Options::numberOfGCMarkers());
    184174   
    185     bool shouldBeParallel;
    186 
    187     shouldBeParallel = Options::numberOfGCMarkers() > 1;
    188    
    189     if (!shouldBeParallel) {
    190         // This call should be a no-op.
    191         ASSERT_UNUSED(sharedDrainMode, sharedDrainMode == MasterDrain);
    192         ASSERT(m_stack.isEmpty());
    193         ASSERT(m_heap.m_sharedMarkStack.isEmpty());
    194         return;
    195     }
    196    
    197175    {
    198176        std::lock_guard<Lock> lock(m_heap.m_markingMutex);
     
    203181            std::unique_lock<Lock> lock(m_heap.m_markingMutex);
    204182            m_heap.m_numberOfActiveParallelMarkers--;
     183            m_heap.m_numberOfWaitingParallelMarkers++;
    205184
    206185            // How we wait differs depending on drain mode.
     
    210189                while (true) {
    211190                    // Did we reach termination?
    212                     if (!m_heap.m_numberOfActiveParallelMarkers && m_heap.m_sharedMarkStack.isEmpty()) {
     191                    if (!m_heap.m_numberOfActiveParallelMarkers
     192                        && m_heap.m_sharedMarkStack.isEmpty()) {
    213193                        // Let any sleeping slaves know it's time for them to return;
    214194                        m_heap.m_markingConditionVariable.notifyAll();
     
    227207               
    228208                // Did we detect termination? If so, let the master know.
    229                 if (!m_heap.m_numberOfActiveParallelMarkers && m_heap.m_sharedMarkStack.isEmpty())
     209                if (!m_heap.m_numberOfActiveParallelMarkers
     210                    && m_heap.m_sharedMarkStack.isEmpty())
    230211                    m_heap.m_markingConditionVariable.notifyAll();
    231212
    232                 m_heap.m_markingConditionVariable.wait(lock, [this] { return !m_heap.m_sharedMarkStack.isEmpty() || m_heap.m_parallelMarkersShouldExit; });
     213                m_heap.m_markingConditionVariable.wait(
     214                    lock,
     215                    [this] {
     216                        return !m_heap.m_sharedMarkStack.isEmpty()
     217                            || m_heap.m_parallelMarkersShouldExit;
     218                    });
    233219               
    234220                // Is the current phase done? If so, return from this function.
     
    237223            }
    238224           
    239             size_t idleThreadCount = Options::numberOfGCMarkers() - m_heap.m_numberOfActiveParallelMarkers;
    240             m_stack.stealSomeCellsFrom(m_heap.m_sharedMarkStack, idleThreadCount);
     225            m_stack.stealSomeCellsFrom(
     226                m_heap.m_sharedMarkStack, m_heap.m_numberOfWaitingParallelMarkers);
    241227            m_heap.m_numberOfActiveParallelMarkers++;
     228            m_heap.m_numberOfWaitingParallelMarkers--;
    242229        }
    243230       
Note: See TracChangeset for help on using the changeset viewer.