Changeset 256482 in webkit


Ignore:
Timestamp:
Feb 12, 2020 2:51:19 PM (4 years ago)
Author:
ysuzuki@apple.com
Message:

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.

Location:
trunk/Source
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r256477 r256482  
     12020-02-12  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        Shrink CachedResource
     4        https://bugs.webkit.org/show_bug.cgi?id=207618
     5
     6        Reviewed by Mark Lam.
     7
     8        * wtf/Markable.h:
     9        (WTF::Markable::asOptional const): Add helper method to get Optional easily from Markable.
     10        * wtf/ObjectIdentifier.h:
     11        (WTF::ObjectIdentifier::MarkableTraits::isEmptyValue):
     12        (WTF::ObjectIdentifier::MarkableTraits::emptyValue):
     13        (WTF::ObjectIdentifier::ObjectIdentifier): Add MarkableTraits for ObjectIdentifier.
     14
    1152020-02-12  Simon Fraser  <simon.fraser@apple.com>
    216
  • trunk/Source/WTF/wtf/Markable.h

    r251959 r256482  
    143143    }
    144144
     145    Optional<T> asOptional() const
     146    {
     147        return Optional<T>(*this);
     148    }
     149
    145150private:
    146151    T m_value;
  • trunk/Source/WTF/wtf/ObjectIdentifier.h

    r255127 r256482  
    9797    }
    9898
     99    struct MarkableTraits {
     100        static bool isEmptyValue(ObjectIdentifier identifier)
     101        {
     102            return !identifier.m_identifier;
     103        }
     104
     105        static constexpr ObjectIdentifier emptyValue()
     106        {
     107            return ObjectIdentifier();
     108        }
     109    };
     110
    99111private:
    100112    template<typename U> friend ObjectIdentifier<U> makeObjectIdentifier(uint64_t);
     
    105117    static bool isValidIdentifier(uint64_t identifier) { return identifier && identifier != hashTableDeletedValue(); }
    106118
    107     explicit ObjectIdentifier(uint64_t identifier)
     119    explicit constexpr ObjectIdentifier(uint64_t identifier)
    108120        : m_identifier(identifier)
    109121    {
  • trunk/Source/WebCore/ChangeLog

    r256477 r256482  
     12020-02-12  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        Shrink CachedResource
     4        https://bugs.webkit.org/show_bug.cgi?id=207618
     5
     6        Reviewed by Mark Lam.
     7
     8        This patch shrinks sizeof(CachedResource) by 80 bytes by aggressively using bit-fields and Markable<>.
     9        For each enum class, we define `bitsOfXXX` value, which indicates # of bits to represent it. And using
     10        this value for bit-field's width.
     11
     12        No behavior change.
     13
     14        * loader/FetchOptions.h:
     15        (WebCore::FetchOptions::encode const):
     16        * loader/ResourceLoaderOptions.h:
     17        (WebCore::ResourceLoaderOptions::ResourceLoaderOptions):
     18        (WebCore::ResourceLoaderOptions::loadedFromOpaqueSource):
     19        * loader/cache/CachedImage.cpp:
     20        (WebCore::CachedImage::CachedImage):
     21        (WebCore::CachedImage::shouldDeferUpdateImageData const):
     22        (WebCore::CachedImage::didUpdateImageData):
     23        * loader/cache/CachedImage.h:
     24        * loader/cache/CachedResource.cpp:
     25        (WebCore::CachedResource::CachedResource):
     26        (WebCore::CachedResource::load):
     27        (WebCore::CachedResource::finish):
     28        * loader/cache/CachedResource.h:
     29        (WebCore::CachedResource::setStatus):
     30        * page/csp/ContentSecurityPolicyResponseHeaders.h:
     31        (WebCore::ContentSecurityPolicyResponseHeaders::MarkableTraits::isEmptyValue):
     32        (WebCore::ContentSecurityPolicyResponseHeaders::MarkableTraits::emptyValue):
     33        (WebCore::ContentSecurityPolicyResponseHeaders::ContentSecurityPolicyResponseHeaders):
     34        * platform/network/NetworkLoadMetrics.h:
     35        (WebCore::NetworkLoadMetrics::isolatedCopy const):
     36        (WebCore::NetworkLoadMetrics::clearNonTimingData):
     37        (WebCore::NetworkLoadMetrics::operator== const):
     38        (WebCore::NetworkLoadMetrics::encode const):
     39        (WebCore::NetworkLoadMetrics::decode):
     40        * platform/network/ResourceLoadPriority.h:
     41        * platform/network/ResourceRequestBase.h:
     42        (WebCore::ResourceRequestBase::ResourceRequestBase):
     43        * platform/network/ResourceResponseBase.h:
     44        * platform/network/StoredCredentialsPolicy.h:
     45
    1462020-02-12  Simon Fraser  <simon.fraser@apple.com>
    247
  • trunk/Source/WebCore/loader/FetchOptions.h

    r243163 r256482  
    3131#include "DocumentIdentifier.h"
    3232#include "ReferrerPolicy.h"
     33#include <wtf/Markable.h>
    3334#include <wtf/text/WTFString.h>
    3435
     
    5960    bool keepAlive { false };
    6061    String integrity;
    61     Optional<DocumentIdentifier> clientIdentifier;
     62    Markable<DocumentIdentifier, DocumentIdentifier::MarkableTraits> clientIdentifier;
    6263};
    6364
     
    229230{
    230231    encodePersistent(encoder);
    231     encoder << clientIdentifier;
     232    encoder << clientIdentifier.asOptional();
    232233}
    233234
  • trunk/Source/WebCore/loader/ResourceLoaderOptions.h

    r251155 r256482  
    4747    DoNotSendCallbacks
    4848};
     49static constexpr unsigned bitWidthOfSendCallbackPolicy = 1;
    4950
    5051// FIXME: These options are named poorly. We only implement force disabling content sniffing, not enabling it,
     
    5455    DoNotSniffContent
    5556};
     57static constexpr unsigned bitWidthOfContentSniffingPolicy = 1;
    5658
    5759enum class DataBufferingPolicy : uint8_t {
     
    5961    DoNotBufferData
    6062};
     63static constexpr unsigned bitWidthOfDataBufferingPolicy = 1;
    6164
    6265enum class SecurityCheckPolicy : uint8_t {
     
    6467    DoSecurityCheck
    6568};
     69static constexpr unsigned bitWidthOfSecurityCheckPolicy = 1;
    6670
    6771enum class CertificateInfoPolicy : uint8_t {
     
    6973    DoNotIncludeCertificateInfo
    7074};
     75static constexpr unsigned bitWidthOfCertificateInfoPolicy = 1;
    7176
    7277enum class ContentSecurityPolicyImposition : uint8_t {
     
    7479    DoPolicyCheck
    7580};
     81static constexpr unsigned bitWidthOfContentSecurityPolicyImposition = 1;
    7682
    7783enum class DefersLoadingPolicy : uint8_t {
     
    7985    DisallowDefersLoading
    8086};
     87static constexpr unsigned bitWidthOfDefersLoadingPolicy = 1;
    8188
    8289enum class CachingPolicy : uint8_t {
     
    8491    DisallowCaching
    8592};
     93static constexpr unsigned bitWidthOfCachingPolicy = 1;
    8694
    8795enum class ClientCredentialPolicy : uint8_t {
     
    8997    MayAskClientForCredentials
    9098};
     99static constexpr unsigned bitWidthOfClientCredentialPolicy = 1;
    91100
    92101enum class SameOriginDataURLFlag : uint8_t {
     
    94103    Unset
    95104};
     105static constexpr unsigned bitWidthOfSameOriginDataURLFlag = 1;
    96106
    97107enum class InitiatorContext : uint8_t {
     
    99109    Worker,
    100110};
     111static constexpr unsigned bitWidthOfInitiatorContext = 1;
    101112
    102113enum class ServiceWorkersMode : uint8_t {
     
    105116    Only // An error will happen if service worker is not handling the fetch. Used to bypass preflight safely.
    106117};
     118static constexpr unsigned bitWidthOfServiceWorkersMode = 2;
    107119
    108120enum class ApplicationCacheMode : uint8_t {
     
    110122    Bypass
    111123};
     124static constexpr unsigned bitWidthOfApplicationCacheMode = 1;
    112125
    113126// FIXME: These options are named poorly. We only implement force disabling content encoding sniffing, not enabling it,
     
    117130    DoNotSniff,
    118131};
     132static constexpr unsigned bitWidthOfContentEncodingSniffingPolicy = 1;
    119133
    120134enum class PreflightPolicy : uint8_t {
     
    123137    Prevent
    124138};
     139static constexpr unsigned bitWidthOfPreflightPolicy = 2;
    125140
    126141enum class LoadedFromOpaqueSource : uint8_t {
     
    128143    No
    129144};
     145static constexpr unsigned bitWidthOfLoadedFromOpaqueSource = 1;
    130146
    131147struct ResourceLoaderOptions : public FetchOptions {
    132     ResourceLoaderOptions() { }
    133 
    134     ResourceLoaderOptions(FetchOptions options) : FetchOptions { WTFMove(options) } { }
     148    ResourceLoaderOptions()
     149        : ResourceLoaderOptions(FetchOptions())
     150    {
     151    }
     152
     153    ResourceLoaderOptions(FetchOptions options)
     154        : FetchOptions { WTFMove(options) }
     155        , sendLoadCallbacks(SendCallbackPolicy::DoNotSendCallbacks)
     156        , sniffContent(ContentSniffingPolicy::DoNotSniffContent)
     157        , sniffContentEncoding(ContentEncodingSniffingPolicy::Sniff)
     158        , dataBufferingPolicy(DataBufferingPolicy::BufferData)
     159        , storedCredentialsPolicy(StoredCredentialsPolicy::DoNotUse)
     160        , securityCheck(SecurityCheckPolicy::DoSecurityCheck)
     161        , certificateInfoPolicy(CertificateInfoPolicy::DoNotIncludeCertificateInfo)
     162        , contentSecurityPolicyImposition(ContentSecurityPolicyImposition::DoPolicyCheck)
     163        , defersLoadingPolicy(DefersLoadingPolicy::AllowDefersLoading)
     164        , cachingPolicy(CachingPolicy::AllowCaching)
     165        , sameOriginDataURLFlag(SameOriginDataURLFlag::Unset)
     166        , initiatorContext(InitiatorContext::Document)
     167        , serviceWorkersMode(ServiceWorkersMode::All)
     168        , applicationCacheMode(ApplicationCacheMode::Use)
     169        , clientCredentialPolicy(ClientCredentialPolicy::CannotAskClientForCredentials)
     170        , preflightPolicy(PreflightPolicy::Consider)
     171        , loadedFromOpaqueSource(LoadedFromOpaqueSource::No)
     172    { }
    135173
    136174    ResourceLoaderOptions(SendCallbackPolicy sendLoadCallbacks, ContentSniffingPolicy sniffContent, DataBufferingPolicy dataBufferingPolicy, StoredCredentialsPolicy storedCredentialsPolicy, ClientCredentialPolicy credentialPolicy, FetchOptions::Credentials credentials, SecurityCheckPolicy securityCheck, FetchOptions::Mode mode, CertificateInfoPolicy certificateInfoPolicy, ContentSecurityPolicyImposition contentSecurityPolicyImposition, DefersLoadingPolicy defersLoadingPolicy, CachingPolicy cachingPolicy)
    137175        : sendLoadCallbacks(sendLoadCallbacks)
    138176        , sniffContent(sniffContent)
     177        , sniffContentEncoding(ContentEncodingSniffingPolicy::Sniff)
    139178        , dataBufferingPolicy(dataBufferingPolicy)
    140179        , storedCredentialsPolicy(storedCredentialsPolicy)
     
    144183        , defersLoadingPolicy(defersLoadingPolicy)
    145184        , cachingPolicy(cachingPolicy)
     185        , sameOriginDataURLFlag(SameOriginDataURLFlag::Unset)
     186        , initiatorContext(InitiatorContext::Document)
     187        , serviceWorkersMode(ServiceWorkersMode::All)
     188        , applicationCacheMode(ApplicationCacheMode::Use)
    146189        , clientCredentialPolicy(credentialPolicy)
     190        , preflightPolicy(PreflightPolicy::Consider)
     191        , loadedFromOpaqueSource(LoadedFromOpaqueSource::No)
     192
    147193    {
    148194        this->credentials = credentials;
     
    151197
    152198#if ENABLE(SERVICE_WORKER)
    153     Optional<ServiceWorkerRegistrationIdentifier> serviceWorkerRegistrationIdentifier;
     199    Markable<ServiceWorkerRegistrationIdentifier, ServiceWorkerRegistrationIdentifier::MarkableTraits> serviceWorkerRegistrationIdentifier;
    154200#endif
     201    Markable<ContentSecurityPolicyResponseHeaders, ContentSecurityPolicyResponseHeaders::MarkableTraits> cspResponseHeaders;
    155202    OptionSet<HTTPHeadersToKeepFromCleaning> httpHeadersToKeep;
    156     Optional<ContentSecurityPolicyResponseHeaders> cspResponseHeaders;
    157     unsigned maxRedirectCount { 20 };
    158 
    159     SendCallbackPolicy sendLoadCallbacks { SendCallbackPolicy::DoNotSendCallbacks };
    160     ContentSniffingPolicy sniffContent { ContentSniffingPolicy::DoNotSniffContent };
    161     ContentEncodingSniffingPolicy sniffContentEncoding { ContentEncodingSniffingPolicy::Sniff };
    162     DataBufferingPolicy dataBufferingPolicy { DataBufferingPolicy::BufferData };
    163     StoredCredentialsPolicy storedCredentialsPolicy { StoredCredentialsPolicy::DoNotUse };
    164     SecurityCheckPolicy securityCheck { SecurityCheckPolicy::DoSecurityCheck };
    165     CertificateInfoPolicy certificateInfoPolicy { CertificateInfoPolicy::DoNotIncludeCertificateInfo };
    166     ContentSecurityPolicyImposition contentSecurityPolicyImposition { ContentSecurityPolicyImposition::DoPolicyCheck };
    167     DefersLoadingPolicy defersLoadingPolicy { DefersLoadingPolicy::AllowDefersLoading };
    168     CachingPolicy cachingPolicy { CachingPolicy::AllowCaching };
    169     SameOriginDataURLFlag sameOriginDataURLFlag { SameOriginDataURLFlag::Unset };
    170     InitiatorContext initiatorContext { InitiatorContext::Document };
    171     ServiceWorkersMode serviceWorkersMode { ServiceWorkersMode::All };
    172     ApplicationCacheMode applicationCacheMode { ApplicationCacheMode::Use };
    173     ClientCredentialPolicy clientCredentialPolicy { ClientCredentialPolicy::CannotAskClientForCredentials };
    174     PreflightPolicy preflightPolicy { PreflightPolicy::Consider };
    175     LoadedFromOpaqueSource loadedFromOpaqueSource { LoadedFromOpaqueSource::No };
     203    uint8_t maxRedirectCount { 20 };
     204
     205    SendCallbackPolicy sendLoadCallbacks : bitWidthOfSendCallbackPolicy;
     206    ContentSniffingPolicy sniffContent : bitWidthOfContentSniffingPolicy;
     207    ContentEncodingSniffingPolicy sniffContentEncoding : bitWidthOfContentEncodingSniffingPolicy;
     208    DataBufferingPolicy dataBufferingPolicy : bitWidthOfDataBufferingPolicy;
     209    StoredCredentialsPolicy storedCredentialsPolicy : bitWidthOfStoredCredentialsPolicy;
     210    SecurityCheckPolicy securityCheck : bitWidthOfSecurityCheckPolicy;
     211    CertificateInfoPolicy certificateInfoPolicy : bitWidthOfCertificateInfoPolicy;
     212    ContentSecurityPolicyImposition contentSecurityPolicyImposition : bitWidthOfContentSecurityPolicyImposition;
     213    DefersLoadingPolicy defersLoadingPolicy : bitWidthOfDefersLoadingPolicy;
     214    CachingPolicy cachingPolicy : bitWidthOfCachingPolicy;
     215    SameOriginDataURLFlag sameOriginDataURLFlag : bitWidthOfSameOriginDataURLFlag;
     216    InitiatorContext initiatorContext : bitWidthOfInitiatorContext;
     217    ServiceWorkersMode serviceWorkersMode : bitWidthOfServiceWorkersMode;
     218    ApplicationCacheMode applicationCacheMode : bitWidthOfApplicationCacheMode;
     219    ClientCredentialPolicy clientCredentialPolicy : bitWidthOfClientCredentialPolicy;
     220    PreflightPolicy preflightPolicy : bitWidthOfPreflightPolicy;
     221    LoadedFromOpaqueSource loadedFromOpaqueSource : bitWidthOfLoadedFromOpaqueSource;
    176222};
    177223
  • trunk/Source/WebCore/loader/cache/CachedImage.cpp

    r254229 r256482  
    5858CachedImage::CachedImage(CachedResourceRequest&& request, const PAL::SessionID& sessionID, const CookieJar* cookieJar)
    5959    : CachedResource(WTFMove(request), Type::ImageResource, sessionID, cookieJar)
     60    , m_updateImageDataCount(0)
     61    , m_isManuallyCached(false)
     62    , m_shouldPaintBrokenImage(true)
     63    , m_forceUpdateImageDataEnabledForTesting(false)
    6064{
    6165    setStatus(Unknown);
     
    6569    : CachedResource(URL(), Type::ImageResource, sessionID, cookieJar)
    6670    , m_image(image)
     71    , m_updateImageDataCount(0)
     72    , m_isManuallyCached(false)
     73    , m_shouldPaintBrokenImage(true)
     74    , m_forceUpdateImageDataEnabledForTesting(false)
    6775{
    6876}
     
    7179    : CachedResource(url, Type::ImageResource, sessionID, cookieJar)
    7280    , m_image(image)
     81    , m_updateImageDataCount(0)
    7382    , m_isManuallyCached(true)
     83    , m_shouldPaintBrokenImage(true)
     84    , m_forceUpdateImageDataEnabledForTesting(false)
    7485{
    7586    m_resourceRequest.setDomainForCachePartition(domainForCachePartition);
     
    494505{
    495506    static const double updateImageDataBackoffIntervals[] = { 0, 1, 3, 6, 15 };
    496     unsigned interval = std::min<unsigned>(m_updateImageDataCount, 4);
     507    unsigned interval = m_updateImageDataCount;
    497508
    498509    // The first time through, the chunk time will be 0 and the image will get an update.
     
    516527{
    517528    m_lastUpdateImageDataTime = MonotonicTime::now();
    518     ASSERT(m_updateImageDataCount < std::numeric_limits<unsigned>::max());
    519     ++m_updateImageDataCount;
     529    unsigned previous = m_updateImageDataCount;
     530    if (previous != maxUpdateImageDataCount)
     531        m_updateImageDataCount += 1;
    520532}
    521533
  • trunk/Source/WebCore/loader/cache/CachedImage.h

    r254229 r256482  
    185185    MonotonicTime m_lastUpdateImageDataTime;
    186186
    187     unsigned m_updateImageDataCount { 0 };
    188     bool m_isManuallyCached { false };
    189     bool m_shouldPaintBrokenImage { true };
    190     bool m_forceUpdateImageDataEnabledForTesting { false };
     187    static constexpr unsigned maxUpdateImageDataCount = 4;
     188    unsigned m_updateImageDataCount : 3;
     189    bool m_isManuallyCached : 1;
     190    bool m_shouldPaintBrokenImage : 1;
     191    bool m_forceUpdateImageDataEnabledForTesting : 1;
    191192};
    192193
  • trunk/Source/WebCore/loader/cache/CachedResource.cpp

    r253987 r256482  
    130130    , m_origin(request.releaseOrigin())
    131131    , m_initiatorName(request.initiatorName())
     132    , m_type(type)
     133    , m_preloadResult(PreloadResult::PreloadNotReferenced)
     134    , m_responseTainting(ResourceResponse::Tainting::Basic)
    132135    , m_loadPriority(defaultPriorityForResourceType(type))
    133     , m_type(type)
     136    , m_status(Pending)
     137    , m_requestedFromNetworkingLayer(false)
     138    , m_inCache(false)
     139    , m_loading(false)
    134140    , m_isLinkPreload(request.isLinkPreload())
    135141    , m_hasUnknownEncoding(request.isLinkPreload())
     142    , m_switchingClientsToRevalidatedResource(false)
    136143    , m_ignoreForRequestCount(request.ignoreForRequestCount())
    137144{
     
    158165    , m_responseTimestamp(WallTime::now())
    159166    , m_fragmentIdentifierForRequest(CachedResourceRequest::splitFragmentIdentifierFromRequestURL(m_resourceRequest))
     167    , m_type(type)
     168    , m_preloadResult(PreloadResult::PreloadNotReferenced)
     169    , m_responseTainting(ResourceResponse::Tainting::Basic)
    160170    , m_status(Cached)
    161     , m_type(type)
     171    , m_requestedFromNetworkingLayer(false)
     172    , m_inCache(false)
     173    , m_loading(false)
     174    , m_isLinkPreload(false)
     175    , m_hasUnknownEncoding(false)
     176    , m_switchingClientsToRevalidatedResource(false)
     177    , m_ignoreForRequestCount(false)
    162178{
    163179    ASSERT(m_sessionID.isValid());
     
    313329            return;
    314330        }
    315         m_status = Pending;
     331        setStatus(Pending);
    316332    });
    317333}
     
    400416{
    401417    if (!errorOccurred())
    402         m_status = Cached;
     418        setStatus(Cached);
    403419}
    404420
  • trunk/Source/WebCore/loader/cache/CachedResource.h

    r254087 r256482  
    7878        Beacon,
    7979        Ping,
    80         SVGDocumentResource
    8180#if ENABLE(XSLT)
    82         , XSLStyleSheet
    83 #endif
    84         , LinkPrefetch
     81        XSLStyleSheet,
     82#endif
     83        LinkPrefetch,
    8584#if ENABLE(VIDEO_TRACK)
    86         , TextTrackResource
     85        TextTrackResource,
    8786#endif
    8887#if ENABLE(APPLICATION_MANIFEST)
    89         , ApplicationManifest
    90 #endif
     88        ApplicationManifest,
     89#endif
     90        SVGDocumentResource,
     91        LastType = SVGDocumentResource,
    9192    };
    92 
    93     enum Status {
     93    static constexpr unsigned bitWidthOfType = 5;
     94    static_assert(static_cast<unsigned>(Type::LastType) <= ((1U << bitWidthOfType) - 1));
     95
     96    enum Status : uint8_t {
    9497        Unknown,      // let cache decide what to do with it
    9598        Pending,      // only partially loaded
     
    98101        DecodeError
    99102    };
     103    static constexpr unsigned bitWidthOfStatus = 3;
     104    static_assert(static_cast<unsigned>(DecodeError) <= ((1ULL << bitWidthOfStatus) - 1));
    100105
    101106    CachedResource(CachedResourceRequest&&, Type, const PAL::SessionID&, const CookieJar*);
     
    143148        PreloadReferencedWhileComplete
    144149    };
     150    static constexpr unsigned bitWidthOfPreloadResult = 2;
     151
    145152    PreloadResult preloadResult() const { return static_cast<PreloadResult>(m_preloadResult); }
    146153
     
    153160
    154161    Status status() const { return static_cast<Status>(m_status); }
    155     void setStatus(Status status) { m_status = status; }
     162    void setStatus(Status status)
     163    {
     164        m_status = status;
     165        ASSERT(this->status() == status);
     166    }
    156167
    157168    unsigned size() const { return encodedSize() + decodedSize() + overheadSize(); }
     
    354365    AtomString m_initiatorName;
    355366
    356     RedirectChainCacheStatus m_redirectChainCacheStatus;
    357 
    358367    unsigned m_encodedSize { 0 };
    359368    unsigned m_decodedSize { 0 };
     
    362371    unsigned m_preloadCount { 0 };
    363372
    364     unsigned m_status { Pending }; // Status
    365 
    366     PreloadResult m_preloadResult { PreloadResult::PreloadNotReferenced };
    367 
    368     ResourceResponse::Tainting m_responseTainting { ResourceResponse::Tainting::Basic };
    369     ResourceLoadPriority m_loadPriority;
    370 
    371     Type m_type; // Type
    372 
    373     bool m_requestedFromNetworkingLayer { false };
    374     bool m_inCache { false };
    375     bool m_loading { false };
    376     bool m_isLinkPreload { false };
    377     bool m_hasUnknownEncoding { false };
    378     bool m_switchingClientsToRevalidatedResource { false };
    379     bool m_ignoreForRequestCount { false };
     373    RedirectChainCacheStatus m_redirectChainCacheStatus;
     374
     375    Type m_type : bitWidthOfType;
     376
     377    PreloadResult m_preloadResult : bitWidthOfPreloadResult;
     378    ResourceResponse::Tainting m_responseTainting : ResourceResponse::bitWidthOfTainting;
     379    ResourceLoadPriority m_loadPriority : bitWidthOfResourceLoadPriority;
     380
     381    Status m_status : bitWidthOfStatus;
     382    bool m_requestedFromNetworkingLayer : 1;
     383    bool m_inCache : 1;
     384    bool m_loading : 1;
     385    bool m_isLinkPreload : 1;
     386    bool m_hasUnknownEncoding : 1;
     387    bool m_switchingClientsToRevalidatedResource : 1;
     388    bool m_ignoreForRequestCount : 1;
    380389
    381390#if ASSERT_ENABLED
  • trunk/Source/WebCore/page/csp/ContentSecurityPolicyResponseHeaders.h

    r253206 r256482  
    5151    template <class Decoder> static bool decode(Decoder&, ContentSecurityPolicyResponseHeaders&);
    5252
     53    enum EmptyTag { Empty };
     54    struct MarkableTraits {
     55        static bool isEmptyValue(const ContentSecurityPolicyResponseHeaders& identifier)
     56        {
     57            return identifier.m_emptyForMarkable;
     58        }
     59
     60        static ContentSecurityPolicyResponseHeaders emptyValue()
     61        {
     62            return ContentSecurityPolicyResponseHeaders(Empty);
     63        }
     64    };
     65
    5366private:
    5467    friend class ContentSecurityPolicy;
     68    ContentSecurityPolicyResponseHeaders(EmptyTag)
     69        : m_emptyForMarkable(true)
     70    { }
    5571
    5672    Vector<std::pair<String, ContentSecurityPolicyHeaderType>> m_headers;
    5773    int m_httpStatusCode { 0 };
     74    bool m_emptyForMarkable { false };
    5875};
    5976
  • trunk/Source/WebCore/platform/network/NetworkLoadMetrics.h

    r251862 r256482  
    7171        copy.remoteAddress = remoteAddress.isolatedCopy();
    7272        copy.connectionIdentifier = connectionIdentifier.isolatedCopy();
    73         copy.priority = priority;
    7473        copy.tlsProtocol = tlsProtocol.isolatedCopy();
    7574        copy.tlsCipher = tlsCipher.isolatedCopy();
     75        copy.priority = priority;
    7676        copy.requestHeaders = requestHeaders.isolatedCopy();
    7777
     
    104104        remoteAddress = String();
    105105        connectionIdentifier = String();
    106         priority = NetworkLoadPriority::Unknown;
    107106        tlsProtocol = String();
    108107        tlsCipher = String();
     108        priority = NetworkLoadPriority::Unknown;
    109109        requestHeaders.clear();
    110110        requestHeaderBytesSent = std::numeric_limits<uint32_t>::max();
     
    129129            && remoteAddress == other.remoteAddress
    130130            && connectionIdentifier == other.connectionIdentifier
    131             && priority == other.priority
    132131            && tlsProtocol == other.tlsProtocol
    133132            && tlsCipher == other.tlsCipher
     133            && priority == other.priority
    134134            && requestHeaders == other.requestHeaders
    135135            && requestHeaderBytesSent == other.requestHeaderBytesSent
     
    167167    String remoteAddress;
    168168    String connectionIdentifier;
    169     NetworkLoadPriority priority;
    170169
    171170    String tlsProtocol;
     
    173172
    174173    // Whether or not all of the properties (0 or otherwise) have been set.
     174    NetworkLoadPriority priority;
    175175    bool complete { false };
    176176
     
    203203    encoder << remoteAddress;
    204204    encoder << connectionIdentifier;
    205     encoder << priority;
    206205    encoder << tlsProtocol;
    207206    encoder << tlsCipher;
     207    encoder << priority;
    208208    encoder << requestHeaders;
    209209    encoder << requestHeaderBytesSent;
     
    229229        && decoder.decode(metrics.remoteAddress)
    230230        && decoder.decode(metrics.connectionIdentifier)
    231         && decoder.decode(metrics.priority)
    232231        && decoder.decode(metrics.tlsProtocol)
    233232        && decoder.decode(metrics.tlsCipher)
     233        && decoder.decode(metrics.priority)
    234234        && decoder.decode(metrics.requestHeaders)
    235235        && decoder.decode(metrics.requestHeaderBytesSent)
  • trunk/Source/WebCore/platform/network/ResourceLoadPriority.h

    r233668 r256482  
    3838    Highest = VeryHigh,
    3939};
     40static constexpr unsigned bitWidthOfResourceLoadPriority = 3;
     41static_assert(static_cast<unsigned>(ResourceLoadPriority::Highest) <= ((1U << bitWidthOfResourceLoadPriority) - 1));
    4042
    4143static const unsigned resourceLoadPriorityCount { static_cast<unsigned>(ResourceLoadPriority::Highest) + 1 };
  • trunk/Source/WebCore/platform/network/ResourceRequestBase.h

    r256166 r256482  
    198198    // Used when ResourceRequest is initialized from a platform representation of the request
    199199    ResourceRequestBase()
    200         : m_platformRequestUpdated(true)
     200        : m_allowCookies(false)
     201        , m_resourceRequestUpdated(false)
     202        , m_platformRequestUpdated(true)
     203        , m_resourceRequestBodyUpdated(false)
    201204        , m_platformRequestBodyUpdated(true)
     205        , m_hiddenFromInspector(false)
     206        , m_isTopSite(false)
    202207    {
    203208    }
     
    210215        , m_allowCookies(true)
    211216        , m_resourceRequestUpdated(true)
     217        , m_platformRequestUpdated(false)
    212218        , m_resourceRequestBodyUpdated(true)
     219        , m_platformRequestBodyUpdated(false)
     220        , m_hiddenFromInspector(false)
     221        , m_isTopSite(false)
    213222    {
    214223    }
     
    237246    Requester m_requester { Requester::Unspecified };
    238247    Optional<int> m_inspectorInitiatorNodeIdentifier;
    239     bool m_allowCookies { false };
    240     mutable bool m_resourceRequestUpdated { false };
    241     mutable bool m_platformRequestUpdated { false };
    242     mutable bool m_resourceRequestBodyUpdated { false };
    243     mutable bool m_platformRequestBodyUpdated { false };
    244     bool m_hiddenFromInspector { false };
    245     bool m_isTopSite { false };
     248    bool m_allowCookies : 1;
     249    mutable bool m_resourceRequestUpdated : 1;
     250    mutable bool m_platformRequestUpdated : 1;
     251    mutable bool m_resourceRequestBodyUpdated : 1;
     252    mutable bool m_platformRequestBodyUpdated : 1;
     253    bool m_hiddenFromInspector : 1;
     254    bool m_isTopSite : 1;
    246255#if USE(SYSTEM_PREVIEW)
    247256    Optional<SystemPreviewInfo> m_systemPreviewInfo;
  • trunk/Source/WebCore/platform/network/ResourceResponseBase.h

    r255846 r256482  
    4949public:
    5050    enum class Type : uint8_t { Basic, Cors, Default, Error, Opaque, Opaqueredirect };
     51    static constexpr unsigned bitWidthOfType = 3;
    5152    enum class Tainting : uint8_t { Basic, Cors, Opaque, Opaqueredirect };
     53    static constexpr unsigned bitWidthOfTainting = 2;
    5254
    5355    static bool isRedirectionStatusCode(int code) { return code == 301 || code == 302 || code == 303 || code == 307 || code == 308; }
  • trunk/Source/WebCore/platform/network/StoredCredentialsPolicy.h

    r252185 r256482  
    3333    EphemeralStateless
    3434};
     35static constexpr unsigned bitWidthOfStoredCredentialsPolicy = 2;
    3536
    3637} // namespace WebCore
Note: See TracChangeset for help on using the changeset viewer.