Web Inspector: NMI add instrumentation for WebAudo related stuff.
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Nov 2012 12:13:06 +0000 (12:13 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Nov 2012 12:13:06 +0000 (12:13 +0000)
They use about 16Mb for shared data on pages with webaudio.
As example Angry Birds app.
https://bugs.webkit.org/show_bug.cgi?id=101729

Reviewed by Yury Semikhatsky.

Plain vanilla instrumentation for audio and webaudio classes.
AudioContext is a kind of ActiveDOMObject. I found that these objects
are accessible through ScriptExecutuionContext and ScriptExecutionContext
is an ancestor of Document. Document class was instrumented earler.
I instrumented ActiveDOMObject, ScriptExecutionContext and other ancestors
and now AudioContext and other ActiveDOMObjects are reacheable from Document.

Source/WebCore:

Test: inspector-protocol/nmi-webaudio.html

* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::reportMemoryUsage):
(WebCore):
* Modules/webaudio/AudioContext.h:
(AudioContext):
* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::reportMemoryUsage):
(WebCore):
* Modules/webaudio/AudioNode.h:
(AudioNode):
* dom/ActiveDOMObject.cpp:
(WebCore::ActiveDOMObject::reportMemoryUsage):
(WebCore):
* dom/ActiveDOMObject.h:
(ActiveDOMObject):
* dom/Document.cpp:
(WebCore::Document::reportMemoryUsage):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::reportMemoryUsage):
(WebCore):
* dom/ScriptExecutionContext.h:
(ScriptExecutionContext):
* dom/SecurityContext.cpp:
(WebCore::SecurityContext::reportMemoryUsage):
(WebCore):
* dom/SecurityContext.h:
(SecurityContext):
* dom/WebCoreMemoryInstrumentation.cpp:
(WebCore):
* dom/WebCoreMemoryInstrumentation.h:
(WebCoreMemoryTypes):
* platform/audio/AudioArray.h:
(AudioArray):
(WebCore::AudioArray::reportMemoryUsage):
* platform/audio/FFTFrame.cpp:
(WebCore::FFTFrame::reportMemoryUsage):
(WebCore):
* platform/audio/FFTFrame.h:
(FFTFrame):
* platform/audio/HRTFDatabase.cpp:
(WebCore::HRTFDatabase::reportMemoryUsage):
(WebCore):
* platform/audio/HRTFDatabase.h:
(HRTFDatabase):
* platform/audio/HRTFDatabaseLoader.cpp:
(WebCore::HRTFDatabaseLoader::reportMemoryUsage):
(WebCore):
* platform/audio/HRTFDatabaseLoader.h:
(HRTFDatabaseLoader):
* platform/audio/HRTFElevation.cpp:
(WebCore::HRTFElevation::reportMemoryUsage):
(WebCore):
* platform/audio/HRTFElevation.h:
(HRTFElevation):
* platform/audio/HRTFKernel.cpp:
(WebCore::HRTFKernel::reportMemoryUsage):
(WebCore):
* platform/audio/HRTFKernel.h:
(HRTFKernel):

LayoutTests:

* inspector-protocol/nmi-webaudio-expected.txt: Added.
* inspector-protocol/nmi-webaudio.html: Added.

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

30 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector-protocol/nmi-webaudio-expected.txt [new file with mode: 0644]
LayoutTests/inspector-protocol/nmi-webaudio.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/webaudio/AudioContext.cpp
Source/WebCore/Modules/webaudio/AudioContext.h
Source/WebCore/Modules/webaudio/AudioNode.cpp
Source/WebCore/Modules/webaudio/AudioNode.h
Source/WebCore/dom/ActiveDOMObject.cpp
Source/WebCore/dom/ActiveDOMObject.h
Source/WebCore/dom/ContextDestructionObserver.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/dom/ScriptExecutionContext.h
Source/WebCore/dom/SecurityContext.cpp
Source/WebCore/dom/SecurityContext.h
Source/WebCore/platform/PlatformMemoryInstrumentation.cpp
Source/WebCore/platform/PlatformMemoryInstrumentation.h
Source/WebCore/platform/audio/AudioArray.h
Source/WebCore/platform/audio/FFTFrame.cpp
Source/WebCore/platform/audio/FFTFrame.h
Source/WebCore/platform/audio/HRTFDatabase.cpp
Source/WebCore/platform/audio/HRTFDatabase.h
Source/WebCore/platform/audio/HRTFDatabaseLoader.cpp
Source/WebCore/platform/audio/HRTFDatabaseLoader.h
Source/WebCore/platform/audio/HRTFElevation.cpp
Source/WebCore/platform/audio/HRTFElevation.h
Source/WebCore/platform/audio/HRTFKernel.cpp
Source/WebCore/platform/audio/HRTFKernel.h
Source/WebCore/platform/audio/ffmpeg/FFTFrameFFMPEG.cpp

index 5dd663d..c6d4830 100644 (file)
@@ -1,3 +1,22 @@
+2012-11-09  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: NMI add instrumentation for WebAudo related stuff.
+        They use about 16Mb for shared data on pages with webaudio.
+        As example Angry Birds app.
+        https://bugs.webkit.org/show_bug.cgi?id=101729
+
+        Reviewed by Yury Semikhatsky.
+
+        Plain vanilla instrumentation for audio and webaudio classes.
+        AudioContext is a kind of ActiveDOMObject. I found that these objects
+        are accessible through ScriptExecutuionContext and ScriptExecutionContext
+        is an ancestor of Document. Document class was instrumented earler.
+        I instrumented ActiveDOMObject, ScriptExecutionContext and other ancestors
+        and now AudioContext and other ActiveDOMObjects are reacheable from Document.
+
+        * inspector-protocol/nmi-webaudio-expected.txt: Added.
+        * inspector-protocol/nmi-webaudio.html: Added.
+
 2012-11-14  Pavel Feldman  <pfeldman@chromium.org>
 
         Not reviewed: proper baselines for inspector's timeline-timer-fired-from-eval-call-site.
diff --git a/LayoutTests/inspector-protocol/nmi-webaudio-expected.txt b/LayoutTests/inspector-protocol/nmi-webaudio-expected.txt
new file mode 100644 (file)
index 0000000..5ddf2af
--- /dev/null
@@ -0,0 +1,3 @@
+PASS: received size for type Page.Audio is more than 15000000
+PASS: received size for type Page.Audio.SharedData is more than 15000000
+
diff --git a/LayoutTests/inspector-protocol/nmi-webaudio.html b/LayoutTests/inspector-protocol/nmi-webaudio.html
new file mode 100644 (file)
index 0000000..d323139
--- /dev/null
@@ -0,0 +1,79 @@
+<html>
+<head>
+<script type="text/javascript" src="../http/tests/inspector-protocol/resources/protocol-test.js"></script>
+<script>
+
+var sampleRate = 44100.0;
+var renderLengthSeconds = 0.125;
+
+function createSinWaveBuffer(context, lengthInSeconds, frequency)
+{
+    var audioBuffer = context.createBuffer(1, lengthInSeconds * sampleRate, sampleRate);
+    var data = audioBuffer.getChannelData(0);
+    for (var i = 0; i < audioBuffer.length; ++i)
+        data[i] = Math.sin(frequency * 2 * Math.PI * i / sampleRate);
+    return audioBuffer;
+}
+
+function runPageTest()
+{
+    testRunner.waitUntilDone();
+
+    // Create offline audio context.
+    var context = new webkitAudioContext(1, sampleRate * renderLengthSeconds, sampleRate);
+
+    var bufferSource = context.createBufferSource();
+    bufferSource.buffer = createSinWaveBuffer(context, renderLengthSeconds, 880);
+    bufferSource.connect(context.destination);
+    context.oncomplete = runTest;
+    context.startRendering();
+}
+
+function test()
+{
+    function sizeForType(entry, typeName)
+    {
+        if (entry.name === typeName)
+            return entry.size;
+
+        if (!entry.children)
+            return -1;
+
+        for (var i = 0; i < entry.children.length; ++i) {
+            var size = sizeForType(entry.children[i], typeName);
+            if (size > -1)
+                return size;
+        }
+
+        return -1;
+    }
+
+    function receivedSizeMoreThan(messageObject, typeName, expectedSize)
+    {
+        var entry = messageObject["result"]["distribution"];
+        var size = sizeForType(entry, typeName);
+        if (size > expectedSize)
+            InspectorTest.log("PASS: received size for type " + typeName + " is more than " + expectedSize);
+        else
+            InspectorTest.log("FAIL: received size " + size + " for type " + typeName + " is less than " + expectedSize);
+    }
+
+    function handleMemorySnapshot(messageObject)
+    {
+        if ("error" in messageObject)
+            InspectorTest.log(messageObject.error.message);
+        else {
+            receivedSizeMoreThan(messageObject, "Page.Audio", 15000000);
+            receivedSizeMoreThan(messageObject, "Page.Audio.SharedData", 15000000);
+        }
+
+        InspectorTest.completeTest();
+    }
+
+    InspectorTest.sendCommand("Memory.getProcessMemoryDistribution", {}, handleMemorySnapshot);
+}
+</script>
+</head>
+<body onLoad="runPageTest();">
+</body>
+</html>
index b0ca444..cfcd810 100644 (file)
@@ -1,3 +1,81 @@
+2012-11-09  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: NMI add instrumentation for WebAudo related stuff.
+        They use about 16Mb for shared data on pages with webaudio.
+        As example Angry Birds app.
+        https://bugs.webkit.org/show_bug.cgi?id=101729
+
+        Reviewed by Yury Semikhatsky.
+
+        Plain vanilla instrumentation for audio and webaudio classes.
+        AudioContext is a kind of ActiveDOMObject. I found that these objects
+        are accessible through ScriptExecutuionContext and ScriptExecutionContext
+        is an ancestor of Document. Document class was instrumented earler.
+        I instrumented ActiveDOMObject, ScriptExecutionContext and other ancestors
+        and now AudioContext and other ActiveDOMObjects are reacheable from Document.
+
+        Test: inspector-protocol/nmi-webaudio.html
+
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::reportMemoryUsage):
+        (WebCore):
+        * Modules/webaudio/AudioContext.h:
+        (AudioContext):
+        * Modules/webaudio/AudioNode.cpp:
+        (WebCore::AudioNode::reportMemoryUsage):
+        (WebCore):
+        * Modules/webaudio/AudioNode.h:
+        (AudioNode):
+        * dom/ActiveDOMObject.cpp:
+        (WebCore::ActiveDOMObject::reportMemoryUsage):
+        (WebCore):
+        * dom/ActiveDOMObject.h:
+        (ActiveDOMObject):
+        * dom/Document.cpp:
+        (WebCore::Document::reportMemoryUsage):
+        * dom/ScriptExecutionContext.cpp:
+        (WebCore::ScriptExecutionContext::reportMemoryUsage):
+        (WebCore):
+        * dom/ScriptExecutionContext.h:
+        (ScriptExecutionContext):
+        * dom/SecurityContext.cpp:
+        (WebCore::SecurityContext::reportMemoryUsage):
+        (WebCore):
+        * dom/SecurityContext.h:
+        (SecurityContext):
+        * dom/WebCoreMemoryInstrumentation.cpp:
+        (WebCore):
+        * dom/WebCoreMemoryInstrumentation.h:
+        (WebCoreMemoryTypes):
+        * platform/audio/AudioArray.h:
+        (AudioArray):
+        (WebCore::AudioArray::reportMemoryUsage):
+        * platform/audio/FFTFrame.cpp:
+        (WebCore::FFTFrame::reportMemoryUsage):
+        (WebCore):
+        * platform/audio/FFTFrame.h:
+        (FFTFrame):
+        * platform/audio/HRTFDatabase.cpp:
+        (WebCore::HRTFDatabase::reportMemoryUsage):
+        (WebCore):
+        * platform/audio/HRTFDatabase.h:
+        (HRTFDatabase):
+        * platform/audio/HRTFDatabaseLoader.cpp:
+        (WebCore::HRTFDatabaseLoader::reportMemoryUsage):
+        (WebCore):
+        * platform/audio/HRTFDatabaseLoader.h:
+        (HRTFDatabaseLoader):
+        * platform/audio/HRTFElevation.cpp:
+        (WebCore::HRTFElevation::reportMemoryUsage):
+        (WebCore):
+        * platform/audio/HRTFElevation.h:
+        (HRTFElevation):
+        * platform/audio/HRTFKernel.cpp:
+        (WebCore::HRTFKernel::reportMemoryUsage):
+        (WebCore):
+        * platform/audio/HRTFKernel.h:
+        (HRTFKernel):
+
 2012-11-14  Eugene Klyuchnikov  <eustas.bug@gmail.com>
 
         Web Inspector: Settings screen: close button overlays view title on mac.
index 9f65880..94bfbb4 100644 (file)
@@ -57,6 +57,9 @@
 #include "ScriptProcessorNode.h"
 #include "WaveShaperNode.h"
 #include "WaveTable.h"
+#include "WebCoreMemoryInstrumentation.h"
+#include <wtf/MemoryInstrumentationHashSet.h>
+#include <wtf/MemoryInstrumentationVector.h>
 
 #if ENABLE(MEDIA_STREAM)
 #include "MediaStream.h"
@@ -962,6 +965,31 @@ void AudioContext::decrementActiveSourceCount()
     atomicDecrement(&m_activeSourceCount);
 }
 
+void AudioContext::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    AutoLocker locker(const_cast<AudioContext*>(this));
+
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Audio);
+    ActiveDOMObject::reportMemoryUsage(memoryObjectInfo);
+    info.addMember(m_document);
+    info.addMember(m_destinationNode);
+    info.addMember(m_listener);
+    info.addMember(m_finishedNodes);
+    info.addMember(m_referencedNodes);
+    info.addMember(m_nodesMarkedForDeletion);
+    info.addMember(m_nodesToDelete);
+    info.addMember(m_dirtySummingJunctions);
+    info.addMember(m_dirtyAudioNodeOutputs);
+    info.addMember(m_automaticPullNodes);
+    info.addMember(m_renderingAutomaticPullNodes);
+    info.addMember(m_contextGraphMutex);
+    info.addMember(m_deferredFinishDerefList);
+    info.addMember(m_hrtfDatabaseLoader);
+    info.addMember(m_eventTargetData);
+    info.addMember(m_renderTarget);
+    info.addMember(m_audioDecoder);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEB_AUDIO)
index 3098d8e..ae70328 100644 (file)
@@ -245,7 +245,9 @@ public:
     void fireCompletionEvent();
     
     static unsigned s_hardwareContextCount;
-    
+
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
+
 private:
     explicit AudioContext(Document*);
     AudioContext(Document*, unsigned numberOfChannels, size_t numberOfFrames, float sampleRate);
index 69fd90b..d14eb3d 100644 (file)
 #include "AudioNodeOutput.h"
 #include "AudioParam.h"
 #include "ExceptionCode.h"
+#include "WebCoreMemoryInstrumentation.h"
 #include <wtf/Atomics.h>
 #include <wtf/MainThread.h>
+#include <wtf/MemoryInstrumentationVector.h>
 
 #if DEBUG_AUDIONODE_REFERENCES
 #include <stdio.h>
@@ -402,6 +404,14 @@ void AudioNode::finishDeref(RefType refType)
     }
 }
 
+void AudioNode::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Audio);
+    info.addMember(m_context);
+    info.addMember(m_inputs);
+    info.addMember(m_outputs);
+}
+
 #if DEBUG_AUDIONODE_REFERENCES
 
 bool AudioNode::s_isNodeCountInitialized = false;
index 4ef3e65..61b5a20 100644 (file)
@@ -25,6 +25,7 @@
 #ifndef AudioNode_h
 #define AudioNode_h
 
+#include <wtf/Forward.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/RefPtr.h>
@@ -156,6 +157,9 @@ public:
 
     void enableOutputsIfNecessary();
     void disableOutputsIfNecessary();
+
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 protected:
     // Inputs and outputs must be created before the AudioNode is initialized.
     void addInput(PassOwnPtr<AudioNodeInput>);
index 1fe832a..b44f07d 100644 (file)
@@ -28,6 +28,7 @@
 #include "ActiveDOMObject.h"
 
 #include "ScriptExecutionContext.h"
+#include "WebCoreMemoryInstrumentation.h"
 #include "WorkerContext.h"
 #include "WorkerThread.h"
 
@@ -91,4 +92,10 @@ void ActiveDOMObject::stop()
 {
 }
 
+void ActiveDOMObject::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
+}
+
+
 } // namespace WebCore
index b4abda0..8c56bf9 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "ContextDestructionObserver.h"
 #include <wtf/Assertions.h>
+#include <wtf/Forward.h>
 
 namespace WebCore {
 
@@ -76,6 +77,8 @@ public:
         thisObject->deref();
     }
 
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const;
+
 protected:
     virtual ~ActiveDOMObject();
 
index a557dc7..8450aa4 100644 (file)
@@ -28,6 +28,7 @@
 #include "ContextDestructionObserver.h"
 
 #include "ScriptExecutionContext.h"
+#include "WebCoreMemoryInstrumentation.h"
 
 namespace WebCore {
 
index 8cf4cd3..c44a212 100644 (file)
@@ -5880,6 +5880,8 @@ void Document::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
     ContainerNode::reportMemoryUsage(memoryObjectInfo);
+    TreeScope::reportMemoryUsage(memoryObjectInfo);
+    ScriptExecutionContext::reportMemoryUsage(memoryObjectInfo);
     info.addMember(m_styleResolver);
     info.addMember(m_url);
     info.addMember(m_baseURL);
index 39a3dcd..d29b87e 100644 (file)
@@ -28,7 +28,6 @@
 #include "config.h"
 #include "ScriptExecutionContext.h"
 
-#include "ActiveDOMObject.h"
 #include "ContentSecurityPolicy.h"
 #include "DOMTimer.h"
 #include "ErrorEvent.h"
 #include "FileThread.h"
 #include "MessagePort.h"
 #include "PublicURLManager.h"
-#include "ScriptCallStack.h"
-#include "SecurityOrigin.h"
 #include "Settings.h"
+#include "WebCoreMemoryInstrumentation.h"
 #include "WorkerContext.h"
 #include "WorkerThread.h"
 #include <wtf/MainThread.h>
+#include <wtf/MemoryInstrumentationHashMap.h>
+#include <wtf/MemoryInstrumentationHashSet.h>
+#include <wtf/MemoryInstrumentationVector.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/Vector.h>
 
 #include "JSDOMWindow.h"
 #endif
 
+namespace WTF {
+
+template<> struct SequenceMemoryInstrumentationTraits<WebCore::ContextDestructionObserver*> {
+    template <typename I> static void reportMemoryUsage(I, I, MemoryClassInfo&) { }
+};
+
+}
 namespace WebCore {
 
 class ProcessMessagesSoonTask : public ScriptExecutionContext::Task {
@@ -409,6 +417,21 @@ double ScriptExecutionContext::timerAlignmentInterval() const
     return Settings::defaultDOMTimerAlignmentInterval();
 }
 
+void ScriptExecutionContext::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
+    SecurityContext::reportMemoryUsage(memoryObjectInfo);
+    info.addMember(m_messagePorts);
+    info.addMember(m_destructionObservers);
+    info.addMember(m_activeDOMObjects);
+    info.addMember(m_timeouts);
+    info.addMember(m_pendingExceptions);
+#if ENABLE(BLOB)
+    info.addMember(m_publicURLManager);
+    info.addMember(m_fileThread);
+#endif
+}
+
 ScriptExecutionContext::Task::~Task()
 {
 }
index b8dca29..c89d09a 100644 (file)
@@ -161,6 +161,8 @@ public:
 
     virtual EventQueue* eventQueue() const = 0;
 
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const OVERRIDE;
+
 protected:
     class AddConsoleMessageTask : public Task {
     public:
index 7e9f839..99252f6 100644 (file)
@@ -30,6 +30,7 @@
 #include "ContentSecurityPolicy.h"
 #include "HTMLParserIdioms.h"
 #include "SecurityOrigin.h"
+#include "WebCoreMemoryInstrumentation.h"
 
 namespace WebCore {
 
@@ -122,4 +123,11 @@ SandboxFlags SecurityContext::parseSandboxPolicy(const String& policy)
     return flags;
 }
 
+void SecurityContext::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
+    info.addMember(m_securityOrigin);
+    info.addMember(m_contentSecurityPolicy);
+}
+
 }
index 9cf49d3..7c097e7 100644 (file)
@@ -73,6 +73,8 @@ public:
 
     static SandboxFlags parseSandboxPolicy(const String& policy);
 
+    virtual void reportMemoryUsage(MemoryObjectInfo*) const;
+
 protected:
     SecurityContext();
     virtual ~SecurityContext();
index d872ff0..a43d3a9 100644 (file)
@@ -36,4 +36,7 @@ namespace WebCore {
 MemoryObjectType PlatformMemoryTypes::Image = "Page.Image";
 MemoryObjectType PlatformMemoryTypes::Loader = "Page.Loader";
 
+MemoryObjectType PlatformMemoryTypes::Audio = "Page.Audio";
+MemoryObjectType PlatformMemoryTypes::AudioSharedData = "Page.Audio.SharedData";
+
 } // namespace WebCore
index 46a84bb..898b96d 100644 (file)
@@ -43,6 +43,9 @@ class PlatformMemoryTypes {
 public:
     static MemoryObjectType Image;
     static MemoryObjectType Loader;
+
+    static MemoryObjectType Audio;
+    static MemoryObjectType AudioSharedData;
 };
 
 } // namespace WebCore
index d2d99e1..2a51b01 100644 (file)
@@ -142,6 +142,13 @@ public:
         memcpy(this->data() + start, sourceData, sizeof(T) * (end - start));
     }
 
+    template<typename MemoryObjectInfo>
+    void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+    {
+        typename MemoryObjectInfo::ClassInfo info(memoryObjectInfo, this);
+        info.addRawBuffer(m_allocation, m_size * sizeof(T));
+    }
+
 private:
     static T* alignedAddress(T* address, intptr_t alignment)
     {
index a1a0a50..63c87dd 100644 (file)
 #endif
 
 #include "Logging.h"
+#include "PlatformMemoryInstrumentation.h"
 #include <wtf/Complex.h>
 #include <wtf/MathExtras.h>
 #include <wtf/OwnPtr.h>
 
+#if !USE_ACCELERATE_FFT && USE(WEBAUDIO_FFMPEG)
+void reportMemoryUsage(const RDFTContext* const&, WTF::MemoryObjectInfo*);
+#endif // USE(WEBAUDIO_FFMPEG)
+
 namespace WebCore {
 
 void FFTFrame::doPaddedFFT(const float* data, size_t dataSize)
@@ -248,6 +253,49 @@ void FFTFrame::addConstantGroupDelay(double sampleFrameDelay)
     }
 }
 
+void FFTFrame::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::AudioSharedData);
+#if USE_ACCELERATE_FFT
+    info.addMember(m_frame);
+    info.addMember(m_realData);
+    info.addMember(m_imagData);
+#else // !USE_ACCELERATE_FFT
+
+#if USE(WEBAUDIO_MKL)
+    info.addMember(m_handle);
+    info.addMember(m_complexData);
+    info.addMember(m_realData);
+    info.addMember(m_imagData);
+#endif // USE(WEBAUDIO_MKL)
+
+#if USE(WEBAUDIO_FFMPEG)
+    info.addMember(m_forwardContext);
+    info.addMember(m_inverseContext);
+    info.addMember(m_complexData);
+    info.addMember(m_realData);
+    info.addMember(m_imagData);
+#endif // USE(WEBAUDIO_FFMPEG)
+
+#if USE(WEBAUDIO_GSTREAMER)
+    info.addMember(m_fft);
+    info.addMember(m_inverseFft);
+    info.addMember(m_complexData);
+    info.addMember(m_realData);
+    info.addMember(m_imagData);
+#endif // USE(WEBAUDIO_GSTREAMER)
+
+#if USE(WEBAUDIO_IPP)
+    info.addMember(m_buffer);
+    info.addMember(m_DFTSpec);
+    info.addMember(m_complexData);
+    info.addMember(m_realData);
+    info.addMember(m_imagData);
+#endif // USE(WEBAUDIO_IPP)
+
+#endif // !USE_ACCELERATE_FFT
+}
+
 #ifndef NDEBUG
 void FFTFrame::print()
 {
index 3fb3a78..6c15349 100644 (file)
@@ -64,6 +64,7 @@ struct RDFTContext;
 #include <ipps.h>
 #endif // USE(WEBAUDIO_IPP)
 
+#include <wtf/Forward.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/Platform.h>
 #include <wtf/Threading.h>
@@ -106,6 +107,8 @@ public:
     unsigned fftSize() const { return m_FFTSize; }
     unsigned log2FFTSize() const { return m_log2FFTSize; }
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     unsigned m_FFTSize;
     unsigned m_log2FFTSize;
index 8558698..e9f2c73 100644 (file)
@@ -33,6 +33,8 @@
 #include "HRTFDatabase.h"
 
 #include "HRTFElevation.h"
+#include "PlatformMemoryInstrumentation.h"
+#include <wtf/MemoryInstrumentationVector.h>
 
 using namespace std;
 
@@ -119,6 +121,12 @@ unsigned HRTFDatabase::indexFromElevationAngle(double elevationAngle)
     return elevationIndex;
 }
 
+void HRTFDatabase::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::AudioSharedData);
+    info.addMember(m_elevations);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEB_AUDIO)
index 8a96a04..88f328a 100644 (file)
 #define HRTFDatabase_h
 
 #include "HRTFElevation.h"
-#include <wtf/HashMap.h>
+#include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/Vector.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -62,6 +59,8 @@ public:
     // Number of elevations loaded from resource.
     static const unsigned NumberOfRawElevations;
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     explicit HRTFDatabase(float sampleRate);
 
index 8f96c96..cb1b739 100644 (file)
@@ -33,6 +33,7 @@
 #include "HRTFDatabaseLoader.h"
 
 #include "HRTFDatabase.h"
+#include "PlatformMemoryInstrumentation.h"
 #include <wtf/MainThread.h>
 
 namespace WebCore {
@@ -131,6 +132,12 @@ HRTFDatabase* HRTFDatabaseLoader::defaultHRTFDatabase()
     return s_loader->database();
 }
 
+void HRTFDatabaseLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::AudioSharedData);
+    info.addMember(m_hrtfDatabase);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEB_AUDIO)
index e67707e..c16fb9f 100644 (file)
@@ -70,6 +70,8 @@ public:
     // is still alive.  Otherwise this will return 0.
     static HRTFDatabase* defaultHRTFDatabase();
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     // Both constructor and destructor must be called from the main thread.
     explicit HRTFDatabaseLoader(float sampleRate);
index cfe13ed..7eed894 100644 (file)
 #include "Biquad.h"
 #include "FFTFrame.h"
 #include "HRTFPanner.h"
+#include "PlatformMemoryInstrumentation.h"
 #include <algorithm>
 #include <math.h>
+#include <wtf/MemoryInstrumentationVector.h>
 #include <wtf/OwnPtr.h>
 
 using namespace std;
@@ -337,6 +339,13 @@ void HRTFElevation::getKernelsFromAzimuth(double azimuthBlend, unsigned azimuthI
     frameDelayR = (1.0 - azimuthBlend) * frameDelayR + azimuthBlend * frameDelay2R;
 }
 
+void HRTFElevation::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::AudioSharedData);
+    info.addMember(m_kernelListL);
+    info.addMember(m_kernelListR);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEB_AUDIO)
index 446e66d..daee4aa 100644 (file)
@@ -91,6 +91,9 @@ public:
     // Returns true on success.
     static bool calculateSymmetricKernelsForAzimuthElevation(int azimuth, int elevation, float sampleRate, const String& subjectName,
                                                              RefPtr<HRTFKernel>& kernelL, RefPtr<HRTFKernel>& kernelR);
+
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     HRTFElevation(PassOwnPtr<HRTFKernelList> kernelListL, PassOwnPtr<HRTFKernelList> kernelListR, int elevation, float sampleRate)
         : m_kernelListL(kernelListL)
index 391f904..337f50d 100644 (file)
@@ -36,6 +36,7 @@
 #include "Biquad.h"
 #include "FFTFrame.h"
 #include "FloatConversion.h"
+#include "PlatformMemoryInstrumentation.h"
 #include <wtf/MathExtras.h>
 
 using namespace std;
@@ -141,6 +142,12 @@ PassRefPtr<HRTFKernel> HRTFKernel::createInterpolatedKernel(HRTFKernel* kernel1,
     return HRTFKernel::create(interpolatedFrame.release(), frameDelay, sampleRate1);
 }
 
+void HRTFKernel::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::AudioSharedData);
+    info.addMember(m_fftFrame);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEB_AUDIO)
index 3a8dbfd..ed18c28 100644 (file)
@@ -75,6 +75,8 @@ public:
     // Converts back into impulse-response form.
     PassOwnPtr<AudioChannel> createImpulseResponse();
 
+    void reportMemoryUsage(MemoryObjectInfo*) const;
+
 private:
     // Note: this is destructive on the passed in AudioChannel.
     HRTFKernel(AudioChannel*, size_t fftSize, float sampleRate, bool bassBoost);
index d4624a7..ac25c22 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "FFTFrame.h"
 
+#include "PlatformMemoryInstrumentation.h"
 #include "VectorMath.h"
 
 extern "C" {
@@ -42,6 +43,56 @@ extern "C" {
 
 #include <wtf/MathExtras.h>
 
+namespace {
+
+struct FFTComplexProxy {
+    int16_t re;
+    int16_t im;
+};
+
+struct FFTContextProxy {
+    int nbits;
+    int inverse;
+    uint16_t* revtab;
+    FFTComplexProxy* tmpBuf;
+    int mdctSize;
+    int mdctBits;
+    void* tcos;
+    void* tsin;
+    void (*fftPermute)();
+    void (*fftCalc)();
+    void (*imdctCalc)();
+    void (*imdctHalf)();
+    void (*mdctCalc)();
+    void (*mdctCalcw)();
+    int fftPermutation;
+    int mdctPermutation;
+};
+
+struct RDFTContextProxy {
+    int nbits;
+    int inverse;
+    int signConvention;
+    const void* tcos;
+    const void* tsin;
+    FFTContextProxy fft;
+    void (*rdft_calc)();
+};
+
+}
+
+void reportMemoryUsage(const struct RDFTContext* const& object, WTF::MemoryObjectInfo* memoryObjectInfo)
+{
+    const RDFTContextProxy* proxyObject = reinterpret_cast<const RDFTContextProxy*>(object);
+
+    WTF::MemoryClassInfo info(memoryObjectInfo, proxyObject, 0, sizeof(RDFTContextProxy));
+
+    // The size of buffers is counted the same way as it is counted in ff_rdft_init && ff_fft_init.
+    size_t count = 1 << (proxyObject->nbits - 1);
+    info.addRawBuffer(proxyObject->fft.revtab, count * sizeof(uint16_t));
+    info.addRawBuffer(proxyObject->fft.tmpBuf, count * sizeof(FFTComplex));
+}
+
 namespace WebCore {
 
 const int kMaxFFTPow2Size = 24;