Title: [256423] trunk/Source/WebCore
- Revision
- 256423
- Author
- ysuz...@apple.com
- Date
- 2020-02-11 20:11:04 -0800 (Tue, 11 Feb 2020)
Log Message
Compress ImmutableStyleProperties by using PackedPtr
https://bugs.webkit.org/show_bug.cgi?id=207604
Reviewed by Mark Lam.
ImmutableStyleProperties is kept so long and consumes enough memory.
We already attempted to compact it by storing CSSProperty's members separately.
But we can compact further by using PackedPtr. This patch makes,
1. Use PackedPtr for CSSValue* in ImmutableStyleProperties so that we can cut some bytes
2. Reorder CSSValue* and StylePropertyMetadata arrays since StylePropertyMetadata requires alignment while PackedPtr<CSSValue> is not.
No behavior change.
* css/StyleProperties.cpp:
(WebCore::sizeForImmutableStylePropertiesWithPropertyCount):
(WebCore::ImmutableStyleProperties::ImmutableStyleProperties):
(WebCore::ImmutableStyleProperties::~ImmutableStyleProperties):
(WebCore::ImmutableStyleProperties::findCustomPropertyIndex const):
* css/StyleProperties.h:
(WebCore::ImmutableStyleProperties::valueArray const):
(WebCore::ImmutableStyleProperties::metadataArray const):
(WebCore::ImmutableStyleProperties::propertyAt const):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (256422 => 256423)
--- trunk/Source/WebCore/ChangeLog 2020-02-12 03:43:23 UTC (rev 256422)
+++ trunk/Source/WebCore/ChangeLog 2020-02-12 04:11:04 UTC (rev 256423)
@@ -1,3 +1,29 @@
+2020-02-11 Yusuke Suzuki <ysuz...@apple.com>
+
+ Compress ImmutableStyleProperties by using PackedPtr
+ https://bugs.webkit.org/show_bug.cgi?id=207604
+
+ Reviewed by Mark Lam.
+
+ ImmutableStyleProperties is kept so long and consumes enough memory.
+ We already attempted to compact it by storing CSSProperty's members separately.
+ But we can compact further by using PackedPtr. This patch makes,
+
+ 1. Use PackedPtr for CSSValue* in ImmutableStyleProperties so that we can cut some bytes
+ 2. Reorder CSSValue* and StylePropertyMetadata arrays since StylePropertyMetadata requires alignment while PackedPtr<CSSValue> is not.
+
+ No behavior change.
+
+ * css/StyleProperties.cpp:
+ (WebCore::sizeForImmutableStylePropertiesWithPropertyCount):
+ (WebCore::ImmutableStyleProperties::ImmutableStyleProperties):
+ (WebCore::ImmutableStyleProperties::~ImmutableStyleProperties):
+ (WebCore::ImmutableStyleProperties::findCustomPropertyIndex const):
+ * css/StyleProperties.h:
+ (WebCore::ImmutableStyleProperties::valueArray const):
+ (WebCore::ImmutableStyleProperties::metadataArray const):
+ (WebCore::ImmutableStyleProperties::propertyAt const):
+
2020-02-11 Carlos Alberto Lopez Perez <clo...@igalia.com>
[GStreamer] Debug build fix after r256353.
Modified: trunk/Source/WebCore/css/StyleProperties.cpp (256422 => 256423)
--- trunk/Source/WebCore/css/StyleProperties.cpp 2020-02-12 03:43:23 UTC (rev 256422)
+++ trunk/Source/WebCore/css/StyleProperties.cpp 2020-02-12 04:11:04 UTC (rev 256423)
@@ -55,7 +55,7 @@
static size_t sizeForImmutableStylePropertiesWithPropertyCount(unsigned count)
{
- return sizeof(ImmutableStyleProperties) - sizeof(void*) + sizeof(CSSValue*) * count + sizeof(StylePropertyMetadata) * count;
+ return sizeof(ImmutableStyleProperties) - sizeof(void*) + sizeof(StylePropertyMetadata) * count + sizeof(PackedPtr<const CSSValue>) * count;
}
static bool isInitialOrInherit(const String& value)
@@ -94,17 +94,18 @@
: StyleProperties(cssParserMode, length)
{
StylePropertyMetadata* metadataArray = const_cast<StylePropertyMetadata*>(this->metadataArray());
- CSSValue** valueArray = const_cast<CSSValue**>(this->valueArray());
+ PackedPtr<CSSValue>* valueArray = bitwise_cast<PackedPtr<CSSValue>*>(this->valueArray());
for (unsigned i = 0; i < length; ++i) {
metadataArray[i] = properties[i].metadata();
- valueArray[i] = properties[i].value();
- valueArray[i]->ref();
+ auto* value = properties[i].value();
+ valueArray[i] = value;
+ value->ref();
}
}
ImmutableStyleProperties::~ImmutableStyleProperties()
{
- CSSValue** valueArray = const_cast<CSSValue**>(this->valueArray());
+ PackedPtr<CSSValue>* valueArray = bitwise_cast<PackedPtr<CSSValue>*>(this->valueArray());
for (unsigned i = 0; i < m_arraySize; ++i)
valueArray[i]->deref();
}
@@ -1471,9 +1472,10 @@
for (int n = m_arraySize - 1 ; n >= 0; --n) {
if (metadataArray()[n].m_propertyID == CSSPropertyCustom) {
// We found a custom property. See if the name matches.
- if (!valueArray()[n])
+ auto* value = valueArray()[n].get();
+ if (!value)
continue;
- if (downcast<CSSCustomPropertyValue>(*valueArray()[n]).name() == propertyName)
+ if (downcast<CSSCustomPropertyValue>(*value).name() == propertyName)
return n;
}
}
Modified: trunk/Source/WebCore/css/StyleProperties.h (256422 => 256423)
--- trunk/Source/WebCore/css/StyleProperties.h 2020-02-12 03:43:23 UTC (rev 256422)
+++ trunk/Source/WebCore/css/StyleProperties.h 2020-02-12 04:11:04 UTC (rev 256423)
@@ -190,8 +190,6 @@
bool isEmpty() const { return !propertyCount(); }
PropertyReference propertyAt(unsigned index) const;
- const CSSValue** valueArray() const;
- const StylePropertyMetadata* metadataArray() const;
int findPropertyIndex(CSSPropertyID) const;
int findCustomPropertyIndex(const String& propertyName) const;
@@ -198,17 +196,19 @@
void* m_storage;
private:
+ PackedPtr<const CSSValue>* valueArray() const;
+ const StylePropertyMetadata* metadataArray() const;
ImmutableStyleProperties(const CSSProperty*, unsigned count, CSSParserMode);
};
-inline const CSSValue** ImmutableStyleProperties::valueArray() const
+inline PackedPtr<const CSSValue>* ImmutableStyleProperties::valueArray() const
{
- return reinterpret_cast<const CSSValue**>(const_cast<const void**>((&(this->m_storage))));
+ return bitwise_cast<PackedPtr<const CSSValue>*>(bitwise_cast<const uint8_t*>(metadataArray()) + (m_arraySize * sizeof(StylePropertyMetadata)));
}
inline const StylePropertyMetadata* ImmutableStyleProperties::metadataArray() const
{
- return reinterpret_cast_ptr<const StylePropertyMetadata*>(&reinterpret_cast_ptr<const char*>(&(this->m_storage))[m_arraySize * sizeof(CSSValue*)]);
+ return reinterpret_cast<const StylePropertyMetadata*>(const_cast<const void**>((&(this->m_storage))));
}
DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(MutableStyleProperties);
@@ -289,7 +289,7 @@
inline ImmutableStyleProperties::PropertyReference ImmutableStyleProperties::propertyAt(unsigned index) const
{
- return PropertyReference(metadataArray()[index], valueArray()[index]);
+ return PropertyReference(metadataArray()[index], valueArray()[index].get());
}
inline MutableStyleProperties::PropertyReference MutableStyleProperties::propertyAt(unsigned index) const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes