Changeset 226885 in webkit


Ignore:
Timestamp:
Jan 12, 2018 4:16:12 AM (6 years ago)
Author:
Yusuke Suzuki
Message:

[JSC] Create parallel SlotVisitors apriori
https://bugs.webkit.org/show_bug.cgi?id=180907

Reviewed by Saam Barati.

The number of SlotVisitors are capped with the number of HeapHelperPool's threads + 2.
If we create these SlotVisitors apropri, we do not need to create SlotVisitors dynamically.
Then we do not need to grab locks while iterating all the SlotVisitors.

In addition, we do not need to consider the case that the number of SlotVisitors increases
after setting up VisitCounters in MarkingConstraintSolver since the number of SlotVisitors
does not increase any more.

  • heap/Heap.cpp:

(JSC::Heap::Heap):
(JSC::Heap::runBeginPhase):

  • heap/Heap.h:
  • heap/HeapInlines.h:

(JSC::Heap::forEachSlotVisitor):
(JSC::Heap::numberOfSlotVisitors): Deleted.

  • heap/MarkingConstraintSolver.cpp:

(JSC::MarkingConstraintSolver::didVisitSomething const):

Location:
trunk/Source/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r226881 r226885  
     12018-01-12  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [JSC] Create parallel SlotVisitors apriori
     4        https://bugs.webkit.org/show_bug.cgi?id=180907
     5
     6        Reviewed by Saam Barati.
     7
     8        The number of SlotVisitors are capped with the number of HeapHelperPool's threads + 2.
     9        If we create these SlotVisitors apropri, we do not need to create SlotVisitors dynamically.
     10        Then we do not need to grab locks while iterating all the SlotVisitors.
     11
     12        In addition, we do not need to consider the case that the number of SlotVisitors increases
     13        after setting up VisitCounters in MarkingConstraintSolver since the number of SlotVisitors
     14        does not increase any more.
     15
     16        * heap/Heap.cpp:
     17        (JSC::Heap::Heap):
     18        (JSC::Heap::runBeginPhase):
     19        * heap/Heap.h:
     20        * heap/HeapInlines.h:
     21        (JSC::Heap::forEachSlotVisitor):
     22        (JSC::Heap::numberOfSlotVisitors): Deleted.
     23        * heap/MarkingConstraintSolver.cpp:
     24        (JSC::MarkingConstraintSolver::didVisitSomething const):
     25
    1262018-01-12  Saam Barati  <sbarati@apple.com>
    227
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r226822 r226885  
    315315{
    316316    m_worldState.store(0);
     317
     318    for (unsigned i = 0, numberOfParallelThreads = heapHelperPool().numberOfThreads(); i < numberOfParallelThreads; ++i) {
     319        std::unique_ptr<SlotVisitor> visitor = std::make_unique<SlotVisitor>(*this, toCString("P", i + 1));
     320        if (Options::optimizeParallelSlotVisitorsForStoppedMutator())
     321            visitor->optimizeForStoppedMutator();
     322        m_availableParallelSlotVisitors.append(visitor.get());
     323        m_parallelSlotVisitors.append(WTFMove(visitor));
     324    }
    317325   
    318326    if (Options::useConcurrentGC()) {
     
    12401248            {
    12411249                LockHolder locker(m_parallelSlotVisitorLock);
    1242                 if (m_availableParallelSlotVisitors.isEmpty()) {
    1243                     std::unique_ptr<SlotVisitor> newVisitor = std::make_unique<SlotVisitor>(
    1244                         *this, toCString("P", m_parallelSlotVisitors.size() + 1));
    1245                    
    1246                     if (Options::optimizeParallelSlotVisitorsForStoppedMutator())
    1247                         newVisitor->optimizeForStoppedMutator();
    1248                    
    1249                     newVisitor->didStartMarking();
    1250                    
    1251                     slotVisitor = newVisitor.get();
    1252                     m_parallelSlotVisitors.append(WTFMove(newVisitor));
    1253                 } else
    1254                     slotVisitor = m_availableParallelSlotVisitors.takeLast();
     1250                RELEASE_ASSERT_WITH_MESSAGE(!m_availableParallelSlotVisitors.isEmpty(), "Parallel SlotVisitors are allocated apriori");
     1251                slotVisitor = m_availableParallelSlotVisitors.takeLast();
    12551252            }
    12561253
  • trunk/Source/JavaScriptCore/heap/Heap.h

    r226822 r226885  
    373373    template<typename Func>
    374374    void forEachSlotVisitor(const Func&);
    375     unsigned numberOfSlotVisitors();
    376375
    377376private:
  • trunk/Source/JavaScriptCore/heap/HeapInlines.h

    r226783 r226885  
    263263void Heap::forEachSlotVisitor(const Func& func)
    264264{
    265     auto locker = holdLock(m_parallelSlotVisitorLock);
    266265    func(*m_collectorSlotVisitor);
    267266    func(*m_mutatorSlotVisitor);
     
    270269}
    271270
    272 inline unsigned Heap::numberOfSlotVisitors()
    273 {
    274     auto locker = holdLock(m_parallelSlotVisitorLock);
    275     return m_parallelSlotVisitors.size() + 2; // m_collectorSlotVisitor and m_mutatorSlotVisitor
    276 }
    277 
    278271} // namespace JSC
  • trunk/Source/JavaScriptCore/heap/MarkingConstraintSolver.cpp

    r226783 r226885  
    5252            return true;
    5353    }
    54     // If the number of SlotVisitors increases after creating m_visitCounters,
    55     // we conservatively say there could be something visited by added SlotVisitors.
    56     if (m_heap.numberOfSlotVisitors() > m_visitCounters.size())
    57         return true;
    5854    return false;
    5955}
  • trunk/Source/JavaScriptCore/heap/SlotVisitor.h

    r226783 r226885  
    237237    MarkingConstraintSolver* m_currentSolver { nullptr };
    238238   
     239    // Put padding here to mitigate false sharing between multiple SlotVisitors.
     240    char padding[64];
    239241public:
    240242#if !ASSERT_DISABLED
Note: See TracChangeset for help on using the changeset viewer.