Title: [122714] trunk/Source/WebCore
Revision
122714
Author
loi...@chromium.org
Date
2012-07-16 05:00:28 -0700 (Mon, 16 Jul 2012)

Log Message

Web Inspector: moving forward to the better memory instrumentation API
https://bugs.webkit.org/show_bug.cgi?id=91259

Reviewed by Pavel Feldman.

I'm trying to remove unnecessary complexity of the API
reportInstrumentedObject and reportInstrumentedPointer will be replaced with addInstrumentedMember
The same will happen with reportPointer, reportObject pair.
Also info.report* will be replaced with info.add*

* bindings/js/ScriptWrappable.h:
(WebCore::ScriptWrappable::reportMemoryUsage):
* bindings/v8/DOMDataStore.cpp:
(WebCore::DOMDataStore::reportMemoryUsage):
* bindings/v8/IntrusiveDOMWrapperMap.h:
(WebCore::ChunkedTable::reportMemoryUsage):
* bindings/v8/ScriptProfiler.cpp:
(WebCore::ScriptProfiler::collectBindingMemoryInfo):
* bindings/v8/ScriptWrappable.h:
(WebCore::ScriptWrappable::reportMemoryUsage):
* bindings/v8/V8Binding.cpp:
(WebCore::V8BindingPerIsolateData::reportMemoryUsage):
(WebCore::StringCache::reportMemoryUsage):
* bindings/v8/V8DOMMap.h:
* css/StylePropertySet.h:
(WebCore::StylePropertySet::reportMemoryUsage):
* dom/CharacterData.cpp:
(WebCore::CharacterData::reportMemoryUsage):
* dom/ContainerNode.h:
(WebCore::ContainerNode::reportMemoryUsage):
* dom/Document.cpp:
(WebCore::Document::reportMemoryUsage):
* dom/Element.h:
(WebCore::Element::reportMemoryUsage):
* dom/ElementAttributeData.h:
(WebCore::ElementAttributeData::reportMemoryUsage):
* dom/MemoryInstrumentation.h:
(WebCore::MemoryInstrumentation::addInstrumentedMember):
(MemoryInstrumentation):
(WebCore::MemoryInstrumentation::addMember):
(WebCore::MemoryInstrumentation::OwningTraits::addInstrumentedMember):
(WebCore::MemoryInstrumentation::OwningTraits::addMember):
(WebCore::MemoryInstrumentation::addInstrumentedMemberImpl):
(WebCore::MemoryInstrumentation::addMemberImpl):
(WebCore::MemoryClassInfo::addInstrumentedMember):
(WebCore::MemoryClassInfo::addMember):
(WebCore::MemoryClassInfo::addHashMap):
(WebCore::MemoryClassInfo::addHashSet):
(WebCore::MemoryClassInfo::addListHashSet):
(WebCore::MemoryClassInfo::addVector):
(WebCore::MemoryClassInfo::addString):
(WebCore::MemoryInstrumentation::addHashMap):
(WebCore::MemoryInstrumentation::addHashSet):
(WebCore::MemoryInstrumentation::addListHashSet):
(WebCore::MemoryInstrumentation::addVector):
* dom/Node.cpp:
(WebCore::Node::reportMemoryUsage):
* dom/QualifiedName.h:
(WebCore::QualifiedName::QualifiedNameImpl::reportMemoryUsage):
(WebCore::QualifiedName::reportMemoryUsage):
* inspector/InspectorMemoryAgent.cpp:
(WebCore):
* platform/TreeShared.h:
(WebCore::TreeShared::reportMemoryUsage):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (122713 => 122714)


--- trunk/Source/WebCore/ChangeLog	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/ChangeLog	2012-07-16 12:00:28 UTC (rev 122714)
@@ -1,5 +1,72 @@
 2012-07-16  Ilya Tikhonovsky  <loi...@chromium.org>
 
+        Web Inspector: moving forward to the better memory instrumentation API
+        https://bugs.webkit.org/show_bug.cgi?id=91259
+
+        Reviewed by Pavel Feldman.
+
+        I'm trying to remove unnecessary complexity of the API
+        reportInstrumentedObject and reportInstrumentedPointer will be replaced with addInstrumentedMember
+        The same will happen with reportPointer, reportObject pair.
+        Also info.report* will be replaced with info.add*
+
+        * bindings/js/ScriptWrappable.h:
+        (WebCore::ScriptWrappable::reportMemoryUsage):
+        * bindings/v8/DOMDataStore.cpp:
+        (WebCore::DOMDataStore::reportMemoryUsage):
+        * bindings/v8/IntrusiveDOMWrapperMap.h:
+        (WebCore::ChunkedTable::reportMemoryUsage):
+        * bindings/v8/ScriptProfiler.cpp:
+        (WebCore::ScriptProfiler::collectBindingMemoryInfo):
+        * bindings/v8/ScriptWrappable.h:
+        (WebCore::ScriptWrappable::reportMemoryUsage):
+        * bindings/v8/V8Binding.cpp:
+        (WebCore::V8BindingPerIsolateData::reportMemoryUsage):
+        (WebCore::StringCache::reportMemoryUsage):
+        * bindings/v8/V8DOMMap.h:
+        * css/StylePropertySet.h:
+        (WebCore::StylePropertySet::reportMemoryUsage):
+        * dom/CharacterData.cpp:
+        (WebCore::CharacterData::reportMemoryUsage):
+        * dom/ContainerNode.h:
+        (WebCore::ContainerNode::reportMemoryUsage):
+        * dom/Document.cpp:
+        (WebCore::Document::reportMemoryUsage):
+        * dom/Element.h:
+        (WebCore::Element::reportMemoryUsage):
+        * dom/ElementAttributeData.h:
+        (WebCore::ElementAttributeData::reportMemoryUsage):
+        * dom/MemoryInstrumentation.h:
+        (WebCore::MemoryInstrumentation::addInstrumentedMember):
+        (MemoryInstrumentation):
+        (WebCore::MemoryInstrumentation::addMember):
+        (WebCore::MemoryInstrumentation::OwningTraits::addInstrumentedMember):
+        (WebCore::MemoryInstrumentation::OwningTraits::addMember):
+        (WebCore::MemoryInstrumentation::addInstrumentedMemberImpl):
+        (WebCore::MemoryInstrumentation::addMemberImpl):
+        (WebCore::MemoryClassInfo::addInstrumentedMember):
+        (WebCore::MemoryClassInfo::addMember):
+        (WebCore::MemoryClassInfo::addHashMap):
+        (WebCore::MemoryClassInfo::addHashSet):
+        (WebCore::MemoryClassInfo::addListHashSet):
+        (WebCore::MemoryClassInfo::addVector):
+        (WebCore::MemoryClassInfo::addString):
+        (WebCore::MemoryInstrumentation::addHashMap):
+        (WebCore::MemoryInstrumentation::addHashSet):
+        (WebCore::MemoryInstrumentation::addListHashSet):
+        (WebCore::MemoryInstrumentation::addVector):
+        * dom/Node.cpp:
+        (WebCore::Node::reportMemoryUsage):
+        * dom/QualifiedName.h:
+        (WebCore::QualifiedName::QualifiedNameImpl::reportMemoryUsage):
+        (WebCore::QualifiedName::reportMemoryUsage):
+        * inspector/InspectorMemoryAgent.cpp:
+        (WebCore):
+        * platform/TreeShared.h:
+        (WebCore::TreeShared::reportMemoryUsage):
+
+2012-07-16  Ilya Tikhonovsky  <loi...@chromium.org>
+
         Web Inspector: native memory instrumentation: extract instrumentation methods into MemoryClassInfo
         https://bugs.webkit.org/show_bug.cgi?id=91227
 

Modified: trunk/Source/WebCore/bindings/js/ScriptWrappable.h (122713 => 122714)


--- trunk/Source/WebCore/bindings/js/ScriptWrappable.h	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/bindings/js/ScriptWrappable.h	2012-07-16 12:00:28 UTC (rev 122714)
@@ -57,7 +57,7 @@
     void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     {
         MemoryClassInfo<ScriptWrappable> info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
-        info.reportObject(m_wrapper);
+        info.addMember(m_wrapper);
     }
 
 private:

Modified: trunk/Source/WebCore/bindings/v8/DOMDataStore.cpp (122713 => 122714)


--- trunk/Source/WebCore/bindings/v8/DOMDataStore.cpp	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/bindings/v8/DOMDataStore.cpp	2012-07-16 12:00:28 UTC (rev 122714)
@@ -122,10 +122,10 @@
 void DOMDataStore::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
     MemoryClassInfo<DOMDataStore> info(memoryObjectInfo, this, MemoryInstrumentation::Binding);
-    info.reportInstrumentedPointer(m_domNodeMap);
-    info.reportInstrumentedPointer(m_activeDomNodeMap);
-    info.reportInstrumentedPointer(m_domObjectMap);
-    info.reportInstrumentedPointer(m_activeDomObjectMap);
+    info.addInstrumentedMember(m_domNodeMap);
+    info.addInstrumentedMember(m_activeDomNodeMap);
+    info.addInstrumentedMember(m_domObjectMap);
+    info.addInstrumentedMember(m_activeDomObjectMap);
 }
 
 // Called when the object is near death (not reachable from JS roots).

Modified: trunk/Source/WebCore/bindings/v8/IntrusiveDOMWrapperMap.h (122713 => 122714)


--- trunk/Source/WebCore/bindings/v8/IntrusiveDOMWrapperMap.h	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/bindings/v8/IntrusiveDOMWrapperMap.h	2012-07-16 12:00:28 UTC (rev 122714)
@@ -106,7 +106,7 @@
     {
         MemoryClassInfo<ChunkedTable> info(memoryObjectInfo, this, MemoryInstrumentation::Binding);
         for (Chunk* chunk = m_chunks; chunk; chunk = chunk->m_previous)
-            info.reportPointer(chunk);
+            info.addMember(chunk);
     }
 
   private:
@@ -187,7 +187,7 @@
     virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const OVERRIDE
     {
         MemoryClassInfo<IntrusiveDOMWrapperMap> info(memoryObjectInfo, this, MemoryInstrumentation::Binding);
-        info.reportInstrumentedObject(m_table);
+        info.addInstrumentedMember(m_table);
     }
 
 private:

Modified: trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp (122713 => 122714)


--- trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp	2012-07-16 12:00:28 UTC (rev 122714)
@@ -223,7 +223,7 @@
 void ScriptProfiler::collectBindingMemoryInfo(MemoryInstrumentation* instrumentation)
 {
     V8BindingPerIsolateData* data = ""
-    instrumentation->reportInstrumentedPointer(data);
+    instrumentation->addInstrumentedMember(data);
 }
 
 size_t ScriptProfiler::profilerSnapshotsSize()

Modified: trunk/Source/WebCore/bindings/v8/ScriptWrappable.h (122713 => 122714)


--- trunk/Source/WebCore/bindings/v8/ScriptWrappable.h	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/bindings/v8/ScriptWrappable.h	2012-07-16 12:00:28 UTC (rev 122714)
@@ -55,7 +55,7 @@
     void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     {
         MemoryClassInfo<ScriptWrappable> info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
-        info.reportPointer(m_wrapper);
+        info.addMember(m_wrapper);
     }
 
 private:

Modified: trunk/Source/WebCore/bindings/v8/V8Binding.cpp (122713 => 122714)


--- trunk/Source/WebCore/bindings/v8/V8Binding.cpp	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.cpp	2012-07-16 12:00:28 UTC (rev 122714)
@@ -93,13 +93,13 @@
 void V8BindingPerIsolateData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
     MemoryClassInfo<V8BindingPerIsolateData> info(memoryObjectInfo, this, MemoryInstrumentation::Binding);
-    info.reportHashMap(m_rawTemplates);
-    info.reportHashMap(m_templates);
-    info.reportInstrumentedObject(m_stringCache);
-    info.reportVector(m_domDataList);
+    info.addHashMap(m_rawTemplates);
+    info.addHashMap(m_templates);
+    info.addInstrumentedMember(m_stringCache);
+    info.addVector(m_domDataList);
 
     for (size_t i = 0; i < m_domDataList.size(); i++)
-        info.reportInstrumentedPointer(m_domDataList[i]);
+        info.addInstrumentedMember(m_domDataList[i]);
 }
 
 // WebCoreStringResource is a helper class for v8ExternalString. It is used
@@ -591,7 +591,7 @@
 void StringCache::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
     MemoryClassInfo<StringCache> info(memoryObjectInfo, this, MemoryInstrumentation::Binding);
-    info.reportHashMap(m_stringCache);
+    info.addHashMap(m_stringCache);
 }
     
 PassRefPtr<DOMStringList> v8ValueToWebCoreDOMStringList(v8::Handle<v8::Value> value)

Modified: trunk/Source/WebCore/bindings/v8/V8DOMMap.h (122713 => 122714)


--- trunk/Source/WebCore/bindings/v8/V8DOMMap.h	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/bindings/v8/V8DOMMap.h	2012-07-16 12:00:28 UTC (rev 122714)
@@ -137,7 +137,7 @@
         virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const OVERRIDE
         {
             MemoryClassInfo<WeakReferenceMap<KeyType, ValueType> > info(memoryObjectInfo, this, MemoryInstrumentation::Binding);
-            info.reportHashMap(m_map);
+            info.addHashMap(m_map);
         }
 
     protected:

Modified: trunk/Source/WebCore/css/StylePropertySet.h (122713 => 122714)


--- trunk/Source/WebCore/css/StylePropertySet.h	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/css/StylePropertySet.h	2012-07-16 12:00:28 UTC (rev 122714)
@@ -120,7 +120,7 @@
     {
         MemoryClassInfo<StylePropertySet> info(memoryObjectInfo, this, MemoryInstrumentation::CSS);
         if (m_isMutable)
-            info.reportPointer(m_mutablePropertyVector);
+            info.addMember(m_mutablePropertyVector);
     }
 
 private:

Modified: trunk/Source/WebCore/dom/CharacterData.cpp (122713 => 122714)


--- trunk/Source/WebCore/dom/CharacterData.cpp	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/dom/CharacterData.cpp	2012-07-16 12:00:28 UTC (rev 122714)
@@ -96,7 +96,7 @@
 {
     MemoryClassInfo<CharacterData> info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
     info.visitBaseClass<Node>(this);
-    info.reportString(m_data);
+    info.addString(m_data);
 }
 
 void CharacterData::appendData(const String& data, ExceptionCode&)

Modified: trunk/Source/WebCore/dom/ContainerNode.h (122713 => 122714)


--- trunk/Source/WebCore/dom/ContainerNode.h	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/dom/ContainerNode.h	2012-07-16 12:00:28 UTC (rev 122714)
@@ -103,8 +103,8 @@
     {
         MemoryClassInfo<ContainerNode> info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
         info.visitBaseClass<Node>(this);
-        info.reportInstrumentedPointer(m_firstChild);
-        info.reportInstrumentedPointer(m_lastChild);
+        info.addInstrumentedMember(m_firstChild);
+        info.addInstrumentedMember(m_lastChild);
     }
 
 protected:

Modified: trunk/Source/WebCore/dom/Document.cpp (122713 => 122714)


--- trunk/Source/WebCore/dom/Document.cpp	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/dom/Document.cpp	2012-07-16 12:00:28 UTC (rev 122714)
@@ -6064,36 +6064,36 @@
 {
     MemoryClassInfo<Document> info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
     info.visitBaseClass<ContainerNode>(this);
-    info.reportVector(m_customFonts);
-    info.reportString(m_documentURI);
-    info.reportString(m_baseTarget);
+    info.addVector(m_customFonts);
+    info.addString(m_documentURI);
+    info.addString(m_baseTarget);
     if (m_pageGroupUserSheets)
-        info.reportVector(*m_pageGroupUserSheets.get());
+        info.addVector(*m_pageGroupUserSheets.get());
     if (m_userSheets)
-        info.reportVector(*m_userSheets.get());
-    info.reportHashSet(m_nodeIterators);
-    info.reportHashSet(m_ranges);
-    info.reportListHashSet(m_styleSheetCandidateNodes);
-    info.reportString(m_preferredStylesheetSet);
-    info.reportString(m_selectedStylesheetSet);
-    info.reportString(m_title.string());
-    info.reportString(m_rawTitle.string());
-    info.reportString(m_xmlEncoding);
-    info.reportString(m_xmlVersion);
-    info.reportString(m_contentLanguage);
-    info.reportHashMap(m_documentNamedItemCollections);
-    info.reportHashMap(m_windowNamedItemCollections);
+        info.addVector(*m_userSheets.get());
+    info.addHashSet(m_nodeIterators);
+    info.addHashSet(m_ranges);
+    info.addListHashSet(m_styleSheetCandidateNodes);
+    info.addString(m_preferredStylesheetSet);
+    info.addString(m_selectedStylesheetSet);
+    info.addString(m_title.string());
+    info.addString(m_rawTitle.string());
+    info.addString(m_xmlEncoding);
+    info.addString(m_xmlVersion);
+    info.addString(m_contentLanguage);
+    info.addHashMap(m_documentNamedItemCollections);
+    info.addHashMap(m_windowNamedItemCollections);
 #if ENABLE(DASHBOARD_SUPPORT)
-    info.reportVector(m_dashboardRegions);
+    info.addVector(m_dashboardRegions);
 #endif
-    info.reportHashMap(m_cssCanvasElements);
-    info.reportVector(m_iconURLs);
-    info.reportHashSet(m_documentSuspensionCallbackElements);
-    info.reportHashSet(m_mediaVolumeCallbackElements);
-    info.reportHashSet(m_privateBrowsingStateChangedElements);
-    info.reportHashMap(m_elementsByAccessKey);
-    info.reportHashSet(m_mediaCanStartListeners);
-    info.reportVector(m_pendingTasks);
+    info.addHashMap(m_cssCanvasElements);
+    info.addVector(m_iconURLs);
+    info.addHashSet(m_documentSuspensionCallbackElements);
+    info.addHashSet(m_mediaVolumeCallbackElements);
+    info.addHashSet(m_privateBrowsingStateChangedElements);
+    info.addHashMap(m_elementsByAccessKey);
+    info.addHashSet(m_mediaCanStartListeners);
+    info.addVector(m_pendingTasks);
 }
 
 #if ENABLE(UNDO_MANAGER)

Modified: trunk/Source/WebCore/dom/Element.h (122713 => 122714)


--- trunk/Source/WebCore/dom/Element.h	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/dom/Element.h	2012-07-16 12:00:28 UTC (rev 122714)
@@ -431,8 +431,8 @@
     {
         MemoryClassInfo<Element> info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
         info.visitBaseClass<ContainerNode>(this);
-        info.reportInstrumentedObject(m_tagName);
-        info.reportInstrumentedPointer(m_attributeData.get());
+        info.addInstrumentedMember(m_tagName);
+        info.addInstrumentedMember(m_attributeData.get());
     }
 
 protected:

Modified: trunk/Source/WebCore/dom/ElementAttributeData.h (122713 => 122714)


--- trunk/Source/WebCore/dom/ElementAttributeData.h	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/dom/ElementAttributeData.h	2012-07-16 12:00:28 UTC (rev 122714)
@@ -103,11 +103,11 @@
     void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     {
         MemoryClassInfo<ElementAttributeData> info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
-        info.reportInstrumentedPointer(m_inlineStyleDecl.get());
-        info.reportInstrumentedPointer(m_attributeStyle.get());
-        info.reportObject(m_classNames);
-        info.reportObject(m_idForStyleResolution);
-        info.reportVector(m_attributes);
+        info.addInstrumentedMember(m_inlineStyleDecl.get());
+        info.addInstrumentedMember(m_attributeStyle.get());
+        info.addMember(m_classNames);
+        info.addMember(m_idForStyleResolution);
+        info.addVector(m_attributes);
     }
 
 private:

Modified: trunk/Source/WebCore/dom/MemoryInstrumentation.h (122713 => 122714)


--- trunk/Source/WebCore/dom/MemoryInstrumentation.h	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/dom/MemoryInstrumentation.h	2012-07-16 12:00:28 UTC (rev 122714)
@@ -52,21 +52,61 @@
         LastTypeEntry
     };
 
-    template <typename T> void reportInstrumentedObject(const T&);
-    template <typename T> void reportObject(const T&) { }
-    template <typename T> void reportInstrumentedPointer(const T*);
-    template <typename T> void reportPointer(const T* object, ObjectType objectType)
+    template <typename T> void addInstrumentedMember(const T& t)
     {
+        OwningTraits<T>::addInstrumentedMember(this, t);
+    }
+
+    template <typename T> void addMember(const T& t, ObjectType objectType)
+    {
+        OwningTraits<T>::addMember(this, t, objectType);
+    }
+
+    template <typename HashMapType> void addHashMap(const HashMapType&, ObjectType, bool contentOnly = false);
+    template <typename HashSetType> void addHashSet(const HashSetType&, 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);
+
+protected:
+    enum OwningType {
+        byPointer,
+        byReference
+    };
+
+    template <typename T>
+    struct OwningTraits { // Default byReference implementation.
+        static void addInstrumentedMember(MemoryInstrumentation* instrumentation, const T& t) { instrumentation->addInstrumentedMemberImpl(&t, byReference); }
+        static void addMember(MemoryInstrumentation* instrumentation, const T& t, MemoryInstrumentation::ObjectType objectType) { instrumentation->addMemberImpl(&t, objectType, byReference); }
+    };
+
+    template <typename T>
+    struct OwningTraits<T*> { // Custom byPointer implementation.
+        static void addInstrumentedMember(MemoryInstrumentation* instrumentation, const T* const& t) { instrumentation->addInstrumentedMemberImpl(t, byPointer); }
+        static void addMember(MemoryInstrumentation* instrumentation, const T* const& t, MemoryInstrumentation::ObjectType objectType) { instrumentation->addMemberImpl(t, objectType, byPointer); }
+    };
+
+    template <typename T>
+    void addInstrumentedMemberImpl(const T* const& object, OwningType owningType)
+    {
         if (!object || visited(object))
             return;
+        if (owningType == byReference) {
+            MemoryObjectInfo memoryObjectInfo(this);
+            object->reportMemoryUsage(&memoryObjectInfo);
+        } else
+            deferInstrumentedPointer(adoptPtr(new InstrumentedPointer<T>(object)));
+    }
+
+    template <typename T>
+    void addMemberImpl(const T* const& object, ObjectType objectType, OwningType owningType)
+    {
+        if (!object || visited(object))
+            return;
+        if (owningType == byReference)
+            return;
         countObjectSize(objectType, sizeof(T));
     }
-    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 {
     public:
         virtual ~InstrumentedPointerBase() { }
@@ -93,7 +133,7 @@
         const T* m_pointer;
     };
 
-    virtual void reportString(ObjectType, const String&) = 0;
+    virtual void addString(const String&, ObjectType) = 0;
     virtual void countObjectSize(ObjectType, size_t) = 0;
     virtual void deferInstrumentedPointer(PassOwnPtr<InstrumentedPointerBase>) = 0;
     virtual bool visited(const void*) = 0;
@@ -141,50 +181,30 @@
 
     template <typename P> void visitBaseClass(const P* ptr) { ptr->P::reportMemoryUsage(m_memoryObjectInfo); }
 
-    template <typename P> void reportInstrumentedPointer(const P* memberPointer) { m_memoryInstrumentation->reportInstrumentedPointer(memberPointer); }
-    template <typename O> void reportInstrumentedObject(const O& memberObject) { m_memoryInstrumentation->reportInstrumentedObject(memberObject); }
+    template <typename M> void addInstrumentedMember(const M& member) { m_memoryInstrumentation->addInstrumentedMember(member); }
+    template <typename M> void addMember(const M& member) { m_memoryInstrumentation->addMember(member, m_objectType); }
 
-    template <typename P> void reportPointer(const P* pointer) { m_memoryInstrumentation->reportPointer(pointer, m_objectType); }
-    template <typename O> void reportObject(const O& object) { m_memoryInstrumentation->reportObject(object); }
+    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 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); }
 
-    template <typename HashMapType> void reportHashMap(const HashMapType& map) { m_memoryInstrumentation->reportHashMap(map, m_objectType, true); }
-    template <typename HashSetType> void reportHashSet(const HashSetType& set) { m_memoryInstrumentation->reportHashSet(set, m_objectType, true); }
-    template <typename ListHashSetType> void reportListHashSet(const ListHashSetType& set) { m_memoryInstrumentation->reportListHashSet(set, m_objectType, true); }
-    template <typename VectorType> void reportVector(const VectorType& vector) { m_memoryInstrumentation->reportVector(vector, m_objectType, true); }
+    void addString(const String& string) { m_memoryInstrumentation->addString(string, m_objectType); }
 
-    void reportString(const String& string) { m_memoryInstrumentation->reportString(m_objectType, string); }
-
 private:
     MemoryObjectInfo* m_memoryObjectInfo;
     MemoryInstrumentation* m_memoryInstrumentation;
     MemoryInstrumentation::ObjectType m_objectType;
 };
 
-template <typename T>
-void MemoryInstrumentation::reportInstrumentedPointer(const T* const object)
-{
-    if (!object || visited(object))
-        return;
-    deferInstrumentedPointer(adoptPtr(new InstrumentedPointer<T>(object)));
-}
-
-template<typename T>
-void MemoryInstrumentation::reportInstrumentedObject(const T& object)
-{
-    if (visited(&object))
-        return;
-    MemoryObjectInfo memoryObjectInfo(this);
-    object.reportMemoryUsage(&memoryObjectInfo);
-}
-
 template<typename HashMapType>
-void MemoryInstrumentation::reportHashMap(const HashMapType& hashMap, ObjectType objectType, bool contentOnly)
+void MemoryInstrumentation::addHashMap(const HashMapType& hashMap, ObjectType objectType, bool contentOnly)
 {
     countObjectSize(objectType, calculateContainerSize(hashMap, contentOnly));
 }
 
 template<typename HashSetType>
-void MemoryInstrumentation::reportHashSet(const HashSetType& hashSet, ObjectType objectType, bool contentOnly)
+void MemoryInstrumentation::addHashSet(const HashSetType& hashSet, ObjectType objectType, bool contentOnly)
 {
     if (visited(&hashSet))
         return;
@@ -192,7 +212,7 @@
 }
 
 template<typename ListHashSetType>
-void MemoryInstrumentation::reportListHashSet(const ListHashSetType& hashSet, ObjectType objectType, bool contentOnly)
+void MemoryInstrumentation::addListHashSet(const ListHashSetType& hashSet, ObjectType objectType, bool contentOnly)
 {
     if (visited(&hashSet))
         return;
@@ -201,7 +221,7 @@
 }
 
 template <typename VectorType>
-void MemoryInstrumentation::reportVector(const VectorType& vector, ObjectType objectType, bool contentOnly)
+void MemoryInstrumentation::addVector(const VectorType& vector, ObjectType objectType, bool contentOnly)
 {
     if (visited(vector.data()))
         return;

Modified: trunk/Source/WebCore/dom/Node.cpp (122713 => 122714)


--- trunk/Source/WebCore/dom/Node.cpp	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/dom/Node.cpp	2012-07-16 12:00:28 UTC (rev 122714)
@@ -2771,9 +2771,9 @@
     MemoryClassInfo<Node> info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
     info.visitBaseClass<TreeShared<Node, ContainerNode> >(this);
     info.visitBaseClass<ScriptWrappable>(this);
-    info.reportInstrumentedPointer(m_document);
-    info.reportInstrumentedPointer(m_next);
-    info.reportInstrumentedPointer(m_previous);
+    info.addInstrumentedMember(m_document);
+    info.addInstrumentedMember(m_next);
+    info.addInstrumentedMember(m_previous);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/QualifiedName.h (122713 => 122714)


--- trunk/Source/WebCore/dom/QualifiedName.h	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/dom/QualifiedName.h	2012-07-16 12:00:28 UTC (rev 122714)
@@ -53,10 +53,10 @@
         void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
         {
             MemoryClassInfo<QualifiedNameImpl> info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
-            info.reportObject(m_prefix);
-            info.reportObject(m_localName);
-            info.reportObject(m_namespace);
-            info.reportObject(m_localNameUpper);
+            info.addMember(m_prefix);
+            info.addMember(m_localName);
+            info.addMember(m_namespace);
+            info.addMember(m_localNameUpper);
         }
     private:
         QualifiedNameImpl(const AtomicString& prefix, const AtomicString& localName, const AtomicString& namespaceURI)
@@ -105,7 +105,7 @@
     void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     {
         MemoryClassInfo<QualifiedName> info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
-        info.reportInstrumentedPointer(m_impl);
+        info.addInstrumentedMember(m_impl);
     }
 private:
     void init(const AtomicString& prefix, const AtomicString& localName, const AtomicString& namespaceURI);

Modified: trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp (122713 => 122714)


--- trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp	2012-07-16 12:00:28 UTC (rev 122714)
@@ -500,7 +500,7 @@
     }
 
 private:
-    virtual void reportString(ObjectType objectType, const String& string)
+    virtual void addString(const String& string, ObjectType objectType)
     {
         if (string.isNull() || visited(string.impl()))
             return;
@@ -541,7 +541,7 @@
         if (node->document() && node->document()->frame() && m_page != node->document()->frame()->page())
             return;
 
-        m_domMemoryUsage.reportInstrumentedPointer(node);
+        m_domMemoryUsage.addInstrumentedMember(node);
         m_domMemoryUsage.processDeferredInstrumentedPointers();
     }
 

Modified: trunk/Source/WebCore/platform/TreeShared.h (122713 => 122714)


--- trunk/Source/WebCore/platform/TreeShared.h	2012-07-16 11:48:11 UTC (rev 122713)
+++ trunk/Source/WebCore/platform/TreeShared.h	2012-07-16 12:00:28 UTC (rev 122714)
@@ -114,7 +114,7 @@
     void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     {
         MemoryClassInfo<TreeShared<NodeType, ParentNodeType> > info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
-        info.reportInstrumentedPointer(m_parent);
+        info.addInstrumentedMember(m_parent);
     }
 
 private:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to