⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 201559 in webkit


Ignore:
Timestamp:
Jun 1, 2016, 11:14:25 AM (10 years ago)
Author:
akling@apple.com
Message:

Use inline capacity for StylePropertyShorthand Vectors.
<https://webkit.org/b/158260>

Reviewed by Antti Koivisto.

Vector<StylePropertyShorthand> was a huge source of heap allocations,
just over 0.5% of all fastMalloc() bytes on PLUM. Giving it an inline capacity
of 4 turns all of it into stack allocations.

  • css/CSSParser.cpp:

(WebCore::CSSParser::addProperty):

  • css/CSSProperty.cpp:

(WebCore::StylePropertyMetadata::shorthandID):

  • css/StylePropertyShorthand.cpp:

(WebCore::indexOfShorthandForLonghand):

  • css/StylePropertyShorthand.h:
  • css/makeprop.pl:

(constructShorthandsVector):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r201557 r201559  
     12016-06-01  Andreas Kling  <akling@apple.com>
     2
     3        Use inline capacity for StylePropertyShorthand Vectors.
     4        <https://webkit.org/b/158260>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Vector<StylePropertyShorthand> was a huge source of heap allocations,
     9        just over 0.5% of all fastMalloc() bytes on PLUM. Giving it an inline capacity
     10        of 4 turns all of it into stack allocations.
     11
     12        * css/CSSParser.cpp:
     13        (WebCore::CSSParser::addProperty):
     14        * css/CSSProperty.cpp:
     15        (WebCore::StylePropertyMetadata::shorthandID):
     16        * css/StylePropertyShorthand.cpp:
     17        (WebCore::indexOfShorthandForLonghand):
     18        * css/StylePropertyShorthand.h:
     19        * css/makeprop.pl:
     20        (constructShorthandsVector):
     21
    1222016-06-01  Nael Ouedraogo  <nael.ouedraogo@crf.canon.fr>
    223
  • trunk/Source/WebCore/css/CSSParser.cpp

    r201498 r201559  
    16101610    }
    16111611
    1612     Vector<StylePropertyShorthand> shorthands = matchingShorthandsForLonghand(propId);
     1612    auto shorthands = matchingShorthandsForLonghand(propId);
    16131613    if (shorthands.size() == 1)
    16141614        m_parsedProperties.append(CSSProperty(propId, WTFMove(value), important, true, CSSPropertyInvalid, m_implicitShorthand || implicit));
  • trunk/Source/WebCore/css/CSSProperty.cpp

    r201113 r201559  
    4444        return CSSPropertyInvalid;
    4545
    46     Vector<StylePropertyShorthand> shorthands = matchingShorthandsForLonghand(static_cast<CSSPropertyID>(m_propertyID));
     46    auto shorthands = matchingShorthandsForLonghand(static_cast<CSSPropertyID>(m_propertyID));
    4747    ASSERT(shorthands.size() && m_indexInShorthandsVector >= 0 && m_indexInShorthandsVector < shorthands.size());
    4848    return shorthands[m_indexInShorthandsVector].id();
  • trunk/Source/WebCore/css/StylePropertyShorthand.cpp

    r201113 r201559  
    6969}
    7070
    71 unsigned indexOfShorthandForLonghand(CSSPropertyID shorthandID, const Vector<StylePropertyShorthand>& shorthands)
     71unsigned indexOfShorthandForLonghand(CSSPropertyID shorthandID, const StylePropertyShorthandVector& shorthands)
    7272{
    7373    for (unsigned i = 0, size = shorthands.size(); i < size; ++i) {
  • trunk/Source/WebCore/css/StylePropertyShorthand.h

    r201113 r201559  
    6262// Return the list of shorthands for a given longhand.
    6363// The implementation is generated in StylePropertyShorthandFunctions.cpp.
    64 Vector<StylePropertyShorthand> matchingShorthandsForLonghand(CSSPropertyID);
     64using StylePropertyShorthandVector = Vector<StylePropertyShorthand, 4>;
     65StylePropertyShorthandVector matchingShorthandsForLonghand(CSSPropertyID);
    6566
    66 unsigned indexOfShorthandForLonghand(CSSPropertyID, const Vector<StylePropertyShorthand>&);
     67unsigned indexOfShorthandForLonghand(CSSPropertyID, const StylePropertyShorthandVector&);
    6768
    6869bool isShorthandCSSProperty(CSSPropertyID);
  • trunk/Source/WebCore/css/makeprop.pl

    r195582 r201559  
    10061006
    10071007print SHORTHANDS_CPP << "EOF";
    1008 Vector<StylePropertyShorthand> matchingShorthandsForLonghand(CSSPropertyID propertyID)
     1008StylePropertyShorthandVector matchingShorthandsForLonghand(CSSPropertyID propertyID)
    10091009{
    10101010    switch (propertyID) {
     
    10141014  my $shorthands = shift;
    10151015
    1016   my $vector = "Vector<StylePropertyShorthand>{";
     1016  my $vector = "StylePropertyShorthandVector{";
    10171017  foreach my $i (0 .. $#$shorthands) {
    10181018    $vector .= ", " unless $i == 0;
Note: See TracChangeset for help on using the changeset viewer.