- Revision
- 235911
- Author
- [email protected]
- Date
- 2018-09-11 12:34:56 -0700 (Tue, 11 Sep 2018)
Log Message
Shrink size of ResourseResponseBase
https://bugs.webkit.org/show_bug.cgi?id=189501
Reviewed by Simon Fraser.
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):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (235910 => 235911)
--- trunk/Source/WebCore/ChangeLog 2018-09-11 19:30:46 UTC (rev 235910)
+++ trunk/Source/WebCore/ChangeLog 2018-09-11 19:34:56 UTC (rev 235911)
@@ -1,3 +1,31 @@
+2018-09-11 Yusuke Suzuki <[email protected]>
+
+ Shrink size of ResourseResponseBase
+ https://bugs.webkit.org/show_bug.cgi?id=189501
+
+ Reviewed by Simon Fraser.
+
+ 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 Michael Catanzaro <[email protected]>
Unreviewed, fix some -Wreturn-type warnings
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm (235910 => 235911)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm 2018-09-11 19:30:46 UTC (rev 235910)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm 2018-09-11 19:34:56 UTC (rev 235911)
@@ -136,7 +136,7 @@
[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 @@
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());
Modified: trunk/Source/WebCore/platform/network/CacheValidation.h (235910 => 235911)
--- trunk/Source/WebCore/platform/network/CacheValidation.h 2018-09-11 19:30:46 UTC (rev 235910)
+++ trunk/Source/WebCore/platform/network/CacheValidation.h 2018-09-11 19:34:56 UTC (rev 235911)
@@ -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 @@
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&);
Modified: trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp (235910 => 235911)
--- trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp 2018-09-11 19:30:46 UTC (rev 235910)
+++ trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp 2018-09-11 19:34:56 UTC (rev 235911)
@@ -47,7 +47,17 @@
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 @@
, 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 @@
return ParsedContentRange(contentRangeValue);
}
-ParsedContentRange& ResourceResponseBase::contentRange() const
+const ParsedContentRange& ResourceResponseBase::contentRange() const
{
lazyInit(CommonFieldsOnly);
Modified: trunk/Source/WebCore/platform/network/ResourceResponseBase.h (235910 => 235911)
--- trunk/Source/WebCore/platform/network/ResourceResponseBase.h 2018-09-11 19:30:46 UTC (rev 235910)
+++ trunk/Source/WebCore/platform/network/ResourceResponseBase.h 2018-09-11 19:34:56 UTC (rev 235911)
@@ -140,7 +140,7 @@
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 @@
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 @@
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;