Title: [226885] trunk/Source/_javascript_Core
- Revision
- 226885
- Author
- [email protected]
- Date
- 2018-01-12 04:16:12 -0800 (Fri, 12 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 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):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (226884 => 226885)
--- trunk/Source/_javascript_Core/ChangeLog 2018-01-12 11:26:40 UTC (rev 226884)
+++ trunk/Source/_javascript_Core/ChangeLog 2018-01-12 12:16:12 UTC (rev 226885)
@@ -1,3 +1,28 @@
+2018-01-12 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 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):
+
2018-01-12 Saam Barati <[email protected]>
Each variant of a polymorphic inlined call should be exitOK at the top of the block
Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (226884 => 226885)
--- trunk/Source/_javascript_Core/heap/Heap.cpp 2018-01-12 11:26:40 UTC (rev 226884)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp 2018-01-12 12:16:12 UTC (rev 226885)
@@ -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())
@@ -1239,19 +1247,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 (226884 => 226885)
--- trunk/Source/_javascript_Core/heap/Heap.h 2018-01-12 11:26:40 UTC (rev 226884)
+++ trunk/Source/_javascript_Core/heap/Heap.h 2018-01-12 12:16:12 UTC (rev 226885)
@@ -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 (226884 => 226885)
--- trunk/Source/_javascript_Core/heap/HeapInlines.h 2018-01-12 11:26:40 UTC (rev 226884)
+++ trunk/Source/_javascript_Core/heap/HeapInlines.h 2018-01-12 12:16:12 UTC (rev 226885)
@@ -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 (226884 => 226885)
--- trunk/Source/_javascript_Core/heap/MarkingConstraintSolver.cpp 2018-01-12 11:26:40 UTC (rev 226884)
+++ trunk/Source/_javascript_Core/heap/MarkingConstraintSolver.cpp 2018-01-12 12:16:12 UTC (rev 226885)
@@ -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;
}
Modified: trunk/Source/_javascript_Core/heap/SlotVisitor.h (226884 => 226885)
--- trunk/Source/_javascript_Core/heap/SlotVisitor.h 2018-01-12 11:26:40 UTC (rev 226884)
+++ trunk/Source/_javascript_Core/heap/SlotVisitor.h 2018-01-12 12:16:12 UTC (rev 226885)
@@ -236,6 +236,8 @@
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
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes