Changeset 121126 in webkit
- Timestamp:
- Jun 24, 2012 5:41:05 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r121125 r121126 1 2012-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 1 53 2012-06-24 Adam Barth <abarth@webkit.org> 2 54 -
trunk/Source/WebCore/dom/Document.cpp
r121106 r121126 3873 3873 } 3874 3874 3875 void Document::clearNodeListCaches(const QualifiedName* attrName) 3876 { 3877 // FIXME: Only invalidate caches of node lists that match attrName. 3875 void Document::clearNodeListCaches() 3876 { 3878 3877 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(); 3883 3880 } 3884 3881 -
trunk/Source/WebCore/dom/Document.h
r121106 r121126 715 715 void registerDynamicSubtreeNodeList(DynamicSubtreeNodeList*); 716 716 void unregisterDynamicSubtreeNodeList(DynamicSubtreeNodeList*); 717 void clearNodeListCaches( const QualifiedName* attrName);717 void clearNodeListCaches(); 718 718 719 719 void attachNodeIterator(NodeIterator*); -
trunk/Source/WebCore/dom/DynamicNodeList.cpp
r121106 r121126 31 31 DynamicSubtreeNodeList::~DynamicSubtreeNodeList() 32 32 { 33 document()->unregisterDynamicSubtreeNodeList(this);34 33 } 35 34 -
trunk/Source/WebCore/dom/DynamicNodeList.h
r121106 r121126 124 124 DynamicSubtreeNodeList(PassRefPtr<Node> node, RootType rootType = RootedAtNode, InvalidationType invalidationType = AlwaysInvalidate) 125 125 : DynamicNodeList(node, rootType, invalidationType) 126 { 127 document()->registerDynamicSubtreeNodeList(this); 128 } 126 { } 129 127 130 128 private: -
trunk/Source/WebCore/dom/Node.cpp
r121106 r121126 483 483 { 484 484 ASSERT(hasRareData()); 485 if (treeScope() && rareData()->nodeLists()) 486 treeScope()->removeNodeListCache(); 487 485 488 #if ENABLE(MUTATION_OBSERVERS) 486 489 ASSERT(!transientMutationObserverRegistry() || transientMutationObserverRegistry()->isEmpty()); … … 949 952 950 953 // 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 clearNodeListCaches954 // appropriate NodeList class. Then use those lists here and in invalidateCachesThatDependOnAttributes 952 955 // to only invalidate the cache types that depend on the attribute that changed. 953 956 // FIXME: Keep track of when we have no caches of a given type so that we can avoid the for-loop 954 // in clearNodeListCacheseven if a related attribute changed (e.g. if we have no RadioNodeLists, we don't need957 // below even if a related attribute changed (e.g. if we have no RadioNodeLists, we don't need 955 958 // to invalidate any caches when id attributes change.) 956 959 if (attrName != classAttr … … 965 968 return; 966 969 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 } 968 985 } 969 986 … … 973 990 rareData()->clearChildNodeListCache(); 974 991 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 } 976 1006 } 977 1007 … … 1519 1549 1520 1550 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); 1523 1553 } 1524 1554 … … 1531 1561 return getElementsByTagName(localName); 1532 1562 1533 return ensureRareData()->ensureNodeLists( )->addCacheWithQualifiedName(this, namespaceURI.isEmpty() ? nullAtom : namespaceURI, localName);1563 return ensureRareData()->ensureNodeLists(this)->addCacheWithQualifiedName(this, namespaceURI.isEmpty() ? nullAtom : namespaceURI, localName); 1534 1564 } 1535 1565 1536 1566 PassRefPtr<NodeList> Node::getElementsByName(const String& elementName) 1537 1567 { 1538 return ensureRareData()->ensureNodeLists( )->addCacheWithAtomicName<NameNodeList>(this, DynamicNodeList::NameNodeListType, elementName);1568 return ensureRareData()->ensureNodeLists(this)->addCacheWithAtomicName<NameNodeList>(this, DynamicNodeList::NameNodeListType, elementName); 1539 1569 } 1540 1570 1541 1571 PassRefPtr<NodeList> Node::getElementsByClassName(const String& classNames) 1542 1572 { 1543 return ensureRareData()->ensureNodeLists( )->addCacheWithName<ClassNodeList>(this, DynamicNodeList::ClassNodeListType, classNames);1573 return ensureRareData()->ensureNodeLists(this)->addCacheWithName<ClassNodeList>(this, DynamicNodeList::ClassNodeListType, classNames); 1544 1574 } 1545 1575 … … 1547 1577 { 1548 1578 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); 1550 1580 } 1551 1581 … … 2209 2239 // -------- 2210 2240 2241 void 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 2211 2263 void Node::getSubresourceURLs(ListHashSet<KURL>& urls) const 2212 2264 { … … 2703 2755 #endif 2704 2756 2705 void NodeRareData::createNodeLists() 2706 { 2757 void NodeRareData::createNodeLists(Node* node) 2758 { 2759 ASSERT(node); 2707 2760 setNodeLists(NodeListsNodeData::create()); 2761 if (TreeScope* treeScope = node->treeScope()) 2762 treeScope->addNodeListCache(); 2708 2763 } 2709 2764 -
trunk/Source/WebCore/dom/NodeRareData.h
r121106 r121126 124 124 } 125 125 126 void invalidateCaches(const QualifiedName* attrName = 0); 126 127 bool isEmpty() const 127 128 { … … 129 130 } 130 131 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 } 140 153 } 141 154 } 142 155 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(); 156 159 } 157 160 … … 213 216 void setNodeLists(PassOwnPtr<NodeListsNodeData> lists) { m_nodeLists = lists; } 214 217 NodeListsNodeData* nodeLists() const { return m_nodeLists.get(); } 215 NodeListsNodeData* ensureNodeLists( )218 NodeListsNodeData* ensureNodeLists(Node* node) 216 219 { 217 220 if (!m_nodeLists) 218 createNodeLists( );221 createNodeLists(node); 219 222 return m_nodeLists.get(); 220 223 } … … 346 349 347 350 private: 348 void createNodeLists( );351 void createNodeLists(Node*); 349 352 350 353 TreeScope* m_treeScope; -
trunk/Source/WebCore/dom/TreeScope.cpp
r121106 r121126 55 55 : m_rootNode(rootNode) 56 56 , m_parentTreeScope(0) 57 , m_numNodeListCaches(0) 57 58 { 58 59 ASSERT(rootNode); -
trunk/Source/WebCore/dom/TreeScope.h
r121106 r121126 62 62 HTMLMapElement* getImageMap(const String& url) const; 63 63 64 void addNodeListCache() { ++m_numNodeListCaches; } 65 void removeNodeListCache() { ASSERT(m_numNodeListCaches > 0); --m_numNodeListCaches; } 66 bool hasNodeListCaches() const { return m_numNodeListCaches; } 67 64 68 DOMSelection* getSelection() const; 65 69 … … 92 96 DocumentOrderedMap m_imageMapsByName; 93 97 98 unsigned m_numNodeListCaches; 99 94 100 mutable RefPtr<DOMSelection> m_selection; 95 101 }; -
trunk/Source/WebCore/dom/TreeScopeAdopter.cpp
r121106 r121126 55 55 NodeRareData* rareData = node->setTreeScope(newDocument == m_newScope ? 0 : m_newScope); 56 56 if (rareData && rareData->nodeLists()) 57 rareData->nodeLists()->adoptTreeScope( oldDocument, newDocument);57 rareData->nodeLists()->adoptTreeScope(m_oldScope, m_newScope, oldDocument, newDocument); 58 58 59 59 if (willMoveToNewDocument) -
trunk/Source/WebCore/html/LabelableElement.cpp
r121106 r121126 48 48 return 0; 49 49 50 return Node::ensureRareData()->ensureNodeLists( )->addCacheWithAtomicName<LabelsNodeList>(this, DynamicNodeList::LabelsNodeListType, starAtom);50 return Node::ensureRareData()->ensureNodeLists(this)->addCacheWithAtomicName<LabelsNodeList>(this, DynamicNodeList::LabelsNodeListType, starAtom); 51 51 } 52 52 -
trunk/Source/WebCore/html/LabelsNodeList.cpp
r121106 r121126 37 37 : DynamicSubtreeNodeList(forNode, RootedAtDocument) 38 38 { 39 document()->registerDynamicSubtreeNodeList(this); 39 40 } 40 41 … … 42 43 { 43 44 ownerNode()->nodeLists()->removeCacheWithAtomicName(this, DynamicNodeList::LabelsNodeListType, starAtom); 45 document()->unregisterDynamicSubtreeNodeList(this); 44 46 } 45 47 -
trunk/Source/WebCore/html/RadioNodeList.cpp
r121106 r121126 42 42 , m_name(name) 43 43 { 44 document()->registerDynamicSubtreeNodeList(this); 44 45 } 45 46 … … 47 48 { 48 49 ownerNode()->nodeLists()->removeCacheWithAtomicName(this, DynamicNodeList::RadioNodeListType, m_name); 50 document()->unregisterDynamicSubtreeNodeList(this); 49 51 } 50 52
Note: See TracChangeset
for help on using the changeset viewer.