[webkit-changes] [WebKit/WebKit] dc904e: Introduce a CompactVariant for efficient variants ...

Sam Weinig noreply at github.com
Tue Dec 24 07:30:33 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: dc904eb4098bab9698ede556c0f2cc6b9955d9ab
      https://github.com/WebKit/WebKit/commit/dc904eb4098bab9698ede556c0f2cc6b9955d9ab
  Author: Sam Weinig <sam at webkit.org>
  Date:   2024-12-24 (Tue, 24 Dec 2024)

  Changed paths:
    M Source/WTF/WTF.xcodeproj/project.pbxproj
    M Source/WTF/wtf/CMakeLists.txt
    A Source/WTF/wtf/CompactVariant.h
    A Source/WTF/wtf/CompactVariantOperations.h
    A Source/WTF/wtf/VariantExtras.h
    M Source/WTF/wtf/VariantList.h
    M Source/WTF/wtf/VariantListOperations.h
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    A Tools/TestWebKitAPI/Tests/WTF/CompactVariant.cpp
    M Tools/TestWebKitAPI/Tests/WTF/LifecycleLogger.h
    M Tools/TestWebKitAPI/Tests/WTF/VariantList.cpp

  Log Message:
  -----------
  Introduce a CompactVariant for efficient variants of pointers and types smaller than 56 bits
https://bugs.webkit.org/show_bug.cgi?id=285099

Reviewed by Darin Adler.

Adds `WTF::CompactVariant`.

A `WTF::CompactVariant` acts like a `std::variant` with the following differences:
- All alternatives must be pointers, smart pointers, have size of 56 bits or fewer,
  or be specialized for `CompactVariantTraits`.
- It can only contain 254 or fewer alternatives.
- Has a more limited API, only offering `holds_alternative()` for type checking and
  `switchOn()` for value access.

Factors out a few share helpers from VariantList into a VariantExtras.h file.

* Source/WTF/WTF.xcodeproj/project.pbxproj:
* Source/WTF/wtf/CMakeLists.txt:
* Source/WTF/wtf/CompactVariant.h: Added.
* Source/WTF/wtf/CompactVariantOperations.h: Added.
* Source/WTF/wtf/VariantExtras.h: Added.
* Source/WTF/wtf/VariantList.h:
* Source/WTF/wtf/VariantListOperations.h:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WTF/CompactVariant.cpp: Added.
* Tools/TestWebKitAPI/Tests/WTF/LifecycleLogger.h:

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



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


More information about the webkit-changes mailing list