Title: [226405] trunk/Source/_javascript_Core
- Revision
- 226405
- Author
- [email protected]
- Date
- 2018-01-04 07:42:06 -0800 (Thu, 04 Jan 2018)
Log 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 apriori, 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):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (226404 => 226405)
--- trunk/Source/_javascript_Core/ChangeLog 2018-01-04 10:04:31 UTC (rev 226404)
+++ trunk/Source/_javascript_Core/ChangeLog 2018-01-04 15:42:06 UTC (rev 226405)
@@ -1,3 +1,28 @@
+2018-01-04 Yusuke Suzuki <[email protected]>
+
+ [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 apriori, 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):
+
2018-01-03 Ting-Wei Lan <[email protected]>
Replace hard-coded paths in shebangs with #!/usr/bin/env
Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (226404 => 226405)
--- trunk/Source/_javascript_Core/heap/Heap.cpp 2018-01-04 10:04:31 UTC (rev 226404)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp 2018-01-04 15:42:06 UTC (rev 226405)
@@ -314,6 +314,14 @@
, 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())
@@ -1245,19 +1253,8 @@
SlotVisitor* slotVisitor;
{
LockHolder locker(m_parallelSlotVisitorLock);
- 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();
+ RELEASE_ASSERT_WITH_MESSAGE(!m_availableParallelSlotVisitors.isEmpty(), "Parallel SlotVisitors are allocated apriori");
+ slotVisitor = m_availableParallelSlotVisitors.takeLast();
}
WTF::registerGCThread(GCThreadType::Helper);
Modified: trunk/Source/_javascript_Core/heap/Heap.h (226404 => 226405)
--- trunk/Source/_javascript_Core/heap/Heap.h 2018-01-04 10:04:31 UTC (rev 226404)
+++ trunk/Source/_javascript_Core/heap/Heap.h 2018-01-04 15:42:06 UTC (rev 226405)
@@ -372,7 +372,6 @@
template<typename Func>
void forEachSlotVisitor(const Func&);
- unsigned numberOfSlotVisitors();
private:
friend class AllocatingScope;
Modified: trunk/Source/_javascript_Core/heap/HeapInlines.h (226404 => 226405)
--- trunk/Source/_javascript_Core/heap/HeapInlines.h 2018-01-04 10:04:31 UTC (rev 226404)
+++ trunk/Source/_javascript_Core/heap/HeapInlines.h 2018-01-04 15:42:06 UTC (rev 226405)
@@ -262,7 +262,6 @@
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)
@@ -269,10 +268,4 @@
func(*slotVisitor);
}
-inline unsigned Heap::numberOfSlotVisitors()
-{
- auto locker = holdLock(m_parallelSlotVisitorLock);
- return m_parallelSlotVisitors.size() + 2; // m_collectorSlotVisitor and m_mutatorSlotVisitor
-}
-
} // namespace JSC
Modified: trunk/Source/_javascript_Core/heap/MarkingConstraintSolver.cpp (226404 => 226405)
--- trunk/Source/_javascript_Core/heap/MarkingConstraintSolver.cpp 2018-01-04 10:04:31 UTC (rev 226404)
+++ trunk/Source/_javascript_Core/heap/MarkingConstraintSolver.cpp 2018-01-04 15:42:06 UTC (rev 226405)
@@ -51,10 +51,6 @@
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;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes