Changeset 121126 in webkit


Ignore:
Timestamp:
Jun 24, 2012 5:41:05 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r121106.
http://trac.webkit.org/changeset/121106
https://bugs.webkit.org/show_bug.cgi?id=89841

Caused 85% performance regressions on Dromaeo/jslib-modify-
jquery.html (Requested by rniwa on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-06-24

  • dom/Document.cpp:

(WebCore::Document::clearNodeListCaches):

  • dom/Document.h:

(Document):

  • dom/DynamicNodeList.cpp:

(WebCore::DynamicSubtreeNodeList::~DynamicSubtreeNodeList):

  • dom/DynamicNodeList.h:

(WebCore::DynamicSubtreeNodeList::DynamicSubtreeNodeList):

  • dom/Node.cpp:

(WebCore::Node::clearRareData):
(WebCore::Node::invalidateNodeListsCacheAfterAttributeChanged):
(WebCore::Node::invalidateNodeListsCacheAfterChildrenChanged):
(WebCore::Node::getElementsByTagName):
(WebCore::Node::getElementsByTagNameNS):
(WebCore::Node::getElementsByName):
(WebCore::Node::getElementsByClassName):
(WebCore::Node::radioNodeList):
(WebCore::NodeListsNodeData::invalidateCaches):
(WebCore):
(WebCore::NodeRareData::createNodeLists):

  • dom/NodeRareData.h:

(NodeListsNodeData):
(WebCore::NodeListsNodeData::adoptTreeScope):
(WebCore::NodeRareData::ensureNodeLists):
(NodeRareData):

  • dom/TreeScope.cpp:

(WebCore::TreeScope::TreeScope):

  • dom/TreeScope.h:

(WebCore::TreeScope::addNodeListCache):
(WebCore::TreeScope::removeNodeListCache):
(WebCore::TreeScope::hasNodeListCaches):
(TreeScope):

  • dom/TreeScopeAdopter.cpp:

(WebCore::TreeScopeAdopter::moveTreeToNewScope):

  • html/LabelableElement.cpp:

(WebCore::LabelableElement::labels):

  • html/LabelsNodeList.cpp:

(WebCore::LabelsNodeList::LabelsNodeList):
(WebCore::LabelsNodeList::~LabelsNodeList):

  • html/RadioNodeList.cpp:

(WebCore::RadioNodeList::RadioNodeList):
(WebCore::RadioNodeList::~RadioNodeList):

Location:
trunk/Source/WebCore
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r121125 r121126  
     12012-06-24  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r121106.
     4        http://trac.webkit.org/changeset/121106
     5        https://bugs.webkit.org/show_bug.cgi?id=89841
     6
     7        Caused 85% performance regressions on Dromaeo/jslib-modify-
     8        jquery.html (Requested by rniwa on #webkit).
     9
     10        * dom/Document.cpp:
     11        (WebCore::Document::clearNodeListCaches):
     12        * dom/Document.h:
     13        (Document):
     14        * dom/DynamicNodeList.cpp:
     15        (WebCore::DynamicSubtreeNodeList::~DynamicSubtreeNodeList):
     16        * dom/DynamicNodeList.h:
     17        (WebCore::DynamicSubtreeNodeList::DynamicSubtreeNodeList):
     18        * dom/Node.cpp:
     19        (WebCore::Node::clearRareData):
     20        (WebCore::Node::invalidateNodeListsCacheAfterAttributeChanged):
     21        (WebCore::Node::invalidateNodeListsCacheAfterChildrenChanged):
     22        (WebCore::Node::getElementsByTagName):
     23        (WebCore::Node::getElementsByTagNameNS):
     24        (WebCore::Node::getElementsByName):
     25        (WebCore::Node::getElementsByClassName):
     26        (WebCore::Node::radioNodeList):
     27        (WebCore::NodeListsNodeData::invalidateCaches):
     28        (WebCore):
     29        (WebCore::NodeRareData::createNodeLists):
     30        * dom/NodeRareData.h:
     31        (NodeListsNodeData):
     32        (WebCore::NodeListsNodeData::adoptTreeScope):
     33        (WebCore::NodeRareData::ensureNodeLists):
     34        (NodeRareData):
     35        * dom/TreeScope.cpp:
     36        (WebCore::TreeScope::TreeScope):
     37        * dom/TreeScope.h:
     38        (WebCore::TreeScope::addNodeListCache):
     39        (WebCore::TreeScope::removeNodeListCache):
     40        (WebCore::TreeScope::hasNodeListCaches):
     41        (TreeScope):
     42        * dom/TreeScopeAdopter.cpp:
     43        (WebCore::TreeScopeAdopter::moveTreeToNewScope):
     44        * html/LabelableElement.cpp:
     45        (WebCore::LabelableElement::labels):
     46        * html/LabelsNodeList.cpp:
     47        (WebCore::LabelsNodeList::LabelsNodeList):
     48        (WebCore::LabelsNodeList::~LabelsNodeList):
     49        * html/RadioNodeList.cpp:
     50        (WebCore::RadioNodeList::RadioNodeList):
     51        (WebCore::RadioNodeList::~RadioNodeList):
     52
    1532012-06-24  Adam Barth  <abarth@webkit.org>
    254
  • trunk/Source/WebCore/dom/Document.cpp

    r121106 r121126  
    38733873}
    38743874
    3875 void Document::clearNodeListCaches(const QualifiedName* attrName)
    3876 {
    3877     // FIXME: Only invalidate caches of node lists that match attrName.
     3875void Document::clearNodeListCaches()
     3876{
    38783877    HashSet<DynamicSubtreeNodeList*>::iterator end = m_listsInvalidatedAtDocument.end();
    3879     for (HashSet<DynamicSubtreeNodeList*>::iterator it = m_listsInvalidatedAtDocument.begin(); it != end; ++it) {
    3880         if (!attrName || (*it)->shouldInvalidateOnAttributeChange())
    3881             (*it)->invalidateCache();
    3882     }
     3878    for (HashSet<DynamicSubtreeNodeList*>::iterator it = m_listsInvalidatedAtDocument.begin(); it != end; ++it)
     3879        (*it)->invalidateCache();
    38833880}
    38843881
  • trunk/Source/WebCore/dom/Document.h

    r121106 r121126  
    715715    void registerDynamicSubtreeNodeList(DynamicSubtreeNodeList*);
    716716    void unregisterDynamicSubtreeNodeList(DynamicSubtreeNodeList*);
    717     void clearNodeListCaches(const QualifiedName* attrName);
     717    void clearNodeListCaches();
    718718
    719719    void attachNodeIterator(NodeIterator*);
  • trunk/Source/WebCore/dom/DynamicNodeList.cpp

    r121106 r121126  
    3131DynamicSubtreeNodeList::~DynamicSubtreeNodeList()
    3232{
    33     document()->unregisterDynamicSubtreeNodeList(this);
    3433}
    3534
  • trunk/Source/WebCore/dom/DynamicNodeList.h

    r121106 r121126  
    124124    DynamicSubtreeNodeList(PassRefPtr<Node> node, RootType rootType = RootedAtNode, InvalidationType invalidationType = AlwaysInvalidate)
    125125        : DynamicNodeList(node, rootType, invalidationType)
    126     {
    127         document()->registerDynamicSubtreeNodeList(this);
    128     }
     126    { }
    129127
    130128private:
  • trunk/Source/WebCore/dom/Node.cpp

    r121106 r121126  
    483483{
    484484    ASSERT(hasRareData());
     485    if (treeScope() && rareData()->nodeLists())
     486        treeScope()->removeNodeListCache();
     487
    485488#if ENABLE(MUTATION_OBSERVERS)
    486489    ASSERT(!transientMutationObserverRegistry() || transientMutationObserverRegistry()->isEmpty());
     
    949952
    950953    // FIXME: Move the list of attributes each NodeList type cares about to be a static on the
    951     // appropriate NodeList class. Then use those lists here and in clearNodeListCaches
     954    // appropriate NodeList class. Then use those lists here and in invalidateCachesThatDependOnAttributes
    952955    // to only invalidate the cache types that depend on the attribute that changed.
    953956    // FIXME: Keep track of when we have no caches of a given type so that we can avoid the for-loop
    954     // in clearNodeListCaches even if a related attribute changed (e.g. if we have no RadioNodeLists, we don't need
     957    // below even if a related attribute changed (e.g. if we have no RadioNodeLists, we don't need
    955958    // to invalidate any caches when id attributes change.)
    956959    if (attrName != classAttr
     
    965968        return;
    966969
    967     document()->clearNodeListCaches(&attrName);
     970    document()->clearNodeListCaches();
     971
     972    if (!treeScope()->hasNodeListCaches())
     973        return;
     974
     975    for (Node* node = this; node; node = node->parentNode()) {
     976        ASSERT(this == node || !node->isAttributeNode());
     977        if (!node->hasRareData())
     978            continue;
     979        NodeRareData* data = node->rareData();
     980        if (!data->nodeLists())
     981            continue;
     982
     983        data->nodeLists()->invalidateCaches(&attrName);
     984    }
    968985}
    969986
     
    973990        rareData()->clearChildNodeListCache();
    974991
    975     document()->clearNodeListCaches(0);
     992    document()->clearNodeListCaches();
     993
     994    if (!treeScope()->hasNodeListCaches())
     995        return;
     996
     997    for (Node* node = this; node; node = node->parentNode()) {
     998        if (!node->hasRareData())
     999            continue;
     1000        NodeRareData* data = node->rareData();
     1001        if (!data->nodeLists())
     1002            continue;
     1003
     1004        data->nodeLists()->invalidateCaches();
     1005    }
    9761006}
    9771007
     
    15191549
    15201550    if (document()->isHTMLDocument())
    1521         return ensureRareData()->ensureNodeLists()->addCacheWithAtomicName<HTMLTagNodeList>(this, DynamicNodeList::TagNodeListType, localName);
    1522     return ensureRareData()->ensureNodeLists()->addCacheWithAtomicName<TagNodeList>(this, DynamicNodeList::TagNodeListType, localName);
     1551        return ensureRareData()->ensureNodeLists(this)->addCacheWithAtomicName<HTMLTagNodeList>(this, DynamicNodeList::TagNodeListType, localName);
     1552    return ensureRareData()->ensureNodeLists(this)->addCacheWithAtomicName<TagNodeList>(this, DynamicNodeList::TagNodeListType, localName);
    15231553}
    15241554
     
    15311561        return getElementsByTagName(localName);
    15321562
    1533     return ensureRareData()->ensureNodeLists()->addCacheWithQualifiedName(this, namespaceURI.isEmpty() ? nullAtom : namespaceURI, localName);
     1563    return ensureRareData()->ensureNodeLists(this)->addCacheWithQualifiedName(this, namespaceURI.isEmpty() ? nullAtom : namespaceURI, localName);
    15341564}
    15351565
    15361566PassRefPtr<NodeList> Node::getElementsByName(const String& elementName)
    15371567{
    1538     return ensureRareData()->ensureNodeLists()->addCacheWithAtomicName<NameNodeList>(this, DynamicNodeList::NameNodeListType, elementName);
     1568    return ensureRareData()->ensureNodeLists(this)->addCacheWithAtomicName<NameNodeList>(this, DynamicNodeList::NameNodeListType, elementName);
    15391569}
    15401570
    15411571PassRefPtr<NodeList> Node::getElementsByClassName(const String& classNames)
    15421572{
    1543     return ensureRareData()->ensureNodeLists()->addCacheWithName<ClassNodeList>(this, DynamicNodeList::ClassNodeListType, classNames);
     1573    return ensureRareData()->ensureNodeLists(this)->addCacheWithName<ClassNodeList>(this, DynamicNodeList::ClassNodeListType, classNames);
    15441574}
    15451575
     
    15471577{
    15481578    ASSERT(hasTagName(formTag) || hasTagName(fieldsetTag));
    1549     return ensureRareData()->ensureNodeLists()->addCacheWithAtomicName<RadioNodeList>(this, DynamicNodeList::RadioNodeListType, name);
     1579    return ensureRareData()->ensureNodeLists(this)->addCacheWithAtomicName<RadioNodeList>(this, DynamicNodeList::RadioNodeListType, name);
    15501580}
    15511581
     
    22092239// --------
    22102240
     2241void NodeListsNodeData::invalidateCaches(const QualifiedName* attrName)
     2242{
     2243    NodeListAtomicNameCacheMap::const_iterator atomicNameCacheEnd = m_atomicNameCaches.end();
     2244    for (NodeListAtomicNameCacheMap::const_iterator it = m_atomicNameCaches.begin(); it != atomicNameCacheEnd; ++it) {
     2245        if (!attrName || it->second->shouldInvalidateOnAttributeChange())
     2246            it->second->invalidateCache();
     2247    }
     2248
     2249    NodeListNameCacheMap::const_iterator nameCacheEnd = m_nameCaches.end();
     2250    for (NodeListNameCacheMap::const_iterator it = m_nameCaches.begin(); it != nameCacheEnd; ++it) {
     2251        if (!attrName || it->second->shouldInvalidateOnAttributeChange())
     2252            it->second->invalidateCache();
     2253    }
     2254
     2255    if (!attrName)
     2256        return;
     2257
     2258    TagNodeListCacheNS::iterator tagCacheEnd = m_tagNodeListCacheNS.end();
     2259    for (TagNodeListCacheNS::iterator it = m_tagNodeListCacheNS.begin(); it != tagCacheEnd; ++it)
     2260        it->second->invalidateCache();
     2261}
     2262
    22112263void Node::getSubresourceURLs(ListHashSet<KURL>& urls) const
    22122264{
     
    27032755#endif
    27042756
    2705 void NodeRareData::createNodeLists()
    2706 {
     2757void NodeRareData::createNodeLists(Node* node)
     2758{
     2759    ASSERT(node);
    27072760    setNodeLists(NodeListsNodeData::create());
     2761    if (TreeScope* treeScope = node->treeScope())
     2762        treeScope->addNodeListCache();
    27082763}
    27092764
  • trunk/Source/WebCore/dom/NodeRareData.h

    r121106 r121126  
    124124    }
    125125
     126    void invalidateCaches(const QualifiedName* attrName = 0);
    126127    bool isEmpty() const
    127128    {
     
    129130    }
    130131
    131     void adoptTreeScope(Document* oldDocument, Document* newDocument)
    132     {
    133         NodeListAtomicNameCacheMap::const_iterator atomicNameCacheEnd = m_atomicNameCaches.end();
    134         for (NodeListAtomicNameCacheMap::const_iterator it = m_atomicNameCaches.begin(); it != atomicNameCacheEnd; ++it) {
    135             DynamicSubtreeNodeList* list = it->second;
    136             list->invalidateCache();
    137             if (oldDocument != newDocument && list->isRootedAtDocument()) {
    138                 oldDocument->unregisterDynamicSubtreeNodeList(list);
    139                 newDocument->registerDynamicSubtreeNodeList(list);
     132    void adoptTreeScope(TreeScope* oldTreeScope, TreeScope* newTreeScope, Document* oldDocument, Document* newDocument)
     133    {
     134        invalidateCaches();
     135
     136        if (oldDocument != newDocument) {
     137            NodeListAtomicNameCacheMap::const_iterator atomicNameCacheEnd = m_atomicNameCaches.end();
     138            for (NodeListAtomicNameCacheMap::const_iterator it = m_atomicNameCaches.begin(); it != atomicNameCacheEnd; ++it) {
     139                DynamicSubtreeNodeList* list = it->second;
     140                if (list->isRootedAtDocument()) {
     141                    oldDocument->unregisterDynamicSubtreeNodeList(list);
     142                    newDocument->registerDynamicSubtreeNodeList(list);
     143                }
     144            }
     145
     146            NodeListNameCacheMap::const_iterator nameCacheEnd = m_nameCaches.end();
     147            for (NodeListNameCacheMap::const_iterator it = m_nameCaches.begin(); it != nameCacheEnd; ++it) {
     148                DynamicSubtreeNodeList* list = it->second;
     149                if (list->isRootedAtDocument()) {
     150                    oldDocument->unregisterDynamicSubtreeNodeList(list);
     151                    newDocument->registerDynamicSubtreeNodeList(list);
     152                }
    140153            }
    141154        }
    142155
    143         NodeListNameCacheMap::const_iterator nameCacheEnd = m_nameCaches.end();
    144         for (NodeListNameCacheMap::const_iterator it = m_nameCaches.begin(); it != nameCacheEnd; ++it) {
    145             DynamicSubtreeNodeList* list = it->second;
    146             list->invalidateCache();
    147             if (oldDocument != newDocument && list->isRootedAtDocument()) {
    148                 oldDocument->unregisterDynamicSubtreeNodeList(list);
    149                 newDocument->registerDynamicSubtreeNodeList(list);
    150             }
    151         }
    152 
    153         TagNodeListCacheNS::iterator tagCacheEnd = m_tagNodeListCacheNS.end();
    154         for (TagNodeListCacheNS::iterator it = m_tagNodeListCacheNS.begin(); it != tagCacheEnd; ++it)
    155             it->second->invalidateCache();
     156        if (oldTreeScope)
     157            oldTreeScope->removeNodeListCache();
     158        newTreeScope->addNodeListCache();
    156159    }
    157160
     
    213216    void setNodeLists(PassOwnPtr<NodeListsNodeData> lists) { m_nodeLists = lists; }
    214217    NodeListsNodeData* nodeLists() const { return m_nodeLists.get(); }
    215     NodeListsNodeData* ensureNodeLists()
     218    NodeListsNodeData* ensureNodeLists(Node* node)
    216219    {
    217220        if (!m_nodeLists)
    218             createNodeLists();
     221            createNodeLists(node);
    219222        return m_nodeLists.get();
    220223    }
     
    346349
    347350private:
    348     void createNodeLists();
     351    void createNodeLists(Node*);
    349352
    350353    TreeScope* m_treeScope;
  • trunk/Source/WebCore/dom/TreeScope.cpp

    r121106 r121126  
    5555    : m_rootNode(rootNode)
    5656    , m_parentTreeScope(0)
     57    , m_numNodeListCaches(0)
    5758{
    5859    ASSERT(rootNode);
  • trunk/Source/WebCore/dom/TreeScope.h

    r121106 r121126  
    6262    HTMLMapElement* getImageMap(const String& url) const;
    6363
     64    void addNodeListCache() { ++m_numNodeListCaches; }
     65    void removeNodeListCache() { ASSERT(m_numNodeListCaches > 0); --m_numNodeListCaches; }
     66    bool hasNodeListCaches() const { return m_numNodeListCaches; }
     67
    6468    DOMSelection* getSelection() const;
    6569
     
    9296    DocumentOrderedMap m_imageMapsByName;
    9397
     98    unsigned m_numNodeListCaches;
     99
    94100    mutable RefPtr<DOMSelection> m_selection;
    95101};
  • trunk/Source/WebCore/dom/TreeScopeAdopter.cpp

    r121106 r121126  
    5555        NodeRareData* rareData = node->setTreeScope(newDocument == m_newScope ? 0 : m_newScope);
    5656        if (rareData && rareData->nodeLists())
    57             rareData->nodeLists()->adoptTreeScope(oldDocument, newDocument);
     57            rareData->nodeLists()->adoptTreeScope(m_oldScope, m_newScope, oldDocument, newDocument);
    5858
    5959        if (willMoveToNewDocument)
  • trunk/Source/WebCore/html/LabelableElement.cpp

    r121106 r121126  
    4848        return 0;
    4949
    50     return Node::ensureRareData()->ensureNodeLists()->addCacheWithAtomicName<LabelsNodeList>(this, DynamicNodeList::LabelsNodeListType, starAtom);
     50    return Node::ensureRareData()->ensureNodeLists(this)->addCacheWithAtomicName<LabelsNodeList>(this, DynamicNodeList::LabelsNodeListType, starAtom);
    5151}
    5252
  • trunk/Source/WebCore/html/LabelsNodeList.cpp

    r121106 r121126  
    3737    : DynamicSubtreeNodeList(forNode, RootedAtDocument)
    3838{
     39    document()->registerDynamicSubtreeNodeList(this);
    3940}
    4041
     
    4243{
    4344    ownerNode()->nodeLists()->removeCacheWithAtomicName(this, DynamicNodeList::LabelsNodeListType, starAtom);
     45    document()->unregisterDynamicSubtreeNodeList(this);
    4446}
    4547   
  • trunk/Source/WebCore/html/RadioNodeList.cpp

    r121106 r121126  
    4242    , m_name(name)
    4343{
     44    document()->registerDynamicSubtreeNodeList(this);
    4445}
    4546
     
    4748{
    4849    ownerNode()->nodeLists()->removeCacheWithAtomicName(this, DynamicNodeList::RadioNodeListType, m_name);
     50    document()->unregisterDynamicSubtreeNodeList(this);
    4951}
    5052
Note: See TracChangeset for help on using the changeset viewer.