Title: [138454] trunk/Source
Revision
138454
Author
[email protected]
Date
2012-12-24 23:41:08 -0800 (Mon, 24 Dec 2012)

Log Message

Memory instrumentation: provide a way to mark a node as a root
https://bugs.webkit.org/show_bug.cgi?id=105737

Reviewed by Alexander Pavlov.

Source/WebCore:

Extended HeapGraphSerializer to add a fake root node with edges to all
real instrumentation roots.

* inspector/HeapGraphSerializer.cpp:
(WebCore::HeapGraphSerializer::reportNode):
(WebCore::HeapGraphSerializer::addRootNode):
(WebCore):
* inspector/HeapGraphSerializer.h:
(HeapGraphSerializer):

Source/WTF:

Objects added using MemoryInstrumentation::addRootObject will be marked as roots.

* wtf/MemoryInstrumentation.cpp:
(WTF::MemoryInstrumentation::WrapperBase::process):
(WTF):
(WTF::MemoryInstrumentation::WrapperBase::processPointer):
(WTF::MemoryInstrumentation::WrapperBase::processRootObjectRef):
* wtf/MemoryInstrumentation.h:
(WrapperBase):
* wtf/MemoryObjectInfo.h: added root marker which can be used by the heap graph builder.
(WTF::MemoryObjectInfo::MemoryObjectInfo):
(WTF::MemoryObjectInfo::isRoot):
(WTF::MemoryObjectInfo::markAsRoot):
(MemoryObjectInfo):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (138453 => 138454)


--- trunk/Source/WTF/ChangeLog	2012-12-25 07:26:03 UTC (rev 138453)
+++ trunk/Source/WTF/ChangeLog	2012-12-25 07:41:08 UTC (rev 138454)
@@ -1,3 +1,25 @@
+2012-12-24  Yury Semikhatsky  <[email protected]>
+
+        Memory instrumentation: provide a way to mark a node as a root
+        https://bugs.webkit.org/show_bug.cgi?id=105737
+
+        Reviewed by Alexander Pavlov.
+
+        Objects added using MemoryInstrumentation::addRootObject will be marked as roots.
+
+        * wtf/MemoryInstrumentation.cpp:
+        (WTF::MemoryInstrumentation::WrapperBase::process):
+        (WTF):
+        (WTF::MemoryInstrumentation::WrapperBase::processPointer):
+        (WTF::MemoryInstrumentation::WrapperBase::processRootObjectRef):
+        * wtf/MemoryInstrumentation.h:
+        (WrapperBase):
+        * wtf/MemoryObjectInfo.h: added root marker which can be used by the heap graph builder.
+        (WTF::MemoryObjectInfo::MemoryObjectInfo):
+        (WTF::MemoryObjectInfo::isRoot):
+        (WTF::MemoryObjectInfo::markAsRoot):
+        (MemoryObjectInfo):
+
 2012-12-24  Ilya Tikhonovsky  <[email protected]>
 
         Web Inspector: Native Memory Instrumentation: propagate member type as edge type to the serialized heap graph.

Modified: trunk/Source/WTF/wtf/MemoryInstrumentation.cpp (138453 => 138454)


--- trunk/Source/WTF/wtf/MemoryInstrumentation.cpp	2012-12-25 07:26:03 UTC (rev 138453)
+++ trunk/Source/WTF/wtf/MemoryInstrumentation.cpp	2012-12-25 07:41:08 UTC (rev 138454)
@@ -84,7 +84,14 @@
 
 void MemoryInstrumentation::WrapperBase::process(MemoryInstrumentation* memoryInstrumentation)
 {
+    processPointer(memoryInstrumentation, false);
+}
+
+void MemoryInstrumentation::WrapperBase::processPointer(MemoryInstrumentation* memoryInstrumentation, bool isRoot)
+{
     MemoryObjectInfo memoryObjectInfo(memoryInstrumentation, m_ownerObjectType, m_pointer);
+    if (isRoot)
+        memoryObjectInfo.markAsRoot();
     callReportMemoryUsage(&memoryObjectInfo);
 
     const void* realAddress = memoryObjectInfo.reportedPointer();
@@ -107,6 +114,7 @@
 void MemoryInstrumentation::WrapperBase::processRootObjectRef(MemoryInstrumentation* memoryInstrumentation)
 {
     MemoryObjectInfo memoryObjectInfo(memoryInstrumentation, m_ownerObjectType, m_pointer);
+    memoryObjectInfo.markAsRoot();
     callReportMemoryUsage(&memoryObjectInfo);
 
     ASSERT(m_pointer == memoryObjectInfo.reportedPointer());

Modified: trunk/Source/WTF/wtf/MemoryInstrumentation.h (138453 => 138454)


--- trunk/Source/WTF/wtf/MemoryInstrumentation.h	2012-12-25 07:26:03 UTC (rev 138453)
+++ trunk/Source/WTF/wtf/MemoryInstrumentation.h	2012-12-25 07:41:08 UTC (rev 138454)
@@ -88,6 +88,7 @@
         WTF_EXPORT_PRIVATE WrapperBase(MemoryObjectType, const void* pointer);
         virtual ~WrapperBase() { }
         WTF_EXPORT_PRIVATE void process(MemoryInstrumentation*);
+        WTF_EXPORT_PRIVATE void processPointer(MemoryInstrumentation*, bool isRoot);
         WTF_EXPORT_PRIVATE void processRootObjectRef(MemoryInstrumentation*);
 
     protected:
@@ -200,7 +201,7 @@
         static void addRootObject(MemoryInstrumentation* instrumentation, const T* const& t, MemoryObjectType objectType)
         {
             if (t && !instrumentation->visited(t))
-                Wrapper<T>(t, objectType).process(instrumentation);
+                Wrapper<T>(t, objectType).processPointer(instrumentation, true);
         }
     };
 

Modified: trunk/Source/WTF/wtf/MemoryObjectInfo.h (138453 => 138454)


--- trunk/Source/WTF/wtf/MemoryObjectInfo.h	2012-12-25 07:26:03 UTC (rev 138453)
+++ trunk/Source/WTF/wtf/MemoryObjectInfo.h	2012-12-25 07:41:08 UTC (rev 138454)
@@ -50,6 +50,7 @@
         , m_pointer(pointer)
         , m_firstVisit(true)
         , m_customAllocation(false)
+        , m_isRoot(false)
     { }
 
     typedef MemoryClassInfo ClassInfo;
@@ -73,6 +74,8 @@
             m_name = name;
     }
     const String& name() const { return m_name; }
+    bool isRoot() const { return m_isRoot; }
+    void markAsRoot() { m_isRoot = true; }
 
     MemoryInstrumentation* memoryInstrumentation() { return m_memoryInstrumentation; }
 
@@ -98,6 +101,7 @@
     const void* m_pointer;
     bool m_firstVisit;
     bool m_customAllocation;
+    bool m_isRoot;
     String m_className;
     String m_name;
 };

Modified: trunk/Source/WebCore/ChangeLog (138453 => 138454)


--- trunk/Source/WebCore/ChangeLog	2012-12-25 07:26:03 UTC (rev 138453)
+++ trunk/Source/WebCore/ChangeLog	2012-12-25 07:41:08 UTC (rev 138454)
@@ -1,5 +1,22 @@
 2012-12-24  Yury Semikhatsky  <[email protected]>
 
+        Memory instrumentation: provide a way to mark a node as a root
+        https://bugs.webkit.org/show_bug.cgi?id=105737
+
+        Reviewed by Alexander Pavlov.
+
+        Extended HeapGraphSerializer to add a fake root node with edges to all
+        real instrumentation roots.
+
+        * inspector/HeapGraphSerializer.cpp:
+        (WebCore::HeapGraphSerializer::reportNode):
+        (WebCore::HeapGraphSerializer::addRootNode):
+        (WebCore):
+        * inspector/HeapGraphSerializer.h:
+        (HeapGraphSerializer):
+
+2012-12-24  Yury Semikhatsky  <[email protected]>
+
         Web Inspector: add message listener only in case of standalone test-runner.html
         https://bugs.webkit.org/show_bug.cgi?id=105715
 

Modified: trunk/Source/WebCore/inspector/HeapGraphSerializer.cpp (138453 => 138454)


--- trunk/Source/WebCore/inspector/HeapGraphSerializer.cpp	2012-12-25 07:26:03 UTC (rev 138453)
+++ trunk/Source/WebCore/inspector/HeapGraphSerializer.cpp	2012-12-25 07:41:08 UTC (rev 138454)
@@ -115,6 +115,8 @@
     m_lastReportedEdgeIndex = m_edges.size();
 
     m_objectToNodeIndex.set(info.reportedPointer(), m_nodes.size());
+    if (info.isRoot())
+        m_roots.append(info.reportedPointer());
     m_nodes.append(node);
 }
 
@@ -205,6 +207,17 @@
     return result.iterator->value;
 }
 
+void HeapGraphSerializer::addRootNode()
+{
+    for (size_t i = 0; i < m_roots.size(); i++)
+        reportEdge(m_roots[i], 0, WTF::PointerMember);
+    HeapGraphNode node;
+    node.m_name = addString("Root");
+    node.m_edgeCount = m_edges.size() - m_lastReportedEdgeIndex;
+    m_lastReportedEdgeIndex = m_edges.size();
+    m_nodes.append(node);
+}
+
 void HeapGraphSerializer::adjutEdgeTargets()
 {
     for (size_t i = 0; i < m_edges.size(); i++) {

Modified: trunk/Source/WebCore/inspector/HeapGraphSerializer.h (138453 => 138454)


--- trunk/Source/WebCore/inspector/HeapGraphSerializer.h	2012-12-25 07:26:03 UTC (rev 138453)
+++ trunk/Source/WebCore/inspector/HeapGraphSerializer.h	2012-12-25 07:41:08 UTC (rev 138454)
@@ -62,6 +62,7 @@
 
 private:
     int addString(const String&);
+    void addRootNode();
     void adjutEdgeTargets();
 
     typedef HashMap<String, int> StringMap;
@@ -77,6 +78,7 @@
 
     Vector<HeapGraphNode> m_nodes;
     Vector<HeapGraphEdge> m_edges;
+    Vector<const void*> m_roots;
 
     size_t m_edgeTypes[WTF::LastMemberTypeEntry];
 };
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to