Changeset 256423 in webkit
- Timestamp:
- Feb 11, 2020 8:11:04 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r256421 r256423 1 2020-02-11 Yusuke Suzuki <ysuzuki@apple.com> 2 3 Compress ImmutableStyleProperties by using PackedPtr 4 https://bugs.webkit.org/show_bug.cgi?id=207604 5 6 Reviewed by Mark Lam. 7 8 ImmutableStyleProperties is kept so long and consumes enough memory. 9 We already attempted to compact it by storing CSSProperty's members separately. 10 But we can compact further by using PackedPtr. This patch makes, 11 12 1. Use PackedPtr for CSSValue* in ImmutableStyleProperties so that we can cut some bytes 13 2. Reorder CSSValue* and StylePropertyMetadata arrays since StylePropertyMetadata requires alignment while PackedPtr<CSSValue> is not. 14 15 No behavior change. 16 17 * css/StyleProperties.cpp: 18 (WebCore::sizeForImmutableStylePropertiesWithPropertyCount): 19 (WebCore::ImmutableStyleProperties::ImmutableStyleProperties): 20 (WebCore::ImmutableStyleProperties::~ImmutableStyleProperties): 21 (WebCore::ImmutableStyleProperties::findCustomPropertyIndex const): 22 * css/StyleProperties.h: 23 (WebCore::ImmutableStyleProperties::valueArray const): 24 (WebCore::ImmutableStyleProperties::metadataArray const): 25 (WebCore::ImmutableStyleProperties::propertyAt const): 26 1 27 2020-02-11 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 28 -
trunk/Source/WebCore/css/StyleProperties.cpp
r253987 r256423 56 56 static size_t sizeForImmutableStylePropertiesWithPropertyCount(unsigned count) 57 57 { 58 return sizeof(ImmutableStyleProperties) - sizeof(void*) + sizeof( CSSValue*) * count + sizeof(StylePropertyMetadata) * count;58 return sizeof(ImmutableStyleProperties) - sizeof(void*) + sizeof(StylePropertyMetadata) * count + sizeof(PackedPtr<const CSSValue>) * count; 59 59 } 60 60 … … 95 95 { 96 96 StylePropertyMetadata* metadataArray = const_cast<StylePropertyMetadata*>(this->metadataArray()); 97 CSSValue** valueArray = const_cast<CSSValue**>(this->valueArray());97 PackedPtr<CSSValue>* valueArray = bitwise_cast<PackedPtr<CSSValue>*>(this->valueArray()); 98 98 for (unsigned i = 0; i < length; ++i) { 99 99 metadataArray[i] = properties[i].metadata(); 100 valueArray[i] = properties[i].value(); 101 valueArray[i]->ref(); 100 auto* value = properties[i].value(); 101 valueArray[i] = value; 102 value->ref(); 102 103 } 103 104 } … … 105 106 ImmutableStyleProperties::~ImmutableStyleProperties() 106 107 { 107 CSSValue** valueArray = const_cast<CSSValue**>(this->valueArray());108 PackedPtr<CSSValue>* valueArray = bitwise_cast<PackedPtr<CSSValue>*>(this->valueArray()); 108 109 for (unsigned i = 0; i < m_arraySize; ++i) 109 110 valueArray[i]->deref(); … … 1472 1473 if (metadataArray()[n].m_propertyID == CSSPropertyCustom) { 1473 1474 // We found a custom property. See if the name matches. 1474 if (!valueArray()[n]) 1475 auto* value = valueArray()[n].get(); 1476 if (!value) 1475 1477 continue; 1476 if (downcast<CSSCustomPropertyValue>(*value Array()[n]).name() == propertyName)1478 if (downcast<CSSCustomPropertyValue>(*value).name() == propertyName) 1477 1479 return n; 1478 1480 } -
trunk/Source/WebCore/css/StyleProperties.h
r253987 r256423 191 191 PropertyReference propertyAt(unsigned index) const; 192 192 193 const CSSValue** valueArray() const;194 const StylePropertyMetadata* metadataArray() const;195 193 int findPropertyIndex(CSSPropertyID) const; 196 194 int findCustomPropertyIndex(const String& propertyName) const; … … 199 197 200 198 private: 199 PackedPtr<const CSSValue>* valueArray() const; 200 const StylePropertyMetadata* metadataArray() const; 201 201 ImmutableStyleProperties(const CSSProperty*, unsigned count, CSSParserMode); 202 202 }; 203 203 204 inline const CSSValue** ImmutableStyleProperties::valueArray() const205 { 206 return reinterpret_cast<const CSSValue**>(const_cast<const void**>((&(this->m_storage))));204 inline PackedPtr<const CSSValue>* ImmutableStyleProperties::valueArray() const 205 { 206 return bitwise_cast<PackedPtr<const CSSValue>*>(bitwise_cast<const uint8_t*>(metadataArray()) + (m_arraySize * sizeof(StylePropertyMetadata))); 207 207 } 208 208 209 209 inline const StylePropertyMetadata* ImmutableStyleProperties::metadataArray() const 210 210 { 211 return reinterpret_cast _ptr<const StylePropertyMetadata*>(&reinterpret_cast_ptr<const char*>(&(this->m_storage))[m_arraySize * sizeof(CSSValue*)]);211 return reinterpret_cast<const StylePropertyMetadata*>(const_cast<const void**>((&(this->m_storage)))); 212 212 } 213 213 … … 290 290 inline ImmutableStyleProperties::PropertyReference ImmutableStyleProperties::propertyAt(unsigned index) const 291 291 { 292 return PropertyReference(metadataArray()[index], valueArray()[index] );292 return PropertyReference(metadataArray()[index], valueArray()[index].get()); 293 293 } 294 294
Note: See TracChangeset
for help on using the changeset viewer.