Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5f4afbfb124bccafc186db3e34984d6aabd61a07
      
https://github.com/WebKit/WebKit/commit/5f4afbfb124bccafc186db3e34984d6aabd61a07
  Author: Adrian Taylor <[email protected]>
  Date:   2026-09-30 (Wed, 30 Sep 2026)

  Changed paths:
    M Source/WTF/wtf/PlatformEnable.h
    M Source/WTF/wtf/RefCountable.h
    M Source/WTF/wtf/RefCounted.h
    M Source/WTF/wtf/RunLoop.h
    M Source/WTF/wtf/SwiftBridging.h
    M Source/WTF/wtf/ThreadSafeRefCounted.h
    M Source/WTF/wtf/ThreadSafeWeakPtr.h
    M Source/WTF/wtf/glib/ActivityObserver.h
    M Source/WTF/wtf/glib/RunLoopGLib.cpp
    M Source/WebCore/platform/RunLoopObserver.h
    M Source/WebGPU/WebGPU/Buffer.swift
    M Source/WebGPU/WebGPU/CommandBuffer.h
    M Source/WebGPU/WebGPU/CommandEncoder.h
    M Source/WebGPU/WebGPU/ComputePassEncoder.h
    M Source/WebGPU/WebGPU/Device.h
    M Source/WebGPU/WebGPU/Queue.h
    M Source/WebGPU/WebGPU/RenderPassEncoder.h
    M Source/WebGPU/WebGPUCpp.h
    M Source/WebKit/ModelProcess/cocoa/WKUSDStageConverter.swift
    M Source/WebKit/Platform/IPC/Connection.cpp
    M Source/WebKit/Platform/IPC/Connection.h
    M Source/WebKit/Platform/IPC/StreamServerConnection.h
    M Source/WebKit/Scripts/webkit/messages.py
    M Source/WebKit/Scripts/webkit/tests/TestWithStreamSwiftEnabledByMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithStreamSwiftMessages.h
    M 
Source/WebKit/Scripts/webkit/tests/TestWithSwiftConditionallyAndEnabledByMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithSwiftConditionallyMessages.h
    M Source/WebKit/Scripts/webkit/tests/TestWithSwiftMessages.h
    M Source/WebKit/Shared/API/APIArray.h
    M Source/WebKit/Shared/API/APIObject.h
    M Source/WebKit/Shared/RunJavaScriptResult.swift
    M Source/WebKit/Shared/SessionState.h
    M Source/WebKit/Shared/WebBackForwardListFrameItem.h
    M Source/WebKit/Shared/WebBackForwardListItem.h
    M Source/WebKit/UIProcess/AuxiliaryProcessProxy.h
    M Source/WebKit/UIProcess/BrowsingContextGroup.h
    M Source/WebKit/UIProcess/Cocoa/Separated/WKSeparatedImageView.swift
    M Source/WebKit/UIProcess/Extensions/WebExtensionURLSchemeHandler.h
    M Source/WebKit/UIProcess/SuspendedPageProxy.h
    M Source/WebKit/UIProcess/WebBackForwardCache.h
    M Source/WebKit/UIProcess/WebBackForwardCacheEntry.h
    M Source/WebKit/UIProcess/WebFrameProxy.h
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/WebPreferences.h
    M Source/WebKit/UIProcess/WebProcessProxy.h
    M Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
    M Source/cmake/OptionsCocoa.cmake
    M Source/cmake/WebKitFeatures.cmake
    M Tools/TestWebKitAPI/Tests/WTF/glib/ActivityObserver.cpp

  Log Message:
  -----------
  Ref count base types
https://bugs.webkit.org/show_bug.cgi?id=303818
rdar://166126888

Reviewed by Richard Robinson.

This adds Swift reference-counting annotations to WTF's main reference counted
base types, such that all derived types are treated as reference types when
manipulated in Swift code.

This is obviously much better as it will avoid the need to annotate a large
proliferation of derived types as Swift usage increases.

However, this has not been possible until now due to a couple of Swift language
improvements we needed:

rdar://160696723 / https://github.com/swiftlang/swift/pull/84343:
- This allows such annotations to refer to member functions.

rdar://162195228 / https://github.com/swiftlang/swift/pull/85711:
- Fixes a crash in the Swift compiler which occurred when we ref counted
  everything like this.

rdar://166227787 / https://github.com/swiftlang/swift/pull/86124
- Behavior difference

rdar://172291423 and/or rdar://185366787
- Swift compiler crash possibly caused by WebKit modularisation quirks

Because base class annotations don't work with older compilers, they are gated
behind a new ENABLE(SWIFT_BASE_CLASS_ANNOTATIONS), which requires Swift 6.4.
On Cocoa ports PlatformEnable.h enables it for SDKs >= 27, as a proxy for the
compiler version. Other ports get it from a CMake option which defaults to on
when the detected Swift compiler is 6.4 or newer; older toolchains do not apply
annotations inherited from base classes. Derived types which were previously
annotated now use DERIVED_CLASS_SWIFT_SHARED_REFERENCE, which expands to 
nothing when
base class annotations are enabled (the annotation is inherited) and to
SWIFT_SHARED_REFERENCE + SWIFT_RETURNED_AS_UNRETAINED_BY_DEFAULT otherwise; the
ref/deref helper functions they name are only defined in the latter case. The
base classes use BASE_CLASS_SWIFT_SHARED_REFERENCE, which is the inverse.
Types which don't inherit from an annotated base, or which inherit from more
than one annotated base (such as WebGPU types which also derive from an
annotated WGPU*Impl), keep their explicit SWIFT_SHARED_REFERENCE.

This has also required us to inline some glib runloop code to avoid forward
declarations, and to remove some ambiguity between wtf.Logger and os.Logger.

* Source/WTF/wtf/PlatformEnable.h:
* Source/cmake/OptionsCocoa.cmake:
* Source/cmake/WebKitFeatures.cmake:
* Source/WTF/wtf/SwiftBridging.h:
* Source/WTF/wtf/RefCountable.h:
* Source/WTF/wtf/RefCounted.h:
(WTF::RefCounted::swiftRef const):
* Source/WTF/wtf/ThreadSafeRefCounted.h:
(WTF::ThreadSafeRefCounted::swiftRef const):
* Source/WTF/wtf/ThreadSafeWeakPtr.h:
* Source/WebGPU/WebGPU/CommandBuffer.h:
* Source/WebGPU/WebGPU/CommandEncoder.h:
* Source/WebGPU/WebGPU/ComputePassEncoder.h:
* Source/WebGPU/WebGPU/Device.h:
* Source/WebGPU/WebGPU/Queue.h:
* Source/WebGPU/WebGPU/RenderPassEncoder.h:
* Source/WebGPU/WebGPUCpp.h:
* Source/WebKit/Platform/IPC/Connection.h:
* Source/WebKit/Platform/IPC/StreamServerConnection.h:
* Source/WebKit/Scripts/webkit/messages.py:
(generate_messages_header):
(generate_messages_header.append_message_forwarder_class_for_swift):
* Source/WebKit/Scripts/webkit/tests/TestWithStreamSwiftEnabledByMessages.h:
* Source/WebKit/Scripts/webkit/tests/TestWithStreamSwiftMessages.h:
* 
Source/WebKit/Scripts/webkit/tests/TestWithSwiftConditionallyAndEnabledByMessages.h:
* Source/WebKit/Scripts/webkit/tests/TestWithSwiftConditionallyMessages.h:
* Source/WebKit/Scripts/webkit/tests/TestWithSwiftMessages.h:
* Source/WebKit/Shared/API/APIArray.h:
* Source/WebKit/Shared/API/APIObject.h:
(API::ObjectImpl::operator new): Deleted.
(API::Object::wrap): Deleted.
(API::Object::unwrap): Deleted.
(refObject): Deleted.
(derefObject): Deleted.
* Source/WebKit/Shared/SessionState.h:
* Source/WebKit/Shared/WebBackForwardListFrameItem.h:
* Source/WebKit/Shared/WebBackForwardListItem.h:
* Source/WebKit/UIProcess/AuxiliaryProcessProxy.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionURLSchemeHandler.h:
* Source/WebKit/UIProcess/BrowsingContextGroup.h:
* Source/WebKit/UIProcess/SuspendedPageProxy.h:
* Source/WebKit/UIProcess/WebBackForwardCache.h:
* Source/WebKit/UIProcess/WebBackForwardCacheEntry.h:
* Source/WebKit/UIProcess/WebFrameProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPreferences.h:
* Source/WebKit/UIProcess/WebProcessProxy.h:
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h:
* Source/WebGPU/WebGPU/Buffer.swift:
* Source/WebKit/Shared/RunJavaScriptResult.swift:
* Source/WTF/wtf/RunLoop.h:
(WTF::ActivityObserver::create):
(WTF::ActivityObserver::~ActivityObserver):
(WTF::ActivityObserver::start):
(WTF::ActivityObserver::stop):
(WTF::ActivityObserver::order const):
(WTF::ActivityObserver::activities const):
(WTF::ActivityObserver::notify):
(WTF::ActivityObserver::ActivityObserver):
* Source/WTF/wtf/glib/ActivityObserver.h:
(WTF::ActivityObserver::create): Deleted.
(WTF::ActivityObserver::~ActivityObserver): Deleted.
(WTF::ActivityObserver::start): Deleted.
(WTF::ActivityObserver::stop): Deleted.
(WTF::ActivityObserver::order const): Deleted.
(WTF::ActivityObserver::activities const): Deleted.
(WTF::ActivityObserver::notify): Deleted.
(WTF::ActivityObserver::ActivityObserver): Deleted.
(): Deleted.
* Source/WTF/wtf/glib/RunLoopGLib.cpp:
* Source/WebCore/platform/RunLoopObserver.h:
* Tools/TestWebKitAPI/Tests/WTF/glib/ActivityObserver.cpp:
* Source/WebKit/ModelProcess/cocoa/WKUSDStageConverter.swift:
* Source/WebKit/UIProcess/Cocoa/Separated/WKSeparatedImageView.swift:
* Source/WebKit/Platform/IPC/Connection.cpp:

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



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

Reply via email to