Title: [242459] releases/WebKitGTK/webkit-2.24/Source/_javascript_Core
Revision
242459
Author
carlo...@webkit.org
Date
2019-03-05 04:42:04 -0800 (Tue, 05 Mar 2019)

Log Message

Merge r242070 - [JSC] Revert r226885 to make SlotVisitor creation lazy
https://bugs.webkit.org/show_bug.cgi?id=195013

Reviewed by Saam Barati.

We once changed SlotVisitor creation apriori to drop the lock. Also, it turns out that SlotVisitor is memory-consuming.
We should defer SlotVisitor creation until it is actually required. This patch reverts r226885. Even with this patch,
we still hold many SlotVisitors after we execute many parallel markers at least once. But recovering the feature of
dynamically allocating SlotVisitors helps further memory optimizations in this area.

* heap/Heap.cpp:
(JSC::Heap::Heap):
(JSC::Heap::runBeginPhase):
* heap/Heap.h:
* heap/HeapInlines.h:
(JSC::Heap::forEachSlotVisitor):
(JSC::Heap::numberOfSlotVisitors):
* heap/MarkingConstraintSolver.cpp:
(JSC::MarkingConstraintSolver::didVisitSomething const):
* heap/SlotVisitor.h:

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/ChangeLog (242458 => 242459)


--- releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/ChangeLog	2019-03-05 12:42:00 UTC (rev 242458)
+++ releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/ChangeLog	2019-03-05 12:42:04 UTC (rev 242459)
@@ -1,5 +1,28 @@
 2019-02-25  Yusuke Suzuki  <ysuz...@apple.com>
 
+        [JSC] Revert r226885 to make SlotVisitor creation lazy
+        https://bugs.webkit.org/show_bug.cgi?id=195013
+
+        Reviewed by Saam Barati.
+
+        We once changed SlotVisitor creation apriori to drop the lock. Also, it turns out that SlotVisitor is memory-consuming.
+        We should defer SlotVisitor creation until it is actually required. This patch reverts r226885. Even with this patch,
+        we still hold many SlotVisitors after we execute many parallel markers at least once. But recovering the feature of
+        dynamically allocating SlotVisitors helps further memory optimizations in this area.
+
+        * heap/Heap.cpp:
+        (JSC::Heap::Heap):
+        (JSC::Heap::runBeginPhase):
+        * heap/Heap.h:
+        * heap/HeapInlines.h:
+        (JSC::Heap::forEachSlotVisitor):
+        (JSC::Heap::numberOfSlotVisitors):
+        * heap/MarkingConstraintSolver.cpp:
+        (JSC::MarkingConstraintSolver::didVisitSomething const):
+        * heap/SlotVisitor.h:
+
+2019-02-25  Yusuke Suzuki  <ysuz...@apple.com>
+
         [JSC] stress/function-constructor-reading-from-global-lexical-environment.js fails in 32bit arch
         https://bugs.webkit.org/show_bug.cgi?id=195030
         <rdar://problem/48385088>

Modified: releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/heap/Heap.cpp (242458 => 242459)


--- releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/heap/Heap.cpp	2019-03-05 12:42:00 UTC (rev 242458)
+++ releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/heap/Heap.cpp	2019-03-05 12:42:04 UTC (rev 242459)
@@ -300,14 +300,6 @@
     , m_threadCondition(AutomaticThreadCondition::create())
 {
     m_worldState.store(0);
-
-    for (unsigned i = 0, numberOfParallelThreads = heapHelperPool().numberOfThreads(); i < numberOfParallelThreads; ++i) {
-        std::unique_ptr<SlotVisitor> visitor = std::make_unique<SlotVisitor>(*this, toCString("P", i + 1));
-        if (Options::optimizeParallelSlotVisitorsForStoppedMutator())
-            visitor->optimizeForStoppedMutator();
-        m_availableParallelSlotVisitors.append(visitor.get());
-        m_parallelSlotVisitors.append(WTFMove(visitor));
-    }
     
     if (Options::useConcurrentGC()) {
         if (Options::useStochasticMutatorScheduler())
@@ -1261,8 +1253,19 @@
             SlotVisitor* slotVisitor;
             {
                 LockHolder locker(m_parallelSlotVisitorLock);
-                RELEASE_ASSERT_WITH_MESSAGE(!m_availableParallelSlotVisitors.isEmpty(), "Parallel SlotVisitors are allocated apriori");
-                slotVisitor = m_availableParallelSlotVisitors.takeLast();
+                if (m_availableParallelSlotVisitors.isEmpty()) {
+                    std::unique_ptr<SlotVisitor> newVisitor = std::make_unique<SlotVisitor>(
+                        *this, toCString("P", m_parallelSlotVisitors.size() + 1));
+                    
+                    if (Options::optimizeParallelSlotVisitorsForStoppedMutator())
+                        newVisitor->optimizeForStoppedMutator();
+                    
+                    newVisitor->didStartMarking();
+                    
+                    slotVisitor = newVisitor.get();
+                    m_parallelSlotVisitors.append(WTFMove(newVisitor));
+                } else
+                    slotVisitor = m_availableParallelSlotVisitors.takeLast();
             }
 
             WTF::registerGCThread(GCThreadType::Helper);

Modified: releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/heap/Heap.h (242458 => 242459)


--- releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/heap/Heap.h	2019-03-05 12:42:00 UTC (rev 242458)
+++ releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/heap/Heap.h	2019-03-05 12:42:04 UTC (rev 242459)
@@ -393,6 +393,7 @@
 
     template<typename Func>
     void forEachSlotVisitor(const Func&);
+    unsigned numberOfSlotVisitors();
     
     Seconds totalGCTime() const { return m_totalGCTime; }
 

Modified: releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/heap/HeapInlines.h (242458 => 242459)


--- releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/heap/HeapInlines.h	2019-03-05 12:42:00 UTC (rev 242458)
+++ releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/heap/HeapInlines.h	2019-03-05 12:42:04 UTC (rev 242459)
@@ -275,6 +275,7 @@
 template<typename Func>
 void Heap::forEachSlotVisitor(const Func& func)
 {
+    auto locker = holdLock(m_parallelSlotVisitorLock);
     func(*m_collectorSlotVisitor);
     func(*m_mutatorSlotVisitor);
     for (auto& slotVisitor : m_parallelSlotVisitors)
@@ -281,4 +282,10 @@
         func(*slotVisitor);
 }
 
+inline unsigned Heap::numberOfSlotVisitors()
+{
+    auto locker = holdLock(m_parallelSlotVisitorLock);
+    return m_parallelSlotVisitors.size() + 2; // m_collectorSlotVisitor and m_mutatorSlotVisitor
+}
+
 } // namespace JSC

Modified: releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/heap/MarkingConstraintSolver.cpp (242458 => 242459)


--- releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/heap/MarkingConstraintSolver.cpp	2019-03-05 12:42:00 UTC (rev 242458)
+++ releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/heap/MarkingConstraintSolver.cpp	2019-03-05 12:42:04 UTC (rev 242459)
@@ -51,6 +51,10 @@
         if (visitCounter.visitCount())
             return true;
     }
+    // If the number of SlotVisitors increases after creating m_visitCounters,
+    // we conservatively say there could be something visited by added SlotVisitors.
+    if (m_heap.numberOfSlotVisitors() > m_visitCounters.size())
+        return true;
     return false;
 }
 

Modified: releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/heap/SlotVisitor.h (242458 => 242459)


--- releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/heap/SlotVisitor.h	2019-03-05 12:42:00 UTC (rev 242458)
+++ releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/heap/SlotVisitor.h	2019-03-05 12:42:04 UTC (rev 242459)
@@ -259,8 +259,6 @@
     MarkingConstraint* m_currentConstraint { nullptr };
     MarkingConstraintSolver* m_currentSolver { nullptr };
     
-    // Put padding here to mitigate false sharing between multiple SlotVisitors.
-    char padding[64];
 public:
 #if !ASSERT_DISABLED
     bool m_isCheckingForDefaultMarkViolation;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to