Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5297538c7daa8e3f87cced4bc68c9a261d1b657c
      
https://github.com/WebKit/WebKit/commit/5297538c7daa8e3f87cced4bc68c9a261d1b657c
  Author: Dan Hecht <[email protected]>
  Date:   2026-10-01 (Thu, 01 Oct 2026)

  Changed paths:
    M Source/JavaScriptCore/heap/Collector.cpp
    M Source/JavaScriptCore/heap/Collector.h
    M Source/JavaScriptCore/heap/Heap.cpp
    M Source/JavaScriptCore/heap/Heap.h

  Log Message:
  -----------
  [JSC] Move the request queue checks and the mutator's phase loop from the 
Heap into the Collector
https://bugs.webkit.org/show_bug.cgi?id=325825
rdar://188834063

Reviewed by Yijia Huang.

Heap read the Collector's request queue directly: to skip a request that a
queued one already covers, to decide whether to wake the collector thread, and
to decide whether to log. It also ran the Collector's phase loop itself when its
mutator conducted a collection. The queue and the phase machine are the
Collector's however many heaps it serves, so these belong with it.

 * Collector::isSubsumedByQueuedRequest() does the check Heap::collectAsync()
   did by hand. Heap::collect() now holds the sequence that collectAsync() and
   collectSync() each spelled out, and Heap::requestCollection() is gone.
 * The request queue, the ticket counters, m_threadIsWorking and
   m_threadShouldStop are annotated as guarded by the Collector's thread lock,
   and the ticket predicates as requiring it, so the thread-safety analysis
   checks every use. Collector::hasOutstandingRequest() takes the lock itself,
   which replaces the Heap taking it for its shutdown check and for the logging
   check in Heap::collectIfNecessaryOrDefer(); the predicates that
   Heap::waitForCollector() runs under the lock are annotated as requiring it.
   Heap::finishRelinquishingConn() asks hasOutstandingRequestWithLock() instead
   of reading the queue, and that predicate asserts that the queue holds exactly
   the requests not yet served.
 * Heap::waitForAllCollections() is the wait that Heap::shutDown() and
   Heap::preventCollection() each spelled out.
 * m_collectorThreadIsRunning becomes m_threadIsWorking, since it records
   whether the thread's last poll handed it work. poll() clears it when it stops
   the thread, so threadIsStopping() asserts it is clear.
 * Collector::collectInMutatorThread() holds the mutator's phase loop, next to
   collectInCollectorThread(). It takes the conducting heap, which for now can
   only be the Collector's own. Heap::collectInMutatorThread() keeps the
   CollectingScope, since that is the mutator's state.

Heap::waitForCollector() and Heap::finishRelinquishingConn() still take the
Collector's lock. It orders the mutator's world-state transitions against the
collector, so where it lives will be addressed together with the rest of the
conn protocol.

No change in behavior, except that --logGC now takes the Collector's lock to
decide whether to log.

* Source/JavaScriptCore/heap/Collector.cpp:
(JSC::Collector::stopThread):
(JSC::Collector::requestCollection):
(JSC::Collector::isSubsumedByQueuedRequest):
(JSC::Collector::shouldCollectInCollectorThread):
(JSC::Collector::collectInMutatorThread):
* Source/JavaScriptCore/heap/Collector.h:
(JSC::Collector::hasOutstandingRequest):
(JSC::Collector::WTF_REQUIRES_LOCK):
(JSC::Collector::WTF_GUARDED_BY_LOCK):
(JSC::Collector::hasOutstandingRequest const): Deleted.
(JSC::Collector::hasServedTicket const): Deleted.
* Source/JavaScriptCore/heap/Heap.cpp:
(JSC::Heap::shutDown):
(JSC::Heap::clearConcurrentRetainedDataIfPossible):
* Source/JavaScriptCore/heap/Heap.h:

Canonical link: https://commits.webkit.org/322396@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to