Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 097a8276c97afa7e42b6e901bbe5e100af33ae48
      
https://github.com/WebKit/WebKit/commit/097a8276c97afa7e42b6e901bbe5e100af33ae48
  Author: Geoffrey Garen <[email protected]>
  Date:   2026-05-19 (Tue, 19 May 2026)

  Changed paths:
    M Source/JavaScriptCore/runtime/Exception.h
    M Source/WTF/wtf/Variant.h
    M Source/WebCore/Modules/indexeddb/IDBKey.h
    M Source/WebCore/SaferCPPExpectations/UncheckedCallArgsCheckerExpectations
    M Source/WebCore/css/CSSGridLineValue.h
    M Source/WebCore/css/calc/CSSCalcValue.h
    M Source/WebCore/css/typedom/color/CSSOMColorValue.h
    M Source/WebCore/platform/cocoa/SharedBufferCocoa.mm
    M Source/WebCore/platform/graphics/GraphicsContextState.h
    M Source/WebCore/platform/graphics/cg/ImageBackingStoreCG.cpp
    M Source/WebCore/platform/network/FormData.h
    M Source/WebCore/style/calc/StyleCalculationValue.h
    M Source/WebCore/svg/SVGPathElement.cpp
    M Tools/TestWebKitAPI/Tests/WTF/Expected.cpp

  Log Message:
  -----------
  [Build Speed] Simplify WTF::Variant
https://bugs.webkit.org/show_bug.cgi?id=315055
rdar://177382367

Reviewed by Brent Fulgham.

Saves 30s (5%) wall time in a clean build.

mpark::variant, like std::variant, uses O(n) and O(n^2) template instantiation
to support pre-C++20, plus edge case features we don't use in WebKit:

    * constexpr construction with a non-empty initializer

    * precise std library feature detection for degenerate copyable / movable
    combinations (e.g. a type that can move-construct but can't move-assign)

    * precise std library feature detection for degenerate trivial combinations
    (e.g. a type that has a non-trivial constructor but a trivial destructor)

Since we're overriding std::variant anyway, let's take the opportunity to
improve compile time.

This patch replaces the giant dispatcher switch with C++20 parameter pack
expansion, and a recursive union with a simple byte buffer.

This changes edge case constexpr and degenerate feature detection like so:

    * A non-empty Variant initializer is no longer constexpr.

    * If T has copy / move constructors, then Variant<T> is copyable / movable
    (even if T has no copy / move assignment operators).

    * If T has any non-trivial special member functions, then Variant<T> is
    non-trivial (even if T has some trivial special member functions).

These are good defaults because they meet all existing use cases and 
dramatically
improve compile time.

If a future use case wants the edge case features above, and is willing to
spend O(n^2) time to get them, that case can use std::variant.

No regressions in upstream mpark::variant tests, with the exception of the
constexpr thing. (The other two things are so edge-case-y that they aren't even
tested.)

* Source/WTF/wtf/Variant.h:
* Tools/TestWebKitAPI/Tests/WTF/Expected.cpp:

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



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

Reply via email to