Web Inspector: NMI add instrumentation to widely used ActiveDOMObjects. XMLHttpReques...
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Nov 2012 12:26:55 +0000 (12:26 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Nov 2012 12:26:55 +0000 (12:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=102818

Reviewed by Vsevolod Vlasov.

Our test bot counts pointers which don't match with objects allocated by tcmalloc.
This counter becomes nonzero after instrumenting ActiveDOMObject class.
It happens because it is the base class for many other classes (~30).
And almost all these classes use multiple inheritance.

* dom/Document.cpp:
(WebCore::Document::reportMemoryUsage):
* dom/DocumentEventQueue.cpp:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::reportMemoryUsage):
(WebCore):
* html/HTMLMediaElement.h:
* loader/Prerenderer.cpp:
(WebCore::Prerenderer::reportMemoryUsage):
(WebCore):
* loader/Prerenderer.h:
(Prerenderer):
* page/DOMTimer.cpp:
(WebCore::DOMTimer::reportMemoryUsage):
(WebCore):
* page/DOMTimer.h:
(DOMTimer):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::reportMemoryUsage):
(WebCore):
* xml/XMLHttpRequest.h:
(XMLHttpRequest):

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

Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/DocumentEventQueue.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/loader/Prerenderer.cpp
Source/WebCore/loader/Prerenderer.h
Source/WebCore/page/DOMTimer.cpp
Source/WebCore/page/DOMTimer.h
Source/WebCore/xml/XMLHttpRequest.cpp
Source/WebCore/xml/XMLHttpRequest.h

index cab8895..f9b78dd 100644 (file)
@@ -1,3 +1,38 @@
+2012-11-21  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: NMI add instrumentation to widely used ActiveDOMObjects. XMLHttpRequest, Prerenderer, HTMLMediaElement and DOMTimer.
+        https://bugs.webkit.org/show_bug.cgi?id=102818
+
+        Reviewed by Vsevolod Vlasov.
+
+        Our test bot counts pointers which don't match with objects allocated by tcmalloc.
+        This counter becomes nonzero after instrumenting ActiveDOMObject class.
+        It happens because it is the base class for many other classes (~30).
+        And almost all these classes use multiple inheritance.
+
+        * dom/Document.cpp:
+        (WebCore::Document::reportMemoryUsage):
+        * dom/DocumentEventQueue.cpp:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::reportMemoryUsage):
+        (WebCore):
+        * html/HTMLMediaElement.h:
+        * loader/Prerenderer.cpp:
+        (WebCore::Prerenderer::reportMemoryUsage):
+        (WebCore):
+        * loader/Prerenderer.h:
+        (Prerenderer):
+        * page/DOMTimer.cpp:
+        (WebCore::DOMTimer::reportMemoryUsage):
+        (WebCore):
+        * page/DOMTimer.h:
+        (DOMTimer):
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::reportMemoryUsage):
+        (WebCore):
+        * xml/XMLHttpRequest.h:
+        (XMLHttpRequest):
+
 2012-11-21  Dan Carney  <dcarney@google.com>
 
         [V8] Add context checks to WorldContextHandle and V8DOMWindowShell
index 450a2f8..05946e7 100644 (file)
@@ -5906,6 +5906,9 @@ void Document::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     info.addMember(m_eventQueue);
     info.addMember(m_mediaCanStartListeners);
     info.addMember(m_pendingTasks);
+#if ENABLE(LINK_PRERENDER)
+    info.addMember(m_prerenderer);
+#endif
 }
 
 class ImmutableAttributeDataCacheKey {
index 8f74595..8aa3048 100644 (file)
@@ -47,6 +47,13 @@ public:
         : SuspendableTimer(context)
         , m_eventQueue(eventQueue) { }
 
+    virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const OVERRIDE
+    {
+        MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
+        SuspendableTimer::reportMemoryUsage(memoryObjectInfo);
+        info.addWeakPointer(m_eventQueue);
+    }
+
 private:
     virtual void fired() { m_eventQueue->pendingEventTimerFired(); }
     DocumentEventQueue* m_eventQueue;
index e42a54b..02b0892 100644 (file)
 #include "ShadowRoot.h"
 #include "TimeRanges.h"
 #include "UUID.h"
+#include "WebCoreMemoryInstrumentation.h"
 #include <limits>
 #include <wtf/CurrentTime.h>
 #include <wtf/MathExtras.h>
+#include <wtf/MemoryInstrumentationVector.h>
 #include <wtf/NonCopyingSort.h>
 #include <wtf/Uint8Array.h>
 #include <wtf/text/CString.h>
@@ -4590,5 +4592,41 @@ void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture()
     m_restrictions = NoRestrictions;
 }
 
+void HTMLMediaElement::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
+    HTMLElement::reportMemoryUsage(memoryObjectInfo);
+    ActiveDOMObject::reportMemoryUsage(memoryObjectInfo);
+    info.addMember(m_loadTimer);
+    info.addMember(m_progressEventTimer);
+    info.addMember(m_playbackProgressTimer);
+    info.addMember(m_playedTimeRanges);
+    info.addMember(m_asyncEventQueue);
+    info.addMember(m_currentSrc);
+    info.addMember(m_error);
+    info.addMember(m_currentSourceNode);
+    info.addMember(m_nextChildNodeToConsider);
+    info.addMember(m_player);
+#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
+    info.addMember(m_proxyWidget);
+#endif
+#if ENABLE(MEDIA_SOURCE)
+    info.addMember(m_mediaSourceURL);
+    info.addMember(m_mediaSource);
+#endif
+#if ENABLE(VIDEO_TRACK)
+    info.addMember(m_textTracks);
+    info.addMember(m_textTracksWhenResourceSelectionBegan);
+    info.addMember(m_cueTree);
+    info.addMember(m_currentlyActiveCues);
+#endif
+    info.addMember(m_mediaGroup);
+    info.addMember(m_mediaController);
+
+#if PLATFORM(MAC)
+    info.addMember(m_sleepDisabler);
+#endif
+}
+
 }
 #endif
index 5e2a00a..2bc7d47 100644 (file)
@@ -320,6 +320,8 @@ public:
 
     virtual bool willRespondToMouseClickEvents() OVERRIDE;
 
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const;
+
 protected:
     HTMLMediaElement(const QualifiedName&, Document*, bool);
     virtual ~HTMLMediaElement();
index 87bac77..164f9e9 100644 (file)
@@ -41,7 +41,9 @@
 #include "PrerendererClient.h"
 #include "ReferrerPolicy.h"
 #include "SecurityPolicy.h"
+#include "WebCoreMemoryInstrumentation.h"
 
+#include <wtf/MemoryInstrumentationVector.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
@@ -142,6 +144,14 @@ PrerendererClient* Prerenderer::client()
     return m_client;
 }
 
+void Prerenderer::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
+    ActiveDOMObject::reportMemoryUsage(memoryObjectInfo);
+    info.addMember(m_activeHandles);
+    info.addMember(m_suspendedHandles);
+}
+
 }
 
 #endif // ENABLE(LINK_PRERENDER)
index 61c6d8c..d9f0128 100644 (file)
@@ -59,6 +59,8 @@ public:
 
     static PassOwnPtr<Prerenderer> create(Document*);
 
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     typedef Vector<RefPtr<PrerenderHandle> > HandleVector;
     typedef Vector<KURL> KURLVector;
index e07e700..9f68cad 100644 (file)
@@ -30,6 +30,7 @@
 #include "InspectorInstrumentation.h"
 #include "ScheduledAction.h"
 #include "ScriptExecutionContext.h"
+#include "WebCoreMemoryInstrumentation.h"
 #include <wtf/CurrentTime.h>
 #include <wtf/HashSet.h>
 #include <wtf/StdLibExtras.h>
@@ -207,4 +208,12 @@ double DOMTimer::alignedFireTime(double fireTime) const
     return fireTime;
 }
 
+void DOMTimer::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
+    SuspendableTimer::reportMemoryUsage(memoryObjectInfo);
+    info.addMember(m_action);
+    info.addMember(m_userGestureToken);
+}
+
 } // namespace WebCore
index e9c1446..dddf2a6 100644 (file)
@@ -53,6 +53,8 @@ namespace WebCore {
         // to events like moving a tab to the background.
         void adjustMinimumTimerInterval(double oldMinimumTimerInterval);
 
+        virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
+
     private:
         DOMTimer(ScriptExecutionContext*, PassOwnPtr<ScheduledAction>, int interval, bool singleShot);
         virtual void fired();
index e79f414..29536da 100644 (file)
@@ -51,6 +51,7 @@
 #include "SharedBuffer.h"
 #include "TextResourceDecoder.h"
 #include "ThreadableLoader.h"
+#include "WebCoreMemoryInstrumentation.h"
 #include "XMLHttpRequestException.h"
 #include "XMLHttpRequestProgressEvent.h"
 #include "XMLHttpRequestUpload.h"
@@ -1297,4 +1298,30 @@ EventTargetData* XMLHttpRequest::ensureEventTargetData()
     return &m_eventTargetData;
 }
 
+void XMLHttpRequest::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
+    ScriptWrappable::reportMemoryUsage(memoryObjectInfo);
+    ActiveDOMObject::reportMemoryUsage(memoryObjectInfo);
+    info.addMember(m_upload);
+    info.addMember(m_url);
+    info.addMember(m_method);
+    info.addMember(m_requestHeaders);
+    info.addMember(m_requestEntityBody);
+    info.addMember(m_mimeTypeOverride);
+    info.addMember(m_responseBlob);
+    info.addMember(m_loader);
+    info.addMember(m_response);
+    info.addMember(m_responseEncoding);
+    info.addMember(m_decoder);
+    info.addMember(m_responseBuilder);
+    info.addMember(m_responseDocument);
+    info.addMember(m_binaryResponseBuilder);
+    info.addMember(m_responseArrayBuffer);
+    info.addMember(m_lastSendURL);
+    info.addMember(m_eventTargetData);
+    info.addMember(m_progressEventThrottle);
+    info.addMember(m_securityOrigin);
+}
+
 } // namespace WebCore
index de02899..f701f3a 100644 (file)
@@ -135,6 +135,8 @@ public:
     XMLHttpRequestUpload* upload();
     XMLHttpRequestUpload* optionalUpload() const { return m_upload.get(); }
 
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const;
+
     DEFINE_ATTRIBUTE_EVENT_LISTENER(readystatechange);
     DEFINE_ATTRIBUTE_EVENT_LISTENER(abort);
     DEFINE_ATTRIBUTE_EVENT_LISTENER(error);