Changeset 117353 in webkit


Ignore:
Timestamp:
May 16, 2012 3:25:10 PM (12 years ago)
Author:
ojan@chromium.org
Message:

Fix perf regression from r116487
https://bugs.webkit.org/show_bug.cgi?id=86680

Reviewed by Ryosuke Niwa.

http://trac.webkit.org/changeset/116487 caused a 6% regression on
Dromaeo's dom-attr test. The issue is that we invalidated NodeList
caches whenever an id/checked/type attribute changed.

First, we don't need to invalidate on checked/type since that only
affects the values return by NodeList items, not the list of items.
Second, we only need to invalidate NodeList caches when an id attribute
changes on a FormControlElement.

Incidentally, we also don't need to invalidate caches for changes
to attributes that don't have an ownerElement.

No new tests. This is strictly a performance improvement.

  • dom/Attr.cpp:

(WebCore::Attr::setValue):
(WebCore::Attr::childrenChanged):

  • dom/Element.cpp:

(WebCore::Element::attributeChanged):

  • dom/Node.cpp:

(WebCore::Node::invalidateNodeListsCacheAfterAttributeChanged):

  • dom/Node.h:

(Node):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r117339 r117353  
     12012-05-16  Ojan Vafai  <ojan@chromium.org>
     2
     3        Fix perf regression from r116487
     4        https://bugs.webkit.org/show_bug.cgi?id=86680
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        http://trac.webkit.org/changeset/116487 caused a 6% regression on
     9        Dromaeo's dom-attr test. The issue is that we invalidated NodeList
     10        caches whenever an id/checked/type attribute changed.
     11
     12        First, we don't need to invalidate on checked/type since that only
     13        affects the values return by NodeList items, not the list of items.
     14        Second, we only need to invalidate NodeList caches when an id attribute
     15        changes on a FormControlElement.
     16
     17        Incidentally, we also don't need to invalidate caches for changes
     18        to attributes that don't have an ownerElement.
     19
     20        No new tests. This is strictly a performance improvement.
     21
     22        * dom/Attr.cpp:
     23        (WebCore::Attr::setValue):
     24        (WebCore::Attr::childrenChanged):
     25        * dom/Element.cpp:
     26        (WebCore::Element::attributeChanged):
     27        * dom/Node.cpp:
     28        (WebCore::Node::invalidateNodeListsCacheAfterAttributeChanged):
     29        * dom/Node.h:
     30        (Node):
     31
    1322012-04-22  Robert Hogan  <robert@webkit.org>
    233
  • trunk/Source/WebCore/dom/Attr.cpp

    r117195 r117353  
    120120    m_ignoreChildrenChanged--;
    121121
    122     invalidateNodeListsCacheAfterAttributeChanged(m_name);
     122    invalidateNodeListsCacheAfterAttributeChanged(m_name, m_element);
    123123}
    124124
     
    163163        return;
    164164
    165     invalidateNodeListsCacheAfterAttributeChanged(qualifiedName());
     165    invalidateNodeListsCacheAfterAttributeChanged(qualifiedName(), m_element);
    166166
    167167    // FIXME: We should include entity references in the value
  • trunk/Source/WebCore/dom/Element.cpp

    r117323 r117353  
    717717    }
    718718
    719     invalidateNodeListsCacheAfterAttributeChanged(attribute.name());
     719    invalidateNodeListsCacheAfterAttributeChanged(attribute.name(), this);
    720720
    721721    if (!AXObjectCache::accessibilityEnabled())
  • trunk/Source/WebCore/dom/Node.cpp

    r117210 r117353  
    977977}
    978978
    979 void Node::invalidateNodeListsCacheAfterAttributeChanged(const QualifiedName& attrName)
     979void Node::invalidateNodeListsCacheAfterAttributeChanged(const QualifiedName& attrName, Element* attributeOwnerElement)
    980980{
    981981    if (hasRareData() && isAttributeNode()) {
     
    985985    }
    986986
    987     // This list should be sync'ed with NodeListsNodeData.
     987    // Modifications to attributes that are not associated with an Element can't invalidate NodeList caches.
     988    if (!attributeOwnerElement)
     989        return;
     990
     991    // FIXME: Move the list of attributes each NodeList type cares about to be a static on the
     992    // appropriate NodeList class. Then use those lists here and in invalidateCachesThatDependOnAttributes
     993    // to only invalidate the cache types that depend on the attribute that changed.
     994    // FIXME: Keep track of when we have no caches of a given type so that we can avoid the for-loop
     995    // below even if a related attribute changed (e.g. if we have no RadioNodeLists, we don't need
     996    // to invalidate any caches when id attributes change.)
    988997    if (attrName != classAttr
    989998#if ENABLE(MICRODATA)
     
    9921001        && attrName != itemtypeAttr
    9931002#endif
    994         && attrName != idAttr
    995         && attrName != typeAttr
    996         && attrName != checkedAttr
    9971003        && attrName != nameAttr
    998         && attrName != forAttr)
     1004        && attrName != forAttr
     1005        && (attrName != idAttr || !attributeOwnerElement->isFormControlElement()))
    9991006        return;
    10001007
  • trunk/Source/WebCore/dom/Node.h

    r117323 r117353  
    558558    void registerDynamicSubtreeNodeList(DynamicSubtreeNodeList*);
    559559    void unregisterDynamicSubtreeNodeList(DynamicSubtreeNodeList*);
    560     void invalidateNodeListsCacheAfterAttributeChanged(const QualifiedName&);
     560    void invalidateNodeListsCacheAfterAttributeChanged(const QualifiedName&, Element* attributeOwnerElement);
    561561    void invalidateNodeListsCacheAfterChildrenChanged();
    562562    void removeCachedClassNodeList(ClassNodeList*, const String&);
Note: See TracChangeset for help on using the changeset viewer.