Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 8ae0649a809b4eb3c69f1e9883d2c7717f4b12ae
      
https://github.com/WebKit/WebKit/commit/8ae0649a809b4eb3c69f1e9883d2c7717f4b12ae
  Author: Yusuke Suzuki <[email protected]>
  Date:   2026-09-11 (Fri, 11 Sep 2026)

  Changed paths:
    A JSTests/stress/weak-gc-map-keeps-live-values.js
    M Source/JavaScriptCore/heap/Heap.cpp
    M Source/JavaScriptCore/heap/Heap.h
    M Source/JavaScriptCore/runtime/WeakGCHashTable.h
    M Source/JavaScriptCore/runtime/WeakGCMap.h
    M Source/JavaScriptCore/runtime/WeakGCMapInlines.h
    M Source/JavaScriptCore/runtime/WeakGCSet.h
    M Source/JavaScriptCore/runtime/WeakGCSetInlines.h

  Log Message:
  -----------
  [JSC] Rewrite WeakGCMap like JS WeakMap
https://bugs.webkit.org/show_bug.cgi?id=323958
rdar://187190421

Reviewed by Tadeu Zagallo.

WeakGCMap / WeakGCSet were using Weak<> for values, but Weak is
double-pointer and its management is costly. This patch changes them to
similar to JS WeakMap design: we clear values when GC ends. At GC end
phase, we know whether vlaue is dead or marked, so we can clean them up.

The problem is that we do not want to scan during Eden GC repeatedly.
Previously WeakGCMap was cleaned up only during Full GC. And each Weak<>
cell clean up is done for each GC cycle, tied to MarkedBlock. But now we
need to use isMarked information to clean things up for each GC end phase.
But the key is that "once your value survives Eden GC, now mark bit is
sticky so it is alive in the next Eden GC too". This means that we
should scan WeakGCMap only when it gets modified during this Eden GC
cycle. So we can reduce clean up cost in GC end phase. didAddValue will
chain the WeakGCMap to the heap list and we scan this chained WeakGCMap.

Test: JSTests/stress/weak-gc-map-keeps-live-values.js

* JSTests/stress/weak-gc-map-keeps-live-values.js: Added.
(shouldBe):
* Source/JavaScriptCore/heap/Heap.cpp:
(JSC::Heap::clearConcurrentRetainedDataIfPossible):
* Source/JavaScriptCore/heap/Heap.h:
* Source/JavaScriptCore/runtime/WeakGCHashTable.h:
(JSC::WeakGCHashTable::markDirty):
(JSC::WeakGCHashTable::~WeakGCHashTable): Deleted.
* Source/JavaScriptCore/runtime/WeakGCMap.h:
* Source/JavaScriptCore/runtime/WeakGCMapInlines.h:
(JSC::KeyTraitsArg>::reconcileWeakReferencesAtGCEnd):
(JSC::KeyTraitsArg>::forEach):
(JSC::KeyTraitsArg>::pruneStaleEntries): Deleted.
* Source/JavaScriptCore/runtime/WeakGCSet.h:
* Source/JavaScriptCore/runtime/WeakGCSetInlines.h:
(JSC::TraitsArg>::reconcileWeakReferencesAtGCEnd):

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



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

Reply via email to