Truly independent web browser
LibGC+Everywhere: Make counted and owned captures declare themselves
Andreas Kling980d4f0be2dd
diff --git a/Libraries/LibGC/CaptureTraits.h b/Libraries/LibGC/CaptureTraits.hindex fde45d95a65..fd817e3e244 100644--- a/Libraries/LibGC/CaptureTraits.h+++ b/Libraries/LibGC/CaptureTraits.h@@ -24,9 +24,9 @@ namespace GC {template<typename T>class Weak;-// A capture whose type the GC does not trace has to hold no cell edges at all. Non-GC objects keep the cells they use in-// GC::Root, so owning and counted pointers to them hold no edges of the function either. A raw pointer is never one of-// these, as it may point into a cell, such as at a mixin of one.+// A capture whose type the GC does not trace has to hold no cell edges at all. An owning or counted pointer is one if what+// it points to is, which a type declares with GC_UNTRACED_CAPTURE(). A raw pointer is never one of these, as it may point+// into a cell, such as at a mixin of one.template<typename T>struct IsUntracedCapture : FalseType { };@@ -34,6 +34,10 @@ template<typename T>requires(IsArithmetic<T> || IsEnum<T>)struct IsUntracedCapture<T> : TrueType { };+template<typename T>+requires(requires { typename T::HoldsNoCellEdges; })+struct IsUntracedCapture<T> : TrueType { };+template<>struct IsUntracedCapture<Empty> : TrueType { };@@ -96,19 +100,19 @@ struct IsUntracedCapture<AK::JsonArray> : TrueType { };template<typename T>requires(!IsCellLike<RemoveCV<T>>)-struct IsUntracedCapture<AK::RefPtr<T>> : TrueType { };+struct IsUntracedCapture<AK::RefPtr<T>> : IsUntracedCapture<RemoveCV<T>> { };template<typename T>requires(!IsCellLike<RemoveCV<T>>)-struct IsUntracedCapture<AK::NonnullRefPtr<T>> : TrueType { };+struct IsUntracedCapture<AK::NonnullRefPtr<T>> : IsUntracedCapture<RemoveCV<T>> { };template<typename T>requires(!IsCellLike<RemoveCV<T>>)-struct IsUntracedCapture<AK::OwnPtr<T>> : TrueType { };+struct IsUntracedCapture<AK::OwnPtr<T>> : IsUntracedCapture<RemoveCV<T>> { };template<typename T>requires(!IsCellLike<RemoveCV<T>>)-struct IsUntracedCapture<AK::NonnullOwnPtr<T>> : TrueType { };+struct IsUntracedCapture<AK::NonnullOwnPtr<T>> : IsUntracedCapture<RemoveCV<T>> { };template<typename T>struct IsUntracedCapture<Optional<T>> : IsUntracedCapture<T> { };@@ -130,7 +134,17 @@ struct IsTracedCapture;// Every part of a capture is either traced or holds no cell edges, so nothing a function captures can keep a cell// that the GC does not see.template<typename T>-inline constexpr bool IsCapturable = IsUntracedCapture<T>::value || IsTracedCapture<T>::value;+consteval bool is_capturable()+{+ // NB: A type that holds no cell edges may be incomplete here, which asking whether it is traced would not allow.+ if constexpr (IsUntracedCapture<T>::value)+ return true;+ else+ return IsTracedCapture<T>::value;+}++template<typename T>+inline constexpr bool IsCapturable = is_capturable<T>();template<typename T>struct IsTracedCapture {@@ -160,11 +174,11 @@ struct IsTracedCapture<Variant<Ts...>> {template<typename T>requires(!IsCellLike<RemoveCV<T>>)-struct IsTracedCapture<AK::RefPtr<T>> : IsTracedCapture<T> { };+struct IsTracedCapture<AK::RefPtr<T>> : IsTracedCapture<RemoveCV<T>> { };template<typename T>requires(!IsCellLike<RemoveCV<T>>)-struct IsTracedCapture<AK::NonnullRefPtr<T>> : IsTracedCapture<T> { };+struct IsTracedCapture<AK::NonnullRefPtr<T>> : IsTracedCapture<RemoveCV<T>> { };// Visits a member of a value type, such as a generated dictionary, from its visit_edges(). Every member must be traced or// hold no cell edges, so that the value can be captured by a GC::Function.diff --git a/Libraries/LibGC/Forward.h b/Libraries/LibGC/Forward.hindex 249724665d2..b7cc0d7b08e 100644--- a/Libraries/LibGC/Forward.h+++ b/Libraries/LibGC/Forward.h@@ -17,6 +17,9 @@static constexpr bool value = true; \}+// Declares inside a type that it holds no cell edges, for a type that can't be named at global scope.+#define GC_HOLDS_NO_CELL_EDGES using HoldsNoCellEdges = void+namespace GC {// Whether a type holds no cell edges, so that a GC::Function may capture it untraced. See LibGC/CaptureTraits.h.diff --git a/Libraries/LibJS/SourceCode.h b/Libraries/LibJS/SourceCode.hindex 82497345c92..242877a1132 100644--- a/Libraries/LibJS/SourceCode.h+++ b/Libraries/LibJS/SourceCode.h@@ -12,6 +12,7 @@#include <AK/RefPtr.h>#include <AK/Utf16String.h>#include <AK/Vector.h>+#include <LibGC/Forward.h>#include <LibJS/Export.h>#include <LibJS/Forward.h>#include <LibJS/Position.h>@@ -26,6 +27,8 @@ class JS_API SourceCode {AK_MAKE_NONMOVABLE(SourceCode);public:+ GC_HOLDS_NO_CELL_EDGES;+static NonnullRefPtr<SourceCode const> create(Utf16String filename, Utf16String code);Utf16String const& filename() const;diff --git a/Libraries/LibWeb/Editing/SpellCheckController.cpp b/Libraries/LibWeb/Editing/SpellCheckController.cppindex c7e25a5263e..15c4aac3ca4 100644--- a/Libraries/LibWeb/Editing/SpellCheckController.cpp+++ b/Libraries/LibWeb/Editing/SpellCheckController.cpp@@ -20,9 +20,6 @@#include <LibWeb/Page/Page.h>#include <LibWeb/Selection/Selection.h>-// NB: A request holds its nodes weakly, so a function can capture it without an edge to trace.-GC_UNTRACED_CAPTURE(Web::Editing::SpellCheckController::Request);-namespace Web::Editing {// https://html.spec.whatwg.org/multipage/interaction.html#spelling-and-grammar-checkingdiff --git a/Libraries/LibWeb/Editing/SpellCheckController.h b/Libraries/LibWeb/Editing/SpellCheckController.hindex 62e8ff67fba..b2331ae4a40 100644--- a/Libraries/LibWeb/Editing/SpellCheckController.h+++ b/Libraries/LibWeb/Editing/SpellCheckController.h@@ -75,7 +75,10 @@ private:Other,};+ // NB: A request holds its nodes weakly, so a function can capture it without an edge to trace.struct Request {+ GC_HOLDS_NO_CELL_EDGES;+RequestKind kind { RequestKind::Other };Utf16String text;Vector<RequestPiece> pieces;diff --git a/Libraries/LibWeb/Editing/WritingSuggestionController.cpp b/Libraries/LibWeb/Editing/WritingSuggestionController.cppindex 0635ba05e4e..4f642bb6687 100644--- a/Libraries/LibWeb/Editing/WritingSuggestionController.cpp+++ b/Libraries/LibWeb/Editing/WritingSuggestionController.cpp@@ -17,9 +17,6 @@#include <LibWeb/Layout/LayoutRustBridge.h>#include <LibWeb/Page/Page.h>-// NB: A request holds its nodes weakly, so a function can capture it without an edge to trace.-GC_UNTRACED_CAPTURE(Web::Editing::WritingSuggestionController::Request);-namespace Web::Editing {WritingSuggestionController::WritingSuggestionController(DOM::Document& document)diff --git a/Libraries/LibWeb/Editing/WritingSuggestionController.h b/Libraries/LibWeb/Editing/WritingSuggestionController.hindex aaa12efb6d9..4f4e7d8be6e 100644--- a/Libraries/LibWeb/Editing/WritingSuggestionController.h+++ b/Libraries/LibWeb/Editing/WritingSuggestionController.h@@ -63,7 +63,10 @@ public:void visit_edges(GC::Cell::Visitor&);private:+ // NB: A request holds its nodes weakly, so a function can capture it without an edge to trace.struct Request {+ GC_HOLDS_NO_CELL_EDGES;+u64 generation { 0 };GC::Weak<DOM::Text> text;size_t offset { 0 };diff --git a/Libraries/LibWeb/Fetch/Fetching/RefCountedFlag.h b/Libraries/LibWeb/Fetch/Fetching/RefCountedFlag.hindex ec82d22f513..7b8e2933b06 100644--- a/Libraries/LibWeb/Fetch/Fetching/RefCountedFlag.h+++ b/Libraries/LibWeb/Fetch/Fetching/RefCountedFlag.h@@ -7,6 +7,7 @@#pragma once#include <AK/RefCounted.h>+#include <LibGC/Forward.h>namespace Web::Fetch::Fetching {@@ -14,6 +15,8 @@ namespace Web::Fetch::Fetching {/// This is used to share flags between multiple callback closures.class RefCountedFlag : public RefCounted<RefCountedFlag> {public:+ GC_HOLDS_NO_CELL_EDGES;+static NonnullRefPtr<RefCountedFlag> create(bool);[[nodiscard]] bool value() const { return m_value; }diff --git a/Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h b/Libraries/LibWeb/Fetch/Infrastructure/FetchParams.hindex ccc8e849960..975b3982422 100644--- a/Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h+++ b/Libraries/LibWeb/Fetch/Infrastructure/FetchParams.h@@ -27,6 +27,8 @@ class WEB_API FetchParams: public RefCounted<FetchParams>, public Weakable<FetchParams> {public:+ GC_HOLDS_NO_CELL_EDGES;+struct PreloadedResponseCandidatePendingTag { };using PreloadedResponseCandidate = Variant<Empty, PreloadedResponseCandidatePendingTag, NonnullRefPtr<Response>>;diff --git a/Libraries/LibWeb/Fetch/Infrastructure/FetchTimingInfo.h b/Libraries/LibWeb/Fetch/Infrastructure/FetchTimingInfo.hindex d9d669e465e..4e2c2cac9d1 100644--- a/Libraries/LibWeb/Fetch/Infrastructure/FetchTimingInfo.h+++ b/Libraries/LibWeb/Fetch/Infrastructure/FetchTimingInfo.h@@ -21,6 +21,8 @@ namespace Web::Fetch::Infrastructure {// https://fetch.spec.whatwg.org/#fetch-timing-infoclass WEB_API FetchTimingInfo : public AtomicRefCounted<FetchTimingInfo> {public:+ GC_HOLDS_NO_CELL_EDGES;+[[nodiscard]] static NonnullRefPtr<FetchTimingInfo> create();[[nodiscard]] HighResolutionTime::DOMHighResTimeStamp start_time() const { return m_start_time; }diff --git a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.hindex e028ed3eb80..b7b166ad04d 100644--- a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h+++ b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h@@ -49,6 +49,8 @@ class Response;// https://fetch.spec.whatwg.org/#concept-requestclass WEB_API Request final : public RefCounted<Request> {public:+ GC_HOLDS_NO_CELL_EDGES;+enum class CredentialsMode {Omit,SameOrigin,diff --git a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.hindex 8a39e2f282d..2c0b75d12c7 100644--- a/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h+++ b/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Responses.h@@ -31,6 +31,8 @@ namespace Web::Fetch::Infrastructure {// https://fetch.spec.whatwg.org/#concept-responseclass WEB_API Response : public RefCounted<Response> {public:+ GC_HOLDS_NO_CELL_EDGES;+using CacheState = ResponseCacheState;enum class Type {diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.hindex 6357d5e49f7..b655c16ece3 100644--- a/Libraries/LibWeb/Forward.h+++ b/Libraries/LibWeb/Forward.h@@ -10,8 +10,10 @@#include <AK/DistinctNumeric.h>#include <AK/Variant.h>#include <LibCompositing/Forward.h>+#include <LibCore/Forward.h>#include <LibGC/Forward.h>#include <LibGfx/Forward.h>+#include <LibHTTP/Forward.h>#include <LibIPC/Forward.h>#include <LibJS/Forward.h>#include <LibURL/Forward.h>@@ -21,6 +23,28 @@#include <LibWeb/Export.h>#include <LibWebCommon/Forward.h>+namespace Gfx {++class Typeface;++}++namespace Web::Fetch::Engine {++class FetchBodyDeliveryGate;+class FetchByteChannel;+class WholeBodyTransport;++}++// NB: The fetch engine can't include LibGC, so these are declared here.+GC_UNTRACED_CAPTURE(Web::Fetch::Engine::FetchBodyDeliveryGate);+GC_UNTRACED_CAPTURE(Web::Fetch::Engine::FetchByteChannel);+GC_UNTRACED_CAPTURE(Web::Fetch::Engine::WholeBodyTransport);+GC_UNTRACED_CAPTURE(Core::Timer);+GC_UNTRACED_CAPTURE(Gfx::Typeface);+GC_UNTRACED_CAPTURE(HTTP::HeaderList);+GC_UNTRACED_CAPTURE(HTTP::MemoryCache);GC_UNTRACED_CAPTURE(URL::URL);GC_UNTRACED_CAPTURE(URL::Origin);diff --git a/Libraries/LibWeb/Geolocation/Geolocation.cpp b/Libraries/LibWeb/Geolocation/Geolocation.cppindex fa0c3da4a29..dcd90b42231 100644--- a/Libraries/LibWeb/Geolocation/Geolocation.cpp+++ b/Libraries/LibWeb/Geolocation/Geolocation.cpp@@ -34,6 +34,8 @@ static WebIDL::UnsignedLong s_next_watch_id = 0;class GeolocationRequestState : public RefCounted<GeolocationRequestState> {public:+ GC_HOLDS_NO_CELL_EDGES;+u64 request_id { 0 };bool completed { false };bool timeout_stopped { false };diff --git a/Libraries/LibWeb/HTML/MediaControls.cpp b/Libraries/LibWeb/HTML/MediaControls.cppindex 6ac70ed12fa..34b244572db 100644--- a/Libraries/LibWeb/HTML/MediaControls.cpp+++ b/Libraries/LibWeb/HTML/MediaControls.cpp@@ -112,6 +112,8 @@ GC::Ref<DOM::IDLEventListener> MediaControls::add_event_listener(JS::Realm& real// NB: A handler uses these controls, which remove their listeners when they go away. It holds no strong pointer to// a cell, as nothing traces it.struct HandlerHolder : RefCounted<HandlerHolder> {+ GC_HOLDS_NO_CELL_EDGES;+explicit HandlerHolder(Handler handler): handler(move(handler)){diff --git a/Libraries/LibWeb/HTML/NavigationParams.h b/Libraries/LibWeb/HTML/NavigationParams.hindex 589efdb1935..9254eb7dbcc 100644--- a/Libraries/LibWeb/HTML/NavigationParams.h+++ b/Libraries/LibWeb/HTML/NavigationParams.h@@ -10,6 +10,7 @@#include <AK/RefCounted.h>#include <AK/Utf16String.h>#include <LibGC/CellAllocator.h>+#include <LibGC/Forward.h>#include <LibGC/Ptr.h>#include <LibURL/Origin.h>#include <LibWeb/Bindings/PerformanceNavigationTiming.h>@@ -32,6 +33,7 @@ namespace Web::HTML {// NB: Reconstructed response callbacks and download adoption share one terminal-event owner.struct NavigationResponseNetworkEventState : RefCounted<NavigationResponseNetworkEventState> {AK_ALLOC_WITH_KMALLOC;+ GC_HOLDS_NO_CELL_EDGES;enum class Owner {Renderer,diff --git a/Libraries/LibWeb/HTML/Scripting/RemoteEnvironmentSettings.h b/Libraries/LibWeb/HTML/Scripting/RemoteEnvironmentSettings.hindex d8087bd33f7..5ece2c9b255 100644--- a/Libraries/LibWeb/HTML/Scripting/RemoteEnvironmentSettings.h+++ b/Libraries/LibWeb/HTML/Scripting/RemoteEnvironmentSettings.h@@ -21,6 +21,8 @@ struct RemoteClientNavigation {// The settings of an environment another process hosts, as that process serialized them.struct RemoteEnvironmentSettings final : public AtomicRefCounted<RemoteEnvironmentSettings> {+ GC_HOLDS_NO_CELL_EDGES;+static NonnullRefPtr<RemoteEnvironmentSettings const> create(SerializedEnvironmentSettingsObject settings){return adopt_ref(*new RemoteEnvironmentSettings(move(settings)));diff --git a/Libraries/LibWeb/HTML/SessionHistoryEntry.h b/Libraries/LibWeb/HTML/SessionHistoryEntry.hindex 2ae0a0ebcce..7a62d4e1d95 100644--- a/Libraries/LibWeb/HTML/SessionHistoryEntry.h+++ b/Libraries/LibWeb/HTML/SessionHistoryEntry.h@@ -29,6 +29,8 @@ namespace Web::HTML {class WEB_API SessionHistoryEntry final : public RefCounted<SessionHistoryEntry> {public:+ GC_HOLDS_NO_CELL_EDGES;+static NonnullRefPtr<SessionHistoryEntry> create();static NonnullRefPtr<SessionHistoryEntry> create(NonnullRefPtr<DirectiveState>);diff --git a/Libraries/LibWeb/Internals/Internals.cpp b/Libraries/LibWeb/Internals/Internals.cppindex 6bcb9d764cf..d9086840676 100644--- a/Libraries/LibWeb/Internals/Internals.cpp+++ b/Libraries/LibWeb/Internals/Internals.cpp@@ -728,6 +728,8 @@ void Internals::grant_transient_activation()namespace {struct MouseEventsTheUIProcessHasNotHandledYet : public RefCounted<MouseEventsTheUIProcessHasNotHandledYet> {+ GC_HOLDS_NO_CELL_EDGES;+size_t count { 0 };};@@ -3692,6 +3694,8 @@ namespace {// The bytes of a stream from create_stream_pulling_from_bytes() that it has not pulled yet.struct UnpulledBytes final : public RefCounted<UnpulledBytes> {+ GC_HOLDS_NO_CELL_EDGES;+explicit UnpulledBytes(ByteBuffer bytes): bytes(move(bytes)){diff --git a/Libraries/LibWeb/Loader/LoadRequest.h b/Libraries/LibWeb/Loader/LoadRequest.hindex 3043b07cf94..6bd65d1ac15 100644--- a/Libraries/LibWeb/Loader/LoadRequest.h+++ b/Libraries/LibWeb/Loader/LoadRequest.h@@ -22,8 +22,11 @@namespace Web {+// NB: A load request keeps its page in a GC::Root, and holds no other cell.class WEB_API LoadRequest {public:+ GC_HOLDS_NO_CELL_EDGES;+explicit LoadRequest(NonnullRefPtr<HTTP::HeaderList> headers): m_headers(move(headers)){diff --git a/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Libraries/LibWeb/Loader/ResourceLoader.cppindex 9fd5f7fdbae..f4efbfa55ea 100644--- a/Libraries/LibWeb/Loader/ResourceLoader.cpp+++ b/Libraries/LibWeb/Loader/ResourceLoader.cpp@@ -31,9 +31,6 @@#include <LibWeb/Platform/Timer.h>#include <LibWebCommon/Loader/UserAgent.h>-// NB: A load request keeps its page in a GC::Root, and holds no other cell.-GC_UNTRACED_CAPTURE(Web::LoadRequest);-namespace Web {static RefPtr<ResourceLoader>& resource_loader()diff --git a/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp b/Libraries/LibWeb/SVG/SVGDecodedImageData.cppindex 2cb0ede91f4..b4c044a65e9 100644--- a/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp+++ b/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp@@ -33,6 +33,8 @@namespace Web::SVG {struct DocumentObserverRoot : RefCounted<DocumentObserverRoot> {+ GC_HOLDS_NO_CELL_EDGES;+explicit DocumentObserverRoot(DOM::DocumentObserver& observer): observer(observer){diff --git a/Libraries/LibWeb/SVG/SVGDecodedImageData.h b/Libraries/LibWeb/SVG/SVGDecodedImageData.hindex 65590684232..bc4ca8a8987 100644--- a/Libraries/LibWeb/SVG/SVGDecodedImageData.h+++ b/Libraries/LibWeb/SVG/SVGDecodedImageData.h@@ -216,3 +216,6 @@ private:};}++// NB: The promise resolves to a root.+GC_UNTRACED_CAPTURE(Web::SVG::SVGDecodedImageData::DecodePromise);diff --git a/Libraries/LibWeb/WebDriver/BiDi/BrowsingContext.cpp b/Libraries/LibWeb/WebDriver/BiDi/BrowsingContext.cppindex cd51b0a9539..7d0bd35861d 100644--- a/Libraries/LibWeb/WebDriver/BiDi/BrowsingContext.cpp+++ b/Libraries/LibWeb/WebDriver/BiDi/BrowsingContext.cpp@@ -819,6 +819,8 @@ void capture_screenshot(HTML::Navigable& navigable, JsonObject const& params, On// NB: Visibility and activity changes complete a pending capture without waiting for its callback to be collected.struct State : RefCounted<State>, Weakable<State> {+ GC_HOLDS_NO_CELL_EDGES;+AK_ALLOC_WITH_KMALLOC;OnCommandComplete on_complete;diff --git a/Libraries/LibWeb/WebDriver/BiDi/Input.cpp b/Libraries/LibWeb/WebDriver/BiDi/Input.cppindex 1b111a2d024..a95848602eb 100644--- a/Libraries/LibWeb/WebDriver/BiDi/Input.cpp+++ b/Libraries/LibWeb/WebDriver/BiDi/Input.cpp@@ -87,6 +87,8 @@ static ActionsOptions actions_options()// NB: The actions running for a command stay alive until they complete.struct ActionsInFlight : RefCounted<ActionsInFlight> {+ GC_HOLDS_NO_CELL_EDGES;+AK_ALLOC_WITH_KMALLOC;Optional<GC::Root<JS::Cell>> executor;diff --git a/Libraries/LibWeb/WebDriver/BiDi/Script.cpp b/Libraries/LibWeb/WebDriver/BiDi/Script.cppindex 783f6983a20..d1e67187f39 100644--- a/Libraries/LibWeb/WebDriver/BiDi/Script.cpp+++ b/Libraries/LibWeb/WebDriver/BiDi/Script.cpp@@ -343,6 +343,8 @@ namespace {// NB: The session keeps an awaited promise and its evaluation alive until it settles or its environment is destroyed.struct PendingEvaluation : RefCounted<PendingEvaluation> {+ GC_HOLDS_NO_CELL_EDGES;+AK_ALLOC_WITH_KMALLOC;String environment_id;diff --git a/Services/WebContent/Worker/DedicatedWorkerThreadLink.h b/Services/WebContent/Worker/DedicatedWorkerThreadLink.hindex ccd773a5f5e..956ea11d090 100644--- a/Services/WebContent/Worker/DedicatedWorkerThreadLink.h+++ b/Services/WebContent/Worker/DedicatedWorkerThreadLink.h@@ -13,6 +13,7 @@#include <AK/Utf16String.h>#include <AK/Vector.h>#include <LibCore/Forward.h>+#include <LibGC/Forward.h>#include <LibURL/URL.h>#include <LibWeb/Forward.h>#include <LibWeb/HTML/DedicatedWorkerThreadLink.h>@@ -64,3 +65,6 @@ private:};}++// NB: The tasks the link keeps cross between threads, so they can't be GC::Functions. They capture no cells.+GC_UNTRACED_CAPTURE(WebWorker::DedicatedWorkerThreadLink);diff --git a/Services/WebContent/Worker/WorkerHost.h b/Services/WebContent/Worker/WorkerHost.hindex fff44676191..cb6a4a24e37 100644--- a/Services/WebContent/Worker/WorkerHost.h+++ b/Services/WebContent/Worker/WorkerHost.h@@ -27,6 +27,8 @@ namespace WebWorker {class WorkerHost : public RefCounted<WorkerHost> {public:+ GC_HOLDS_NO_CELL_EDGES;+explicit WorkerHost(URL::URL url, Web::HTML::WorkerType type, String name);~WorkerHost();diff --git a/Tests/LibGC/TestGCFunction.cpp b/Tests/LibGC/TestGCFunction.cppindex 085dde399d7..92ed1918407 100644--- a/Tests/LibGC/TestGCFunction.cpp+++ b/Tests/LibGC/TestGCFunction.cpp@@ -52,6 +52,8 @@ private:GC_DEFINE_ALLOCATOR(CellWithFunction);struct DestructionFlag {+ GC_HOLDS_NO_CELL_EDGES;+AK_ALLOC_WITH_KMALLOC;explicit DestructionFlag(bool& destroyed)@@ -64,10 +66,41 @@ struct DestructionFlag {};struct RunState : RefCounted<RunState> {+ GC_HOLDS_NO_CELL_EDGES;+GC::Weak<GC::Function<void()>> function;bool survived_collection { false };};+struct CountedWithCell : RefCounted<CountedWithCell> {+ GC::Ptr<TestCell> cell;+};++struct CountedWithoutCells : RefCounted<CountedWithoutCells> {+ GC_HOLDS_NO_CELL_EDGES;+};++struct CountedAndTraced : RefCounted<CountedAndTraced> {+ GC::Ptr<TestCell> cell;++ void visit_edges(GC::Cell::Visitor& visitor) { visitor.visit(cell); }+};++// Nothing can reach a capture without saying how it is traced, also not through a counted or owning pointer.+static_assert(!GC::IsCapturable<CountedWithCell>);+static_assert(!GC::IsCapturable<NonnullRefPtr<CountedWithCell>>);+static_assert(!GC::IsCapturable<RefPtr<CountedWithCell>>);+static_assert(!GC::IsCapturable<OwnPtr<CountedWithCell>>);+static_assert(!GC::IsCapturable<NonnullOwnPtr<CountedWithCell>>);+static_assert(!GC::IsCapturable<Vector<NonnullRefPtr<CountedWithCell>>>);+static_assert(!GC::IsCapturable<AK::Function<void()>>);+static_assert(!GC::IsCapturable<int*>);+static_assert(GC::IsCapturable<NonnullRefPtr<CountedWithoutCells>>);+static_assert(GC::IsCapturable<NonnullRefPtr<CountedWithoutCells const>>);+static_assert(GC::IsCapturable<OwnPtr<CountedWithoutCells>>);+static_assert(GC::IsCapturable<NonnullRefPtr<CountedAndTraced>>);+static_assert(GC::IsCapturable<Optional<RefPtr<CountedAndTraced>>>);+struct Holders {GC::Root<GC::Function<int()>> function;GC::Weak<TestCell> cell;diff --git a/Tests/LibJS/TestVMThreads.cpp b/Tests/LibJS/TestVMThreads.cppindex af2e00cb14f..4198f4097c6 100644--- a/Tests/LibJS/TestVMThreads.cpp+++ b/Tests/LibJS/TestVMThreads.cpp@@ -316,6 +316,8 @@ static constexpr StringView NEVER_ENDING_PROMISE_JOBS[] = {// NB: The native function the script calls sets this, so it is shared with the function's captures.struct JobRanFlag : AtomicRefCounted<JobRanFlag> {+ GC_HOLDS_NO_CELL_EDGES;+Atomic<bool> value { false };};diff --git a/Tests/LibWeb/TestFetchAlgorithms.cpp b/Tests/LibWeb/TestFetchAlgorithms.cppindex b70efbe49c9..9a14da89492 100644--- a/Tests/LibWeb/TestFetchAlgorithms.cpp+++ b/Tests/LibWeb/TestFetchAlgorithms.cpp@@ -30,6 +30,8 @@ namespace {// What the algorithms of a fetch saw, which the test reads once they have run.struct AlgorithmCalls : RefCounted<AlgorithmCalls> {+ GC_HOLDS_NO_CELL_EDGES;+Vector<StringView> calls;Vector<GC::Root<ResponseView>> responses;Optional<ByteBuffer> consumed_bytes;diff --git a/Tests/LibWeb/TestFetchBodyStream.cpp b/Tests/LibWeb/TestFetchBodyStream.cppindex c83510e3b4f..462640c4821 100644--- a/Tests/LibWeb/TestFetchBodyStream.cpp+++ b/Tests/LibWeb/TestFetchBodyStream.cpp@@ -134,6 +134,8 @@ struct BodyStreamHarness {};struct SniffWaiter : RefCounted<SniffWaiter> {+ GC_HOLDS_NO_CELL_EDGES;+size_t wake_count { 0 };ByteBuffer bytes;Optional<Body::SniffOutcome> outcome;@@ -151,6 +153,8 @@ struct SniffWaiter : RefCounted<SniffWaiter> {// A value that the callbacks of a test change, and the test reads afterwards.template<typename T>struct SharedValue : RefCounted<SharedValue<T>> {+ GC_HOLDS_NO_CELL_EDGES;+T value {};};diff --git a/Tests/LibWeb/TestWindowProxyWorld.cpp b/Tests/LibWeb/TestWindowProxyWorld.cppindex 7f0215af484..f687e416bfa 100644--- a/Tests/LibWeb/TestWindowProxyWorld.cpp+++ b/Tests/LibWeb/TestWindowProxyWorld.cpp@@ -70,6 +70,8 @@ GC_DEFINE_ALLOCATOR(TestPageClient);}struct ListenerCall : RefCounted<ListenerCall> {+ GC_HOLDS_NO_CELL_EDGES;+bool value { false };};diff --git a/Tests/LibWeb/TestWorldCallback.cpp b/Tests/LibWeb/TestWorldCallback.cppindex 22fc2b7783f..6dd290e3e7f 100644--- a/Tests/LibWeb/TestWorldCallback.cpp+++ b/Tests/LibWeb/TestWorldCallback.cpp@@ -30,6 +30,8 @@ static void install_test_host_defined(JS::Realm& realm, Web::Bindings::WrapperWo}struct ListenerCall : RefCounted<ListenerCall> {+ GC_HOLDS_NO_CELL_EDGES;+bool value { false };};diff --git a/Tests/LibWeb/TestWrapperWorld.cpp b/Tests/LibWeb/TestWrapperWorld.cppindex e5caf12438c..bb334a5b741 100644--- a/Tests/LibWeb/TestWrapperWorld.cpp+++ b/Tests/LibWeb/TestWrapperWorld.cpp@@ -875,6 +875,8 @@ TEST_CASE(cross_origin_descriptor_cache_does_not_root_realm_after_wrapper_dies)}struct TimerFired : RefCounted<TimerFired> {+ GC_HOLDS_NO_CELL_EDGES;+bool value { false };};diff --git a/Utilities/wasm.cpp b/Utilities/wasm.cppindex 8c50835db64..64d9f5b0edd 100644--- a/Utilities/wasm.cpp+++ b/Utilities/wasm.cpp@@ -45,6 +45,8 @@ using WasmValue = Wasm::Runtime::Value;// What a host function's "invoke" calls back into. NB: Both live in main() for as long as the utility runs.struct ReentryTarget : RefCounted<ReentryTarget> {+ GC_HOLDS_NO_CELL_EDGES;+ReentryTarget(Wasm::Runtime::Store& store, Entity& main_instance): store(store), main_instance(main_instance)