Changeset 123726 in webkit


Ignore:
Timestamp:
Jul 26, 2012 3:42:27 AM (12 years ago)
Author:
yurys@chromium.org
Message:

Web Inspector: add memory reporting routine to StyleResolver
https://bugs.webkit.org/show_bug.cgi?id=92259

Reviewed by Vsevolod Vlasov.

SyleResolver::reportMemoryUsage is added for estimating StyleResolver
memory footprint.

  • css/StyleResolver.cpp:

(RuleData):
(RuleSet):
(RuleSetSelectorPair):
(WebCore::StyleResolver::Features::reportMemoryUsage):
(WebCore):
(WebCore::StyleResolver::collectMatchingRulesForList):

  • css/StyleResolver.h:

(Features):
(StyleResolver):

  • dom/Document.cpp:

(WebCore::Document::reportMemoryUsage):

  • dom/MemoryInstrumentation.h:

(MemoryInstrumentation):
(WebCore::MemoryClassInfo::addInstrumentedHashSet):
(WebCore::MemoryClassInfo::addInstrumentedVector):
(WebCore::MemoryInstrumentation::addHashMap):
(WebCore):
(WebCore::MemoryInstrumentation::addInstrumentedCollection):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r123724 r123726  
     12012-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
    1312012-07-26  Tommy Widenflycht  <tommyw@google.com>
    232
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r123426 r123726  
    8383#include "MediaList.h"
    8484#include "MediaQueryEvaluator.h"
     85#include "MemoryInstrumentation.h"
    8586#include "NodeRenderStyle.h"
    8687#include "NodeRenderingContext.h"
     
    217218    const unsigned* descendantSelectorIdentifierHashes() const { return m_descendantSelectorIdentifierHashes; }
    218219
     220    void reportMemoryUsage(MemoryObjectInfo*) const;
     221
    219222private:
    220223    StyleRule* m_rule;
     
    273276    const Vector<StyleRulePage*>& pageRules() const { return m_pageRules; }
    274277
     278    void reportMemoryUsage(MemoryObjectInfo*) const;
     279
    275280public:
    276281    RuleSet();
     
    291296        RuleSetSelectorPair(CSSSelector* selector, PassOwnPtr<RuleSet> ruleSet) : selector(selector), ruleSet(ruleSet) { }
    292297        RuleSetSelectorPair(const RuleSetSelectorPair& rs) : selector(rs.selector), ruleSet(const_cast<RuleSetSelectorPair*>(&rs)->ruleSet.release()) { }
     298        void reportMemoryUsage(MemoryObjectInfo*) const;
     299
    293300        CSSSelector* selector;
    294301        OwnPtr<RuleSet> ruleSet;
     
    727734    usesBeforeAfterRules = false;
    728735    usesLinkRules = false;
     736}
     737
     738void 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);
    729745}
    730746
     
    24822498}
    24832499
     2500void RuleData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     2501{
     2502    MemoryClassInfo<RuleData> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
     2503}
     2504
    24842505RuleSet::RuleSet()
    24852506    : m_ruleCount(0)
    24862507    , m_autoShrinkToFitEnabled(true)
    24872508{
     2509}
     2510
     2511
     2512static 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
     2519void 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
     2533void RuleSet::RuleSetSelectorPair::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     2534{
     2535    MemoryClassInfo<RuleSet::RuleSetSelectorPair> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
     2536    info.addInstrumentedMember(ruleSet);
    24882537}
    24892538
     
    55795628}
    55805629
     5630void 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
    55815662} // namespace WebCore
  • trunk/Source/WebCore/css/StyleResolver.h

    r123426 r123726  
    6666class KeyframeValue;
    6767class MediaQueryEvaluator;
     68class MemoryObjectInfo;
    6869class Node;
    6970class RenderRegion;
     
    288289        void add(const StyleResolver::Features&);
    289290        void clear();
     291        void reportMemoryUsage(MemoryObjectInfo*) const;
    290292        HashSet<AtomicStringImpl*> idsInRules;
    291293        HashSet<AtomicStringImpl*> attrsInRules;
     
    421423
    422424    CSSToStyleMap* styleMap() { return &m_styleMap; }
     425
     426    void reportMemoryUsage(MemoryObjectInfo*) const;
    423427   
    424428private:
  • trunk/Source/WebCore/dom/Document.cpp

    r123722 r123726  
    60896089{
    60906090    MemoryClassInfo<Document> info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
     6091    info.addInstrumentedMember(m_styleResolver);
    60916092    info.visitBaseClass<ContainerNode>(this);
    60926093    info.addVector(m_customFonts);
  • trunk/Source/WebCore/dom/MemoryInstrumentation.h

    r123451 r123726  
    6868    template <typename HashMapType> void addHashMap(const HashMapType&, ObjectType, bool contentOnly = false);
    6969    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);
    7171    template <typename ListHashSetType> void addListHashSet(const ListHashSetType&, ObjectType, bool contentOnly = false);
    7272    template <typename VectorType> void addVector(const VectorType&, ObjectType, bool contentOnly = false);
     
    207207    template <typename HashMapType> void addHashMap(const HashMapType& map) { m_memoryInstrumentation->addHashMap(map, m_objectType, true); }
    208208    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); }
    210211    template <typename ListHashSetType> void addListHashSet(const ListHashSetType& set) { m_memoryInstrumentation->addListHashSet(set, m_objectType, true); }
    211212    template <typename VectorType> void addVector(const VectorType& vector) { m_memoryInstrumentation->addVector(vector, m_objectType, true); }
     
    224225void MemoryInstrumentation::addHashMap(const HashMapType& hashMap, ObjectType objectType, bool contentOnly)
    225226{
     227    if (visited(&hashMap))
     228        return;
    226229    countObjectSize(objectType, calculateContainerSize(hashMap, contentOnly));
    227230}
     
    235238}
    236239
    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)
     240template <typename CollectionType>
     241void 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)
    244248        addInstrumentedMember(*i);
    245249}
Note: See TracChangeset for help on using the changeset viewer.