WebKit Bugzilla
Attachment 349413 Details for
Bug 189501
: Shrink size of ResourseResponseBase
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-189501-20180912030830.patch (text/plain), 8.59 KB, created by
Yusuke Suzuki
on 2018-09-11 11:08:31 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2018-09-11 11:08:31 PDT
Size:
8.59 KB
patch
obsolete
>Subversion Revision: 235901 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index b897297c241ecc7cc6d925fe0f6406ce8bd69308..ee4b74672c9c8a8def6d480dc400db1a1d61e053 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,31 @@ >+2018-09-11 Yusuke Suzuki <yusukesuzuki@slowstart.org> >+ >+ Shrink size of ResourseResponseBase >+ https://bugs.webkit.org/show_bug.cgi?id=189501 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ We reduce the size of ResourceResponseBase by the following two optimizations. >+ >+ 1. Use bitfields for bool flags and reorder them. >+ >+ 2. Use Markable<> in CacheControlDirectives, which is held by ResourceResponseBase. >+ >+ This patch reduces the size of ResourceResponseBase from 416 to 392 bytes. >+ >+ No behavior change. >+ >+ * platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm: >+ (WebCore::WebCoreAVFResourceLoader::responseReceived): >+ (WebCore::WebCoreAVFResourceLoader::fulfillRequestWithResource): >+ * platform/network/CacheValidation.h: >+ (WebCore::CacheControlDirectives::CacheControlDirectives): >+ * platform/network/ResourceResponseBase.cpp: >+ (WebCore::ResourceResponseBase::ResourceResponseBase): >+ (WebCore::ResourceResponseBase::contentRange const): >+ * platform/network/ResourceResponseBase.h: >+ (WebCore::ResourceResponseBase::decode): >+ > 2018-09-11 Jiewen Tan <jiewen_tan@apple.com> > > Unreviewed, a speculative build fix for r235888. >diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm b/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm >index 406d50282641e161b11ea732db05b7194d6e89c8..be4037807b18f4cc1694fc94ef517154a29c6015 100644 >--- a/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm >+++ b/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm >@@ -136,7 +136,7 @@ void WebCoreAVFResourceLoader::responseReceived(CachedResource& resource, const > > [contentInfo setContentType:uti]; > >- ParsedContentRange& contentRange = m_resource->response().contentRange(); >+ const ParsedContentRange& contentRange = m_resource->response().contentRange(); > [contentInfo setContentLength:contentRange.isValid() ? contentRange.instanceLength() : response.expectedContentLength()]; > [contentInfo setByteRangeAccessSupported:YES]; > >@@ -181,7 +181,7 @@ void WebCoreAVFResourceLoader::fulfillRequestWithResource(CachedResource& resour > return; > > NSUInteger responseOffset = 0; >- ParsedContentRange contentRange = m_resource->response().contentRange(); >+ const ParsedContentRange& contentRange = m_resource->response().contentRange(); > if (contentRange.isValid()) > responseOffset = static_cast<NSUInteger>(contentRange.firstBytePosition()); > >diff --git a/Source/WebCore/platform/network/CacheValidation.h b/Source/WebCore/platform/network/CacheValidation.h >index f415ca8b2e13576dd3cb1072743d625be1c3e8fe..da990769b42d1e2d9782b9913f14a04be81c7f7d 100644 >--- a/Source/WebCore/platform/network/CacheValidation.h >+++ b/Source/WebCore/platform/network/CacheValidation.h >@@ -26,6 +26,7 @@ > #pragma once > > #include <pal/SessionID.h> >+#include <wtf/Markable.h> > #include <wtf/Optional.h> > #include <wtf/Vector.h> > #include <wtf/WallTime.h> >@@ -60,12 +61,19 @@ enum ReuseExpiredRedirectionOrNot { DoNotReuseExpiredRedirection, ReuseExpiredRe > WEBCORE_EXPORT bool redirectChainAllowsReuse(RedirectChainCacheStatus, ReuseExpiredRedirectionOrNot); > > struct CacheControlDirectives { >- std::optional<Seconds> maxAge; >- std::optional<Seconds> maxStale; >- bool noCache { false }; >- bool noStore { false }; >- bool mustRevalidate { false }; >- bool immutable { false }; >+ constexpr CacheControlDirectives() >+ : noCache(false) >+ , noStore(false) >+ , mustRevalidate(false) >+ , immutable(false) >+ { } >+ >+ Markable<Seconds, Seconds::MarkableTraits> maxAge; >+ Markable<Seconds, Seconds::MarkableTraits> maxStale; >+ bool noCache : 1; >+ bool noStore : 1; >+ bool mustRevalidate : 1; >+ bool immutable : 1; > }; > WEBCORE_EXPORT CacheControlDirectives parseCacheControlDirectives(const HTTPHeaderMap&); > >diff --git a/Source/WebCore/platform/network/ResourceResponseBase.cpp b/Source/WebCore/platform/network/ResourceResponseBase.cpp >index fb914216a0fe1693cf35d0cc904b1db0484b89c1..0ef1db7cd343742f4390c460ae92c24ad5869165 100644 >--- a/Source/WebCore/platform/network/ResourceResponseBase.cpp >+++ b/Source/WebCore/platform/network/ResourceResponseBase.cpp >@@ -47,7 +47,17 @@ bool isScriptAllowedByNosniff(const ResourceResponse& response) > return MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType); > } > >-ResourceResponseBase::ResourceResponseBase() = default; >+ResourceResponseBase::ResourceResponseBase() >+ : m_haveParsedCacheControlHeader(false) >+ , m_haveParsedAgeHeader(false) >+ , m_haveParsedDateHeader(false) >+ , m_haveParsedExpiresHeader(false) >+ , m_haveParsedLastModifiedHeader(false) >+ , m_haveParsedContentRangeHeader(false) >+ , m_isRedirected(false) >+ , m_isNull(true) >+{ >+} > > ResourceResponseBase::ResourceResponseBase(const URL& url, const String& mimeType, long long expectedLength, const String& textEncodingName) > : m_url(url) >@@ -55,6 +65,13 @@ ResourceResponseBase::ResourceResponseBase(const URL& url, const String& mimeTyp > , m_expectedContentLength(expectedLength) > , m_textEncodingName(textEncodingName) > , m_certificateInfo(CertificateInfo()) // Empty but valid for synthetic responses. >+ , m_haveParsedCacheControlHeader(false) >+ , m_haveParsedAgeHeader(false) >+ , m_haveParsedDateHeader(false) >+ , m_haveParsedExpiresHeader(false) >+ , m_haveParsedLastModifiedHeader(false) >+ , m_haveParsedContentRangeHeader(false) >+ , m_isRedirected(false) > , m_isNull(false) > { > } >@@ -702,7 +719,7 @@ static ParsedContentRange parseContentRangeInHeader(const HTTPHeaderMap& headers > return ParsedContentRange(contentRangeValue); > } > >-ParsedContentRange& ResourceResponseBase::contentRange() const >+const ParsedContentRange& ResourceResponseBase::contentRange() const > { > lazyInit(CommonFieldsOnly); > >diff --git a/Source/WebCore/platform/network/ResourceResponseBase.h b/Source/WebCore/platform/network/ResourceResponseBase.h >index cb4653015477eae769d8cd34c6d6bd40ad41699a..d8fcc1431b50bc7ab67f1d1968b91ce70ea161ef 100644 >--- a/Source/WebCore/platform/network/ResourceResponseBase.h >+++ b/Source/WebCore/platform/network/ResourceResponseBase.h >@@ -140,7 +140,7 @@ class ResourceResponseBase { > WEBCORE_EXPORT std::optional<Seconds> age() const; > WEBCORE_EXPORT std::optional<WallTime> expires() const; > WEBCORE_EXPORT std::optional<WallTime> lastModified() const; >- ParsedContentRange& contentRange() const; >+ const ParsedContentRange& contentRange() const; > > enum class Source : uint8_t { Unknown, Network, DiskCache, DiskCacheAfterValidation, MemoryCache, MemoryCacheAfterValidation, ServiceWorker, ApplicationCache }; > WEBCORE_EXPORT Source source() const; >@@ -222,20 +222,22 @@ class ResourceResponseBase { > mutable ParsedContentRange m_contentRange; > mutable CacheControlDirectives m_cacheControlDirectives; > >- mutable bool m_haveParsedCacheControlHeader { false }; >- mutable bool m_haveParsedAgeHeader { false }; >- mutable bool m_haveParsedDateHeader { false }; >- mutable bool m_haveParsedExpiresHeader { false }; >- mutable bool m_haveParsedLastModifiedHeader { false }; >- mutable bool m_haveParsedContentRangeHeader { false }; >- bool m_isRedirected { false }; >+ mutable bool m_haveParsedCacheControlHeader : 1; >+ mutable bool m_haveParsedAgeHeader : 1; >+ mutable bool m_haveParsedDateHeader : 1; >+ mutable bool m_haveParsedExpiresHeader : 1; >+ mutable bool m_haveParsedLastModifiedHeader : 1; >+ mutable bool m_haveParsedContentRangeHeader : 1; >+ bool m_isRedirected : 1; >+protected: >+ bool m_isNull : 1; > >+private: > Source m_source { Source::Unknown }; > Type m_type { Type::Default }; > Tainting m_tainting { Tainting::Basic }; > > protected: >- bool m_isNull { true }; > int m_httpStatusCode { 0 }; > }; > >@@ -310,8 +312,10 @@ bool ResourceResponseBase::decode(Decoder& decoder, ResourceResponseBase& respon > return false; > if (!decoder.decodeEnum(response.m_tainting)) > return false; >- if (!decoder.decode(response.m_isRedirected)) >+ bool isRedirected = false; >+ if (!decoder.decode(isRedirected)) > return false; >+ response.m_isRedirected = isRedirected; > response.m_isNull = false; > > return true;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189501
:
349398
| 349413