Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 729712aa495ce94f6874274092178c037d049312
https://github.com/WebKit/WebKit/commit/729712aa495ce94f6874274092178c037d049312
Author: Dan Hecht <[email protected]>
Date: 2026-10-05 (Mon, 05 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] Group the per-heap work of the Collector's Begin and End phases
https://bugs.webkit.org/show_bug.cgi?id=326368
rdar://189203207
Reviewed by Yijia Huang.
A collection will cover several heaps. Begin and End each do some work for the
collection as a whole and some for each heap; the per-heap work is interleaved
with the rest, so covering several heaps would mean a loop around each of half
a dozen calls. Gather each phase's per-heap work into one function,
beginCollectionInEachHeap() and endCollectionInEachHeap(), which still work on
the one heap. Collector::beginMarking() and endMarking() fold into the phases.
The collection count used in the GC signpost, Heap::m_gcVersion, moves to the
Collector, and the signpost is keyed by the Collector rather than the heap:
both describe the collection. That lets the signpost open before any per-heap
work instead of after Heap::willStartCollection(), which used to increment the
count.
Grouping reorders these steps. Each moves past steps that do not touch what it
reads or writes:
Begin:
- The heap's GC start time is stored in its per-heap step; the value is still
taken at the start of Begin.
- Reseeding the VM's random generator moves after decideCollectionScope() and
the signpost. Only the cell audits during marking draw from it.
- The count increment and the signpost move ahead of willStartCollection().
The signpost now also covers willStartCollection() and Heap::beginMarking(),
and on Full collections its capacity includes extra memory, as the logGC
START line's already does, since it is read before willStartCollection()
resets the extra-memory counters.
- Clearing the opaque roots and the collector visitor's mark stacks on Full
collections, and the race-mark-stack assertion, move after
Heap::beginMarking(), next to the visitors' didStartMarking(). Neither
Heap::beginMarking() nor these touch the other's state.
End:
- assertMarkStacksEmpty() moves ahead of remembering the executing CodeBlocks,
which only appends to the heap's own mutator mark stack. The two race-mark-
stack assertions on either side of it become one RELEASE_ASSERT.
- Resetting the visitors moves after verifyMarking(), pruneDeadReferences(),
prepareForAllocation() and didFinishCollection(), none of which read the
visitors' bytes-visited count, visit count or analyzer.
- didFinishCollection() moves ahead of taking m_afterGC, so the logged pause
and recordCollectionTime() include it.
No behavior changes.
* Source/JavaScriptCore/heap/Collector.cpp:
(JSC::Collector::runBeginPhase):
(JSC::Collector::beginCollectionInEachHeap):
(JSC::Collector::runEndPhase):
(JSC::Collector::endCollectionInEachHeap):
(JSC::Collector::beginMarking): Deleted.
(JSC::Collector::endMarking): Deleted.
* Source/JavaScriptCore/heap/Collector.h:
* Source/JavaScriptCore/heap/Heap.cpp:
(JSC::Heap::clearConcurrentRetainedDataIfPossible):
* Source/JavaScriptCore/heap/Heap.h:
Canonical link: https://commits.webkit.org/322785@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications