haikuwebkit/Source/WTF/wtf/Markable.h

174 lines
6.0 KiB
C
Raw Permalink Normal View History

[WTF] Add Markable<T, Traits> https://bugs.webkit.org/show_bug.cgi?id=189231 Reviewed by Sam Weinig. Source/WebCore: Use Markable<Seconds> and Markable<WallTime> in ResourceResponseBase. Since these fields are parsed results from http header fields, Seconds::nan() and WallTime::nan() can be used as an empty value for these fields. Thus we can use Markable because it uses these nan values as an empty values (they are configured by Seconds::MarkableTraits and WallTime::MarkableTraits). This reduces the size of ResourceResponseBase from 448 to 416. * platform/network/ResourceResponseBase.h: Source/WTF: We can represent a value with nullopt by using std::optional<T>. However, std::optional<T> has storage efficiency problem. It always has a bool indicating that the value is nullopt or not. If we have a following class, class A { std::optional<WallTime> m_timeA; std::optional<WallTime> m_timeB; std::optional<WallTime> m_timeC; }; This class has significant amount of padding between m_timeA / m_timeB, m_timeB / m_timeC due to the above bool. If we know that WallTime has a value that represents invalid, we can use it instead and save the storage. This is very similar problem to our HashTable implementation. In our HashTable implementation, we need Deleted and Empty value, which can represent Deleted and Empty values without sacrificing storage efficiency. We should have similar mechanism here. In this patch, we have WTF::Markable<T, Traits>. Traits offers `Traits::isEmptyValue(value)` and `Traits::emptyValue()`. Then, we use this empty value instead of having bool flag. This way, we can make `sizeof(WTF::Markable<T>) == sizeof(T)`. This idea is inspired from https://github.com/akrzemi1/markable. But we would like to have WTF::Markable<T> here instead of importing it since we would like to have (1) integrated interfaces with std::optional<T> and (2) aligned function names to HashTraits' `isEmptyValue` and `emptyValue`. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Markable.h: Added. (WTF::std::underlying_type<EnumType>::type>::max): EnumMarkableTraits can be used as an MarkableTraits for enum values. We can specify a constant value as an empty value. (WTF::IntegralMarkableTraits::isEmptyValue): (WTF::IntegralMarkableTraits::emptyValue): IntegralMarkableTraits can be used as an MarkableTraits for integral types including int etc. (WTF::Markable::Markable): (WTF::Markable::operator bool const): (WTF::Markable::reset): (WTF::Markable::value const): (WTF::Markable::value): (WTF::Markable::operator-> const): (WTF::Markable::operator->): (WTF::Markable::operator* const): (WTF::Markable::operator*): (WTF::Markable::operator std::optional<T>): (WTF::Markable::operator std::optional<T> const): This operator allows us to cast Markable<T> to std::optional<T>. * wtf/MonotonicTime.h: (WTF::MonotonicTime::MarkableTraits::isEmptyValue): (WTF::MonotonicTime::MarkableTraits::emptyValue): MarkableTraits for MonotonicTime. MonotonicTime::nan() is used as an empty value. * wtf/Seconds.h: (WTF::Seconds::MarkableTraits::isEmptyValue): (WTF::Seconds::MarkableTraits::emptyValue): MarkableTraits for Seconds. Seconds::nan() is used as an empty value. * wtf/WallTime.h: (WTF::WallTime::nan): (WTF::WallTime::MarkableTraits::isEmptyValue): (WTF::WallTime::MarkableTraits::emptyValue): MarkableTraits for WallTime. WallTime::nan() is used as an empty value. Tools: Add tests for Markable. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/Markable.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/204438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-10 18:19:09 +00:00
/*
* Copyright (C) 2018 Yusuke Suzuki <yusukesuzuki@slowstart.org>.
* Copyright (C) 2016-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// The idea of Markable<T> is derived from markable<T> at
// https://github.com/akrzemi1/markable.
//
// Copyright (C) 2015-2018 Andrzej Krzemienski.
//
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#pragma once
Remove <wtf/Optional.h> https://bugs.webkit.org/show_bug.cgi?id=226437 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Remove include of <wtf/Optional.h>. * inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py: (CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes): Don't generate an include of wtf/Optional.h; including WTFString.h takes care of this anyway. * inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py: (CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes): Ditto. * inspector/scripts/codegen/generate_cpp_protocol_types_header.py: (CppProtocolTypesHeaderGenerator._generate_secondary_header_includes): Ditto. * inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py: (CppProtocolTypesImplementationGenerator.generate_output): Generate an include of <optional> instead of <wtf/Optional.h>. * inspector/scripts/tests/expected/*: Regenerate. Source/WebCore: * <many files>: Removed include of <wtf/Optional.h>. * platform/graphics/Font.h: Tweaked style a bit. * Modules/geolocation/GeolocationClient.h: Added include of <optional>. * Modules/mediastream/DoubleRange.h: Ditto. * Modules/mediastream/LongRange.h: Ditto. * Modules/webauthn/AuthenticationExtensionsClientOutputs.h: Ditto. * css/CSSToLengthConversionData.h: Ditto. * css/DOMMatrix2DInit.h: Ditto. * dom/AddEventListenerOptions.h: Ditto. * dom/DeviceMotionData.h: Ditto. * dom/DeviceOrientationData.h: Ditto. * dom/SuccessOr.h: Ditto. * html/DateTimeFieldsState.h: Ditto. * html/ImageBitmapOptions.h: Ditto. * html/canvas/PredefinedColorSpace.h: Ditto. * layout/LayoutPhase.h: Ditto. * layout/MarginTypes.h: Ditto. * loader/ResourceLoadNotifier.h: Ditto. * page/RuntimeEnabledFeatures.h: Ditto. * page/ScrollOptions.h: Ditto. * platform/MediaCapabilitiesInfo.h: Ditto. * platform/cocoa/SystemBattery.h: Ditto. * platform/graphics/DecodingOptions.h: Ditto. * platform/graphics/DestinationColorSpace.h: Ditto. * platform/graphics/DisplayRefreshMonitorClient.h: Ditto. * platform/graphics/FloatLine.h: Ditto. * platform/graphics/gpu/GPURequestAdapterOptions.h: Ditto. * platform/graphics/x11/PlatformDisplayX11.h: Ditto. * platform/ios/SelectionGeometry.h: Ditto. * platform/mac/NSScrollerImpDetails.h: Ditto. * platform/network/DNS.h: Ditto. * platform/text/EncodingTables.h: Ditto. * platform/text/TextCodecCJK.h: Ditto. * platform/text/TextCodecUTF16.h: Ditto. * platform/text/TextFlags.h: Ditto. Source/WebCore/PAL: * pal/SessionID.h: Include <optional>. * pal/crypto/gcrypt/Utilities.h: Ditto. * pal/crypto/tasn1/Utilities.cpp: Removed include of <wtf/Optional.h>. Source/WebDriver: * SessionHost.h: Removed include of <wtf/Optional.h>. Source/WebKit: * <many files>: Removed include of <wtf/Optional.h>. Source/WebKitLegacy/mac: * DOM/DOMRangeInternal.h: Added import of <optional>. * WebView/WebGeolocationPosition.mm: Removed import of <wtf/Optional.h>. * WebView/WebGeolocationPositionInternal.h: Added import of <optional>. Source/WTF: * <many files>: Removed include of <wtf/Optional.h>. * WTF.xcodeproj/project.pbxproj: Removed Optional.h. * wtf/Markable.h: Added include of <optional>. * wtf/OptionSet.h: Ditto. * wtf/Optional.h: Emptied this file. On the Windows build system, we can't seem to build successfully without an empty file here. The copied forwarding header seems to linger even if we remove the original. Until we fix the Windows build system, if we want to support incremental builds, we need to keep this empty file around. * wtf/PrintStream.h: Added include of <optional>. * wtf/Seconds.h: Ditto. * wtf/StackTrace.h: Ditto. * wtf/StdLibExtras.h: Moved the valueOrCompute function here from Optional.h. Re-sorted the "using" at the bottom of the file. * wtf/URLHelpers.h: Added include of <optional>. * wtf/Vector.h: Ditto. Tools: * <many files>: Removed include of <wtf/Optional.h>. Canonical link: https://commits.webkit.org/238372@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278340 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-02 06:45:51 +00:00
#include <optional>
[WTF] Add Markable<T, Traits> https://bugs.webkit.org/show_bug.cgi?id=189231 Reviewed by Sam Weinig. Source/WebCore: Use Markable<Seconds> and Markable<WallTime> in ResourceResponseBase. Since these fields are parsed results from http header fields, Seconds::nan() and WallTime::nan() can be used as an empty value for these fields. Thus we can use Markable because it uses these nan values as an empty values (they are configured by Seconds::MarkableTraits and WallTime::MarkableTraits). This reduces the size of ResourceResponseBase from 448 to 416. * platform/network/ResourceResponseBase.h: Source/WTF: We can represent a value with nullopt by using std::optional<T>. However, std::optional<T> has storage efficiency problem. It always has a bool indicating that the value is nullopt or not. If we have a following class, class A { std::optional<WallTime> m_timeA; std::optional<WallTime> m_timeB; std::optional<WallTime> m_timeC; }; This class has significant amount of padding between m_timeA / m_timeB, m_timeB / m_timeC due to the above bool. If we know that WallTime has a value that represents invalid, we can use it instead and save the storage. This is very similar problem to our HashTable implementation. In our HashTable implementation, we need Deleted and Empty value, which can represent Deleted and Empty values without sacrificing storage efficiency. We should have similar mechanism here. In this patch, we have WTF::Markable<T, Traits>. Traits offers `Traits::isEmptyValue(value)` and `Traits::emptyValue()`. Then, we use this empty value instead of having bool flag. This way, we can make `sizeof(WTF::Markable<T>) == sizeof(T)`. This idea is inspired from https://github.com/akrzemi1/markable. But we would like to have WTF::Markable<T> here instead of importing it since we would like to have (1) integrated interfaces with std::optional<T> and (2) aligned function names to HashTraits' `isEmptyValue` and `emptyValue`. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Markable.h: Added. (WTF::std::underlying_type<EnumType>::type>::max): EnumMarkableTraits can be used as an MarkableTraits for enum values. We can specify a constant value as an empty value. (WTF::IntegralMarkableTraits::isEmptyValue): (WTF::IntegralMarkableTraits::emptyValue): IntegralMarkableTraits can be used as an MarkableTraits for integral types including int etc. (WTF::Markable::Markable): (WTF::Markable::operator bool const): (WTF::Markable::reset): (WTF::Markable::value const): (WTF::Markable::value): (WTF::Markable::operator-> const): (WTF::Markable::operator->): (WTF::Markable::operator* const): (WTF::Markable::operator*): (WTF::Markable::operator std::optional<T>): (WTF::Markable::operator std::optional<T> const): This operator allows us to cast Markable<T> to std::optional<T>. * wtf/MonotonicTime.h: (WTF::MonotonicTime::MarkableTraits::isEmptyValue): (WTF::MonotonicTime::MarkableTraits::emptyValue): MarkableTraits for MonotonicTime. MonotonicTime::nan() is used as an empty value. * wtf/Seconds.h: (WTF::Seconds::MarkableTraits::isEmptyValue): (WTF::Seconds::MarkableTraits::emptyValue): MarkableTraits for Seconds. Seconds::nan() is used as an empty value. * wtf/WallTime.h: (WTF::WallTime::nan): (WTF::WallTime::MarkableTraits::isEmptyValue): (WTF::WallTime::MarkableTraits::emptyValue): MarkableTraits for WallTime. WallTime::nan() is used as an empty value. Tools: Add tests for Markable. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/Markable.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/204438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-10 18:19:09 +00:00
#include <type_traits>
#include <wtf/StdLibExtras.h>
namespace WTF {
// Example:
// enum class Type { Value1, Value2, Value3 };
// Markable<Type, EnumMarkableTraits<Type, 42>> optional;
template<
typename EnumType,
typename std::underlying_type<EnumType>::type constant = std::numeric_limits<typename std::underlying_type<EnumType>::type>::max()>
struct EnumMarkableTraits {
static_assert(std::is_enum<EnumType>::value, "");
using UnderlyingType = typename std::underlying_type<EnumType>::type;
constexpr static bool isEmptyValue(EnumType value)
{
return static_cast<UnderlyingType>(value) == constant;
}
constexpr static EnumType emptyValue()
{
return static_cast<EnumType>(constant);
}
};
template<typename IntegralType, IntegralType constant = 0>
struct IntegralMarkableTraits {
static_assert(std::is_integral<IntegralType>::value, "");
constexpr static bool isEmptyValue(IntegralType value)
{
return value == constant;
}
constexpr static IntegralType emptyValue()
{
return constant;
}
};
wtf/Optional.h: move-constructor and move-assignment operator should disengage the value being moved from https://bugs.webkit.org/show_bug.cgi?id=192728 <rdar://problem/46746779> Reviewed by Geoff Garen. Source/JavaScriptCore: * API/*: * Scripts/*: * assembler/*: * b3/*: * bytecode/*: * bytecompiler/*: * debugger/*: * dfg/*: * ftl/*: * heap/*: * inspector/*: * jit/*: * llint/*: * parser/*: * runtime/*: * tools/*: * wasm/*: * yarr/*: Source/WebCore: * Modules/*: * animation/*: * bindings/*: * crypto/*: * css/*: * dom/*: * editing/*: * fileapi/*: * html/*: * inspector/*: * layout/*: * loader/*: * mathml/*: * page/*: * platform/*: * plugins/*: * rendering/*: * testing/*: * workers/*: * xml/*: Source/WebCore/PAL: * pal/*: Source/WebDriver: * : Source/WebKit: * NetworkProcess/*: * Platform/*: * Scripts/*: * Shared/*: * UIProcess/*: * WebProcess/*: Source/WebKitLegacy/mac: * DOM/*: * Plugins/*: * WebCoreSupport/*: * WebView/*: Source/WebKitLegacy/win: * Plugins/*: * WebCoreSupport/*: Source/WTF: Update optional's move-constructor and move-assignment operator to disengage the value being moved from. Rename to optional to Optional, make_optional() to makeOptional(), and move class from std to WTF namespace. Based on patch by David Kilzer. * wtf/*: Tools: * DumpRenderTree/*: * MiniBrowser/*: * TestRunnerShared/*: * TestWebKitAPI/*: * WebGPUAPIStructure/*: * WebKitTestRunner/*: Canonical link: https://commits.webkit.org/207469@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239427 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-12-20 04:41:11 +00:00
// The goal of Markable is offering Optional without sacrificing storage efficiency.
[WTF] Add Markable<T, Traits> https://bugs.webkit.org/show_bug.cgi?id=189231 Reviewed by Sam Weinig. Source/WebCore: Use Markable<Seconds> and Markable<WallTime> in ResourceResponseBase. Since these fields are parsed results from http header fields, Seconds::nan() and WallTime::nan() can be used as an empty value for these fields. Thus we can use Markable because it uses these nan values as an empty values (they are configured by Seconds::MarkableTraits and WallTime::MarkableTraits). This reduces the size of ResourceResponseBase from 448 to 416. * platform/network/ResourceResponseBase.h: Source/WTF: We can represent a value with nullopt by using std::optional<T>. However, std::optional<T> has storage efficiency problem. It always has a bool indicating that the value is nullopt or not. If we have a following class, class A { std::optional<WallTime> m_timeA; std::optional<WallTime> m_timeB; std::optional<WallTime> m_timeC; }; This class has significant amount of padding between m_timeA / m_timeB, m_timeB / m_timeC due to the above bool. If we know that WallTime has a value that represents invalid, we can use it instead and save the storage. This is very similar problem to our HashTable implementation. In our HashTable implementation, we need Deleted and Empty value, which can represent Deleted and Empty values without sacrificing storage efficiency. We should have similar mechanism here. In this patch, we have WTF::Markable<T, Traits>. Traits offers `Traits::isEmptyValue(value)` and `Traits::emptyValue()`. Then, we use this empty value instead of having bool flag. This way, we can make `sizeof(WTF::Markable<T>) == sizeof(T)`. This idea is inspired from https://github.com/akrzemi1/markable. But we would like to have WTF::Markable<T> here instead of importing it since we would like to have (1) integrated interfaces with std::optional<T> and (2) aligned function names to HashTraits' `isEmptyValue` and `emptyValue`. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Markable.h: Added. (WTF::std::underlying_type<EnumType>::type>::max): EnumMarkableTraits can be used as an MarkableTraits for enum values. We can specify a constant value as an empty value. (WTF::IntegralMarkableTraits::isEmptyValue): (WTF::IntegralMarkableTraits::emptyValue): IntegralMarkableTraits can be used as an MarkableTraits for integral types including int etc. (WTF::Markable::Markable): (WTF::Markable::operator bool const): (WTF::Markable::reset): (WTF::Markable::value const): (WTF::Markable::value): (WTF::Markable::operator-> const): (WTF::Markable::operator->): (WTF::Markable::operator* const): (WTF::Markable::operator*): (WTF::Markable::operator std::optional<T>): (WTF::Markable::operator std::optional<T> const): This operator allows us to cast Markable<T> to std::optional<T>. * wtf/MonotonicTime.h: (WTF::MonotonicTime::MarkableTraits::isEmptyValue): (WTF::MonotonicTime::MarkableTraits::emptyValue): MarkableTraits for MonotonicTime. MonotonicTime::nan() is used as an empty value. * wtf/Seconds.h: (WTF::Seconds::MarkableTraits::isEmptyValue): (WTF::Seconds::MarkableTraits::emptyValue): MarkableTraits for Seconds. Seconds::nan() is used as an empty value. * wtf/WallTime.h: (WTF::WallTime::nan): (WTF::WallTime::MarkableTraits::isEmptyValue): (WTF::WallTime::MarkableTraits::emptyValue): MarkableTraits for WallTime. WallTime::nan() is used as an empty value. Tools: Add tests for Markable. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/Markable.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/204438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-10 18:19:09 +00:00
// Markable takes Traits, which should have isEmptyValue and emptyValue functions. By using
wtf/Optional.h: move-constructor and move-assignment operator should disengage the value being moved from https://bugs.webkit.org/show_bug.cgi?id=192728 <rdar://problem/46746779> Reviewed by Geoff Garen. Source/JavaScriptCore: * API/*: * Scripts/*: * assembler/*: * b3/*: * bytecode/*: * bytecompiler/*: * debugger/*: * dfg/*: * ftl/*: * heap/*: * inspector/*: * jit/*: * llint/*: * parser/*: * runtime/*: * tools/*: * wasm/*: * yarr/*: Source/WebCore: * Modules/*: * animation/*: * bindings/*: * crypto/*: * css/*: * dom/*: * editing/*: * fileapi/*: * html/*: * inspector/*: * layout/*: * loader/*: * mathml/*: * page/*: * platform/*: * plugins/*: * rendering/*: * testing/*: * workers/*: * xml/*: Source/WebCore/PAL: * pal/*: Source/WebDriver: * : Source/WebKit: * NetworkProcess/*: * Platform/*: * Scripts/*: * Shared/*: * UIProcess/*: * WebProcess/*: Source/WebKitLegacy/mac: * DOM/*: * Plugins/*: * WebCoreSupport/*: * WebView/*: Source/WebKitLegacy/win: * Plugins/*: * WebCoreSupport/*: Source/WTF: Update optional's move-constructor and move-assignment operator to disengage the value being moved from. Rename to optional to Optional, make_optional() to makeOptional(), and move class from std to WTF namespace. Based on patch by David Kilzer. * wtf/*: Tools: * DumpRenderTree/*: * MiniBrowser/*: * TestRunnerShared/*: * TestWebKitAPI/*: * WebGPUAPIStructure/*: * WebKitTestRunner/*: Canonical link: https://commits.webkit.org/207469@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239427 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-12-20 04:41:11 +00:00
// one value of T as an empty value, we can remove bool flag in Optional. This strategy is
[WTF] Add Markable<T, Traits> https://bugs.webkit.org/show_bug.cgi?id=189231 Reviewed by Sam Weinig. Source/WebCore: Use Markable<Seconds> and Markable<WallTime> in ResourceResponseBase. Since these fields are parsed results from http header fields, Seconds::nan() and WallTime::nan() can be used as an empty value for these fields. Thus we can use Markable because it uses these nan values as an empty values (they are configured by Seconds::MarkableTraits and WallTime::MarkableTraits). This reduces the size of ResourceResponseBase from 448 to 416. * platform/network/ResourceResponseBase.h: Source/WTF: We can represent a value with nullopt by using std::optional<T>. However, std::optional<T> has storage efficiency problem. It always has a bool indicating that the value is nullopt or not. If we have a following class, class A { std::optional<WallTime> m_timeA; std::optional<WallTime> m_timeB; std::optional<WallTime> m_timeC; }; This class has significant amount of padding between m_timeA / m_timeB, m_timeB / m_timeC due to the above bool. If we know that WallTime has a value that represents invalid, we can use it instead and save the storage. This is very similar problem to our HashTable implementation. In our HashTable implementation, we need Deleted and Empty value, which can represent Deleted and Empty values without sacrificing storage efficiency. We should have similar mechanism here. In this patch, we have WTF::Markable<T, Traits>. Traits offers `Traits::isEmptyValue(value)` and `Traits::emptyValue()`. Then, we use this empty value instead of having bool flag. This way, we can make `sizeof(WTF::Markable<T>) == sizeof(T)`. This idea is inspired from https://github.com/akrzemi1/markable. But we would like to have WTF::Markable<T> here instead of importing it since we would like to have (1) integrated interfaces with std::optional<T> and (2) aligned function names to HashTraits' `isEmptyValue` and `emptyValue`. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Markable.h: Added. (WTF::std::underlying_type<EnumType>::type>::max): EnumMarkableTraits can be used as an MarkableTraits for enum values. We can specify a constant value as an empty value. (WTF::IntegralMarkableTraits::isEmptyValue): (WTF::IntegralMarkableTraits::emptyValue): IntegralMarkableTraits can be used as an MarkableTraits for integral types including int etc. (WTF::Markable::Markable): (WTF::Markable::operator bool const): (WTF::Markable::reset): (WTF::Markable::value const): (WTF::Markable::value): (WTF::Markable::operator-> const): (WTF::Markable::operator->): (WTF::Markable::operator* const): (WTF::Markable::operator*): (WTF::Markable::operator std::optional<T>): (WTF::Markable::operator std::optional<T> const): This operator allows us to cast Markable<T> to std::optional<T>. * wtf/MonotonicTime.h: (WTF::MonotonicTime::MarkableTraits::isEmptyValue): (WTF::MonotonicTime::MarkableTraits::emptyValue): MarkableTraits for MonotonicTime. MonotonicTime::nan() is used as an empty value. * wtf/Seconds.h: (WTF::Seconds::MarkableTraits::isEmptyValue): (WTF::Seconds::MarkableTraits::emptyValue): MarkableTraits for Seconds. Seconds::nan() is used as an empty value. * wtf/WallTime.h: (WTF::WallTime::nan): (WTF::WallTime::MarkableTraits::isEmptyValue): (WTF::WallTime::MarkableTraits::emptyValue): MarkableTraits for WallTime. WallTime::nan() is used as an empty value. Tools: Add tests for Markable. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/Markable.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/204438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-10 18:19:09 +00:00
// similar to WTF::HashTable, which uses two values of T as an empty value and a deleted value.
// This class is intended to be used as a member of a class to compact the size of the class.
wtf/Optional.h: move-constructor and move-assignment operator should disengage the value being moved from https://bugs.webkit.org/show_bug.cgi?id=192728 <rdar://problem/46746779> Reviewed by Geoff Garen. Source/JavaScriptCore: * API/*: * Scripts/*: * assembler/*: * b3/*: * bytecode/*: * bytecompiler/*: * debugger/*: * dfg/*: * ftl/*: * heap/*: * inspector/*: * jit/*: * llint/*: * parser/*: * runtime/*: * tools/*: * wasm/*: * yarr/*: Source/WebCore: * Modules/*: * animation/*: * bindings/*: * crypto/*: * css/*: * dom/*: * editing/*: * fileapi/*: * html/*: * inspector/*: * layout/*: * loader/*: * mathml/*: * page/*: * platform/*: * plugins/*: * rendering/*: * testing/*: * workers/*: * xml/*: Source/WebCore/PAL: * pal/*: Source/WebDriver: * : Source/WebKit: * NetworkProcess/*: * Platform/*: * Scripts/*: * Shared/*: * UIProcess/*: * WebProcess/*: Source/WebKitLegacy/mac: * DOM/*: * Plugins/*: * WebCoreSupport/*: * WebView/*: Source/WebKitLegacy/win: * Plugins/*: * WebCoreSupport/*: Source/WTF: Update optional's move-constructor and move-assignment operator to disengage the value being moved from. Rename to optional to Optional, make_optional() to makeOptional(), and move class from std to WTF namespace. Based on patch by David Kilzer. * wtf/*: Tools: * DumpRenderTree/*: * MiniBrowser/*: * TestRunnerShared/*: * TestWebKitAPI/*: * WebGPUAPIStructure/*: * WebKitTestRunner/*: Canonical link: https://commits.webkit.org/207469@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239427 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-12-20 04:41:11 +00:00
// Otherwise, you should use Optional.
[WTF] Add Markable<T, Traits> https://bugs.webkit.org/show_bug.cgi?id=189231 Reviewed by Sam Weinig. Source/WebCore: Use Markable<Seconds> and Markable<WallTime> in ResourceResponseBase. Since these fields are parsed results from http header fields, Seconds::nan() and WallTime::nan() can be used as an empty value for these fields. Thus we can use Markable because it uses these nan values as an empty values (they are configured by Seconds::MarkableTraits and WallTime::MarkableTraits). This reduces the size of ResourceResponseBase from 448 to 416. * platform/network/ResourceResponseBase.h: Source/WTF: We can represent a value with nullopt by using std::optional<T>. However, std::optional<T> has storage efficiency problem. It always has a bool indicating that the value is nullopt or not. If we have a following class, class A { std::optional<WallTime> m_timeA; std::optional<WallTime> m_timeB; std::optional<WallTime> m_timeC; }; This class has significant amount of padding between m_timeA / m_timeB, m_timeB / m_timeC due to the above bool. If we know that WallTime has a value that represents invalid, we can use it instead and save the storage. This is very similar problem to our HashTable implementation. In our HashTable implementation, we need Deleted and Empty value, which can represent Deleted and Empty values without sacrificing storage efficiency. We should have similar mechanism here. In this patch, we have WTF::Markable<T, Traits>. Traits offers `Traits::isEmptyValue(value)` and `Traits::emptyValue()`. Then, we use this empty value instead of having bool flag. This way, we can make `sizeof(WTF::Markable<T>) == sizeof(T)`. This idea is inspired from https://github.com/akrzemi1/markable. But we would like to have WTF::Markable<T> here instead of importing it since we would like to have (1) integrated interfaces with std::optional<T> and (2) aligned function names to HashTraits' `isEmptyValue` and `emptyValue`. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Markable.h: Added. (WTF::std::underlying_type<EnumType>::type>::max): EnumMarkableTraits can be used as an MarkableTraits for enum values. We can specify a constant value as an empty value. (WTF::IntegralMarkableTraits::isEmptyValue): (WTF::IntegralMarkableTraits::emptyValue): IntegralMarkableTraits can be used as an MarkableTraits for integral types including int etc. (WTF::Markable::Markable): (WTF::Markable::operator bool const): (WTF::Markable::reset): (WTF::Markable::value const): (WTF::Markable::value): (WTF::Markable::operator-> const): (WTF::Markable::operator->): (WTF::Markable::operator* const): (WTF::Markable::operator*): (WTF::Markable::operator std::optional<T>): (WTF::Markable::operator std::optional<T> const): This operator allows us to cast Markable<T> to std::optional<T>. * wtf/MonotonicTime.h: (WTF::MonotonicTime::MarkableTraits::isEmptyValue): (WTF::MonotonicTime::MarkableTraits::emptyValue): MarkableTraits for MonotonicTime. MonotonicTime::nan() is used as an empty value. * wtf/Seconds.h: (WTF::Seconds::MarkableTraits::isEmptyValue): (WTF::Seconds::MarkableTraits::emptyValue): MarkableTraits for Seconds. Seconds::nan() is used as an empty value. * wtf/WallTime.h: (WTF::WallTime::nan): (WTF::WallTime::MarkableTraits::isEmptyValue): (WTF::WallTime::MarkableTraits::emptyValue): MarkableTraits for WallTime. WallTime::nan() is used as an empty value. Tools: Add tests for Markable. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/Markable.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/204438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-10 18:19:09 +00:00
template<typename T, typename Traits>
class Markable {
[WTF][JSC] Make JSC and WTF aggressively-fast-malloced https://bugs.webkit.org/show_bug.cgi?id=200611 Reviewed by Saam Barati. Source/JavaScriptCore: This patch aggressively puts many classes into FastMalloc. In JSC side, we grep `std::make_unique` etc. to find potentially system-malloc-allocated classes. After this patch, all the JSC related allocations in JetStream2 cli is done from bmalloc. In the future, it would be nice that we add `WTF::makeUnique<T>` helper function and throw a compile error if `T` is not FastMalloc annotated[1]. Putting WebKit classes in FastMalloc has many benefits. 1. Simply, it is fast. 2. vmmap can tell the amount of memory used for WebKit. 3. bmalloc can isolate WebKit memory allocation from the rest of the world. This is useful since we can know more about what component is corrupting the memory from the memory corruption crash. [1]: https://bugs.webkit.org/show_bug.cgi?id=200620 * API/ObjCCallbackFunction.mm: * assembler/AbstractMacroAssembler.h: * b3/B3PhiChildren.h: * b3/air/AirAllocateRegistersAndStackAndGenerateCode.h: * b3/air/AirDisassembler.h: * bytecode/AccessCaseSnippetParams.h: * bytecode/CallVariant.h: * bytecode/DeferredSourceDump.h: * bytecode/ExecutionCounter.h: * bytecode/GetByIdStatus.h: * bytecode/GetByIdVariant.h: * bytecode/InByIdStatus.h: * bytecode/InByIdVariant.h: * bytecode/InstanceOfStatus.h: * bytecode/InstanceOfVariant.h: * bytecode/PutByIdStatus.h: * bytecode/PutByIdVariant.h: * bytecode/ValueProfile.h: * dfg/DFGAbstractInterpreter.h: * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::newVariableAccessData): * dfg/DFGFlowIndexing.h: * dfg/DFGFlowMap.h: * dfg/DFGLiveCatchVariablePreservationPhase.cpp: (JSC::DFG::LiveCatchVariablePreservationPhase::newVariableAccessData): * dfg/DFGMaximalFlushInsertionPhase.cpp: (JSC::DFG::MaximalFlushInsertionPhase::newVariableAccessData): * dfg/DFGOSRExit.h: * dfg/DFGSpeculativeJIT.h: * dfg/DFGVariableAccessData.h: * disassembler/ARM64/A64DOpcode.h: * inspector/remote/socket/RemoteInspectorMessageParser.h: * inspector/remote/socket/RemoteInspectorSocket.h: * inspector/remote/socket/RemoteInspectorSocketEndpoint.h: * jit/PCToCodeOriginMap.h: * runtime/BasicBlockLocation.h: * runtime/DoublePredictionFuzzerAgent.h: * runtime/JSRunLoopTimer.h: * runtime/PromiseDeferredTimer.h: (JSC::PromiseDeferredTimer::create): PromiseDeferredTimer should be allocated as `Ref<>` instead of `std::unique_ptr` since it is inheriting ThreadSafeRefCounted<>. Holding such a class with std::unique_ptr could lead to potentially dangerous operations (like, someone holds it with Ref<> while it is deleted by std::unique_ptr<>). * runtime/RandomizingFuzzerAgent.h: * runtime/SymbolTable.h: * runtime/VM.cpp: (JSC::VM::VM): * runtime/VM.h: * tools/JSDollarVM.cpp: * tools/SigillCrashAnalyzer.cpp: * wasm/WasmFormat.h: * wasm/WasmMemory.cpp: * wasm/WasmSignature.h: * yarr/YarrJIT.h: Source/WebCore: Changed the accessor since we changed std::unique_ptr to Ref for this field. No behavior change. * bindings/js/WorkerScriptController.cpp: (WebCore::WorkerScriptController::addTimerSetNotification): (WebCore::WorkerScriptController::removeTimerSetNotification): Source/WTF: WTF has many data structures, in particular, containers. And these containers can be allocated like `std::make_unique<Container>()`. Without WTF_MAKE_FAST_ALLOCATED, this container itself is allocated from the system malloc. This patch attaches WTF_MAKE_FAST_ALLOCATED more aggressively not to allocate them from the system malloc. And we add some `final` to containers and classes that would be never inherited. * wtf/Assertions.cpp: * wtf/Atomics.h: * wtf/AutodrainedPool.h: * wtf/Bag.h: (WTF::Bag::Bag): Deleted. (WTF::Bag::~Bag): Deleted. (WTF::Bag::clear): Deleted. (WTF::Bag::add): Deleted. (WTF::Bag::iterator::iterator): Deleted. (WTF::Bag::iterator::operator! const): Deleted. (WTF::Bag::iterator::operator* const): Deleted. (WTF::Bag::iterator::operator++): Deleted. (WTF::Bag::iterator::operator== const): Deleted. (WTF::Bag::iterator::operator!= const): Deleted. (WTF::Bag::begin): Deleted. (WTF::Bag::begin const): Deleted. (WTF::Bag::end const): Deleted. (WTF::Bag::isEmpty const): Deleted. (WTF::Bag::unwrappedHead const): Deleted. * wtf/BitVector.h: (WTF::BitVector::BitVector): Deleted. (WTF::BitVector::~BitVector): Deleted. (WTF::BitVector::operator=): Deleted. (WTF::BitVector::size const): Deleted. (WTF::BitVector::ensureSize): Deleted. (WTF::BitVector::quickGet const): Deleted. (WTF::BitVector::quickSet): Deleted. (WTF::BitVector::quickClear): Deleted. (WTF::BitVector::get const): Deleted. (WTF::BitVector::contains const): Deleted. (WTF::BitVector::set): Deleted. (WTF::BitVector::add): Deleted. (WTF::BitVector::ensureSizeAndSet): Deleted. (WTF::BitVector::clear): Deleted. (WTF::BitVector::remove): Deleted. (WTF::BitVector::merge): Deleted. (WTF::BitVector::filter): Deleted. (WTF::BitVector::exclude): Deleted. (WTF::BitVector::bitCount const): Deleted. (WTF::BitVector::isEmpty const): Deleted. (WTF::BitVector::findBit const): Deleted. (WTF::BitVector::isEmptyValue const): Deleted. (WTF::BitVector::isDeletedValue const): Deleted. (WTF::BitVector::isEmptyOrDeletedValue const): Deleted. (WTF::BitVector::operator== const): Deleted. (WTF::BitVector::hash const): Deleted. (WTF::BitVector::iterator::iterator): Deleted. (WTF::BitVector::iterator::operator* const): Deleted. (WTF::BitVector::iterator::operator++): Deleted. (WTF::BitVector::iterator::isAtEnd const): Deleted. (WTF::BitVector::iterator::operator== const): Deleted. (WTF::BitVector::iterator::operator!= const): Deleted. (WTF::BitVector::begin const): Deleted. (WTF::BitVector::end const): Deleted. (WTF::BitVector::bitsInPointer): Deleted. (WTF::BitVector::maxInlineBits): Deleted. (WTF::BitVector::byteCount): Deleted. (WTF::BitVector::makeInlineBits): Deleted. (WTF::BitVector::cleanseInlineBits): Deleted. (WTF::BitVector::bitCount): Deleted. (WTF::BitVector::findBitFast const): Deleted. (WTF::BitVector::findBitSimple const): Deleted. (WTF::BitVector::OutOfLineBits::numBits const): Deleted. (WTF::BitVector::OutOfLineBits::numWords const): Deleted. (WTF::BitVector::OutOfLineBits::bits): Deleted. (WTF::BitVector::OutOfLineBits::bits const): Deleted. (WTF::BitVector::OutOfLineBits::OutOfLineBits): Deleted. (WTF::BitVector::isInline const): Deleted. (WTF::BitVector::outOfLineBits const): Deleted. (WTF::BitVector::outOfLineBits): Deleted. (WTF::BitVector::bits): Deleted. (WTF::BitVector::bits const): Deleted. * wtf/Bitmap.h: (WTF::Bitmap::size): Deleted. (WTF::Bitmap::iterator::iterator): Deleted. (WTF::Bitmap::iterator::operator* const): Deleted. (WTF::Bitmap::iterator::operator++): Deleted. (WTF::Bitmap::iterator::operator== const): Deleted. (WTF::Bitmap::iterator::operator!= const): Deleted. (WTF::Bitmap::begin const): Deleted. (WTF::Bitmap::end const): Deleted. * wtf/Box.h: * wtf/BumpPointerAllocator.h: * wtf/CPUTime.h: * wtf/CheckedBoolean.h: * wtf/CommaPrinter.h: (WTF::CommaPrinter::CommaPrinter): Deleted. (WTF::CommaPrinter::dump const): Deleted. (WTF::CommaPrinter::didPrint const): Deleted. * wtf/CompactPointerTuple.h: (WTF::CompactPointerTuple::encodeType): Deleted. (WTF::CompactPointerTuple::decodeType): Deleted. (WTF::CompactPointerTuple::CompactPointerTuple): Deleted. (WTF::CompactPointerTuple::pointer const): Deleted. (WTF::CompactPointerTuple::setPointer): Deleted. (WTF::CompactPointerTuple::type const): Deleted. (WTF::CompactPointerTuple::setType): Deleted. * wtf/CompilationThread.h: (WTF::CompilationScope::CompilationScope): Deleted. (WTF::CompilationScope::~CompilationScope): Deleted. (WTF::CompilationScope::leaveEarly): Deleted. * wtf/CompletionHandler.h: (WTF::CompletionHandler<Out): (WTF::Detail::CallableWrapper<CompletionHandler<Out): (WTF::CompletionHandlerCallingScope::CompletionHandlerCallingScope): Deleted. (WTF::CompletionHandlerCallingScope::~CompletionHandlerCallingScope): Deleted. (WTF::CompletionHandlerCallingScope::CompletionHandler<void): Deleted. * wtf/ConcurrentBuffer.h: (WTF::ConcurrentBuffer::ConcurrentBuffer): Deleted. (WTF::ConcurrentBuffer::~ConcurrentBuffer): Deleted. (WTF::ConcurrentBuffer::growExact): Deleted. (WTF::ConcurrentBuffer::grow): Deleted. (WTF::ConcurrentBuffer::array const): Deleted. (WTF::ConcurrentBuffer::operator[]): Deleted. (WTF::ConcurrentBuffer::operator[] const): Deleted. (WTF::ConcurrentBuffer::createArray): Deleted. * wtf/ConcurrentPtrHashSet.h: (WTF::ConcurrentPtrHashSet::contains): Deleted. (WTF::ConcurrentPtrHashSet::add): Deleted. (WTF::ConcurrentPtrHashSet::size const): Deleted. (WTF::ConcurrentPtrHashSet::Table::maxLoad const): Deleted. (WTF::ConcurrentPtrHashSet::hash): Deleted. (WTF::ConcurrentPtrHashSet::cast): Deleted. (WTF::ConcurrentPtrHashSet::containsImpl const): Deleted. (WTF::ConcurrentPtrHashSet::addImpl): Deleted. * wtf/ConcurrentVector.h: (WTF::ConcurrentVector::~ConcurrentVector): Deleted. (WTF::ConcurrentVector::size const): Deleted. (WTF::ConcurrentVector::isEmpty const): Deleted. (WTF::ConcurrentVector::at): Deleted. (WTF::ConcurrentVector::at const): Deleted. (WTF::ConcurrentVector::operator[]): Deleted. (WTF::ConcurrentVector::operator[] const): Deleted. (WTF::ConcurrentVector::first): Deleted. (WTF::ConcurrentVector::first const): Deleted. (WTF::ConcurrentVector::last): Deleted. (WTF::ConcurrentVector::last const): Deleted. (WTF::ConcurrentVector::takeLast): Deleted. (WTF::ConcurrentVector::append): Deleted. (WTF::ConcurrentVector::alloc): Deleted. (WTF::ConcurrentVector::removeLast): Deleted. (WTF::ConcurrentVector::grow): Deleted. (WTF::ConcurrentVector::begin): Deleted. (WTF::ConcurrentVector::end): Deleted. (WTF::ConcurrentVector::segmentExistsFor): Deleted. (WTF::ConcurrentVector::segmentFor): Deleted. (WTF::ConcurrentVector::subscriptFor): Deleted. (WTF::ConcurrentVector::ensureSegmentsFor): Deleted. (WTF::ConcurrentVector::ensureSegment): Deleted. (WTF::ConcurrentVector::allocateSegment): Deleted. * wtf/Condition.h: (WTF::Condition::waitUntil): Deleted. (WTF::Condition::waitFor): Deleted. (WTF::Condition::wait): Deleted. (WTF::Condition::notifyOne): Deleted. (WTF::Condition::notifyAll): Deleted. * wtf/CountingLock.h: (WTF::CountingLock::LockHooks::lockHook): Deleted. (WTF::CountingLock::LockHooks::unlockHook): Deleted. (WTF::CountingLock::LockHooks::parkHook): Deleted. (WTF::CountingLock::LockHooks::handoffHook): Deleted. (WTF::CountingLock::tryLock): Deleted. (WTF::CountingLock::lock): Deleted. (WTF::CountingLock::unlock): Deleted. (WTF::CountingLock::isHeld const): Deleted. (WTF::CountingLock::isLocked const): Deleted. (WTF::CountingLock::Count::operator bool const): Deleted. (WTF::CountingLock::Count::operator== const): Deleted. (WTF::CountingLock::Count::operator!= const): Deleted. (WTF::CountingLock::tryOptimisticRead): Deleted. (WTF::CountingLock::validate): Deleted. (WTF::CountingLock::doOptimizedRead): Deleted. (WTF::CountingLock::tryOptimisticFencelessRead): Deleted. (WTF::CountingLock::fencelessValidate): Deleted. (WTF::CountingLock::doOptimizedFencelessRead): Deleted. (WTF::CountingLock::getCount): Deleted. * wtf/CrossThreadQueue.h: * wtf/CrossThreadTask.h: * wtf/CryptographicallyRandomNumber.cpp: * wtf/DataMutex.h: * wtf/DateMath.h: * wtf/Deque.h: (WTF::Deque::size const): Deleted. (WTF::Deque::isEmpty const): Deleted. (WTF::Deque::begin): Deleted. (WTF::Deque::end): Deleted. (WTF::Deque::begin const): Deleted. (WTF::Deque::end const): Deleted. (WTF::Deque::rbegin): Deleted. (WTF::Deque::rend): Deleted. (WTF::Deque::rbegin const): Deleted. (WTF::Deque::rend const): Deleted. (WTF::Deque::first): Deleted. (WTF::Deque::first const): Deleted. (WTF::Deque::last): Deleted. (WTF::Deque::last const): Deleted. (WTF::Deque::append): Deleted. * wtf/Dominators.h: * wtf/DoublyLinkedList.h: * wtf/Expected.h: * wtf/FastBitVector.h: * wtf/FileMetadata.h: * wtf/FileSystem.h: * wtf/GraphNodeWorklist.h: * wtf/GregorianDateTime.h: (WTF::GregorianDateTime::GregorianDateTime): Deleted. (WTF::GregorianDateTime::year const): Deleted. (WTF::GregorianDateTime::month const): Deleted. (WTF::GregorianDateTime::yearDay const): Deleted. (WTF::GregorianDateTime::monthDay const): Deleted. (WTF::GregorianDateTime::weekDay const): Deleted. (WTF::GregorianDateTime::hour const): Deleted. (WTF::GregorianDateTime::minute const): Deleted. (WTF::GregorianDateTime::second const): Deleted. (WTF::GregorianDateTime::utcOffset const): Deleted. (WTF::GregorianDateTime::isDST const): Deleted. (WTF::GregorianDateTime::setYear): Deleted. (WTF::GregorianDateTime::setMonth): Deleted. (WTF::GregorianDateTime::setYearDay): Deleted. (WTF::GregorianDateTime::setMonthDay): Deleted. (WTF::GregorianDateTime::setWeekDay): Deleted. (WTF::GregorianDateTime::setHour): Deleted. (WTF::GregorianDateTime::setMinute): Deleted. (WTF::GregorianDateTime::setSecond): Deleted. (WTF::GregorianDateTime::setUtcOffset): Deleted. (WTF::GregorianDateTime::setIsDST): Deleted. (WTF::GregorianDateTime::operator tm const): Deleted. (WTF::GregorianDateTime::copyFrom): Deleted. * wtf/HashTable.h: * wtf/Hasher.h: * wtf/HexNumber.h: * wtf/Indenter.h: * wtf/IndexMap.h: * wtf/IndexSet.h: * wtf/IndexSparseSet.h: * wtf/IndexedContainerIterator.h: * wtf/Insertion.h: * wtf/IteratorAdaptors.h: * wtf/IteratorRange.h: * wtf/KeyValuePair.h: * wtf/ListHashSet.h: (WTF::ListHashSet::begin): Deleted. (WTF::ListHashSet::end): Deleted. (WTF::ListHashSet::begin const): Deleted. (WTF::ListHashSet::end const): Deleted. (WTF::ListHashSet::random): Deleted. (WTF::ListHashSet::random const): Deleted. (WTF::ListHashSet::rbegin): Deleted. (WTF::ListHashSet::rend): Deleted. (WTF::ListHashSet::rbegin const): Deleted. (WTF::ListHashSet::rend const): Deleted. * wtf/Liveness.h: * wtf/LocklessBag.h: (WTF::LocklessBag::LocklessBag): Deleted. (WTF::LocklessBag::add): Deleted. (WTF::LocklessBag::iterate): Deleted. (WTF::LocklessBag::consumeAll): Deleted. (WTF::LocklessBag::consumeAllWithNode): Deleted. (WTF::LocklessBag::~LocklessBag): Deleted. * wtf/LoggingHashID.h: * wtf/MD5.h: * wtf/MachSendRight.h: * wtf/MainThreadData.h: * wtf/Markable.h: * wtf/MediaTime.h: * wtf/MemoryPressureHandler.h: * wtf/MessageQueue.h: (WTF::MessageQueue::MessageQueue): Deleted. * wtf/MetaAllocator.h: * wtf/MonotonicTime.h: (WTF::MonotonicTime::MonotonicTime): Deleted. (WTF::MonotonicTime::fromRawSeconds): Deleted. (WTF::MonotonicTime::infinity): Deleted. (WTF::MonotonicTime::nan): Deleted. (WTF::MonotonicTime::secondsSinceEpoch const): Deleted. (WTF::MonotonicTime::approximateMonotonicTime const): Deleted. (WTF::MonotonicTime::operator bool const): Deleted. (WTF::MonotonicTime::operator+ const): Deleted. (WTF::MonotonicTime::operator- const): Deleted. (WTF::MonotonicTime::operator% const): Deleted. (WTF::MonotonicTime::operator+=): Deleted. (WTF::MonotonicTime::operator-=): Deleted. (WTF::MonotonicTime::operator== const): Deleted. (WTF::MonotonicTime::operator!= const): Deleted. (WTF::MonotonicTime::operator< const): Deleted. (WTF::MonotonicTime::operator> const): Deleted. (WTF::MonotonicTime::operator<= const): Deleted. (WTF::MonotonicTime::operator>= const): Deleted. (WTF::MonotonicTime::isolatedCopy const): Deleted. (WTF::MonotonicTime::encode const): Deleted. (WTF::MonotonicTime::decode): Deleted. * wtf/NaturalLoops.h: * wtf/NoLock.h: * wtf/OSAllocator.h: * wtf/OptionSet.h: * wtf/Optional.h: * wtf/OrderMaker.h: * wtf/Packed.h: (WTF::alignof): * wtf/PackedIntVector.h: (WTF::PackedIntVector::PackedIntVector): Deleted. (WTF::PackedIntVector::operator=): Deleted. (WTF::PackedIntVector::size const): Deleted. (WTF::PackedIntVector::ensureSize): Deleted. (WTF::PackedIntVector::resize): Deleted. (WTF::PackedIntVector::clearAll): Deleted. (WTF::PackedIntVector::get const): Deleted. (WTF::PackedIntVector::set): Deleted. (WTF::PackedIntVector::mask): Deleted. * wtf/PageBlock.h: * wtf/ParallelJobsOpenMP.h: * wtf/ParkingLot.h: * wtf/PriorityQueue.h: (WTF::PriorityQueue::size const): Deleted. (WTF::PriorityQueue::isEmpty const): Deleted. (WTF::PriorityQueue::enqueue): Deleted. (WTF::PriorityQueue::peek const): Deleted. (WTF::PriorityQueue::dequeue): Deleted. (WTF::PriorityQueue::decreaseKey): Deleted. (WTF::PriorityQueue::increaseKey): Deleted. (WTF::PriorityQueue::begin const): Deleted. (WTF::PriorityQueue::end const): Deleted. (WTF::PriorityQueue::isValidHeap const): Deleted. (WTF::PriorityQueue::parentOf): Deleted. (WTF::PriorityQueue::leftChildOf): Deleted. (WTF::PriorityQueue::rightChildOf): Deleted. (WTF::PriorityQueue::siftUp): Deleted. (WTF::PriorityQueue::siftDown): Deleted. * wtf/RandomDevice.h: * wtf/Range.h: * wtf/RangeSet.h: (WTF::RangeSet::RangeSet): Deleted. (WTF::RangeSet::~RangeSet): Deleted. (WTF::RangeSet::add): Deleted. (WTF::RangeSet::contains const): Deleted. (WTF::RangeSet::overlaps const): Deleted. (WTF::RangeSet::clear): Deleted. (WTF::RangeSet::dump const): Deleted. (WTF::RangeSet::dumpRaw const): Deleted. (WTF::RangeSet::begin const): Deleted. (WTF::RangeSet::end const): Deleted. (WTF::RangeSet::addAll): Deleted. (WTF::RangeSet::compact): Deleted. (WTF::RangeSet::overlapsNonEmpty): Deleted. (WTF::RangeSet::subsumesNonEmpty): Deleted. (WTF::RangeSet::findRange const): Deleted. * wtf/RecursableLambda.h: * wtf/RedBlackTree.h: (WTF::RedBlackTree::Node::successor const): Deleted. (WTF::RedBlackTree::Node::predecessor const): Deleted. (WTF::RedBlackTree::Node::successor): Deleted. (WTF::RedBlackTree::Node::predecessor): Deleted. (WTF::RedBlackTree::Node::reset): Deleted. (WTF::RedBlackTree::Node::parent const): Deleted. (WTF::RedBlackTree::Node::setParent): Deleted. (WTF::RedBlackTree::Node::left const): Deleted. (WTF::RedBlackTree::Node::setLeft): Deleted. (WTF::RedBlackTree::Node::right const): Deleted. (WTF::RedBlackTree::Node::setRight): Deleted. (WTF::RedBlackTree::Node::color const): Deleted. (WTF::RedBlackTree::Node::setColor): Deleted. (WTF::RedBlackTree::RedBlackTree): Deleted. (WTF::RedBlackTree::insert): Deleted. (WTF::RedBlackTree::remove): Deleted. (WTF::RedBlackTree::findExact const): Deleted. (WTF::RedBlackTree::findLeastGreaterThanOrEqual const): Deleted. (WTF::RedBlackTree::findGreatestLessThanOrEqual const): Deleted. (WTF::RedBlackTree::first const): Deleted. (WTF::RedBlackTree::last const): Deleted. (WTF::RedBlackTree::size): Deleted. (WTF::RedBlackTree::isEmpty): Deleted. (WTF::RedBlackTree::treeMinimum): Deleted. (WTF::RedBlackTree::treeMaximum): Deleted. (WTF::RedBlackTree::treeInsert): Deleted. (WTF::RedBlackTree::leftRotate): Deleted. (WTF::RedBlackTree::rightRotate): Deleted. (WTF::RedBlackTree::removeFixup): Deleted. * wtf/ResourceUsage.h: * wtf/RunLoop.cpp: * wtf/RunLoopTimer.h: * wtf/SHA1.h: * wtf/Seconds.h: (WTF::Seconds::Seconds): Deleted. (WTF::Seconds::value const): Deleted. (WTF::Seconds::minutes const): Deleted. (WTF::Seconds::seconds const): Deleted. (WTF::Seconds::milliseconds const): Deleted. (WTF::Seconds::microseconds const): Deleted. (WTF::Seconds::nanoseconds const): Deleted. (WTF::Seconds::minutesAs const): Deleted. (WTF::Seconds::secondsAs const): Deleted. (WTF::Seconds::millisecondsAs const): Deleted. (WTF::Seconds::microsecondsAs const): Deleted. (WTF::Seconds::nanosecondsAs const): Deleted. (WTF::Seconds::fromMinutes): Deleted. (WTF::Seconds::fromHours): Deleted. (WTF::Seconds::fromMilliseconds): Deleted. (WTF::Seconds::fromMicroseconds): Deleted. (WTF::Seconds::fromNanoseconds): Deleted. (WTF::Seconds::infinity): Deleted. (WTF::Seconds::nan): Deleted. (WTF::Seconds::operator bool const): Deleted. (WTF::Seconds::operator+ const): Deleted. (WTF::Seconds::operator- const): Deleted. (WTF::Seconds::operator* const): Deleted. (WTF::Seconds::operator/ const): Deleted. (WTF::Seconds::operator% const): Deleted. (WTF::Seconds::operator+=): Deleted. (WTF::Seconds::operator-=): Deleted. (WTF::Seconds::operator*=): Deleted. (WTF::Seconds::operator/=): Deleted. (WTF::Seconds::operator%=): Deleted. (WTF::Seconds::operator== const): Deleted. (WTF::Seconds::operator!= const): Deleted. (WTF::Seconds::operator< const): Deleted. (WTF::Seconds::operator> const): Deleted. (WTF::Seconds::operator<= const): Deleted. (WTF::Seconds::operator>= const): Deleted. (WTF::Seconds::isolatedCopy const): Deleted. (WTF::Seconds::encode const): Deleted. (WTF::Seconds::decode): Deleted. * wtf/SegmentedVector.h: (WTF::SegmentedVector::~SegmentedVector): Deleted. (WTF::SegmentedVector::size const): Deleted. (WTF::SegmentedVector::isEmpty const): Deleted. (WTF::SegmentedVector::at): Deleted. (WTF::SegmentedVector::at const): Deleted. (WTF::SegmentedVector::operator[]): Deleted. (WTF::SegmentedVector::operator[] const): Deleted. (WTF::SegmentedVector::first): Deleted. (WTF::SegmentedVector::first const): Deleted. (WTF::SegmentedVector::last): Deleted. (WTF::SegmentedVector::last const): Deleted. (WTF::SegmentedVector::takeLast): Deleted. (WTF::SegmentedVector::append): Deleted. (WTF::SegmentedVector::alloc): Deleted. (WTF::SegmentedVector::removeLast): Deleted. (WTF::SegmentedVector::grow): Deleted. (WTF::SegmentedVector::clear): Deleted. (WTF::SegmentedVector::begin): Deleted. (WTF::SegmentedVector::end): Deleted. (WTF::SegmentedVector::shrinkToFit): Deleted. (WTF::SegmentedVector::deleteAllSegments): Deleted. (WTF::SegmentedVector::segmentExistsFor): Deleted. (WTF::SegmentedVector::segmentFor): Deleted. (WTF::SegmentedVector::subscriptFor): Deleted. (WTF::SegmentedVector::ensureSegmentsFor): Deleted. (WTF::SegmentedVector::ensureSegment): Deleted. (WTF::SegmentedVector::allocateSegment): Deleted. * wtf/SetForScope.h: * wtf/SingleRootGraph.h: * wtf/SinglyLinkedList.h: * wtf/SmallPtrSet.h: * wtf/SpanningTree.h: * wtf/Spectrum.h: * wtf/StackBounds.h: * wtf/StackShot.h: * wtf/StackShotProfiler.h: * wtf/StackStats.h: * wtf/StackTrace.h: * wtf/StreamBuffer.h: * wtf/SynchronizedFixedQueue.h: (WTF::SynchronizedFixedQueue::create): Deleted. (WTF::SynchronizedFixedQueue::open): Deleted. (WTF::SynchronizedFixedQueue::close): Deleted. (WTF::SynchronizedFixedQueue::isOpen): Deleted. (WTF::SynchronizedFixedQueue::enqueue): Deleted. (WTF::SynchronizedFixedQueue::dequeue): Deleted. (WTF::SynchronizedFixedQueue::SynchronizedFixedQueue): Deleted. * wtf/SystemTracing.h: * wtf/ThreadGroup.h: (WTF::ThreadGroup::create): Deleted. (WTF::ThreadGroup::threads const): Deleted. (WTF::ThreadGroup::getLock): Deleted. (WTF::ThreadGroup::weakFromThis): Deleted. * wtf/ThreadSpecific.h: * wtf/ThreadingPrimitives.h: (WTF::Mutex::impl): Deleted. * wtf/TimeWithDynamicClockType.h: (WTF::TimeWithDynamicClockType::TimeWithDynamicClockType): Deleted. (WTF::TimeWithDynamicClockType::fromRawSeconds): Deleted. (WTF::TimeWithDynamicClockType::secondsSinceEpoch const): Deleted. (WTF::TimeWithDynamicClockType::clockType const): Deleted. (WTF::TimeWithDynamicClockType::withSameClockAndRawSeconds const): Deleted. (WTF::TimeWithDynamicClockType::operator bool const): Deleted. (WTF::TimeWithDynamicClockType::operator+ const): Deleted. (WTF::TimeWithDynamicClockType::operator- const): Deleted. (WTF::TimeWithDynamicClockType::operator+=): Deleted. (WTF::TimeWithDynamicClockType::operator-=): Deleted. (WTF::TimeWithDynamicClockType::operator== const): Deleted. (WTF::TimeWithDynamicClockType::operator!= const): Deleted. * wtf/TimingScope.h: * wtf/TinyLRUCache.h: * wtf/TinyPtrSet.h: * wtf/URLParser.cpp: * wtf/URLParser.h: * wtf/Unexpected.h: * wtf/Variant.h: * wtf/WTFSemaphore.h: (WTF::Semaphore::Semaphore): Deleted. (WTF::Semaphore::signal): Deleted. (WTF::Semaphore::waitUntil): Deleted. (WTF::Semaphore::waitFor): Deleted. (WTF::Semaphore::wait): Deleted. * wtf/WallTime.h: (WTF::WallTime::WallTime): Deleted. (WTF::WallTime::fromRawSeconds): Deleted. (WTF::WallTime::infinity): Deleted. (WTF::WallTime::nan): Deleted. (WTF::WallTime::secondsSinceEpoch const): Deleted. (WTF::WallTime::approximateWallTime const): Deleted. (WTF::WallTime::operator bool const): Deleted. (WTF::WallTime::operator+ const): Deleted. (WTF::WallTime::operator- const): Deleted. (WTF::WallTime::operator+=): Deleted. (WTF::WallTime::operator-=): Deleted. (WTF::WallTime::operator== const): Deleted. (WTF::WallTime::operator!= const): Deleted. (WTF::WallTime::operator< const): Deleted. (WTF::WallTime::operator> const): Deleted. (WTF::WallTime::operator<= const): Deleted. (WTF::WallTime::operator>= const): Deleted. (WTF::WallTime::isolatedCopy const): Deleted. * wtf/WeakHashSet.h: (WTF::WeakHashSet::WeakHashSetConstIterator::WeakHashSetConstIterator): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::get const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator* const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator-> const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator++): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::skipEmptyBuckets): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator== const): Deleted. (WTF::WeakHashSet::WeakHashSetConstIterator::operator!= const): Deleted. (WTF::WeakHashSet::WeakHashSet): Deleted. (WTF::WeakHashSet::begin const): Deleted. (WTF::WeakHashSet::end const): Deleted. (WTF::WeakHashSet::add): Deleted. (WTF::WeakHashSet::remove): Deleted. (WTF::WeakHashSet::contains const): Deleted. (WTF::WeakHashSet::capacity const): Deleted. (WTF::WeakHashSet::computesEmpty const): Deleted. (WTF::WeakHashSet::hasNullReferences const): Deleted. (WTF::WeakHashSet::computeSize const): Deleted. (WTF::WeakHashSet::checkConsistency const): Deleted. * wtf/WeakRandom.h: (WTF::WeakRandom::WeakRandom): Deleted. (WTF::WeakRandom::setSeed): Deleted. (WTF::WeakRandom::seed const): Deleted. (WTF::WeakRandom::get): Deleted. (WTF::WeakRandom::getUint32): Deleted. (WTF::WeakRandom::lowOffset): Deleted. (WTF::WeakRandom::highOffset): Deleted. (WTF::WeakRandom::nextState): Deleted. (WTF::WeakRandom::generate): Deleted. (WTF::WeakRandom::advance): Deleted. * wtf/WordLock.h: (WTF::WordLock::lock): Deleted. (WTF::WordLock::unlock): Deleted. (WTF::WordLock::isHeld const): Deleted. (WTF::WordLock::isLocked const): Deleted. (WTF::WordLock::isFullyReset const): Deleted. * wtf/generic/MainThreadGeneric.cpp: * wtf/glib/GMutexLocker.h: * wtf/linux/CurrentProcessMemoryStatus.h: * wtf/posix/ThreadingPOSIX.cpp: (WTF::Semaphore::Semaphore): Deleted. (WTF::Semaphore::~Semaphore): Deleted. (WTF::Semaphore::wait): Deleted. (WTF::Semaphore::post): Deleted. * wtf/text/ASCIILiteral.h: (WTF::ASCIILiteral::operator const char* const): Deleted. (WTF::ASCIILiteral::fromLiteralUnsafe): Deleted. (WTF::ASCIILiteral::null): Deleted. (WTF::ASCIILiteral::characters const): Deleted. (WTF::ASCIILiteral::ASCIILiteral): Deleted. * wtf/text/AtomString.h: (WTF::AtomString::operator=): Deleted. (WTF::AtomString::isHashTableDeletedValue const): Deleted. (WTF::AtomString::existingHash const): Deleted. (WTF::AtomString::operator const String& const): Deleted. (WTF::AtomString::string const): Deleted. (WTF::AtomString::impl const): Deleted. (WTF::AtomString::is8Bit const): Deleted. (WTF::AtomString::characters8 const): Deleted. (WTF::AtomString::characters16 const): Deleted. (WTF::AtomString::length const): Deleted. (WTF::AtomString::operator[] const): Deleted. (WTF::AtomString::contains const): Deleted. (WTF::AtomString::containsIgnoringASCIICase const): Deleted. (WTF::AtomString::find const): Deleted. (WTF::AtomString::findIgnoringASCIICase const): Deleted. (WTF::AtomString::startsWith const): Deleted. (WTF::AtomString::startsWithIgnoringASCIICase const): Deleted. (WTF::AtomString::endsWith const): Deleted. (WTF::AtomString::endsWithIgnoringASCIICase const): Deleted. (WTF::AtomString::toInt const): Deleted. (WTF::AtomString::toDouble const): Deleted. (WTF::AtomString::toFloat const): Deleted. (WTF::AtomString::percentage const): Deleted. (WTF::AtomString::isNull const): Deleted. (WTF::AtomString::isEmpty const): Deleted. (WTF::AtomString::operator NSString * const): Deleted. * wtf/text/AtomStringImpl.h: (WTF::AtomStringImpl::lookUp): Deleted. (WTF::AtomStringImpl::add): Deleted. (WTF::AtomStringImpl::addWithStringTableProvider): Deleted. * wtf/text/CString.h: (WTF::CStringBuffer::data): Deleted. (WTF::CStringBuffer::length const): Deleted. (WTF::CStringBuffer::CStringBuffer): Deleted. (WTF::CStringBuffer::mutableData): Deleted. (WTF::CString::CString): Deleted. (WTF::CString::data const): Deleted. (WTF::CString::length const): Deleted. (WTF::CString::isNull const): Deleted. (WTF::CString::buffer const): Deleted. (WTF::CString::isHashTableDeletedValue const): Deleted. * wtf/text/ExternalStringImpl.h: (WTF::ExternalStringImpl::freeExternalBuffer): Deleted. * wtf/text/LineBreakIteratorPoolICU.h: * wtf/text/NullTextBreakIterator.h: * wtf/text/OrdinalNumber.h: * wtf/text/StringBuffer.h: * wtf/text/StringBuilder.h: * wtf/text/StringConcatenateNumbers.h: * wtf/text/StringHasher.h: * wtf/text/StringImpl.h: * wtf/text/StringView.cpp: * wtf/text/StringView.h: (WTF::StringView::left const): Deleted. (WTF::StringView::right const): Deleted. (WTF::StringView::underlyingStringIsValid const): Deleted. (WTF::StringView::setUnderlyingString): Deleted. * wtf/text/SymbolImpl.h: (WTF::SymbolImpl::StaticSymbolImpl::StaticSymbolImpl): Deleted. (WTF::SymbolImpl::StaticSymbolImpl::operator SymbolImpl&): Deleted. (WTF::PrivateSymbolImpl::PrivateSymbolImpl): Deleted. (WTF::RegisteredSymbolImpl::symbolRegistry const): Deleted. (WTF::RegisteredSymbolImpl::clearSymbolRegistry): Deleted. (WTF::RegisteredSymbolImpl::RegisteredSymbolImpl): Deleted. * wtf/text/SymbolRegistry.h: * wtf/text/TextBreakIterator.h: * wtf/text/TextPosition.h: * wtf/text/TextStream.h: * wtf/text/WTFString.h: (WTF::String::swap): Deleted. (WTF::String::adopt): Deleted. (WTF::String::isNull const): Deleted. (WTF::String::isEmpty const): Deleted. (WTF::String::impl const): Deleted. (WTF::String::releaseImpl): Deleted. (WTF::String::length const): Deleted. (WTF::String::characters8 const): Deleted. (WTF::String::characters16 const): Deleted. (WTF::String::is8Bit const): Deleted. (WTF::String::sizeInBytes const): Deleted. (WTF::String::operator[] const): Deleted. (WTF::String::find const): Deleted. (WTF::String::findIgnoringASCIICase const): Deleted. (WTF::String::reverseFind const): Deleted. (WTF::String::contains const): Deleted. (WTF::String::containsIgnoringASCIICase const): Deleted. (WTF::String::startsWith const): Deleted. (WTF::String::startsWithIgnoringASCIICase const): Deleted. (WTF::String::hasInfixStartingAt const): Deleted. (WTF::String::endsWith const): Deleted. (WTF::String::endsWithIgnoringASCIICase const): Deleted. (WTF::String::hasInfixEndingAt const): Deleted. (WTF::String::append): Deleted. (WTF::String::left const): Deleted. (WTF::String::right const): Deleted. (WTF::String::createUninitialized): Deleted. (WTF::String::fromUTF8WithLatin1Fallback): Deleted. (WTF::String::isAllASCII const): Deleted. (WTF::String::isAllLatin1 const): Deleted. (WTF::String::isSpecialCharacter const): Deleted. (WTF::String::isHashTableDeletedValue const): Deleted. (WTF::String::hash const): Deleted. (WTF::String::existingHash const): Deleted. * wtf/text/cf/TextBreakIteratorCF.h: * wtf/text/icu/TextBreakIteratorICU.h: * wtf/text/icu/UTextProviderLatin1.h: * wtf/threads/BinarySemaphore.h: (WTF::BinarySemaphore::waitFor): Deleted. (WTF::BinarySemaphore::wait): Deleted. * wtf/unicode/Collator.h: * wtf/win/GDIObject.h: * wtf/win/PathWalker.h: * wtf/win/Win32Handle.h: Canonical link: https://commits.webkit.org/214396@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248546 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-08-12 20:57:15 +00:00
WTF_MAKE_FAST_ALLOCATED;
[WTF] Add Markable<T, Traits> https://bugs.webkit.org/show_bug.cgi?id=189231 Reviewed by Sam Weinig. Source/WebCore: Use Markable<Seconds> and Markable<WallTime> in ResourceResponseBase. Since these fields are parsed results from http header fields, Seconds::nan() and WallTime::nan() can be used as an empty value for these fields. Thus we can use Markable because it uses these nan values as an empty values (they are configured by Seconds::MarkableTraits and WallTime::MarkableTraits). This reduces the size of ResourceResponseBase from 448 to 416. * platform/network/ResourceResponseBase.h: Source/WTF: We can represent a value with nullopt by using std::optional<T>. However, std::optional<T> has storage efficiency problem. It always has a bool indicating that the value is nullopt or not. If we have a following class, class A { std::optional<WallTime> m_timeA; std::optional<WallTime> m_timeB; std::optional<WallTime> m_timeC; }; This class has significant amount of padding between m_timeA / m_timeB, m_timeB / m_timeC due to the above bool. If we know that WallTime has a value that represents invalid, we can use it instead and save the storage. This is very similar problem to our HashTable implementation. In our HashTable implementation, we need Deleted and Empty value, which can represent Deleted and Empty values without sacrificing storage efficiency. We should have similar mechanism here. In this patch, we have WTF::Markable<T, Traits>. Traits offers `Traits::isEmptyValue(value)` and `Traits::emptyValue()`. Then, we use this empty value instead of having bool flag. This way, we can make `sizeof(WTF::Markable<T>) == sizeof(T)`. This idea is inspired from https://github.com/akrzemi1/markable. But we would like to have WTF::Markable<T> here instead of importing it since we would like to have (1) integrated interfaces with std::optional<T> and (2) aligned function names to HashTraits' `isEmptyValue` and `emptyValue`. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Markable.h: Added. (WTF::std::underlying_type<EnumType>::type>::max): EnumMarkableTraits can be used as an MarkableTraits for enum values. We can specify a constant value as an empty value. (WTF::IntegralMarkableTraits::isEmptyValue): (WTF::IntegralMarkableTraits::emptyValue): IntegralMarkableTraits can be used as an MarkableTraits for integral types including int etc. (WTF::Markable::Markable): (WTF::Markable::operator bool const): (WTF::Markable::reset): (WTF::Markable::value const): (WTF::Markable::value): (WTF::Markable::operator-> const): (WTF::Markable::operator->): (WTF::Markable::operator* const): (WTF::Markable::operator*): (WTF::Markable::operator std::optional<T>): (WTF::Markable::operator std::optional<T> const): This operator allows us to cast Markable<T> to std::optional<T>. * wtf/MonotonicTime.h: (WTF::MonotonicTime::MarkableTraits::isEmptyValue): (WTF::MonotonicTime::MarkableTraits::emptyValue): MarkableTraits for MonotonicTime. MonotonicTime::nan() is used as an empty value. * wtf/Seconds.h: (WTF::Seconds::MarkableTraits::isEmptyValue): (WTF::Seconds::MarkableTraits::emptyValue): MarkableTraits for Seconds. Seconds::nan() is used as an empty value. * wtf/WallTime.h: (WTF::WallTime::nan): (WTF::WallTime::MarkableTraits::isEmptyValue): (WTF::WallTime::MarkableTraits::emptyValue): MarkableTraits for WallTime. WallTime::nan() is used as an empty value. Tools: Add tests for Markable. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/Markable.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/204438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-10 18:19:09 +00:00
public:
constexpr Markable()
: m_value(Traits::emptyValue())
{ }
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
constexpr Markable(std::nullopt_t)
[WTF] Add Markable<T, Traits> https://bugs.webkit.org/show_bug.cgi?id=189231 Reviewed by Sam Weinig. Source/WebCore: Use Markable<Seconds> and Markable<WallTime> in ResourceResponseBase. Since these fields are parsed results from http header fields, Seconds::nan() and WallTime::nan() can be used as an empty value for these fields. Thus we can use Markable because it uses these nan values as an empty values (they are configured by Seconds::MarkableTraits and WallTime::MarkableTraits). This reduces the size of ResourceResponseBase from 448 to 416. * platform/network/ResourceResponseBase.h: Source/WTF: We can represent a value with nullopt by using std::optional<T>. However, std::optional<T> has storage efficiency problem. It always has a bool indicating that the value is nullopt or not. If we have a following class, class A { std::optional<WallTime> m_timeA; std::optional<WallTime> m_timeB; std::optional<WallTime> m_timeC; }; This class has significant amount of padding between m_timeA / m_timeB, m_timeB / m_timeC due to the above bool. If we know that WallTime has a value that represents invalid, we can use it instead and save the storage. This is very similar problem to our HashTable implementation. In our HashTable implementation, we need Deleted and Empty value, which can represent Deleted and Empty values without sacrificing storage efficiency. We should have similar mechanism here. In this patch, we have WTF::Markable<T, Traits>. Traits offers `Traits::isEmptyValue(value)` and `Traits::emptyValue()`. Then, we use this empty value instead of having bool flag. This way, we can make `sizeof(WTF::Markable<T>) == sizeof(T)`. This idea is inspired from https://github.com/akrzemi1/markable. But we would like to have WTF::Markable<T> here instead of importing it since we would like to have (1) integrated interfaces with std::optional<T> and (2) aligned function names to HashTraits' `isEmptyValue` and `emptyValue`. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Markable.h: Added. (WTF::std::underlying_type<EnumType>::type>::max): EnumMarkableTraits can be used as an MarkableTraits for enum values. We can specify a constant value as an empty value. (WTF::IntegralMarkableTraits::isEmptyValue): (WTF::IntegralMarkableTraits::emptyValue): IntegralMarkableTraits can be used as an MarkableTraits for integral types including int etc. (WTF::Markable::Markable): (WTF::Markable::operator bool const): (WTF::Markable::reset): (WTF::Markable::value const): (WTF::Markable::value): (WTF::Markable::operator-> const): (WTF::Markable::operator->): (WTF::Markable::operator* const): (WTF::Markable::operator*): (WTF::Markable::operator std::optional<T>): (WTF::Markable::operator std::optional<T> const): This operator allows us to cast Markable<T> to std::optional<T>. * wtf/MonotonicTime.h: (WTF::MonotonicTime::MarkableTraits::isEmptyValue): (WTF::MonotonicTime::MarkableTraits::emptyValue): MarkableTraits for MonotonicTime. MonotonicTime::nan() is used as an empty value. * wtf/Seconds.h: (WTF::Seconds::MarkableTraits::isEmptyValue): (WTF::Seconds::MarkableTraits::emptyValue): MarkableTraits for Seconds. Seconds::nan() is used as an empty value. * wtf/WallTime.h: (WTF::WallTime::nan): (WTF::WallTime::MarkableTraits::isEmptyValue): (WTF::WallTime::MarkableTraits::emptyValue): MarkableTraits for WallTime. WallTime::nan() is used as an empty value. Tools: Add tests for Markable. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/Markable.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/204438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-10 18:19:09 +00:00
: Markable()
{ }
constexpr Markable(T&& value)
: m_value(WTFMove(value))
{ }
constexpr Markable(const T& value)
: m_value(value)
{ }
template<typename... Args>
constexpr explicit Markable(std::in_place_t, Args&&... args)
: m_value(std::forward<Args>(args)...)
{ }
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
constexpr Markable(const std::optional<T>& value)
[WTF] Add Markable<T, Traits> https://bugs.webkit.org/show_bug.cgi?id=189231 Reviewed by Sam Weinig. Source/WebCore: Use Markable<Seconds> and Markable<WallTime> in ResourceResponseBase. Since these fields are parsed results from http header fields, Seconds::nan() and WallTime::nan() can be used as an empty value for these fields. Thus we can use Markable because it uses these nan values as an empty values (they are configured by Seconds::MarkableTraits and WallTime::MarkableTraits). This reduces the size of ResourceResponseBase from 448 to 416. * platform/network/ResourceResponseBase.h: Source/WTF: We can represent a value with nullopt by using std::optional<T>. However, std::optional<T> has storage efficiency problem. It always has a bool indicating that the value is nullopt or not. If we have a following class, class A { std::optional<WallTime> m_timeA; std::optional<WallTime> m_timeB; std::optional<WallTime> m_timeC; }; This class has significant amount of padding between m_timeA / m_timeB, m_timeB / m_timeC due to the above bool. If we know that WallTime has a value that represents invalid, we can use it instead and save the storage. This is very similar problem to our HashTable implementation. In our HashTable implementation, we need Deleted and Empty value, which can represent Deleted and Empty values without sacrificing storage efficiency. We should have similar mechanism here. In this patch, we have WTF::Markable<T, Traits>. Traits offers `Traits::isEmptyValue(value)` and `Traits::emptyValue()`. Then, we use this empty value instead of having bool flag. This way, we can make `sizeof(WTF::Markable<T>) == sizeof(T)`. This idea is inspired from https://github.com/akrzemi1/markable. But we would like to have WTF::Markable<T> here instead of importing it since we would like to have (1) integrated interfaces with std::optional<T> and (2) aligned function names to HashTraits' `isEmptyValue` and `emptyValue`. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Markable.h: Added. (WTF::std::underlying_type<EnumType>::type>::max): EnumMarkableTraits can be used as an MarkableTraits for enum values. We can specify a constant value as an empty value. (WTF::IntegralMarkableTraits::isEmptyValue): (WTF::IntegralMarkableTraits::emptyValue): IntegralMarkableTraits can be used as an MarkableTraits for integral types including int etc. (WTF::Markable::Markable): (WTF::Markable::operator bool const): (WTF::Markable::reset): (WTF::Markable::value const): (WTF::Markable::value): (WTF::Markable::operator-> const): (WTF::Markable::operator->): (WTF::Markable::operator* const): (WTF::Markable::operator*): (WTF::Markable::operator std::optional<T>): (WTF::Markable::operator std::optional<T> const): This operator allows us to cast Markable<T> to std::optional<T>. * wtf/MonotonicTime.h: (WTF::MonotonicTime::MarkableTraits::isEmptyValue): (WTF::MonotonicTime::MarkableTraits::emptyValue): MarkableTraits for MonotonicTime. MonotonicTime::nan() is used as an empty value. * wtf/Seconds.h: (WTF::Seconds::MarkableTraits::isEmptyValue): (WTF::Seconds::MarkableTraits::emptyValue): MarkableTraits for Seconds. Seconds::nan() is used as an empty value. * wtf/WallTime.h: (WTF::WallTime::nan): (WTF::WallTime::MarkableTraits::isEmptyValue): (WTF::WallTime::MarkableTraits::emptyValue): MarkableTraits for WallTime. WallTime::nan() is used as an empty value. Tools: Add tests for Markable. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/Markable.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/204438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-10 18:19:09 +00:00
: m_value(bool(value) ? *value : Traits::emptyValue())
{ }
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
constexpr Markable(std::optional<T>&& value)
[WTF] Add Markable<T, Traits> https://bugs.webkit.org/show_bug.cgi?id=189231 Reviewed by Sam Weinig. Source/WebCore: Use Markable<Seconds> and Markable<WallTime> in ResourceResponseBase. Since these fields are parsed results from http header fields, Seconds::nan() and WallTime::nan() can be used as an empty value for these fields. Thus we can use Markable because it uses these nan values as an empty values (they are configured by Seconds::MarkableTraits and WallTime::MarkableTraits). This reduces the size of ResourceResponseBase from 448 to 416. * platform/network/ResourceResponseBase.h: Source/WTF: We can represent a value with nullopt by using std::optional<T>. However, std::optional<T> has storage efficiency problem. It always has a bool indicating that the value is nullopt or not. If we have a following class, class A { std::optional<WallTime> m_timeA; std::optional<WallTime> m_timeB; std::optional<WallTime> m_timeC; }; This class has significant amount of padding between m_timeA / m_timeB, m_timeB / m_timeC due to the above bool. If we know that WallTime has a value that represents invalid, we can use it instead and save the storage. This is very similar problem to our HashTable implementation. In our HashTable implementation, we need Deleted and Empty value, which can represent Deleted and Empty values without sacrificing storage efficiency. We should have similar mechanism here. In this patch, we have WTF::Markable<T, Traits>. Traits offers `Traits::isEmptyValue(value)` and `Traits::emptyValue()`. Then, we use this empty value instead of having bool flag. This way, we can make `sizeof(WTF::Markable<T>) == sizeof(T)`. This idea is inspired from https://github.com/akrzemi1/markable. But we would like to have WTF::Markable<T> here instead of importing it since we would like to have (1) integrated interfaces with std::optional<T> and (2) aligned function names to HashTraits' `isEmptyValue` and `emptyValue`. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Markable.h: Added. (WTF::std::underlying_type<EnumType>::type>::max): EnumMarkableTraits can be used as an MarkableTraits for enum values. We can specify a constant value as an empty value. (WTF::IntegralMarkableTraits::isEmptyValue): (WTF::IntegralMarkableTraits::emptyValue): IntegralMarkableTraits can be used as an MarkableTraits for integral types including int etc. (WTF::Markable::Markable): (WTF::Markable::operator bool const): (WTF::Markable::reset): (WTF::Markable::value const): (WTF::Markable::value): (WTF::Markable::operator-> const): (WTF::Markable::operator->): (WTF::Markable::operator* const): (WTF::Markable::operator*): (WTF::Markable::operator std::optional<T>): (WTF::Markable::operator std::optional<T> const): This operator allows us to cast Markable<T> to std::optional<T>. * wtf/MonotonicTime.h: (WTF::MonotonicTime::MarkableTraits::isEmptyValue): (WTF::MonotonicTime::MarkableTraits::emptyValue): MarkableTraits for MonotonicTime. MonotonicTime::nan() is used as an empty value. * wtf/Seconds.h: (WTF::Seconds::MarkableTraits::isEmptyValue): (WTF::Seconds::MarkableTraits::emptyValue): MarkableTraits for Seconds. Seconds::nan() is used as an empty value. * wtf/WallTime.h: (WTF::WallTime::nan): (WTF::WallTime::MarkableTraits::isEmptyValue): (WTF::WallTime::MarkableTraits::emptyValue): MarkableTraits for WallTime. WallTime::nan() is used as an empty value. Tools: Add tests for Markable. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/Markable.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/204438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-10 18:19:09 +00:00
: m_value(bool(value) ? WTFMove(*value) : Traits::emptyValue())
{ }
constexpr explicit operator bool() const { return !Traits::isEmptyValue(m_value); }
void reset() { m_value = Traits::emptyValue(); }
constexpr const T& value() const& { return m_value; }
constexpr T& value() & { return m_value; }
constexpr T&& value() && { return WTFMove(m_value); }
constexpr const T* operator->() const { return std::addressof(m_value); }
constexpr T* operator->() { return std::addressof(m_value); }
constexpr const T& operator*() const& { return m_value; }
constexpr T& operator*() & { return m_value; }
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
operator std::optional<T>() &&
[WTF] Add Markable<T, Traits> https://bugs.webkit.org/show_bug.cgi?id=189231 Reviewed by Sam Weinig. Source/WebCore: Use Markable<Seconds> and Markable<WallTime> in ResourceResponseBase. Since these fields are parsed results from http header fields, Seconds::nan() and WallTime::nan() can be used as an empty value for these fields. Thus we can use Markable because it uses these nan values as an empty values (they are configured by Seconds::MarkableTraits and WallTime::MarkableTraits). This reduces the size of ResourceResponseBase from 448 to 416. * platform/network/ResourceResponseBase.h: Source/WTF: We can represent a value with nullopt by using std::optional<T>. However, std::optional<T> has storage efficiency problem. It always has a bool indicating that the value is nullopt or not. If we have a following class, class A { std::optional<WallTime> m_timeA; std::optional<WallTime> m_timeB; std::optional<WallTime> m_timeC; }; This class has significant amount of padding between m_timeA / m_timeB, m_timeB / m_timeC due to the above bool. If we know that WallTime has a value that represents invalid, we can use it instead and save the storage. This is very similar problem to our HashTable implementation. In our HashTable implementation, we need Deleted and Empty value, which can represent Deleted and Empty values without sacrificing storage efficiency. We should have similar mechanism here. In this patch, we have WTF::Markable<T, Traits>. Traits offers `Traits::isEmptyValue(value)` and `Traits::emptyValue()`. Then, we use this empty value instead of having bool flag. This way, we can make `sizeof(WTF::Markable<T>) == sizeof(T)`. This idea is inspired from https://github.com/akrzemi1/markable. But we would like to have WTF::Markable<T> here instead of importing it since we would like to have (1) integrated interfaces with std::optional<T> and (2) aligned function names to HashTraits' `isEmptyValue` and `emptyValue`. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Markable.h: Added. (WTF::std::underlying_type<EnumType>::type>::max): EnumMarkableTraits can be used as an MarkableTraits for enum values. We can specify a constant value as an empty value. (WTF::IntegralMarkableTraits::isEmptyValue): (WTF::IntegralMarkableTraits::emptyValue): IntegralMarkableTraits can be used as an MarkableTraits for integral types including int etc. (WTF::Markable::Markable): (WTF::Markable::operator bool const): (WTF::Markable::reset): (WTF::Markable::value const): (WTF::Markable::value): (WTF::Markable::operator-> const): (WTF::Markable::operator->): (WTF::Markable::operator* const): (WTF::Markable::operator*): (WTF::Markable::operator std::optional<T>): (WTF::Markable::operator std::optional<T> const): This operator allows us to cast Markable<T> to std::optional<T>. * wtf/MonotonicTime.h: (WTF::MonotonicTime::MarkableTraits::isEmptyValue): (WTF::MonotonicTime::MarkableTraits::emptyValue): MarkableTraits for MonotonicTime. MonotonicTime::nan() is used as an empty value. * wtf/Seconds.h: (WTF::Seconds::MarkableTraits::isEmptyValue): (WTF::Seconds::MarkableTraits::emptyValue): MarkableTraits for Seconds. Seconds::nan() is used as an empty value. * wtf/WallTime.h: (WTF::WallTime::nan): (WTF::WallTime::MarkableTraits::isEmptyValue): (WTF::WallTime::MarkableTraits::emptyValue): MarkableTraits for WallTime. WallTime::nan() is used as an empty value. Tools: Add tests for Markable. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/Markable.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/204438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-10 18:19:09 +00:00
{
if (bool(*this))
return WTFMove(m_value);
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
return std::nullopt;
[WTF] Add Markable<T, Traits> https://bugs.webkit.org/show_bug.cgi?id=189231 Reviewed by Sam Weinig. Source/WebCore: Use Markable<Seconds> and Markable<WallTime> in ResourceResponseBase. Since these fields are parsed results from http header fields, Seconds::nan() and WallTime::nan() can be used as an empty value for these fields. Thus we can use Markable because it uses these nan values as an empty values (they are configured by Seconds::MarkableTraits and WallTime::MarkableTraits). This reduces the size of ResourceResponseBase from 448 to 416. * platform/network/ResourceResponseBase.h: Source/WTF: We can represent a value with nullopt by using std::optional<T>. However, std::optional<T> has storage efficiency problem. It always has a bool indicating that the value is nullopt or not. If we have a following class, class A { std::optional<WallTime> m_timeA; std::optional<WallTime> m_timeB; std::optional<WallTime> m_timeC; }; This class has significant amount of padding between m_timeA / m_timeB, m_timeB / m_timeC due to the above bool. If we know that WallTime has a value that represents invalid, we can use it instead and save the storage. This is very similar problem to our HashTable implementation. In our HashTable implementation, we need Deleted and Empty value, which can represent Deleted and Empty values without sacrificing storage efficiency. We should have similar mechanism here. In this patch, we have WTF::Markable<T, Traits>. Traits offers `Traits::isEmptyValue(value)` and `Traits::emptyValue()`. Then, we use this empty value instead of having bool flag. This way, we can make `sizeof(WTF::Markable<T>) == sizeof(T)`. This idea is inspired from https://github.com/akrzemi1/markable. But we would like to have WTF::Markable<T> here instead of importing it since we would like to have (1) integrated interfaces with std::optional<T> and (2) aligned function names to HashTraits' `isEmptyValue` and `emptyValue`. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Markable.h: Added. (WTF::std::underlying_type<EnumType>::type>::max): EnumMarkableTraits can be used as an MarkableTraits for enum values. We can specify a constant value as an empty value. (WTF::IntegralMarkableTraits::isEmptyValue): (WTF::IntegralMarkableTraits::emptyValue): IntegralMarkableTraits can be used as an MarkableTraits for integral types including int etc. (WTF::Markable::Markable): (WTF::Markable::operator bool const): (WTF::Markable::reset): (WTF::Markable::value const): (WTF::Markable::value): (WTF::Markable::operator-> const): (WTF::Markable::operator->): (WTF::Markable::operator* const): (WTF::Markable::operator*): (WTF::Markable::operator std::optional<T>): (WTF::Markable::operator std::optional<T> const): This operator allows us to cast Markable<T> to std::optional<T>. * wtf/MonotonicTime.h: (WTF::MonotonicTime::MarkableTraits::isEmptyValue): (WTF::MonotonicTime::MarkableTraits::emptyValue): MarkableTraits for MonotonicTime. MonotonicTime::nan() is used as an empty value. * wtf/Seconds.h: (WTF::Seconds::MarkableTraits::isEmptyValue): (WTF::Seconds::MarkableTraits::emptyValue): MarkableTraits for Seconds. Seconds::nan() is used as an empty value. * wtf/WallTime.h: (WTF::WallTime::nan): (WTF::WallTime::MarkableTraits::isEmptyValue): (WTF::WallTime::MarkableTraits::emptyValue): MarkableTraits for WallTime. WallTime::nan() is used as an empty value. Tools: Add tests for Markable. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/Markable.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/204438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-10 18:19:09 +00:00
}
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
operator std::optional<T>() const&
[WTF] Add Markable<T, Traits> https://bugs.webkit.org/show_bug.cgi?id=189231 Reviewed by Sam Weinig. Source/WebCore: Use Markable<Seconds> and Markable<WallTime> in ResourceResponseBase. Since these fields are parsed results from http header fields, Seconds::nan() and WallTime::nan() can be used as an empty value for these fields. Thus we can use Markable because it uses these nan values as an empty values (they are configured by Seconds::MarkableTraits and WallTime::MarkableTraits). This reduces the size of ResourceResponseBase from 448 to 416. * platform/network/ResourceResponseBase.h: Source/WTF: We can represent a value with nullopt by using std::optional<T>. However, std::optional<T> has storage efficiency problem. It always has a bool indicating that the value is nullopt or not. If we have a following class, class A { std::optional<WallTime> m_timeA; std::optional<WallTime> m_timeB; std::optional<WallTime> m_timeC; }; This class has significant amount of padding between m_timeA / m_timeB, m_timeB / m_timeC due to the above bool. If we know that WallTime has a value that represents invalid, we can use it instead and save the storage. This is very similar problem to our HashTable implementation. In our HashTable implementation, we need Deleted and Empty value, which can represent Deleted and Empty values without sacrificing storage efficiency. We should have similar mechanism here. In this patch, we have WTF::Markable<T, Traits>. Traits offers `Traits::isEmptyValue(value)` and `Traits::emptyValue()`. Then, we use this empty value instead of having bool flag. This way, we can make `sizeof(WTF::Markable<T>) == sizeof(T)`. This idea is inspired from https://github.com/akrzemi1/markable. But we would like to have WTF::Markable<T> here instead of importing it since we would like to have (1) integrated interfaces with std::optional<T> and (2) aligned function names to HashTraits' `isEmptyValue` and `emptyValue`. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Markable.h: Added. (WTF::std::underlying_type<EnumType>::type>::max): EnumMarkableTraits can be used as an MarkableTraits for enum values. We can specify a constant value as an empty value. (WTF::IntegralMarkableTraits::isEmptyValue): (WTF::IntegralMarkableTraits::emptyValue): IntegralMarkableTraits can be used as an MarkableTraits for integral types including int etc. (WTF::Markable::Markable): (WTF::Markable::operator bool const): (WTF::Markable::reset): (WTF::Markable::value const): (WTF::Markable::value): (WTF::Markable::operator-> const): (WTF::Markable::operator->): (WTF::Markable::operator* const): (WTF::Markable::operator*): (WTF::Markable::operator std::optional<T>): (WTF::Markable::operator std::optional<T> const): This operator allows us to cast Markable<T> to std::optional<T>. * wtf/MonotonicTime.h: (WTF::MonotonicTime::MarkableTraits::isEmptyValue): (WTF::MonotonicTime::MarkableTraits::emptyValue): MarkableTraits for MonotonicTime. MonotonicTime::nan() is used as an empty value. * wtf/Seconds.h: (WTF::Seconds::MarkableTraits::isEmptyValue): (WTF::Seconds::MarkableTraits::emptyValue): MarkableTraits for Seconds. Seconds::nan() is used as an empty value. * wtf/WallTime.h: (WTF::WallTime::nan): (WTF::WallTime::MarkableTraits::isEmptyValue): (WTF::WallTime::MarkableTraits::emptyValue): MarkableTraits for WallTime. WallTime::nan() is used as an empty value. Tools: Add tests for Markable. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/Markable.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/204438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-10 18:19:09 +00:00
{
if (bool(*this))
return m_value;
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
return std::nullopt;
[WTF] Add Markable<T, Traits> https://bugs.webkit.org/show_bug.cgi?id=189231 Reviewed by Sam Weinig. Source/WebCore: Use Markable<Seconds> and Markable<WallTime> in ResourceResponseBase. Since these fields are parsed results from http header fields, Seconds::nan() and WallTime::nan() can be used as an empty value for these fields. Thus we can use Markable because it uses these nan values as an empty values (they are configured by Seconds::MarkableTraits and WallTime::MarkableTraits). This reduces the size of ResourceResponseBase from 448 to 416. * platform/network/ResourceResponseBase.h: Source/WTF: We can represent a value with nullopt by using std::optional<T>. However, std::optional<T> has storage efficiency problem. It always has a bool indicating that the value is nullopt or not. If we have a following class, class A { std::optional<WallTime> m_timeA; std::optional<WallTime> m_timeB; std::optional<WallTime> m_timeC; }; This class has significant amount of padding between m_timeA / m_timeB, m_timeB / m_timeC due to the above bool. If we know that WallTime has a value that represents invalid, we can use it instead and save the storage. This is very similar problem to our HashTable implementation. In our HashTable implementation, we need Deleted and Empty value, which can represent Deleted and Empty values without sacrificing storage efficiency. We should have similar mechanism here. In this patch, we have WTF::Markable<T, Traits>. Traits offers `Traits::isEmptyValue(value)` and `Traits::emptyValue()`. Then, we use this empty value instead of having bool flag. This way, we can make `sizeof(WTF::Markable<T>) == sizeof(T)`. This idea is inspired from https://github.com/akrzemi1/markable. But we would like to have WTF::Markable<T> here instead of importing it since we would like to have (1) integrated interfaces with std::optional<T> and (2) aligned function names to HashTraits' `isEmptyValue` and `emptyValue`. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Markable.h: Added. (WTF::std::underlying_type<EnumType>::type>::max): EnumMarkableTraits can be used as an MarkableTraits for enum values. We can specify a constant value as an empty value. (WTF::IntegralMarkableTraits::isEmptyValue): (WTF::IntegralMarkableTraits::emptyValue): IntegralMarkableTraits can be used as an MarkableTraits for integral types including int etc. (WTF::Markable::Markable): (WTF::Markable::operator bool const): (WTF::Markable::reset): (WTF::Markable::value const): (WTF::Markable::value): (WTF::Markable::operator-> const): (WTF::Markable::operator->): (WTF::Markable::operator* const): (WTF::Markable::operator*): (WTF::Markable::operator std::optional<T>): (WTF::Markable::operator std::optional<T> const): This operator allows us to cast Markable<T> to std::optional<T>. * wtf/MonotonicTime.h: (WTF::MonotonicTime::MarkableTraits::isEmptyValue): (WTF::MonotonicTime::MarkableTraits::emptyValue): MarkableTraits for MonotonicTime. MonotonicTime::nan() is used as an empty value. * wtf/Seconds.h: (WTF::Seconds::MarkableTraits::isEmptyValue): (WTF::Seconds::MarkableTraits::emptyValue): MarkableTraits for Seconds. Seconds::nan() is used as an empty value. * wtf/WallTime.h: (WTF::WallTime::nan): (WTF::WallTime::MarkableTraits::isEmptyValue): (WTF::WallTime::MarkableTraits::emptyValue): MarkableTraits for WallTime. WallTime::nan() is used as an empty value. Tools: Add tests for Markable. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/Markable.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/204438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-10 18:19:09 +00:00
}
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<T> asOptional() const
Shrink CachedResource https://bugs.webkit.org/show_bug.cgi?id=207618 Reviewed by Mark Lam. Source/WebCore: This patch shrinks sizeof(CachedResource) by 80 bytes by aggressively using bit-fields and Markable<>. For each enum class, we define `bitsOfXXX` value, which indicates # of bits to represent it. And using this value for bit-field's width. No behavior change. * loader/FetchOptions.h: (WebCore::FetchOptions::encode const): * loader/ResourceLoaderOptions.h: (WebCore::ResourceLoaderOptions::ResourceLoaderOptions): (WebCore::ResourceLoaderOptions::loadedFromOpaqueSource): * loader/cache/CachedImage.cpp: (WebCore::CachedImage::CachedImage): (WebCore::CachedImage::shouldDeferUpdateImageData const): (WebCore::CachedImage::didUpdateImageData): * loader/cache/CachedImage.h: * loader/cache/CachedResource.cpp: (WebCore::CachedResource::CachedResource): (WebCore::CachedResource::load): (WebCore::CachedResource::finish): * loader/cache/CachedResource.h: (WebCore::CachedResource::setStatus): * page/csp/ContentSecurityPolicyResponseHeaders.h: (WebCore::ContentSecurityPolicyResponseHeaders::MarkableTraits::isEmptyValue): (WebCore::ContentSecurityPolicyResponseHeaders::MarkableTraits::emptyValue): (WebCore::ContentSecurityPolicyResponseHeaders::ContentSecurityPolicyResponseHeaders): * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::clearNonTimingData): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceLoadPriority.h: * platform/network/ResourceRequestBase.h: (WebCore::ResourceRequestBase::ResourceRequestBase): * platform/network/ResourceResponseBase.h: * platform/network/StoredCredentialsPolicy.h: Source/WTF: * wtf/Markable.h: (WTF::Markable::asOptional const): Add helper method to get Optional easily from Markable. * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::MarkableTraits::isEmptyValue): (WTF::ObjectIdentifier::MarkableTraits::emptyValue): (WTF::ObjectIdentifier::ObjectIdentifier): Add MarkableTraits for ObjectIdentifier. Canonical link: https://commits.webkit.org/220633@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-12 22:51:19 +00:00
{
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
return std::optional<T>(*this);
Shrink CachedResource https://bugs.webkit.org/show_bug.cgi?id=207618 Reviewed by Mark Lam. Source/WebCore: This patch shrinks sizeof(CachedResource) by 80 bytes by aggressively using bit-fields and Markable<>. For each enum class, we define `bitsOfXXX` value, which indicates # of bits to represent it. And using this value for bit-field's width. No behavior change. * loader/FetchOptions.h: (WebCore::FetchOptions::encode const): * loader/ResourceLoaderOptions.h: (WebCore::ResourceLoaderOptions::ResourceLoaderOptions): (WebCore::ResourceLoaderOptions::loadedFromOpaqueSource): * loader/cache/CachedImage.cpp: (WebCore::CachedImage::CachedImage): (WebCore::CachedImage::shouldDeferUpdateImageData const): (WebCore::CachedImage::didUpdateImageData): * loader/cache/CachedImage.h: * loader/cache/CachedResource.cpp: (WebCore::CachedResource::CachedResource): (WebCore::CachedResource::load): (WebCore::CachedResource::finish): * loader/cache/CachedResource.h: (WebCore::CachedResource::setStatus): * page/csp/ContentSecurityPolicyResponseHeaders.h: (WebCore::ContentSecurityPolicyResponseHeaders::MarkableTraits::isEmptyValue): (WebCore::ContentSecurityPolicyResponseHeaders::MarkableTraits::emptyValue): (WebCore::ContentSecurityPolicyResponseHeaders::ContentSecurityPolicyResponseHeaders): * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::clearNonTimingData): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceLoadPriority.h: * platform/network/ResourceRequestBase.h: (WebCore::ResourceRequestBase::ResourceRequestBase): * platform/network/ResourceResponseBase.h: * platform/network/StoredCredentialsPolicy.h: Source/WTF: * wtf/Markable.h: (WTF::Markable::asOptional const): Add helper method to get Optional easily from Markable. * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::MarkableTraits::isEmptyValue): (WTF::ObjectIdentifier::MarkableTraits::emptyValue): (WTF::ObjectIdentifier::ObjectIdentifier): Add MarkableTraits for ObjectIdentifier. Canonical link: https://commits.webkit.org/220633@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-12 22:51:19 +00:00
}
[WTF] Add Markable<T, Traits> https://bugs.webkit.org/show_bug.cgi?id=189231 Reviewed by Sam Weinig. Source/WebCore: Use Markable<Seconds> and Markable<WallTime> in ResourceResponseBase. Since these fields are parsed results from http header fields, Seconds::nan() and WallTime::nan() can be used as an empty value for these fields. Thus we can use Markable because it uses these nan values as an empty values (they are configured by Seconds::MarkableTraits and WallTime::MarkableTraits). This reduces the size of ResourceResponseBase from 448 to 416. * platform/network/ResourceResponseBase.h: Source/WTF: We can represent a value with nullopt by using std::optional<T>. However, std::optional<T> has storage efficiency problem. It always has a bool indicating that the value is nullopt or not. If we have a following class, class A { std::optional<WallTime> m_timeA; std::optional<WallTime> m_timeB; std::optional<WallTime> m_timeC; }; This class has significant amount of padding between m_timeA / m_timeB, m_timeB / m_timeC due to the above bool. If we know that WallTime has a value that represents invalid, we can use it instead and save the storage. This is very similar problem to our HashTable implementation. In our HashTable implementation, we need Deleted and Empty value, which can represent Deleted and Empty values without sacrificing storage efficiency. We should have similar mechanism here. In this patch, we have WTF::Markable<T, Traits>. Traits offers `Traits::isEmptyValue(value)` and `Traits::emptyValue()`. Then, we use this empty value instead of having bool flag. This way, we can make `sizeof(WTF::Markable<T>) == sizeof(T)`. This idea is inspired from https://github.com/akrzemi1/markable. But we would like to have WTF::Markable<T> here instead of importing it since we would like to have (1) integrated interfaces with std::optional<T> and (2) aligned function names to HashTraits' `isEmptyValue` and `emptyValue`. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Markable.h: Added. (WTF::std::underlying_type<EnumType>::type>::max): EnumMarkableTraits can be used as an MarkableTraits for enum values. We can specify a constant value as an empty value. (WTF::IntegralMarkableTraits::isEmptyValue): (WTF::IntegralMarkableTraits::emptyValue): IntegralMarkableTraits can be used as an MarkableTraits for integral types including int etc. (WTF::Markable::Markable): (WTF::Markable::operator bool const): (WTF::Markable::reset): (WTF::Markable::value const): (WTF::Markable::value): (WTF::Markable::operator-> const): (WTF::Markable::operator->): (WTF::Markable::operator* const): (WTF::Markable::operator*): (WTF::Markable::operator std::optional<T>): (WTF::Markable::operator std::optional<T> const): This operator allows us to cast Markable<T> to std::optional<T>. * wtf/MonotonicTime.h: (WTF::MonotonicTime::MarkableTraits::isEmptyValue): (WTF::MonotonicTime::MarkableTraits::emptyValue): MarkableTraits for MonotonicTime. MonotonicTime::nan() is used as an empty value. * wtf/Seconds.h: (WTF::Seconds::MarkableTraits::isEmptyValue): (WTF::Seconds::MarkableTraits::emptyValue): MarkableTraits for Seconds. Seconds::nan() is used as an empty value. * wtf/WallTime.h: (WTF::WallTime::nan): (WTF::WallTime::MarkableTraits::isEmptyValue): (WTF::WallTime::MarkableTraits::emptyValue): MarkableTraits for WallTime. WallTime::nan() is used as an empty value. Tools: Add tests for Markable. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/Markable.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/204438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-10 18:19:09 +00:00
private:
T m_value;
};
Web Inspector: Timelines: add a timeline that shows information about any recorded CSS animation/transition https://bugs.webkit.org/show_bug.cgi?id=203651 <rdar://problem/56128726> Reviewed by Brian Burg. Source/JavaScriptCore: Unlike all other forms of Web Animations, CSS animations/transitions, are _not_ created by JavaScript, and therefore can seemingly appear out of nowhere. This patch expands the Media timeline to be the Media & Animations timeline, which tracks when CSS animations/transitions are created, started, delayed, iterated, canceled, or finished. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources.make: * inspector/protocol/Animation.json: Added. * inspector/protocol/Timeline.json: Add an Animation domain for handling the tracking of CSS Web Animations. Source/WebCore: Unlike all other forms of Web Animations, CSS animations/transitions, are _not_ created by JavaScript, and therefore can seemingly appear out of nowhere. This patch expands the Media timeline to be the Media & Animations timeline, which tracks when CSS animations/transitions are created, started, delayed, iterated, canceled, or finished. Test: inspector/animation/tracking.html * animation/KeyframeEffect.cpp: (WebCore::KeyframeEffect::apply): * animation/WebAnimation.h: * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): (WebCore::WebAnimation::contextDestroyed): Added. (WebCore::WebAnimation::setEffectInternal): * inspector/InspectorInstrumentation.h: (WebCore::InspectorInstrumentation::willApplyKeyframeEffect): Added. (WebCore::InspectorInstrumentation::didChangeWebAnimationEffect): Added. (WebCore::InspectorInstrumentation::willDestroyWebAnimation): Added. * inspector/InspectorInstrumentation.cpp: (WebCore::InspectorInstrumentation::willApplyKeyframeEffectImpl): Added. (WebCore::InspectorInstrumentation::didChangeWebAnimationEffectImpl): Added. (WebCore::InspectorInstrumentation::willDestroyWebAnimationImpl): Added. Add instrumentation points for CSS animations/transitions. * inspector/agents/InspectorAnimationAgent.h: Added. * inspector/agents/InspectorAnimationAgent.cpp: Added. (WebCore::InspectorAnimationAgent::InspectorAnimationAgent): (WebCore::InspectorAnimationAgent::didCreateFrontendAndBackend): (WebCore::InspectorAnimationAgent::willDestroyFrontendAndBackend): (WebCore::InspectorAnimationAgent::startTracking): (WebCore::InspectorAnimationAgent::stopTracking): (WebCore::isDelayed): (WebCore::InspectorAnimationAgent::willApplyKeyframeEffect): (WebCore::InspectorAnimationAgent::didChangeWebAnimationEffect): (WebCore::InspectorAnimationAgent::willDestroyWebAnimation): (WebCore::InspectorAnimationAgent::stopTrackingDeclarativeAnimation): * inspector/InstrumentingAgents.h: (WebCore::InstrumentingAgents::persistentInspectorAnimationAgent const): Added. (WebCore::InstrumentingAgents::setPersistentInspectorAnimationAgent): Added. (WebCore::InstrumentingAgents::trackingInspectorAnimationAgent const): Added. (WebCore::InstrumentingAgents::setTrackingInspectorAnimationAgent): Added. * inspector/InstrumentingAgents.cpp: (WebCore::InstrumentingAgents::reset): * inspector/InspectorController.cpp: (WebCore::InspectorController::createLazyAgents): Add an Animation domain for handling the tracking of CSS Web Animations. * inspector/agents/InspectorTimelineAgent.h: * inspector/agents/InspectorTimelineAgent.cpp: (WebCore::InspectorTimelineAgent::toggleInstruments): (WebCore::InspectorTimelineAgent::toggleAnimationInstrument): Added. * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Source/WebInspectorUI: Unlike all other forms of Web Animations, CSS animations/transitions, are _not_ created by JavaScript, and therefore can seemingly appear out of nowhere. This patch expands the Media timeline to be the Media & Animations timeline, which tracks when CSS animations/transitions are created, started, delayed, iterated, canceled, or finished. * UserInterface/Protocol/AnimationObserver.js: Added. (WI.AnimationObserver.prototype.trackingStart): (WI.AnimationObserver.prototype.trackingUpdate): (WI.AnimationObserver.prototype.trackingComplete): * UserInterface/Protocol/Target.js: (WI.Target.prototype.get AnimationAgent): Added. * UserInterface/Main.html: * UserInterface/Base/Main.js: (WI.loaded): * UserInterface/Test.html: * UserInterface/Test/Test.js: (WI.loaded): Add an Animation domain for handling the tracking of CSS Web Animations. * UserInterface/Models/MediaInstrument.js: (WI.MediaInstrument.prototype.startInstrumentation): (WI.MediaInstrument.prototype.stopInstrumentation): (WI.MediaInstrument): * UserInterface/Models/MediaTimeline.js: Added. (WI.MediaTimeline.prototype.recordForTrackingAnimationId): (WI.MediaTimeline.prototype.recordForMediaElementEvents): (WI.MediaTimeline.prototype.reset): (WI.MediaTimeline.prototype.addRecord): * UserInterface/Models/MediaTimelineRecord.js: (WI.MediaTimelineRecord): (WI.MediaTimelineRecord.async fromJSON): (WI.MediaTimelineRecord.prototype.toJSON): (WI.MediaTimelineRecord.prototype.get trackingAnimationId): Added. (WI.MediaTimelineRecord.prototype.get timestamps): Added. (WI.MediaTimelineRecord.prototype.get activeStartTime): Added. (WI.MediaTimelineRecord.prototype.get updatesDynamically): Added. (WI.MediaTimelineRecord.prototype.get usesActiveStartTime): Added. (WI.MediaTimelineRecord.prototype.get displayName): (WI.MediaTimelineRecord.prototype.get subtitle): Added. (WI.MediaTimelineRecord.prototype.saveIdentityToCookie): (WI.MediaTimelineRecord.prototype.updateProgress): Added. (WI.MediaTimelineRecord.prototype.addDOMEvent): Added. (WI.MediaTimelineRecord.prototype.powerEfficientPlaybackStateChanged): Added. (WI.MediaTimelineRecord.prototype._updateTimes): Added. (WI.MediaTimelineRecord.fromJSON): Deleted. (WI.MediaTimelineRecord.prototype.get domEvent): Deleted. (WI.MediaTimelineRecord.prototype.get isPowerEfficient): Deleted. * UserInterface/Models/Timeline.js: (WI.Timeline.create): * UserInterface/Controllers/TimelineManager.js: (WI.TimelineManager): (WI.TimelineManager.prototype.async processJSON): (WI.TimelineManager.prototype.animationTrackingStarted): Added. (WI.TimelineManager.prototype.animationTrackingUpdated): Added. (WI.TimelineManager.prototype.animationTrackingCompleted): Added. (WI.TimelineManager.prototype._updateAutoCaptureInstruments): (WI.TimelineManager.prototype._handleDOMNodeDidFireEvent): (WI.TimelineManager.prototype._handleDOMNodePowerEfficientPlaybackStateChanged): Start/Stop tracking animations based on whether the Media & Animations timeline is enabled. * UserInterface/Views/MediaTimelineOverviewGraph.js: (WI.MediaTimelineOverviewGraph): (WI.MediaTimelineOverviewGraph.get maximumRowCount): Added. (WI.MediaTimelineOverviewGraph.prototype.reset): (WI.MediaTimelineOverviewGraph.prototype.layout): (WI.MediaTimelineOverviewGraph.prototype.updateSelectedRecord): (WI.MediaTimelineOverviewGraph.prototype._processRecord): Added. (WI.MediaTimelineOverviewGraph.prototype._processRecord.compareByStartTime): Added. (WI.MediaTimelineOverviewGraph.prototype._handleRecordAdded): (WI.MediaTimelineOverviewGraph.prototype._handleTimesUpdated): Added. (WI.MediaTimelineOverviewGraph.prototype.shown): Deleted. (WI.MediaTimelineOverviewGraph.prototype.hidden): Deleted. * UserInterface/Views/MediaTimelineOverviewGraph.css: (.timeline-overview-graph.media): Added. (.timeline-overview-graph.media > .graph-row): Added. (.timeline-overview-graph.media > .graph-row > .timeline-record-bar): Added. (.timeline-overview-graph.media > .graph-row > .timeline-record-bar:not(.unfinished) > .segment:not(.inactive)): Added. (.timeline-overview-graph.media:nth-child(even) > .graph-row > .timeline-record-bar:not(.unfinished) > .segment:not(.inactive)): Added. (.timeline-overview-graph.media > .timeline-record-bar): Deleted. (.timeline-overview-graph.media > .timeline-record-bar > .segment): Deleted. * UserInterface/Views/MediaTimelineView.js: (WI.MediaTimelineView): (WI.MediaTimelineView.prototype.shown): Added. (WI.MediaTimelineView.prototype.hidden): Added. (WI.MediaTimelineView.prototype.closed): (WI.MediaTimelineView.prototype.reset): (WI.MediaTimelineView.prototype.dataGridSortComparator): (WI.MediaTimelineView.prototype.dataGridSortComparator.compareDOMNodes): (WI.MediaTimelineView.prototype._processPendingRecords): * UserInterface/Views/MediaTimelineDataGridNode.js: (WI.MediaTimelineDataGridNode): (WI.MediaTimelineDataGridNode.prototype.get data): (WI.MediaTimelineDataGridNode.prototype.createCellContent): (WI.MediaTimelineDataGridNode.prototype.timelineRecordBarCustomChildren): Added. (WI.MediaTimelineDataGridNode.prototype.timelineRecordBarCustomChildren.addReadySegment): ADded. (WI.MediaTimelineDataGridNode.prototype.timelineRecordBarCustomChildren.addDelaySegment): ADded. (WI.MediaTimelineDataGridNode.prototype.timelineRecordBarCustomChildren.addActiveSegment): ADded. (WI.MediaTimelineDataGridNode.prototype.timelineRecordBarCustomChildren.addFullScreenSegment): ADded. (WI.MediaTimelineDataGridNode.prototype.timelineRecordBarCustomChildren.addPowerEfficientPlaybackSegment): ADded. (WI.MediaTimelineDataGridNode.prototype.timelineRecordBarCustomChildren.addPausedSegment): ADded. (WI.MediaTimelineDataGridNode.prototype.timelineRecordBarCustomChildren.addPlayingSegment): ADded. (WI.MediaTimelineDataGridNode.prototype.filterableDataForColumn): (WI.MediaTimelineDataGridNode.prototype._createNameCellDocumentFragment): Added. (WI.MediaTimelineDataGridNode.prototype.iconClassNames): Deleted. * UserInterface/Views/TimelineRecordBar.js: (WI.TimelineRecordBar): (WI.TimelineRecordBar.prototype.refresh): (WI.TimelineRecordBar.prototype._handleClick): * UserInterface/Views/TimelineRecordBar.css: (.timeline-record-bar): (.timeline-record-bar > :matches(img, .segment)): (.timeline-record-bar > img): (.timeline-record-bar > .segment): (body[dir=ltr] .timeline-record-bar > .segment): (body[dir=ltr] .timeline-record-bar > .segment:first-of-type): (body[dir=ltr] .timeline-record-bar > .segment:last-of-type): (body[dir=rtl] .timeline-record-bar > .segment): (body[dir=rtl] .timeline-record-bar > .segment:first-of-type): (body[dir=rtl] .timeline-record-bar > .segment:last-of-type): (.timeline-record-bar > .segment:not(:last-of-type)): (.timeline-record-bar.selected > .segment): (.timeline-record-bar > .segment.inactive,): (.timeline-record-bar.has-inactive-segment > .segment:not(.inactive)): (:focus .selected .timeline-record-bar:not(.has-custom-children) > .segment): (:focus .selected .timeline-record-bar:not(.has-custom-children) > .segment.inactive): (:focus .selected .timeline-record-bar.has-inactive-segment > .segment:not(.inactive)): (.timeline-record-bar.timeline-record-type-network > .segment): (.timeline-record-bar.timeline-record-type-network > .segment.inactive): (.timeline-record-bar.timeline-record-type-layout > .segment): (.timeline-record-bar.timeline-record-type-layout.paint > .segment,): (.timeline-record-bar.timeline-record-type-script > .segment): (.timeline-record-bar.timeline-record-type-script.garbage-collected > .segment,): (.timeline-record-bar.timeline-record-type-media > .segment): (.timeline-record-bar.has-custom-children.timeline-record-type-media > .segment): (.timeline-record-bar.has-custom-children.timeline-record-type-media > .segment.css-animation-ready): (.timeline-record-bar.has-custom-children.timeline-record-type-media > .segment:matches(.css-animation-delay, .media-element-paused)): (.timeline-record-bar.has-custom-children.timeline-record-type-media.media-element > .segment): (.timeline-record-bar.has-custom-children.timeline-record-type-media.media-element > .segment.media-element-full-screen): (.timeline-record-bar.has-custom-children.timeline-record-type-media.media-element > .segment.media-element-power-efficient-playback): (body[dir=ltr] .timeline-record-bar > .segment.inactive,): Deleted. (body[dir=ltr] .timeline-record-bar.has-inactive-segment > .segment:not(.inactive),): Deleted. (:focus .selected .timeline-record-bar > .segment): Deleted. (:focus .selected .timeline-record-bar > .segment.inactive): Deleted. (body[dir=ltr] :focus .selected .timeline-record-bar.has-inactive-segment > .segment:not(.inactive)): Deleted. (body[dir=rtl] :focus .selected .timeline-record-bar.has-inactive-segment > .segment:not(.inactive)): Deleted. Allow timeline record bars to be customized through a delegate callback. If provided, it will be used instead of any default content. It is expected to return an array of objects, each having a `startTime` number, `classNames` array, and `title` string. It can also have a `endTime` number and an `image` string. If `endTime` is `NaN`, the record is unfinished. If `image` is provided, an `<img>` will be used instead of a segment, allowing for markers. * UserInterface/Views/TimelineDataGridNode.js: (WI.TimelineDataGridNode.prototype.createCellContent): Add a default fallback for `WI.DOMNode` values. * UserInterface/Views/TimelineTabContentView.js: (WI.TimelineTabContentView.displayNameForTimelineType): (WI.TimelineTabContentView.iconClassNameForRecord): (WI.TimelineTabContentView.displayNameForRecord): * UserInterface/Views/TimelineRecordTreeElement.js: * UserInterface/Views/TimelineIcons.css: (.animation-frame-record .icon): (.css-animation-record .icon): Added. (.css-transition-record .icon): Added. (.media-element-record .icon): Added. (.animation-record .icon): Deleted. (.dom-event-record .icon): Deleted. (.dom-event-record.fullscreen .icon): Deleted. (.power-efficient-playback-state-changed-record .icon): Deleted. * UserInterface/Images/DOMEventFullscreen.svg: Removed. * UserInterface/Images/EventCancel.svg: Added. * UserInterface/Images/EventIteration.svg: Added. * UserInterface/Images/EventPause.svg: * UserInterface/Images/EventPlay.svg: * UserInterface/Images/EventProcessing.svg: * UserInterface/Images/EventStop.svg: * UserInterface/Images/PowerEfficientPlaybackStateChanged.svg: Removed. * UserInterface/Images/TimelineRecordAnimationFrame.svg: Renamed from Source/WebInspectorUI/UserInterface/Images/TimelineRecordAnimation.svg. * UserInterface/Images/TimelineRecordCSSAnimation.svg: Added. * UserInterface/Images/TimelineRecordCSSTransition.svg: Added. * UserInterface/Images/TimelineRecordMediaElement.svg: Added. Add new media icons. * UserInterface/Models/TimelineRecording.js: (WI.TimelineRecording.async import): Added. (WI.TimelineRecording.import): Deleted. * UserInterface/Models/TimelineRecord.js: * UserInterface/Models/CPUTimelineRecord.js: * UserInterface/Models/HeapAllocationsTimelineRecord.js: (WI.HeapAllocationsTimelineRecord.async fromJSON): Added. (WI.HeapAllocationsTimelineRecord.fromJSON): Deleted. * UserInterface/Models/LayoutTimelineRecord.js: * UserInterface/Models/MemoryTimelineRecord.js: * UserInterface/Models/RenderingFrameTimelineRecord.js: * UserInterface/Models/ResourceTimelineRecord.js: * UserInterface/Models/ScriptTimelineRecord.js: Make the importing of timeline records `async` so we can attempt to rehydrate the DOM nodes of any media records (as well as wait for heap snapshots). * UserInterface/Models/DOMNode.js: (WI.DOMNode): (WI.DOMNode.prototype.isMediaElement): Added. (WI.DOMNode.prototype._shouldListenForEventListeners): Deleted. * Localizations/en.lproj/localizedStrings.js: Source/WTF: * wtf/Markable.h: (WTF::operator==): (WTF::operator!=): Add extra utility operators. Tools: * TestWebKitAPI/Tests/WTF/Markable.cpp: (TestWebKitAPI::TEST): Add tests for extra utility operators. LayoutTests: * inspector/animation/tracking.html: Added. * inspector/animation/tracking-expected.txt: Added. Canonical link: https://commits.webkit.org/217127@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-11-02 00:45:35 +00:00
template <typename T, typename Traits> constexpr bool operator==(const Markable<T, Traits>& x, const Markable<T, Traits>& y)
{
if (bool(x) != bool(y))
return false;
if (!bool(x))
return true;
return x.value() == y.value();
}
template <typename T, typename Traits> constexpr bool operator==(const Markable<T, Traits>& x, const T& v) { return bool(x) && x.value() == v; }
template <typename T, typename Traits> constexpr bool operator==(const T& v, const Markable<T, Traits>& x) { return bool(x) && v == x.value(); }
template <typename T, typename Traits> constexpr bool operator!=(const Markable<T, Traits>& x, const Markable<T, Traits>& y) { return !(x == y); }
template <typename T, typename Traits> constexpr bool operator!=(const Markable<T, Traits>& x, const T& v) { return !(x == v); }
template <typename T, typename Traits> constexpr bool operator!=(const T& v, const Markable<T, Traits>& x) { return !(v == x); }
[WTF] Add Markable<T, Traits> https://bugs.webkit.org/show_bug.cgi?id=189231 Reviewed by Sam Weinig. Source/WebCore: Use Markable<Seconds> and Markable<WallTime> in ResourceResponseBase. Since these fields are parsed results from http header fields, Seconds::nan() and WallTime::nan() can be used as an empty value for these fields. Thus we can use Markable because it uses these nan values as an empty values (they are configured by Seconds::MarkableTraits and WallTime::MarkableTraits). This reduces the size of ResourceResponseBase from 448 to 416. * platform/network/ResourceResponseBase.h: Source/WTF: We can represent a value with nullopt by using std::optional<T>. However, std::optional<T> has storage efficiency problem. It always has a bool indicating that the value is nullopt or not. If we have a following class, class A { std::optional<WallTime> m_timeA; std::optional<WallTime> m_timeB; std::optional<WallTime> m_timeC; }; This class has significant amount of padding between m_timeA / m_timeB, m_timeB / m_timeC due to the above bool. If we know that WallTime has a value that represents invalid, we can use it instead and save the storage. This is very similar problem to our HashTable implementation. In our HashTable implementation, we need Deleted and Empty value, which can represent Deleted and Empty values without sacrificing storage efficiency. We should have similar mechanism here. In this patch, we have WTF::Markable<T, Traits>. Traits offers `Traits::isEmptyValue(value)` and `Traits::emptyValue()`. Then, we use this empty value instead of having bool flag. This way, we can make `sizeof(WTF::Markable<T>) == sizeof(T)`. This idea is inspired from https://github.com/akrzemi1/markable. But we would like to have WTF::Markable<T> here instead of importing it since we would like to have (1) integrated interfaces with std::optional<T> and (2) aligned function names to HashTraits' `isEmptyValue` and `emptyValue`. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/Markable.h: Added. (WTF::std::underlying_type<EnumType>::type>::max): EnumMarkableTraits can be used as an MarkableTraits for enum values. We can specify a constant value as an empty value. (WTF::IntegralMarkableTraits::isEmptyValue): (WTF::IntegralMarkableTraits::emptyValue): IntegralMarkableTraits can be used as an MarkableTraits for integral types including int etc. (WTF::Markable::Markable): (WTF::Markable::operator bool const): (WTF::Markable::reset): (WTF::Markable::value const): (WTF::Markable::value): (WTF::Markable::operator-> const): (WTF::Markable::operator->): (WTF::Markable::operator* const): (WTF::Markable::operator*): (WTF::Markable::operator std::optional<T>): (WTF::Markable::operator std::optional<T> const): This operator allows us to cast Markable<T> to std::optional<T>. * wtf/MonotonicTime.h: (WTF::MonotonicTime::MarkableTraits::isEmptyValue): (WTF::MonotonicTime::MarkableTraits::emptyValue): MarkableTraits for MonotonicTime. MonotonicTime::nan() is used as an empty value. * wtf/Seconds.h: (WTF::Seconds::MarkableTraits::isEmptyValue): (WTF::Seconds::MarkableTraits::emptyValue): MarkableTraits for Seconds. Seconds::nan() is used as an empty value. * wtf/WallTime.h: (WTF::WallTime::nan): (WTF::WallTime::MarkableTraits::isEmptyValue): (WTF::WallTime::MarkableTraits::emptyValue): MarkableTraits for WallTime. WallTime::nan() is used as an empty value. Tools: Add tests for Markable. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/Markable.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/204438@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-10 18:19:09 +00:00
} // namespace WTF
using WTF::Markable;
using WTF::IntegralMarkableTraits;
using WTF::EnumMarkableTraits;