Title: [256689] branches/safari-609-branch/Source/WebCore
- Revision
- 256689
- Author
- repst...@apple.com
- Date
- 2020-02-14 19:02:31 -0800 (Fri, 14 Feb 2020)
Log Message
Cherry-pick r256423. rdar://problem/59478731
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):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256423 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Diff
Modified: branches/safari-609-branch/Source/WebCore/ChangeLog (256688 => 256689)
--- branches/safari-609-branch/Source/WebCore/ChangeLog 2020-02-15 03:02:27 UTC (rev 256688)
+++ branches/safari-609-branch/Source/WebCore/ChangeLog 2020-02-15 03:02:31 UTC (rev 256689)
@@ -1,5 +1,61 @@
2020-02-14 Russell Epstein <repst...@apple.com>
+ Cherry-pick r256423. rdar://problem/59478731
+
+ 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):
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256423 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 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-14 Russell Epstein <repst...@apple.com>
+
Cherry-pick r254681. rdar://problem/59474790
[Win] Fix AppleWin build
Modified: branches/safari-609-branch/Source/WebCore/css/StyleProperties.cpp (256688 => 256689)
--- branches/safari-609-branch/Source/WebCore/css/StyleProperties.cpp 2020-02-15 03:02:27 UTC (rev 256688)
+++ branches/safari-609-branch/Source/WebCore/css/StyleProperties.cpp 2020-02-15 03:02:31 UTC (rev 256689)
@@ -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: branches/safari-609-branch/Source/WebCore/css/StyleProperties.h (256688 => 256689)
--- branches/safari-609-branch/Source/WebCore/css/StyleProperties.h 2020-02-15 03:02:27 UTC (rev 256688)
+++ branches/safari-609-branch/Source/WebCore/css/StyleProperties.h 2020-02-15 03:02:31 UTC (rev 256689)
@@ -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