Diff
Modified: trunk/Source/WebCore/ChangeLog (123725 => 123726)
--- trunk/Source/WebCore/ChangeLog 2012-07-26 10:35:49 UTC (rev 123725)
+++ trunk/Source/WebCore/ChangeLog 2012-07-26 10:42:27 UTC (rev 123726)
@@ -1,3 +1,33 @@
+2012-07-26 Yury Semikhatsky <[email protected]>
+
+ 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):
+
2012-07-26 Tommy Widenflycht <[email protected]>
MediaStream API: Remove DeprecatedPeerConnection
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (123725 => 123726)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2012-07-26 10:35:49 UTC (rev 123725)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2012-07-26 10:42:27 UTC (rev 123726)
@@ -82,6 +82,7 @@
#include "MatrixTransformOperation.h"
#include "MediaList.h"
#include "MediaQueryEvaluator.h"
+#include "MemoryInstrumentation.h"
#include "NodeRenderStyle.h"
#include "NodeRenderingContext.h"
#include "Page.h"
@@ -216,6 +217,8 @@
static const unsigned maximumIdentifierCount = 4;
const unsigned* descendantSelectorIdentifierHashes() const { return m_descendantSelectorIdentifierHashes; }
+ void reportMemoryUsage(MemoryObjectInfo*) const;
+
private:
StyleRule* m_rule;
CSSSelector* m_selector;
@@ -272,6 +275,8 @@
const Vector<RuleData>* universalRules() const { return &m_universalRules; }
const Vector<StyleRulePage*>& pageRules() const { return m_pageRules; }
+ void reportMemoryUsage(MemoryObjectInfo*) const;
+
public:
RuleSet();
@@ -290,6 +295,8 @@
struct RuleSetSelectorPair {
RuleSetSelectorPair(CSSSelector* selector, PassOwnPtr<RuleSet> ruleSet) : selector(selector), ruleSet(ruleSet) { }
RuleSetSelectorPair(const RuleSetSelectorPair& rs) : selector(rs.selector), ruleSet(const_cast<RuleSetSelectorPair*>(&rs)->ruleSet.release()) { }
+ void reportMemoryUsage(MemoryObjectInfo*) const;
+
CSSSelector* selector;
OwnPtr<RuleSet> ruleSet;
};
@@ -728,6 +735,15 @@
usesLinkRules = false;
}
+void StyleResolver::Features::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+ MemoryClassInfo<StyleResolver::Features> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ info.addHashSet(idsInRules);
+ info.addHashSet(attrsInRules);
+ info.addVector(siblingRules);
+ info.addVector(uncommonAttributeRules);
+}
+
static StyleSheetContents* parseUASheet(const String& str)
{
StyleSheetContents* sheet = StyleSheetContents::create().leakRef(); // leak the sheet on purpose
@@ -2481,12 +2497,45 @@
SelectorChecker::collectIdentifierHashes(m_selector, m_descendantSelectorIdentifierHashes, maximumIdentifierCount);
}
+void RuleData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+ MemoryClassInfo<RuleData> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+}
+
RuleSet::RuleSet()
: m_ruleCount(0)
, m_autoShrinkToFitEnabled(true)
{
}
+
+static void reportAtomRuleMap(MemoryClassInfo<RuleSet>* info, const RuleSet::AtomRuleMap& atomicRuleMap)
+{
+ info->addHashMap(atomicRuleMap);
+ for (RuleSet::AtomRuleMap::const_iterator it = atomicRuleMap.begin(); it != atomicRuleMap.end(); ++it)
+ info->addInstrumentedVector(*it->second);
+}
+
+void RuleSet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+ MemoryClassInfo<RuleSet> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ reportAtomRuleMap(&info, m_idRules);
+ reportAtomRuleMap(&info, m_classRules);
+ reportAtomRuleMap(&info, m_tagRules);
+ reportAtomRuleMap(&info, m_shadowPseudoElementRules);
+ info.addInstrumentedVector(m_linkPseudoClassRules);
+ info.addInstrumentedVector(m_focusPseudoClassRules);
+ info.addInstrumentedVector(m_universalRules);
+ info.addVector(m_pageRules);
+ info.addInstrumentedVector(m_regionSelectorsAndRuleSets);
+}
+
+void RuleSet::RuleSetSelectorPair::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+ MemoryClassInfo<RuleSet::RuleSetSelectorPair> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ info.addInstrumentedMember(ruleSet);
+}
+
static inline void collectFeaturesFromSelector(StyleResolver::Features& features, const CSSSelector* selector)
{
if (selector->m_match == CSSSelector::Id)
@@ -5578,4 +5627,36 @@
#endif
}
+void StyleResolver::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+ MemoryClassInfo<StyleResolver> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
+ info.addMember(m_style);
+ info.addInstrumentedMember(m_authorStyle);
+ info.addInstrumentedMember(m_userStyle);
+ info.addInstrumentedMember(m_siblingRuleSet);
+ info.addInstrumentedMember(m_uncommonAttributeRuleSet);
+ info.addHashMap(m_keyframesRuleMap);
+ info.addHashMap(m_matchedPropertiesCache);
+ info.addVector(m_matchedRules);
+
+ // FIXME: Instrument StaticCSSRuleList and add m_ruleList here.
+ info.addHashSet(m_pendingImageProperties);
+ info.addVector(m_viewportDependentMediaQueryResults);
+ info.addHashMap(m_styleRuleToCSSOMWrapperMap);
+ info.addHashSet(m_styleSheetCSSOMWrapperSet);
+#if ENABLE(CSS_FILTERS) && ENABLE(SVG)
+ info.addHashMap(m_pendingSVGDocuments);
+#endif
+#if ENABLE(STYLE_SCOPED)
+ info.addHashMap(m_scopedAuthorStyles);
+ info.addVector(m_scopeStack);
+#endif
+
+ // FIXME: move this to a place where it would be called only once?
+ info.addInstrumentedMember(defaultStyle);
+ info.addInstrumentedMember(defaultQuirksStyle);
+ info.addInstrumentedMember(defaultPrintStyle);
+ info.addInstrumentedMember(defaultViewSourceStyle);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/css/StyleResolver.h (123725 => 123726)
--- trunk/Source/WebCore/css/StyleResolver.h 2012-07-26 10:35:49 UTC (rev 123725)
+++ trunk/Source/WebCore/css/StyleResolver.h 2012-07-26 10:42:27 UTC (rev 123726)
@@ -65,6 +65,7 @@
class KeyframeList;
class KeyframeValue;
class MediaQueryEvaluator;
+class MemoryObjectInfo;
class Node;
class RenderRegion;
class RuleData;
@@ -287,6 +288,7 @@
~Features();
void add(const StyleResolver::Features&);
void clear();
+ void reportMemoryUsage(MemoryObjectInfo*) const;
HashSet<AtomicStringImpl*> idsInRules;
HashSet<AtomicStringImpl*> attrsInRules;
Vector<RuleFeature> siblingRules;
@@ -420,6 +422,8 @@
static Length convertToFloatLength(CSSPrimitiveValue*, RenderStyle*, RenderStyle* rootStyle, double multiplier = 1);
CSSToStyleMap* styleMap() { return &m_styleMap; }
+
+ void reportMemoryUsage(MemoryObjectInfo*) const;
private:
static RenderStyle* s_styleNotYetAvailable;
Modified: trunk/Source/WebCore/dom/Document.cpp (123725 => 123726)
--- trunk/Source/WebCore/dom/Document.cpp 2012-07-26 10:35:49 UTC (rev 123725)
+++ trunk/Source/WebCore/dom/Document.cpp 2012-07-26 10:42:27 UTC (rev 123726)
@@ -6088,6 +6088,7 @@
void Document::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
MemoryClassInfo<Document> info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
+ info.addInstrumentedMember(m_styleResolver);
info.visitBaseClass<ContainerNode>(this);
info.addVector(m_customFonts);
info.addString(m_documentURI);
Modified: trunk/Source/WebCore/dom/MemoryInstrumentation.h (123725 => 123726)
--- trunk/Source/WebCore/dom/MemoryInstrumentation.h 2012-07-26 10:35:49 UTC (rev 123725)
+++ trunk/Source/WebCore/dom/MemoryInstrumentation.h 2012-07-26 10:42:27 UTC (rev 123726)
@@ -67,7 +67,7 @@
template <typename HashMapType> void addHashMap(const HashMapType&, ObjectType, bool contentOnly = false);
template <typename HashSetType> void addHashSet(const HashSetType&, ObjectType, bool contentOnly = false);
- template <typename HashSetType> void addInstrumentedHashSet(const HashSetType&, ObjectType, bool contentOnly = false);
+ template <typename CollectionType> void addInstrumentedCollection(const CollectionType&, ObjectType, bool contentOnly = false);
template <typename ListHashSetType> void addListHashSet(const ListHashSetType&, ObjectType, bool contentOnly = false);
template <typename VectorType> void addVector(const VectorType&, ObjectType, bool contentOnly = false);
void addRawBuffer(const void* const& buffer, ObjectType objectType, size_t size)
@@ -206,7 +206,8 @@
template <typename HashMapType> void addHashMap(const HashMapType& map) { m_memoryInstrumentation->addHashMap(map, m_objectType, true); }
template <typename HashSetType> void addHashSet(const HashSetType& set) { m_memoryInstrumentation->addHashSet(set, m_objectType, true); }
- template <typename HashSetType> void addInstrumentedHashSet(const HashSetType& set) { m_memoryInstrumentation->addInstrumentedHashSet(set, m_objectType, true); }
+ template <typename HashSetType> void addInstrumentedHashSet(const HashSetType& set) { m_memoryInstrumentation->addInstrumentedCollection(set, m_objectType, true); }
+ template <typename VectorType> void addInstrumentedVector(const VectorType& vector) { m_memoryInstrumentation->addInstrumentedCollection(vector, m_objectType, true); }
template <typename ListHashSetType> void addListHashSet(const ListHashSetType& set) { m_memoryInstrumentation->addListHashSet(set, m_objectType, true); }
template <typename VectorType> void addVector(const VectorType& vector) { m_memoryInstrumentation->addVector(vector, m_objectType, true); }
void addRawBuffer(const void* const& buffer, size_t size) { m_memoryInstrumentation->addRawBuffer(buffer, m_objectType, size); }
@@ -223,6 +224,8 @@
template<typename HashMapType>
void MemoryInstrumentation::addHashMap(const HashMapType& hashMap, ObjectType objectType, bool contentOnly)
{
+ if (visited(&hashMap))
+ return;
countObjectSize(objectType, calculateContainerSize(hashMap, contentOnly));
}
@@ -234,13 +237,14 @@
countObjectSize(objectType, calculateContainerSize(hashSet, contentOnly));
}
-template<typename HashSetType>
-void MemoryInstrumentation::addInstrumentedHashSet(const HashSetType& hashSet, ObjectType objectType, bool contentOnly)
+template <typename CollectionType>
+void MemoryInstrumentation::addInstrumentedCollection(const CollectionType& collection, ObjectType objectType, bool contentOnly)
{
- if (visited(&hashSet))
+ if (visited(&collection))
return;
- countObjectSize(objectType, calculateContainerSize(hashSet, contentOnly));
- for (typename HashSetType::const_iterator i = hashSet.begin(); i != hashSet.end(); ++i)
+ countObjectSize(objectType, calculateContainerSize(collection, contentOnly));
+ typename CollectionType::const_iterator end = collection.end();
+ for (typename CollectionType::const_iterator i = collection.begin(); i != end; ++i)
addInstrumentedMember(*i);
}