Changeset 123726 in webkit
- Timestamp:
- Jul 26, 2012 3:42:27 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r123724 r123726 1 2012-07-26 Yury Semikhatsky <yurys@chromium.org> 2 3 Web Inspector: add memory reporting routine to StyleResolver 4 https://bugs.webkit.org/show_bug.cgi?id=92259 5 6 Reviewed by Vsevolod Vlasov. 7 8 SyleResolver::reportMemoryUsage is added for estimating StyleResolver 9 memory footprint. 10 11 * css/StyleResolver.cpp: 12 (RuleData): 13 (RuleSet): 14 (RuleSetSelectorPair): 15 (WebCore::StyleResolver::Features::reportMemoryUsage): 16 (WebCore): 17 (WebCore::StyleResolver::collectMatchingRulesForList): 18 * css/StyleResolver.h: 19 (Features): 20 (StyleResolver): 21 * dom/Document.cpp: 22 (WebCore::Document::reportMemoryUsage): 23 * dom/MemoryInstrumentation.h: 24 (MemoryInstrumentation): 25 (WebCore::MemoryClassInfo::addInstrumentedHashSet): 26 (WebCore::MemoryClassInfo::addInstrumentedVector): 27 (WebCore::MemoryInstrumentation::addHashMap): 28 (WebCore): 29 (WebCore::MemoryInstrumentation::addInstrumentedCollection): 30 1 31 2012-07-26 Tommy Widenflycht <tommyw@google.com> 2 32 -
trunk/Source/WebCore/css/StyleResolver.cpp
r123426 r123726 83 83 #include "MediaList.h" 84 84 #include "MediaQueryEvaluator.h" 85 #include "MemoryInstrumentation.h" 85 86 #include "NodeRenderStyle.h" 86 87 #include "NodeRenderingContext.h" … … 217 218 const unsigned* descendantSelectorIdentifierHashes() const { return m_descendantSelectorIdentifierHashes; } 218 219 220 void reportMemoryUsage(MemoryObjectInfo*) const; 221 219 222 private: 220 223 StyleRule* m_rule; … … 273 276 const Vector<StyleRulePage*>& pageRules() const { return m_pageRules; } 274 277 278 void reportMemoryUsage(MemoryObjectInfo*) const; 279 275 280 public: 276 281 RuleSet(); … … 291 296 RuleSetSelectorPair(CSSSelector* selector, PassOwnPtr<RuleSet> ruleSet) : selector(selector), ruleSet(ruleSet) { } 292 297 RuleSetSelectorPair(const RuleSetSelectorPair& rs) : selector(rs.selector), ruleSet(const_cast<RuleSetSelectorPair*>(&rs)->ruleSet.release()) { } 298 void reportMemoryUsage(MemoryObjectInfo*) const; 299 293 300 CSSSelector* selector; 294 301 OwnPtr<RuleSet> ruleSet; … … 727 734 usesBeforeAfterRules = false; 728 735 usesLinkRules = false; 736 } 737 738 void StyleResolver::Features::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 739 { 740 MemoryClassInfo<StyleResolver::Features> info(memoryObjectInfo, this, MemoryInstrumentation::CSS); 741 info.addHashSet(idsInRules); 742 info.addHashSet(attrsInRules); 743 info.addVector(siblingRules); 744 info.addVector(uncommonAttributeRules); 729 745 } 730 746 … … 2482 2498 } 2483 2499 2500 void RuleData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 2501 { 2502 MemoryClassInfo<RuleData> info(memoryObjectInfo, this, MemoryInstrumentation::CSS); 2503 } 2504 2484 2505 RuleSet::RuleSet() 2485 2506 : m_ruleCount(0) 2486 2507 , m_autoShrinkToFitEnabled(true) 2487 2508 { 2509 } 2510 2511 2512 static void reportAtomRuleMap(MemoryClassInfo<RuleSet>* info, const RuleSet::AtomRuleMap& atomicRuleMap) 2513 { 2514 info->addHashMap(atomicRuleMap); 2515 for (RuleSet::AtomRuleMap::const_iterator it = atomicRuleMap.begin(); it != atomicRuleMap.end(); ++it) 2516 info->addInstrumentedVector(*it->second); 2517 } 2518 2519 void RuleSet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 2520 { 2521 MemoryClassInfo<RuleSet> info(memoryObjectInfo, this, MemoryInstrumentation::CSS); 2522 reportAtomRuleMap(&info, m_idRules); 2523 reportAtomRuleMap(&info, m_classRules); 2524 reportAtomRuleMap(&info, m_tagRules); 2525 reportAtomRuleMap(&info, m_shadowPseudoElementRules); 2526 info.addInstrumentedVector(m_linkPseudoClassRules); 2527 info.addInstrumentedVector(m_focusPseudoClassRules); 2528 info.addInstrumentedVector(m_universalRules); 2529 info.addVector(m_pageRules); 2530 info.addInstrumentedVector(m_regionSelectorsAndRuleSets); 2531 } 2532 2533 void RuleSet::RuleSetSelectorPair::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 2534 { 2535 MemoryClassInfo<RuleSet::RuleSetSelectorPair> info(memoryObjectInfo, this, MemoryInstrumentation::CSS); 2536 info.addInstrumentedMember(ruleSet); 2488 2537 } 2489 2538 … … 5579 5628 } 5580 5629 5630 void StyleResolver::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 5631 { 5632 MemoryClassInfo<StyleResolver> info(memoryObjectInfo, this, MemoryInstrumentation::CSS); 5633 info.addMember(m_style); 5634 info.addInstrumentedMember(m_authorStyle); 5635 info.addInstrumentedMember(m_userStyle); 5636 info.addInstrumentedMember(m_siblingRuleSet); 5637 info.addInstrumentedMember(m_uncommonAttributeRuleSet); 5638 info.addHashMap(m_keyframesRuleMap); 5639 info.addHashMap(m_matchedPropertiesCache); 5640 info.addVector(m_matchedRules); 5641 5642 // FIXME: Instrument StaticCSSRuleList and add m_ruleList here. 5643 info.addHashSet(m_pendingImageProperties); 5644 info.addVector(m_viewportDependentMediaQueryResults); 5645 info.addHashMap(m_styleRuleToCSSOMWrapperMap); 5646 info.addHashSet(m_styleSheetCSSOMWrapperSet); 5647 #if ENABLE(CSS_FILTERS) && ENABLE(SVG) 5648 info.addHashMap(m_pendingSVGDocuments); 5649 #endif 5650 #if ENABLE(STYLE_SCOPED) 5651 info.addHashMap(m_scopedAuthorStyles); 5652 info.addVector(m_scopeStack); 5653 #endif 5654 5655 // FIXME: move this to a place where it would be called only once? 5656 info.addInstrumentedMember(defaultStyle); 5657 info.addInstrumentedMember(defaultQuirksStyle); 5658 info.addInstrumentedMember(defaultPrintStyle); 5659 info.addInstrumentedMember(defaultViewSourceStyle); 5660 } 5661 5581 5662 } // namespace WebCore -
trunk/Source/WebCore/css/StyleResolver.h
r123426 r123726 66 66 class KeyframeValue; 67 67 class MediaQueryEvaluator; 68 class MemoryObjectInfo; 68 69 class Node; 69 70 class RenderRegion; … … 288 289 void add(const StyleResolver::Features&); 289 290 void clear(); 291 void reportMemoryUsage(MemoryObjectInfo*) const; 290 292 HashSet<AtomicStringImpl*> idsInRules; 291 293 HashSet<AtomicStringImpl*> attrsInRules; … … 421 423 422 424 CSSToStyleMap* styleMap() { return &m_styleMap; } 425 426 void reportMemoryUsage(MemoryObjectInfo*) const; 423 427 424 428 private: -
trunk/Source/WebCore/dom/Document.cpp
r123722 r123726 6089 6089 { 6090 6090 MemoryClassInfo<Document> info(memoryObjectInfo, this, MemoryInstrumentation::DOM); 6091 info.addInstrumentedMember(m_styleResolver); 6091 6092 info.visitBaseClass<ContainerNode>(this); 6092 6093 info.addVector(m_customFonts); -
trunk/Source/WebCore/dom/MemoryInstrumentation.h
r123451 r123726 68 68 template <typename HashMapType> void addHashMap(const HashMapType&, ObjectType, bool contentOnly = false); 69 69 template <typename HashSetType> void addHashSet(const HashSetType&, ObjectType, bool contentOnly = false); 70 template <typename HashSetType> void addInstrumentedHashSet(const HashSetType&, ObjectType, bool contentOnly = false);70 template <typename CollectionType> void addInstrumentedCollection(const CollectionType&, ObjectType, bool contentOnly = false); 71 71 template <typename ListHashSetType> void addListHashSet(const ListHashSetType&, ObjectType, bool contentOnly = false); 72 72 template <typename VectorType> void addVector(const VectorType&, ObjectType, bool contentOnly = false); … … 207 207 template <typename HashMapType> void addHashMap(const HashMapType& map) { m_memoryInstrumentation->addHashMap(map, m_objectType, true); } 208 208 template <typename HashSetType> void addHashSet(const HashSetType& set) { m_memoryInstrumentation->addHashSet(set, m_objectType, true); } 209 template <typename HashSetType> void addInstrumentedHashSet(const HashSetType& set) { m_memoryInstrumentation->addInstrumentedHashSet(set, m_objectType, true); } 209 template <typename HashSetType> void addInstrumentedHashSet(const HashSetType& set) { m_memoryInstrumentation->addInstrumentedCollection(set, m_objectType, true); } 210 template <typename VectorType> void addInstrumentedVector(const VectorType& vector) { m_memoryInstrumentation->addInstrumentedCollection(vector, m_objectType, true); } 210 211 template <typename ListHashSetType> void addListHashSet(const ListHashSetType& set) { m_memoryInstrumentation->addListHashSet(set, m_objectType, true); } 211 212 template <typename VectorType> void addVector(const VectorType& vector) { m_memoryInstrumentation->addVector(vector, m_objectType, true); } … … 224 225 void MemoryInstrumentation::addHashMap(const HashMapType& hashMap, ObjectType objectType, bool contentOnly) 225 226 { 227 if (visited(&hashMap)) 228 return; 226 229 countObjectSize(objectType, calculateContainerSize(hashMap, contentOnly)); 227 230 } … … 235 238 } 236 239 237 template<typename HashSetType> 238 void MemoryInstrumentation::addInstrumentedHashSet(const HashSetType& hashSet, ObjectType objectType, bool contentOnly) 239 { 240 if (visited(&hashSet)) 241 return; 242 countObjectSize(objectType, calculateContainerSize(hashSet, contentOnly)); 243 for (typename HashSetType::const_iterator i = hashSet.begin(); i != hashSet.end(); ++i) 240 template <typename CollectionType> 241 void MemoryInstrumentation::addInstrumentedCollection(const CollectionType& collection, ObjectType objectType, bool contentOnly) 242 { 243 if (visited(&collection)) 244 return; 245 countObjectSize(objectType, calculateContainerSize(collection, contentOnly)); 246 typename CollectionType::const_iterator end = collection.end(); 247 for (typename CollectionType::const_iterator i = collection.begin(); i != end; ++i) 244 248 addInstrumentedMember(*i); 245 249 }
Note: See TracChangeset
for help on using the changeset viewer.