Web Inspector: Native Memory Instrumentation: do not validate pointers to objects...
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Dec 2012 14:23:42 +0000 (14:23 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Dec 2012 14:23:42 +0000 (14:23 +0000)
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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@137589 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
Source/WTF/ChangeLog
Source/WTF/wtf/MemoryInstrumentation.cpp
Source/WTF/wtf/MemoryInstrumentation.h
Source/WTF/wtf/MemoryObjectInfo.h
Source/WebCore/ChangeLog
Source/WebCore/rendering/InlineBox.cpp
Source/WebCore/rendering/InlineBox.h
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebCore/rendering/InlineTextBox.h
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderObject.cpp

index 99a61f4..8fd054d 100755 (executable)
@@ -347,6 +347,7 @@ EXPORTS
     ?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
index ad8a9a3..75239f3 100644 (file)
@@ -1,3 +1,23 @@
+2012-12-13  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        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  <loislo@chromium.org>
 
         Web Inspector: Native Memory Instrumentation: remove fake root MemoryObjectInfo.
index af8b924..3cf6c02 100644 (file)
@@ -96,7 +96,7 @@ void MemoryInstrumentation::WrapperBase::process(MemoryInstrumentation* memoryIn
     }
     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 @@ void MemoryClassInfo::addPrivateBuffer(size_t size, MemoryObjectType ownerObject
     m_memoryInstrumentation->reportLinkToBuffer(m_memoryObjectInfo->reportedPointer(), 0, ownerObjectType, size, nodeName, edgeName);
 }
 
+void MemoryClassInfo::setCustomAllocation(bool customAllocation)
+{
+    m_memoryObjectInfo->setCustomAllocation(customAllocation);
+}
+
 } // namespace WTF
index 1a6c5ea..0cc9417 100644 (file)
@@ -208,6 +208,7 @@ public:
     }
     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*) { }
 
index bc5e299..bbc1494 100644 (file)
@@ -49,6 +49,7 @@ public:
         , m_objectSize(0)
         , m_pointer(pointer)
         , m_firstVisit(true)
+        , m_customAllocation(false)
     { }
 
     typedef MemoryClassInfo ClassInfo;
@@ -57,6 +58,8 @@ public:
     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 @@ private:
     size_t m_objectSize;
     const void* m_pointer;
     bool m_firstVisit;
+    bool m_customAllocation;
     String m_className;
     String m_name;
 };
index a81a139..e4679f9 100644 (file)
@@ -1,3 +1,29 @@
+2012-12-13  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        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  <agarcia@igalia.com>
 
         [GTK] Don't leak GStaticRecMutex
index 18079ff..fb125aa 100644 (file)
@@ -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 @@ LayoutPoint InlineBox::flipForWritingMode(const LayoutPoint& point)
     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
index e2cf85f..034db13 100644 (file)
@@ -302,6 +302,8 @@ public:
     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.
index 50648e3..1678a21 100644 (file)
@@ -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 @@ void InlineTextBox::showBox(int printedCharacters) const
 
 #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
index 1f2a63a..f5bfb10 100644 (file)
@@ -101,6 +101,9 @@ public:
     virtual void showBox(int = 0) const;
     virtual const char* boxName() const;
 #endif
+
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
+
 private:
     LayoutUnit selectionTop();
     LayoutUnit selectionBottom();
index 4710300..9cd1c04 100644 (file)
@@ -5448,6 +5448,7 @@ void RenderLayer::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 #if USE(ACCELERATED_COMPOSITING)
     info.addMember(m_backing);
 #endif
+    info.setCustomAllocation(true);
 }
 
 } // namespace WebCore
index 34a6a3c..718cdb3 100644 (file)
@@ -3086,6 +3086,8 @@ void RenderObject::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     info.addWeakPointer(m_parent);
     info.addWeakPointer(m_previous);
     info.addWeakPointer(m_next);
+
+    info.setCustomAllocation(true);
 }
 
 #if ENABLE(SVG)