Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d3c92619498dc6f6b26f09d8b84c895a2a66e611
      
https://github.com/WebKit/WebKit/commit/d3c92619498dc6f6b26f09d8b84c895a2a66e611
  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] Clean up the boundary between the Collector and the Heap at the end of 
a collection
https://bugs.webkit.org/show_bug.cgi?id=325862
rdar://188858563

Reviewed by Yusuke Suzuki.

Collector::runEndPhase() did most of the heap's end-of-collection work itself,
reaching into the Heap 45 times: its verifier, weak-reference reconciliation,
sweeping, allocation limits and GC time accounting. A Collector that ends a
collection of several heaps needs each heap to do that work for itself. Move it
into Heap methods, which runEndPhase() calls in the same order:

 * Heap::rememberExecutingAndCompilingCodeBlocks() is the barrier loop over
   executing and compiling CodeBlocks. It takes the Collector's visitor, which
   answers whether the executable a compiling CodeBlock belongs to was marked.
   Defined next to iterateExecutingAndCompilingCodeBlocks(), it no longer needs
   that template explicitly instantiated.
 * Heap::endMarking() takes the bytes marking visited and records them in
   recordBytesVisited(), formerly updateObjectCounts(), which counted no
   objects.
 * Heap::verifyMarking() runs the GC verifier and the heap verifier's pass after
   marking.
 * Heap::pruneDeadReferences() drops references to and from cells marking
   found dead: weak handles, weak table entries and other weak references,
   compiler plans, deferred work and jettisoned stub routines whose cells died,
   CodeBlockSet entries, and references to array buffers from dead ArrayBuffer
   objects and views, which frees buffers nothing live uses. The sweeper frees
   the cells themselves.
 * Heap::prepareForAllocation() starts the sweeper, prepares the allocators,
   sets the next allocation limits and runs the heap verifier's pass after GC.
 * Heap::recordCollectionTime() records the collection's length, its end time,
   the total GC time and the rate-limiting count, so Heap::didFinishCollection()
   no longer takes the length.

Each of these, and the Heap's Begin-phase helpers willStartCollection() and
beginMarking(), asserts the phase that calls it. The helpers that ask liveness
questions also assert that marking has ended, and recordCollectionTime() that
didFinishCollection() has run.

Some statements move relative to others; none depends on the old order:

 * Clearing the set of executing CodeBlocks, with the second barrier loop over
   it, comes before the sweeper is started, which only schedules its timer, and
   inside the scope that clears the atom string table; neither the loop nor the
   clear touches an atom string.
 * Collector::endMarking() ends the heap's marking before resetting its
   visitors, which touches only visitor state.
 * The collection's length is recorded with the rest of its timing at the end
   of the End phase; nothing reads it before the world resumes.

The verbose heap dump moves into Heap::didFinishCollection(), and the comment
that reconciliation must precede clearing the executing set goes, since nothing
reads that set during reconciliation.

The Collector keeps stopping the markers, serving the request, logging and the
signpost. Clearing the mutator-waiting bit and asking for the collection
epilogue belong to the conn protocol and stay where they are for now.

No change in behavior.

* Source/JavaScriptCore/heap/Collector.cpp:
(JSC::Collector::runEndPhase):
(JSC::Collector::endMarking):
(JSC::Collector::didFinishCollection): Deleted.
* Source/JavaScriptCore/heap/Collector.h:
* Source/JavaScriptCore/heap/Heap.cpp:
(JSC::Heap::beginMarking):
(JSC::Heap::rememberExecutingAndCompilingCodeBlocks):
(JSC::Heap::recordBytesVisited):
(JSC::Heap::endMarking):
(JSC::Heap::verifyMarking):
(JSC::Heap::pruneDeadReferences):
(JSC::Heap::prepareForAllocation):
(JSC::Heap::clearConcurrentRetainedDataIfPossible):
(JSC::Heap::updateObjectCounts): Deleted.
* Source/JavaScriptCore/heap/Heap.h:

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



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

Reply via email to