Title: [137589] trunk/Source
Revision
137589
Author
[email protected]
Date
2012-12-13 06:23:42 -0800 (Thu, 13 Dec 2012)

Log Message

Web Inspector: Native Memory Instrumentation: do not validate pointers to objects in RenderArena agains tcmalloc data.
https://bugs.webkit.org/show_bug.cgi?id=104903

Reviewed by Yury Semikhatsky.

This is a simplest approach to do that with zero performance overhead.

Source/WebCore:

* inspector/InspectorResourceAgent.cpp:
(WebCore::InspectorResourceAgent::reportMemoryUsage):
* rendering/InlineBox.cpp:
(WebCore::InlineBox::reportMemoryUsage):
(WebCore):
* rendering/InlineBox.h:
(InlineBox):
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::reportMemoryUsage):
(WebCore):
* rendering/InlineTextBox.h:
(InlineTextBox):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::reportMemoryUsage):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::reportMemoryUsage):

Source/WTF:

* wtf/MemoryInstrumentation.cpp:
(WTF::MemoryClassInfo::setCustomAllocation):
(WTF):
* wtf/MemoryInstrumentation.h:
(MemoryClassInfo):
* wtf/MemoryObjectInfo.h:
(WTF::MemoryObjectInfo::MemoryObjectInfo):
(WTF::MemoryObjectInfo::customAllocation):
(WTF::MemoryObjectInfo::setCustomAllocations):
(MemoryObjectInfo):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def (137588 => 137589)


--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2012-12-13 14:21:49 UTC (rev 137588)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2012-12-13 14:23:42 UTC (rev 137589)
@@ -347,6 +347,7 @@
     ?retrieveLastCaller@Interpreter@JSC@@QBEXPAVExecState@2@AAH1AAVString@WTF@@AAVJSValue@2@@Z
     ?save@Database@Profiler@JSC@@QBE_NPBD@Z
     ?setConfigurable@PropertyDescriptor@JSC@@QAEX_N@Z
+    ?setCustomAllocation@MemoryClassInfo@WTF@@QAEX_N@Z
     ?setDescriptor@PropertyDescriptor@JSC@@QAEXVJSValue@2@I@Z
     ?setEnumerable@PropertyDescriptor@JSC@@QAEX_N@Z
     ?setGarbageCollectionTimerEnabled@Heap@JSC@@QAEX_N@Z

Modified: trunk/Source/WTF/ChangeLog (137588 => 137589)


--- trunk/Source/WTF/ChangeLog	2012-12-13 14:21:49 UTC (rev 137588)
+++ trunk/Source/WTF/ChangeLog	2012-12-13 14:23:42 UTC (rev 137589)
@@ -1,3 +1,23 @@
+2012-12-13  Ilya Tikhonovsky  <[email protected]>
+
+        Web Inspector: Native Memory Instrumentation: do not validate pointers to objects in RenderArena agains tcmalloc data.
+        https://bugs.webkit.org/show_bug.cgi?id=104903
+
+        Reviewed by Yury Semikhatsky.
+
+        This is a simplest approach to do that with zero performance overhead.
+
+        * wtf/MemoryInstrumentation.cpp:
+        (WTF::MemoryClassInfo::setCustomAllocation):
+        (WTF):
+        * wtf/MemoryInstrumentation.h:
+        (MemoryClassInfo):
+        * wtf/MemoryObjectInfo.h:
+        (WTF::MemoryObjectInfo::MemoryObjectInfo):
+        (WTF::MemoryObjectInfo::customAllocation):
+        (WTF::MemoryObjectInfo::setCustomAllocations):
+        (MemoryObjectInfo):
+
 2012-12-12  Ilya Tikhonovsky  <[email protected]>
 
         Web Inspector: Native Memory Instrumentation: remove fake root MemoryObjectInfo.

Modified: trunk/Source/WTF/wtf/MemoryInstrumentation.cpp (137588 => 137589)


--- trunk/Source/WTF/wtf/MemoryInstrumentation.cpp	2012-12-13 14:21:49 UTC (rev 137588)
+++ trunk/Source/WTF/wtf/MemoryInstrumentation.cpp	2012-12-13 14:23:42 UTC (rev 137589)
@@ -96,7 +96,7 @@
     }
     memoryInstrumentation->countObjectSize(realAddress, memoryObjectInfo.objectType(), memoryObjectInfo.objectSize());
     memoryInstrumentation->m_client->reportNode(memoryObjectInfo);
-    if (!memoryInstrumentation->checkCountedObject(realAddress)) {
+    if (!memoryObjectInfo.customAllocation() && !memoryInstrumentation->checkCountedObject(realAddress)) {
 #if DEBUG_POINTER_INSTRUMENTATION
         fputs("Unknown object counted:\n", stderr);
         WTFPrintBacktrace(m_callStack, m_callStackSize);
@@ -139,4 +139,9 @@
     m_memoryInstrumentation->reportLinkToBuffer(m_memoryObjectInfo->reportedPointer(), 0, ownerObjectType, size, nodeName, edgeName);
 }
 
+void MemoryClassInfo::setCustomAllocation(bool customAllocation)
+{
+    m_memoryObjectInfo->setCustomAllocation(customAllocation);
+}
+
 } // namespace WTF

Modified: trunk/Source/WTF/wtf/MemoryInstrumentation.h (137588 => 137589)


--- trunk/Source/WTF/wtf/MemoryInstrumentation.h	2012-12-13 14:21:49 UTC (rev 137588)
+++ trunk/Source/WTF/wtf/MemoryInstrumentation.h	2012-12-13 14:23:42 UTC (rev 137589)
@@ -208,6 +208,7 @@
     }
     WTF_EXPORT_PRIVATE void addRawBuffer(const void* buffer, size_t, const char* nodeName = 0, const char* edgeName = 0);
     WTF_EXPORT_PRIVATE void addPrivateBuffer(size_t, MemoryObjectType ownerObjectType = 0, const char* nodeName = 0, const char* edgeName = 0);
+    WTF_EXPORT_PRIVATE void setCustomAllocation(bool);
 
     void addWeakPointer(void*) { }
 

Modified: trunk/Source/WTF/wtf/MemoryObjectInfo.h (137588 => 137589)


--- trunk/Source/WTF/wtf/MemoryObjectInfo.h	2012-12-13 14:21:49 UTC (rev 137588)
+++ trunk/Source/WTF/wtf/MemoryObjectInfo.h	2012-12-13 14:23:42 UTC (rev 137589)
@@ -49,6 +49,7 @@
         , m_objectSize(0)
         , m_pointer(pointer)
         , m_firstVisit(true)
+        , m_customAllocation(false)
     { }
 
     typedef MemoryClassInfo ClassInfo;
@@ -57,6 +58,8 @@
     size_t objectSize() const { return m_objectSize; }
     const void* reportedPointer() const { return m_pointer; }
     bool firstVisit() const { return m_firstVisit; }
+    bool customAllocation() const { return m_customAllocation; }
+    void setCustomAllocation(bool customAllocation) { m_customAllocation = customAllocation; }
 
     void setClassName(const String& className) { m_className = className; }
     const String& className() const { return m_className; }
@@ -86,6 +89,7 @@
     size_t m_objectSize;
     const void* m_pointer;
     bool m_firstVisit;
+    bool m_customAllocation;
     String m_className;
     String m_name;
 };

Modified: trunk/Source/WebCore/ChangeLog (137588 => 137589)


--- trunk/Source/WebCore/ChangeLog	2012-12-13 14:21:49 UTC (rev 137588)
+++ trunk/Source/WebCore/ChangeLog	2012-12-13 14:23:42 UTC (rev 137589)
@@ -1,3 +1,29 @@
+2012-12-13  Ilya Tikhonovsky  <[email protected]>
+
+        Web Inspector: Native Memory Instrumentation: do not validate pointers to objects in RenderArena agains tcmalloc data.
+        https://bugs.webkit.org/show_bug.cgi?id=104903
+
+        Reviewed by Yury Semikhatsky.
+
+        This is a simplest approach to do that with zero performance overhead.
+
+        * inspector/InspectorResourceAgent.cpp:
+        (WebCore::InspectorResourceAgent::reportMemoryUsage):
+        * rendering/InlineBox.cpp:
+        (WebCore::InlineBox::reportMemoryUsage):
+        (WebCore):
+        * rendering/InlineBox.h:
+        (InlineBox):
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::reportMemoryUsage):
+        (WebCore):
+        * rendering/InlineTextBox.h:
+        (InlineTextBox):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::reportMemoryUsage):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::reportMemoryUsage):
+
 2012-12-13  Alberto Garcia  <[email protected]>
 
         [GTK] Don't leak GStaticRecMutex

Modified: trunk/Source/WebCore/rendering/InlineBox.cpp (137588 => 137589)


--- trunk/Source/WebCore/rendering/InlineBox.cpp	2012-12-13 14:21:49 UTC (rev 137588)
+++ trunk/Source/WebCore/rendering/InlineBox.cpp	2012-12-13 14:23:42 UTC (rev 137589)
@@ -29,6 +29,7 @@
 #include "RenderArena.h"
 #include "RenderBlock.h"
 #include "RootInlineBox.h"
+#include "WebCoreMemoryInstrumentation.h"
 
 #ifndef NDEBUG
 #include <stdio.h>
@@ -387,6 +388,17 @@
     return root()->block()->flipForWritingMode(point);
 }
 
+void InlineBox::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Rendering);
+    info.addMember(m_next);
+    info.addMember(m_prev);
+    info.addMember(m_parent);
+    info.addMember(m_renderer);
+
+    info.setCustomAllocation(true);
+}
+
 } // namespace WebCore
 
 #ifndef NDEBUG

Modified: trunk/Source/WebCore/rendering/InlineBox.h (137588 => 137589)


--- trunk/Source/WebCore/rendering/InlineBox.h	2012-12-13 14:21:49 UTC (rev 137588)
+++ trunk/Source/WebCore/rendering/InlineBox.h	2012-12-13 14:23:42 UTC (rev 137589)
@@ -302,6 +302,8 @@
     bool dirOverride() const { return m_bitfields.dirOverride(); }
     void setDirOverride(bool dirOverride) { m_bitfields.setDirOverride(dirOverride); }
 
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     InlineBox* m_next; // The next element on the same line as us.
     InlineBox* m_prev; // The previous element on the same line as us.

Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (137588 => 137589)


--- trunk/Source/WebCore/rendering/InlineTextBox.cpp	2012-12-13 14:21:49 UTC (rev 137588)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp	2012-12-13 14:23:42 UTC (rev 137589)
@@ -46,6 +46,7 @@
 #include "Settings.h"
 #include "SVGTextRunRenderingContext.h"
 #include "Text.h"
+#include "WebCoreMemoryInstrumentation.h"
 #include "break_lines.h"
 #include <wtf/AlwaysInline.h>
 #include <wtf/text/CString.h>
@@ -1454,4 +1455,12 @@
 
 #endif
 
+void InlineTextBox::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Rendering);
+    InlineBox::reportMemoryUsage(memoryObjectInfo);
+    info.addMember(m_prevTextBox);
+    info.addMember(m_nextTextBox);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/InlineTextBox.h (137588 => 137589)


--- trunk/Source/WebCore/rendering/InlineTextBox.h	2012-12-13 14:21:49 UTC (rev 137588)
+++ trunk/Source/WebCore/rendering/InlineTextBox.h	2012-12-13 14:23:42 UTC (rev 137589)
@@ -101,6 +101,9 @@
     virtual void showBox(int = 0) const;
     virtual const char* boxName() const;
 #endif
+
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
+
 private:
     LayoutUnit selectionTop();
     LayoutUnit selectionBottom();

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (137588 => 137589)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-12-13 14:21:49 UTC (rev 137588)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-12-13 14:23:42 UTC (rev 137589)
@@ -5448,6 +5448,7 @@
 #if USE(ACCELERATED_COMPOSITING)
     info.addMember(m_backing);
 #endif
+    info.setCustomAllocation(true);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (137588 => 137589)


--- trunk/Source/WebCore/rendering/RenderObject.cpp	2012-12-13 14:21:49 UTC (rev 137588)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp	2012-12-13 14:23:42 UTC (rev 137589)
@@ -3086,6 +3086,8 @@
     info.addWeakPointer(m_parent);
     info.addWeakPointer(m_previous);
     info.addWeakPointer(m_next);
+
+    info.setCustomAllocation(true);
 }
 
 #if ENABLE(SVG)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to