Modified: trunk/Source/WebCore/ChangeLog (121951 => 121952)
--- trunk/Source/WebCore/ChangeLog 2012-07-06 10:05:07 UTC (rev 121951)
+++ trunk/Source/WebCore/ChangeLog 2012-07-06 11:25:28 UTC (rev 121952)
@@ -1,3 +1,35 @@
+2012-07-06 Yury Semikhatsky <yu...@chromium.org>
+
+ Web Inspector: add memory reporting routine to Document
+ https://bugs.webkit.org/show_bug.cgi?id=90668
+
+ Reviewed by Pavel Feldman.
+
+ Added methods for reporting HashSet, ListHashSet and Vector memory
+ footprint. Made Document report its size along with its internal
+ collections sizes.
+
+ * dom/Document.cpp:
+ (WebCore::Document::reportMemoryUsage):
+ (WebCore):
+ * dom/Document.h:
+ (Document):
+ * dom/MemoryInstrumentation.h:
+ (MemoryInstrumentation):
+ (MemoryObjectInfo):
+ (WebCore::MemoryObjectInfo::reportHashMap):
+ (WebCore::MemoryObjectInfo::reportHashSet):
+ (WebCore::MemoryObjectInfo::reportListHashSet):
+ (WebCore::MemoryObjectInfo::reportVector):
+ (WebCore::MemoryObjectInfo::memoryInstrumentation):
+ (WebCore::MemoryInstrumentation::reportHashMap):
+ (WebCore):
+ (WebCore::MemoryInstrumentation::reportHashSet):
+ (WebCore::MemoryInstrumentation::reportListHashSet):
+ (WebCore::MemoryInstrumentation::reportVector):
+ * inspector/InspectorMemoryAgent.cpp:
+ (WebCore):
+
2012-07-06 Gabor Rapcsanyi <rga...@webkit.org>
Fixing defines for NEON intrinsics.
Modified: trunk/Source/WebCore/dom/Document.cpp (121951 => 121952)
--- trunk/Source/WebCore/dom/Document.cpp 2012-07-06 10:05:07 UTC (rev 121951)
+++ trunk/Source/WebCore/dom/Document.cpp 2012-07-06 11:25:28 UTC (rev 121952)
@@ -109,6 +109,7 @@
#include "Logging.h"
#include "MediaQueryList.h"
#include "MediaQueryMatcher.h"
+#include "MemoryInstrumentation.h"
#include "MouseEventWithHitTestResults.h"
#include "NameNodeList.h"
#include "NestingLevelIncrementer.h"
@@ -5994,6 +5995,42 @@
m_contextFeatures = features;
}
+void Document::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+ memoryObjectInfo->reportObjectInfo(this, MemoryInstrumentation::DOM);
+ ContainerNode::reportMemoryUsage(memoryObjectInfo);
+ memoryObjectInfo->reportVector(m_customFonts);
+ memoryObjectInfo->reportString(m_documentURI);
+ memoryObjectInfo->reportString(m_baseTarget);
+ if (m_pageGroupUserSheets)
+ memoryObjectInfo->reportVector(*m_pageGroupUserSheets.get());
+ if (m_userSheets)
+ memoryObjectInfo->reportVector(*m_userSheets.get());
+ memoryObjectInfo->reportHashSet(m_nodeIterators);
+ memoryObjectInfo->reportHashSet(m_ranges);
+ memoryObjectInfo->reportListHashSet(m_styleSheetCandidateNodes);
+ memoryObjectInfo->reportString(m_preferredStylesheetSet);
+ memoryObjectInfo->reportString(m_selectedStylesheetSet);
+ memoryObjectInfo->reportString(m_title.string());
+ memoryObjectInfo->reportString(m_rawTitle.string());
+ memoryObjectInfo->reportString(m_xmlEncoding);
+ memoryObjectInfo->reportString(m_xmlVersion);
+ memoryObjectInfo->reportString(m_contentLanguage);
+ memoryObjectInfo->reportHashMap(m_documentNamedItemCollections);
+ memoryObjectInfo->reportHashMap(m_windowNamedItemCollections);
+#if ENABLE(DASHBOARD_SUPPORT)
+ memoryObjectInfo->reportVector(m_dashboardRegions);
+#endif
+ memoryObjectInfo->reportHashMap(m_cssCanvasElements);
+ memoryObjectInfo->reportVector(m_iconURLs);
+ memoryObjectInfo->reportHashSet(m_documentSuspensionCallbackElements);
+ memoryObjectInfo->reportHashSet(m_mediaVolumeCallbackElements);
+ memoryObjectInfo->reportHashSet(m_privateBrowsingStateChangedElements);
+ memoryObjectInfo->reportHashMap(m_elementsByAccessKey);
+ memoryObjectInfo->reportHashSet(m_mediaCanStartListeners);
+ memoryObjectInfo->reportVector(m_pendingTasks);
+}
+
#if ENABLE(UNDO_MANAGER)
PassRefPtr<UndoManager> Document::undoManager()
{
Modified: trunk/Source/WebCore/dom/Document.h (121951 => 121952)
--- trunk/Source/WebCore/dom/Document.h 2012-07-06 10:05:07 UTC (rev 121951)
+++ trunk/Source/WebCore/dom/Document.h 2012-07-06 11:25:28 UTC (rev 121952)
@@ -1143,6 +1143,8 @@
void setContextFeatures(PassRefPtr<ContextFeatures>);
ContextFeatures* contextFeatures() { return m_contextFeatures.get(); }
+ virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
+
protected:
Document(Frame*, const KURL&, bool isXHTML, bool isHTML);
Modified: trunk/Source/WebCore/dom/MemoryInstrumentation.h (121951 => 121952)
--- trunk/Source/WebCore/dom/MemoryInstrumentation.h 2012-07-06 10:05:07 UTC (rev 121951)
+++ trunk/Source/WebCore/dom/MemoryInstrumentation.h 2012-07-06 11:25:28 UTC (rev 121952)
@@ -61,7 +61,10 @@
return;
countObjectSize(objectType, sizeof(T));
}
- template <typename HashMapType> void reportHashMap(const HashMapType&, ObjectType);
+ template <typename HashMapType> void reportHashMap(const HashMapType&, ObjectType, bool contentOnly = false);
+ template <typename HashSetType> void reportHashSet(const HashSetType&, ObjectType, bool contentOnly = false);
+ template <typename ListHashSetType> void reportListHashSet(const ListHashSetType&, ObjectType, bool contentOnly = false);
+ template <typename VectorType> void reportVector(const VectorType&, ObjectType, bool contentOnly = false);
protected:
class InstrumentedPointerBase {
@@ -129,6 +132,30 @@
m_objectSize = sizeof(T);
}
+ template <typename HashMapType>
+ void reportHashMap(const HashMapType& map)
+ {
+ m_memoryInstrumentation->reportHashMap(map, objectType(), true);
+ }
+
+ template <typename HashSetType>
+ void reportHashSet(const HashSetType& set)
+ {
+ m_memoryInstrumentation->reportHashSet(set, objectType(), true);
+ }
+
+ template <typename ListHashSetType>
+ void reportListHashSet(const ListHashSetType& set)
+ {
+ m_memoryInstrumentation->reportListHashSet(set, objectType(), true);
+ }
+
+ template <typename VectorType>
+ void reportVector(const VectorType& vector)
+ {
+ m_memoryInstrumentation->reportVector(vector, objectType(), true);
+ }
+
void reportString(const String& string)
{
m_memoryInstrumentation->reportString(objectType(), string);
@@ -137,6 +164,8 @@
MemoryInstrumentation::ObjectType objectType() const { return m_objectType; }
size_t objectSize() const { return m_objectSize; }
+ MemoryInstrumentation* memoryInstrumentation() { return m_memoryInstrumentation; }
+
private:
MemoryInstrumentation* m_memoryInstrumentation;
MemoryInstrumentation::ObjectType m_objectType;
@@ -161,12 +190,39 @@
}
template<typename HashMapType>
-void MemoryInstrumentation::reportHashMap(const HashMapType& hashMap, ObjectType objectType)
+void MemoryInstrumentation::reportHashMap(const HashMapType& hashMap, ObjectType objectType, bool contentOnly)
{
- size_t size = sizeof(HashMapType) + hashMap.capacity() * sizeof(typename HashMapType::ValueType);
+ size_t size = (contentOnly ? 0 : sizeof(HashMapType)) + hashMap.capacity() * sizeof(typename HashMapType::ValueType);
countObjectSize(objectType, size);
}
+template<typename HashSetType>
+void MemoryInstrumentation::reportHashSet(const HashSetType& hashSet, ObjectType objectType, bool contentOnly)
+{
+ if (visited(&hashSet))
+ return;
+ size_t size = (contentOnly ? 0 : sizeof(HashSetType)) + hashSet.capacity() * sizeof(typename HashSetType::ValueType);
+ countObjectSize(objectType, size);
+}
+
+template<typename ListHashSetType>
+void MemoryInstrumentation::reportListHashSet(const ListHashSetType& hashSet, ObjectType objectType, bool contentOnly)
+{
+ if (visited(&hashSet))
+ return;
+ size_t size = (contentOnly ? 0 : sizeof(ListHashSetType)) + hashSet.capacity() * sizeof(void*) + hashSet.size() * (sizeof(typename ListHashSetType::ValueType) + 2 * sizeof(void*));
+ countObjectSize(objectType, size);
+}
+
+template <typename VectorType>
+void MemoryInstrumentation::reportVector(const VectorType& vector, ObjectType objectType, bool contentOnly)
+{
+ if (visited(vector.data()))
+ return;
+ size_t size = (contentOnly ? 0 : sizeof(VectorType)) + vector.capacity() * sizeof(typename VectorType::ValueType);
+ countObjectSize(objectType, size);
+}
+
template<typename T>
void MemoryInstrumentation::InstrumentedPointer<T>::process(MemoryInstrumentation* memoryInstrumentation)
{
Modified: trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp (121951 => 121952)
--- trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp 2012-07-06 10:05:07 UTC (rev 121951)
+++ trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp 2012-07-06 11:25:28 UTC (rev 121952)
@@ -471,7 +471,7 @@
private:
virtual void reportString(ObjectType objectType, const String& string)
{
- if (visited(string.impl()))
+ if (string.isNull() || visited(string.impl()))
return;
countObjectSize(objectType, stringSize(string.impl()));
}