Title: [122466] trunk/Source/WebCore
Revision
122466
Author
[email protected]
Date
2012-07-12 08:59:49 -0700 (Thu, 12 Jul 2012)

Log Message

Web Inspector: fix native memory instrumentation code for the bindings instrumentation.
https://bugs.webkit.org/show_bug.cgi?id=91096

The instrumented class has to have instrumentation method which reports class size and type and
the member objects and pointers.

Sample:
void Node::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
    memoryObjectInfo->reportObjectInfo(this, MemoryInstrumentation::DOM); // report object size and type.
    TreeShared<Node, ContainerNode>::reportMemoryUsage(memoryObjectInfo); // call base class instrumentation.
    ScriptWrappable::reportMemoryUsage(memoryObjectInfo); // call base class instrumentation.
    memoryObjectInfo->reportPointer(m_document, MemoryInstrumentation::DOM); // report uninstrumented pointer.
    memoryObjectInfo->reportInstrumentedPointer(m_next); // report instrumented pointer.
    memoryObjectInfo->reportInstrumentedObject(m_anObject); // report instrumented object.
}

Reviewed by Pavel Feldman.

Existing tests for native memory instrumentation.

* bindings/v8/DOMDataStore.cpp:
(WebCore::DOMDataStore::reportMemoryUsage):
* bindings/v8/DOMDataStore.h:
(WebCore):
(DOMDataStore):
* bindings/v8/IntrusiveDOMWrapperMap.h:
(WebCore::ChunkedTable::reportMemoryUsage):
* bindings/v8/ScriptProfiler.cpp:
(WebCore::ScriptProfiler::collectBindingMemoryInfo):
* bindings/v8/V8Binding.cpp:
(WebCore::V8BindingPerIsolateData::reportMemoryUsage):
(WebCore::StringCache::reportMemoryUsage):
* bindings/v8/V8Binding.h:
(WebCore):
(StringCache):
(V8BindingPerIsolateData):
* bindings/v8/V8DOMMap.h:
(WebCore):
(AbstractWeakReferenceMap):
* inspector/InspectorMemoryAgent.cpp:
(WebCore):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (122465 => 122466)


--- trunk/Source/WebCore/ChangeLog	2012-07-12 15:54:04 UTC (rev 122465)
+++ trunk/Source/WebCore/ChangeLog	2012-07-12 15:59:49 UTC (rev 122466)
@@ -1,3 +1,48 @@
+2012-07-12  Ilya Tikhonovsky  <[email protected]>
+
+        Web Inspector: fix native memory instrumentation code for the bindings instrumentation.
+        https://bugs.webkit.org/show_bug.cgi?id=91096
+
+        The instrumented class has to have instrumentation method which reports class size and type and
+        the member objects and pointers.
+
+        Sample:
+        void Node::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+        {
+            memoryObjectInfo->reportObjectInfo(this, MemoryInstrumentation::DOM); // report object size and type.
+            TreeShared<Node, ContainerNode>::reportMemoryUsage(memoryObjectInfo); // call base class instrumentation.
+            ScriptWrappable::reportMemoryUsage(memoryObjectInfo); // call base class instrumentation.
+            memoryObjectInfo->reportPointer(m_document, MemoryInstrumentation::DOM); // report uninstrumented pointer.
+            memoryObjectInfo->reportInstrumentedPointer(m_next); // report instrumented pointer.
+            memoryObjectInfo->reportInstrumentedObject(m_anObject); // report instrumented object.
+        }
+
+        Reviewed by Pavel Feldman.
+
+        Existing tests for native memory instrumentation.
+
+        * bindings/v8/DOMDataStore.cpp:
+        (WebCore::DOMDataStore::reportMemoryUsage):
+        * bindings/v8/DOMDataStore.h:
+        (WebCore):
+        (DOMDataStore):
+        * bindings/v8/IntrusiveDOMWrapperMap.h:
+        (WebCore::ChunkedTable::reportMemoryUsage):
+        * bindings/v8/ScriptProfiler.cpp:
+        (WebCore::ScriptProfiler::collectBindingMemoryInfo):
+        * bindings/v8/V8Binding.cpp:
+        (WebCore::V8BindingPerIsolateData::reportMemoryUsage):
+        (WebCore::StringCache::reportMemoryUsage):
+        * bindings/v8/V8Binding.h:
+        (WebCore):
+        (StringCache):
+        (V8BindingPerIsolateData):
+        * bindings/v8/V8DOMMap.h:
+        (WebCore):
+        (AbstractWeakReferenceMap):
+        * inspector/InspectorMemoryAgent.cpp:
+        (WebCore):
+
 2012-07-12  Pavel Feldman  <[email protected]>
 
         Web Inspector: beautify find bar looks, simplify search update routines.

Modified: trunk/Source/WebCore/bindings/v8/DOMDataStore.cpp (122465 => 122466)


--- trunk/Source/WebCore/bindings/v8/DOMDataStore.cpp	2012-07-12 15:54:04 UTC (rev 122465)
+++ trunk/Source/WebCore/bindings/v8/DOMDataStore.cpp	2012-07-12 15:59:49 UTC (rev 122466)
@@ -119,13 +119,13 @@
     return 0;
 }
 
-void DOMDataStore::reportMemoryUsage(MemoryInstrumentation* instrumentation)
+void DOMDataStore::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
-    instrumentation->reportPointer(this, MemoryInstrumentation::Binding);
-    domNodeMap().reportMemoryUsage(instrumentation);
-    activeDomNodeMap().reportMemoryUsage(instrumentation);
-    domObjectMap().reportMemoryUsage(instrumentation);
-    activeDomObjectMap().reportMemoryUsage(instrumentation);
+    memoryObjectInfo->reportObjectInfo(this, MemoryInstrumentation::Binding);
+    memoryObjectInfo->reportInstrumentedPointer(m_domNodeMap);
+    memoryObjectInfo->reportInstrumentedPointer(m_activeDomNodeMap);
+    memoryObjectInfo->reportInstrumentedPointer(m_domObjectMap);
+    memoryObjectInfo->reportInstrumentedPointer(m_activeDomObjectMap);
 }
 
 // Called when the object is near death (not reachable from JS roots).

Modified: trunk/Source/WebCore/bindings/v8/DOMDataStore.h (122465 => 122466)


--- trunk/Source/WebCore/bindings/v8/DOMDataStore.h	2012-07-12 15:54:04 UTC (rev 122465)
+++ trunk/Source/WebCore/bindings/v8/DOMDataStore.h	2012-07-12 15:59:49 UTC (rev 122466)
@@ -47,7 +47,7 @@
 
     class DOMData;
     class DOMDataStore;
-    class MemoryInstrumentation;
+    class MemoryObjectInfo;
 
     typedef WTF::Vector<DOMDataStore*> DOMDataList;
 
@@ -87,7 +87,7 @@
         static void weakActiveDOMObjectCallback(v8::Persistent<v8::Value> v8Object, void* domObject);
         static void weakNodeCallback(v8::Persistent<v8::Value> v8Object, void* domObject);
 
-        void reportMemoryUsage(MemoryInstrumentation*);
+        void reportMemoryUsage(MemoryObjectInfo*) const;
 
     protected:
         static void weakDOMObjectCallback(v8::Persistent<v8::Value> v8Object, void* domObject);

Modified: trunk/Source/WebCore/bindings/v8/IntrusiveDOMWrapperMap.h (122465 => 122466)


--- trunk/Source/WebCore/bindings/v8/IntrusiveDOMWrapperMap.h	2012-07-12 15:54:04 UTC (rev 122465)
+++ trunk/Source/WebCore/bindings/v8/IntrusiveDOMWrapperMap.h	2012-07-12 15:59:49 UTC (rev 122466)
@@ -102,10 +102,11 @@
             visitEntries(store, chunk->m_entries, chunk->m_entries + CHUNK_SIZE, visitor);
     }
 
-    void reportMemoryUsage(MemoryInstrumentation* instrumentation)
+    void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     {
+        memoryObjectInfo->reportObjectInfo(this, MemoryInstrumentation::Binding);
         for (Chunk* chunk = m_chunks; chunk; chunk = chunk->m_previous)
-            instrumentation->reportPointer(chunk, MemoryInstrumentation::Binding);
+            memoryObjectInfo->reportPointer(chunk, MemoryInstrumentation::Binding);
     }
 
   private:
@@ -183,10 +184,10 @@
         m_table.clear();
     }
 
-    virtual void reportMemoryUsage(MemoryInstrumentation* instrumentation) OVERRIDE
+    virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const OVERRIDE
     {
-        instrumentation->reportPointer(this, MemoryInstrumentation::Binding);
-        m_table.reportMemoryUsage(instrumentation);
+        memoryObjectInfo->reportObjectInfo(this, MemoryInstrumentation::Binding);
+        memoryObjectInfo->reportInstrumentedObject(m_table);
     }
 
 private:

Modified: trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp (122465 => 122466)


--- trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp	2012-07-12 15:54:04 UTC (rev 122465)
+++ trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp	2012-07-12 15:59:49 UTC (rev 122466)
@@ -223,9 +223,7 @@
 void ScriptProfiler::collectBindingMemoryInfo(MemoryInstrumentation* instrumentation)
 {
     V8BindingPerIsolateData* data = ""
-    if (!data)
-        return;
-    data->reportMemoryUsage(instrumentation);
+    instrumentation->reportInstrumentedPointer(data);
 }
 
 size_t ScriptProfiler::profilerSnapshotsSize()

Modified: trunk/Source/WebCore/bindings/v8/V8Binding.cpp (122465 => 122466)


--- trunk/Source/WebCore/bindings/v8/V8Binding.cpp	2012-07-12 15:54:04 UTC (rev 122465)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.cpp	2012-07-12 15:59:49 UTC (rev 122466)
@@ -90,15 +90,16 @@
     isolate->SetData(0);
 }
 
-void V8BindingPerIsolateData::reportMemoryUsage(MemoryInstrumentation* instrumentation)
+void V8BindingPerIsolateData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
-    instrumentation->reportPointer(this, MemoryInstrumentation::Binding);
-    instrumentation->reportHashMap(m_rawTemplates, MemoryInstrumentation::Binding);
-    instrumentation->reportHashMap(m_templates, MemoryInstrumentation::Binding);
-    m_stringCache.reportMemoryUsage(instrumentation);
+    memoryObjectInfo->reportObjectInfo(this, MemoryInstrumentation::Binding);
+    memoryObjectInfo->reportHashMap(m_rawTemplates);
+    memoryObjectInfo->reportHashMap(m_templates);
+    memoryObjectInfo->reportInstrumentedObject(m_stringCache);
+    memoryObjectInfo->reportVector(m_domDataList);
 
     for (size_t i = 0; i < m_domDataList.size(); i++)
-        m_domDataList[i]->reportMemoryUsage(instrumentation);
+        memoryObjectInfo->reportInstrumentedPointer(m_domDataList[i]);
 }
 
 // WebCoreStringResource is a helper class for v8ExternalString. It is used
@@ -587,9 +588,10 @@
     return toStringTemplate;
 }
 
-void StringCache::reportMemoryUsage(MemoryInstrumentation* instrumentation)
+void StringCache::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
-    instrumentation->reportHashMap(m_stringCache, MemoryInstrumentation::Binding);
+    memoryObjectInfo->reportObjectInfo(this, MemoryInstrumentation::Binding);
+    memoryObjectInfo->reportHashMap(m_stringCache);
 }
     
 PassRefPtr<DOMStringList> v8ValueToWebCoreDOMStringList(v8::Handle<v8::Value> value)

Modified: trunk/Source/WebCore/bindings/v8/V8Binding.h (122465 => 122466)


--- trunk/Source/WebCore/bindings/v8/V8Binding.h	2012-07-12 15:54:04 UTC (rev 122465)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.h	2012-07-12 15:59:49 UTC (rev 122466)
@@ -49,7 +49,7 @@
     class EventListener;
     class EventTarget;
     class ExternalStringVisitor;
-    class MemoryInstrumentation;
+    class MemoryObjectInfo;
 
     // FIXME: Remove V8Binding.
     class V8Binding {
@@ -79,7 +79,7 @@
 
         void remove(StringImpl*);
 
-        void reportMemoryUsage(MemoryInstrumentation*);
+        void reportMemoryUsage(MemoryObjectInfo*) const;
 
     private:
         v8::Local<v8::String> v8ExternalStringSlow(StringImpl*, v8::Isolate*);
@@ -217,7 +217,7 @@
 
         GCEventData& gcEventData() { return m_gcEventData; }
 
-        void reportMemoryUsage(MemoryInstrumentation*);
+        void reportMemoryUsage(MemoryObjectInfo*) const;
 
     private:
         explicit V8BindingPerIsolateData(v8::Isolate*);

Modified: trunk/Source/WebCore/bindings/v8/V8DOMMap.h (122465 => 122466)


--- trunk/Source/WebCore/bindings/v8/V8DOMMap.h	2012-07-12 15:54:04 UTC (rev 122465)
+++ trunk/Source/WebCore/bindings/v8/V8DOMMap.h	2012-07-12 15:59:49 UTC (rev 122466)
@@ -39,7 +39,7 @@
 namespace WebCore {
     class DOMDataStore;
     class Node;
-    class MemoryInstrumentation;
+    class MemoryObjectInfo;
 
     template <class KeyType, class ValueType> class AbstractWeakReferenceMap {
     public:
@@ -64,7 +64,7 @@
 
         v8::WeakReferenceCallback weakReferenceCallback() { return m_weakReferenceCallback; }
 
-        virtual void reportMemoryUsage(MemoryInstrumentation*) = 0;
+        virtual void reportMemoryUsage(MemoryObjectInfo*) const = 0;
 
     private:
         v8::WeakReferenceCallback m_weakReferenceCallback;
@@ -134,9 +134,10 @@
             visitor->endMap();
         }
 
-        virtual void reportMemoryUsage(MemoryInstrumentation* instrumentation) OVERRIDE
+        virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const OVERRIDE
         {
-            instrumentation->reportHashMap(m_map, MemoryInstrumentation::Binding);
+            memoryObjectInfo->reportObjectInfo(this, MemoryInstrumentation::Binding);
+            memoryObjectInfo->reportHashMap(m_map);
         }
 
     protected:

Modified: trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp (122465 => 122466)


--- trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp	2012-07-12 15:54:04 UTC (rev 122465)
+++ trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp	2012-07-12 15:59:49 UTC (rev 122466)
@@ -548,6 +548,7 @@
     void visitBindings()
     {
         ScriptProfiler::collectBindingMemoryInfo(&m_domMemoryUsage);
+        m_domMemoryUsage.processDeferredInstrumentedPointers();
     }
 
     PassRefPtr<InspectorMemoryBlock> dumpStatistics(InspectorDataCounter* inspectorData)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to