Diff
Modified: trunk/Source/WebCore/ChangeLog (122919 => 122920)
--- trunk/Source/WebCore/ChangeLog 2012-07-18 04:42:55 UTC (rev 122919)
+++ trunk/Source/WebCore/ChangeLog 2012-07-18 05:58:49 UTC (rev 122920)
@@ -1,3 +1,58 @@
+2012-07-17 Ilya Tikhonovsky <[email protected]>
+
+ Web Inspector: show loaders memory consumption on the memory chart.
+ https://bugs.webkit.org/show_bug.cgi?id=90686
+
+ Reviewed by Pavel Feldman.
+
+ Size of FrameLoader, DocumentLoader, ResourceLoader and their resources should be shown on the memory pie chart.
+
+ It is covered by existing WebInspector performance tests infrastructure.
+
+ * WebCore.exp.in:
+ * dom/MemoryInstrumentation.h:
+ (MemoryInstrumentation):
+ (WebCore::MemoryInstrumentation::addRawBuffer):
+ (WebCore::MemoryInstrumentation::addInstrumentedMemberImpl):
+ (WebCore):
+ (WebCore::MemoryClassInfo::addInstrumentedHashSet):
+ (WebCore::MemoryClassInfo::addRawBuffer):
+ (WebCore::MemoryInstrumentation::addInstrumentedHashSet):
+ (WebCore::MemoryInstrumentation::addVector):
+ * inspector/InspectorMemoryAgent.cpp:
+ (WebCore):
+ (WebCore::domTreeInfo):
+ * loader/DocumentLoader.cpp:
+ (WebCore::DocumentLoader::reportMemoryUsage):
+ (WebCore):
+ * loader/DocumentLoader.h:
+ (WebCore):
+ (DocumentLoader):
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::reportMemoryUsage):
+ (WebCore):
+ * loader/FrameLoader.h:
+ (WebCore):
+ (FrameLoader):
+ * loader/ResourceLoader.cpp:
+ (WebCore::ResourceLoader::reportMemoryUsage):
+ (WebCore):
+ * loader/ResourceLoader.h:
+ (WebCore):
+ (ResourceLoader):
+ * page/Frame.cpp:
+ (WebCore::Frame::reportMemoryUsage):
+ (WebCore):
+ * page/Frame.h:
+ (WebCore):
+ (Frame):
+ * platform/SharedBuffer.cpp:
+ (WebCore::SharedBuffer::reportMemoryUsage):
+ (WebCore):
+ * platform/SharedBuffer.h:
+ (WebCore):
+ (SharedBuffer):
+
2012-07-17 Kent Tamura <[email protected]>
Fix an assertion failure in CalendarPickerElement::hostInput().
Modified: trunk/Source/WebCore/WebCore.exp.in (122919 => 122920)
--- trunk/Source/WebCore/WebCore.exp.in 2012-07-18 04:42:55 UTC (rev 122919)
+++ trunk/Source/WebCore/WebCore.exp.in 2012-07-18 05:58:49 UTC (rev 122920)
@@ -250,6 +250,7 @@
__ZN7WebCore14DocumentLoaderC1ERKNS_15ResourceRequestERKNS_14SubstituteDataE
__ZN7WebCore14DocumentLoaderC2ERKNS_15ResourceRequestERKNS_14SubstituteDataE
__ZN7WebCore14DocumentLoaderD2Ev
+__ZNK7WebCore14DocumentLoader17reportMemoryUsageEPNS_16MemoryObjectInfoE
__ZN7WebCore14DocumentWriter11setEncodingERKN3WTF6StringEb
__ZN7WebCore14FileIconLoader14notifyFinishedEN3WTF10PassRefPtrINS_4IconEEE
__ZN7WebCore14FrameSelection10setFocusedEb
Modified: trunk/Source/WebCore/dom/MemoryInstrumentation.h (122919 => 122920)
--- trunk/Source/WebCore/dom/MemoryInstrumentation.h 2012-07-18 04:42:55 UTC (rev 122919)
+++ trunk/Source/WebCore/dom/MemoryInstrumentation.h 2012-07-18 05:58:49 UTC (rev 122920)
@@ -30,6 +30,7 @@
#ifndef MemoryInstrumentation_h
#define MemoryInstrumentation_h
+#include <stdio.h>
#include <wtf/Assertions.h>
#include <wtf/Forward.h>
@@ -50,6 +51,7 @@
DOM,
CSS,
Binding,
+ Loader,
LastTypeEntry
};
@@ -65,8 +67,15 @@
template <typename HashMapType> void addHashMap(const HashMapType&, ObjectType, bool contentOnly = false);
template <typename HashSetType> void addHashSet(const HashSetType&, ObjectType, bool contentOnly = false);
+ template <typename HashSetType> void addInstrumentedHashSet(const HashSetType&, ObjectType, bool contentOnly = false);
template <typename ListHashSetType> void addListHashSet(const ListHashSetType&, ObjectType, bool contentOnly = false);
template <typename VectorType> void addVector(const VectorType&, ObjectType, bool contentOnly = false);
+ void addRawBuffer(const void* const& buffer, ObjectType objectType, size_t size)
+ {
+ if (!buffer || visited(buffer))
+ return;
+ countObjectSize(objectType, size);
+ }
protected:
enum OwningType {
@@ -86,8 +95,9 @@
static void addMember(MemoryInstrumentation* instrumentation, const T* const& t, MemoryInstrumentation::ObjectType objectType) { instrumentation->addMemberImpl(t, objectType, byPointer); }
};
- template <typename T>
- void addInstrumentedMemberImpl(const T* const& object, OwningType owningType);
+ template <typename T> void addInstrumentedMemberImpl(const T* const&, OwningType);
+ template <typename T> void addInstrumentedMemberImpl(const OwnPtr<T>* const& object, MemoryInstrumentation::OwningType owningType) { addInstrumentedMemberImpl(object->get(), owningType); }
+ template <typename T> void addInstrumentedMemberImpl(const RefPtr<T>* const& object, MemoryInstrumentation::OwningType owningType) { addInstrumentedMemberImpl(object->get(), owningType); }
template <typename T>
void addMemberImpl(const T* const& object, ObjectType objectType, OwningType owningType)
@@ -164,6 +174,7 @@
template <> void MemoryInstrumentation::addMemberImpl<AtomicString>(const AtomicString* const&, MemoryInstrumentation::ObjectType, MemoryInstrumentation::OwningType);
template <> void MemoryInstrumentation::addMemberImpl<String>(const String* const&, MemoryInstrumentation::ObjectType, MemoryInstrumentation::OwningType);
+
template <typename T>
void MemoryInstrumentation::addInstrumentedMemberImpl(const T* const& object, MemoryInstrumentation::OwningType owningType)
{
@@ -176,6 +187,7 @@
deferInstrumentedPointer(adoptPtr(new InstrumentedPointer<T>(object)));
}
+
template <typename T>
class MemoryClassInfo {
public:
@@ -194,8 +206,10 @@
template <typename HashMapType> void addHashMap(const HashMapType& map) { m_memoryInstrumentation->addHashMap(map, m_objectType, true); }
template <typename HashSetType> void addHashSet(const HashSetType& set) { m_memoryInstrumentation->addHashSet(set, m_objectType, true); }
+ template <typename HashSetType> void addInstrumentedHashSet(const HashSetType& set) { m_memoryInstrumentation->addInstrumentedHashSet(set, m_objectType, true); }
template <typename ListHashSetType> void addListHashSet(const ListHashSetType& set) { m_memoryInstrumentation->addListHashSet(set, m_objectType, true); }
template <typename VectorType> void addVector(const VectorType& vector) { m_memoryInstrumentation->addVector(vector, m_objectType, true); }
+ void addRawBuffer(const void* const& buffer, size_t size) { m_memoryInstrumentation->addRawBuffer(buffer, m_objectType, size); }
void addString(const String& string) { m_memoryInstrumentation->addString(string, m_objectType); }
void addString(const AtomicString& string) { m_memoryInstrumentation->addString((const String&)string, m_objectType); }
@@ -220,6 +234,16 @@
countObjectSize(objectType, calculateContainerSize(hashSet, contentOnly));
}
+template<typename HashSetType>
+void MemoryInstrumentation::addInstrumentedHashSet(const HashSetType& hashSet, ObjectType objectType, bool contentOnly)
+{
+ if (visited(&hashSet))
+ return;
+ countObjectSize(objectType, calculateContainerSize(hashSet, contentOnly));
+ for (typename HashSetType::const_iterator i = hashSet.begin(); i != hashSet.end(); ++i)
+ addInstrumentedMember(*i);
+}
+
template<typename ListHashSetType>
void MemoryInstrumentation::addListHashSet(const ListHashSetType& hashSet, ObjectType objectType, bool contentOnly)
{
@@ -232,7 +256,7 @@
template <typename VectorType>
void MemoryInstrumentation::addVector(const VectorType& vector, ObjectType objectType, bool contentOnly)
{
- if (visited(vector.data()))
+ if (!vector.data() || visited(vector.data()))
return;
countObjectSize(objectType, calculateContainerSize(vector, contentOnly));
}
@@ -245,6 +269,7 @@
memoryInstrumentation->countObjectSize(memoryObjectInfo.objectType(), memoryObjectInfo.objectSize());
}
+
} // namespace WebCore
#endif // !defined(MemoryInstrumentation_h)
Modified: trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp (122919 => 122920)
--- trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp 2012-07-18 04:42:55 UTC (rev 122919)
+++ trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp 2012-07-18 05:58:49 UTC (rev 122920)
@@ -545,6 +545,12 @@
m_domMemoryUsage.processDeferredInstrumentedPointers();
}
+ void visitFrame(Frame* frame)
+ {
+ m_domMemoryUsage.addInstrumentedMember(frame);
+ m_domMemoryUsage.processDeferredInstrumentedPointers();
+ }
+
void visitBindings()
{
ScriptProfiler::collectBindingMemoryInfo(&m_domMemoryUsage);
@@ -570,8 +576,10 @@
// Make sure all documents reachable from the main frame are accounted.
for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
- if (Document* doc = frame->document())
+ if (Document* doc = frame->document()) {
domTreesIterator.visitNode(doc);
+ domTreesIterator.visitFrame(frame);
+ }
}
domTreesIterator.visitBindings();
Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (122919 => 122920)
--- trunk/Source/WebCore/loader/DocumentLoader.cpp 2012-07-18 04:42:55 UTC (rev 122919)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp 2012-07-18 05:58:49 UTC (rev 122920)
@@ -47,6 +47,7 @@
#include "InspectorInstrumentation.h"
#include "Logging.h"
#include "MainResourceLoader.h"
+#include "MemoryInstrumentation.h"
#include "Page.h"
#include "PlatformString.h"
#include "Settings.h"
@@ -354,6 +355,24 @@
m_writer.addData(bytes, length);
}
+void DocumentLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+ MemoryClassInfo<DocumentLoader> info(memoryObjectInfo, this, MemoryInstrumentation::Loader);
+ info.addInstrumentedMember(m_frame);
+ info.addInstrumentedMember(m_mainResourceLoader);
+ info.addInstrumentedHashSet(m_subresourceLoaders);
+ info.addInstrumentedHashSet(m_multipartSubresourceLoaders);
+ info.addInstrumentedHashSet(m_plugInStreamLoaders);
+ info.addString(m_pageTitle.string());
+ info.addString(m_overrideEncoding);
+ info.addVector(m_responses);
+ info.addHashMap(m_pendingSubstituteResources);
+ info.addHashSet(m_resourcesClientKnowsAbout);
+ info.addVector(m_resourcesLoadedFromMemoryCacheForClientNotification);
+ info.addString(m_clientRedirectSourceForHistory);
+ info.addInstrumentedMember(m_mainResourceData);
+}
+
bool DocumentLoader::doesProgressiveLoad(const String& MIMEType) const
{
return !frameLoader()->isReplacing() || MIMEType == "text/html";
Modified: trunk/Source/WebCore/loader/DocumentLoader.h (122919 => 122920)
--- trunk/Source/WebCore/loader/DocumentLoader.h 2012-07-18 04:42:55 UTC (rev 122919)
+++ trunk/Source/WebCore/loader/DocumentLoader.h 2012-07-18 05:58:49 UTC (rev 122920)
@@ -55,6 +55,7 @@
class Frame;
class FrameLoader;
class MainResourceLoader;
+ class MemoryObjectInfo;
class Page;
class ResourceLoader;
class SchedulePair;
@@ -242,6 +243,8 @@
ApplicationCacheHost* applicationCacheHost() const { return m_applicationCacheHost.get(); }
+ virtual void reportMemoryUsage(MemoryObjectInfo*) const;
+
protected:
DocumentLoader(const ResourceRequest&, const SubstituteData&);
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (122919 => 122920)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2012-07-18 04:42:55 UTC (rev 122919)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2012-07-18 05:58:49 UTC (rev 122920)
@@ -77,6 +77,7 @@
#include "Logging.h"
#include "MIMETypeRegistry.h"
#include "MainResourceLoader.h"
+#include "MemoryInstrumentation.h"
#include "Page.h"
#include "PageCache.h"
#include "PageGroup.h"
@@ -3220,6 +3221,16 @@
return m_networkingContext.get();
}
+void FrameLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+ MemoryClassInfo<FrameLoader> info(memoryObjectInfo, this, MemoryInstrumentation::Loader);
+ info.addInstrumentedMember(m_documentLoader.get());
+ info.addInstrumentedMember(m_provisionalDocumentLoader.get());
+ info.addInstrumentedMember(m_policyDocumentLoader.get());
+ info.addString(m_outgoingReferrer);
+ info.addInstrumentedHashSet(m_openedFrames);
+}
+
bool FrameLoaderClient::hasHTMLView() const
{
return true;
Modified: trunk/Source/WebCore/loader/FrameLoader.h (122919 => 122920)
--- trunk/Source/WebCore/loader/FrameLoader.h 2012-07-18 04:42:55 UTC (rev 122919)
+++ trunk/Source/WebCore/loader/FrameLoader.h 2012-07-18 05:58:49 UTC (rev 122920)
@@ -61,6 +61,7 @@
class FormSubmission;
class FrameLoaderClient;
class FrameNetworkingContext;
+class MemoryObjectInfo;
class NavigationAction;
class NetworkingContext;
class Page;
@@ -283,6 +284,8 @@
NetworkingContext* networkingContext() const;
+ void reportMemoryUsage(MemoryObjectInfo*) const;
+
private:
bool allChildrenAreComplete() const; // immediate children, not all descendants
Modified: trunk/Source/WebCore/loader/ResourceLoader.cpp (122919 => 122920)
--- trunk/Source/WebCore/loader/ResourceLoader.cpp 2012-07-18 04:42:55 UTC (rev 122919)
+++ trunk/Source/WebCore/loader/ResourceLoader.cpp 2012-07-18 05:58:49 UTC (rev 122920)
@@ -528,4 +528,17 @@
}
#endif
+void ResourceLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+ MemoryClassInfo<ResourceLoader> info(memoryObjectInfo, this, MemoryInstrumentation::Loader);
+ info.addMember(m_handle.get());
+ info.addInstrumentedMember(m_frame);
+ info.addInstrumentedMember(m_documentLoader);
+ info.addMember(m_request);
+ info.addMember(m_originalRequest);
+ info.addInstrumentedMember(m_resourceData);
+ info.addMember(m_deferredRequest);
+ info.addMember(m_options);
}
+
+}
Modified: trunk/Source/WebCore/loader/ResourceLoader.h (122919 => 122920)
--- trunk/Source/WebCore/loader/ResourceLoader.h 2012-07-18 04:42:55 UTC (rev 122919)
+++ trunk/Source/WebCore/loader/ResourceLoader.h 2012-07-18 05:58:49 UTC (rev 122920)
@@ -44,6 +44,7 @@
class Frame;
class FrameLoader;
class KURL;
+ class MemoryObjectInfo;
class ResourceHandle;
class SharedBuffer;
@@ -144,6 +145,8 @@
void setShouldBufferData(DataBufferingPolicy);
+ virtual void reportMemoryUsage(MemoryObjectInfo*) const;
+
protected:
ResourceLoader(Frame*, ResourceLoaderOptions);
Modified: trunk/Source/WebCore/page/Frame.cpp (122919 => 122920)
--- trunk/Source/WebCore/page/Frame.cpp 2012-07-18 04:42:55 UTC (rev 122919)
+++ trunk/Source/WebCore/page/Frame.cpp 2012-07-18 05:58:49 UTC (rev 122920)
@@ -685,6 +685,13 @@
}
#endif
+void Frame::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+ MemoryClassInfo<Frame> info(memoryObjectInfo, this, MemoryInstrumentation::DOM);
+ info.addInstrumentedMember(m_doc.get());
+ info.addInstrumentedMember(m_loader);
+}
+
DOMWindow* Frame::domWindow() const
{
if (!m_domWindow)
Modified: trunk/Source/WebCore/page/Frame.h (122919 => 122920)
--- trunk/Source/WebCore/page/Frame.h 2012-07-18 04:42:55 UTC (rev 122919)
+++ trunk/Source/WebCore/page/Frame.h 2012-07-18 05:58:49 UTC (rev 122920)
@@ -66,6 +66,7 @@
class FrameDestructionObserver;
class FrameView;
class HTMLTableCellElement;
+ class MemoryObjectInfo;
class RegularExpression;
class RenderPart;
class TiledBackingStore;
@@ -117,6 +118,8 @@
void dispatchVisibilityStateChangeEvent();
#endif
+ void reportMemoryUsage(MemoryObjectInfo*) const;
+
// ======== All public functions below this point are candidates to move out of Frame into another class. ========
bool inScope(TreeScope*) const;
Modified: trunk/Source/WebCore/platform/SharedBuffer.cpp (122919 => 122920)
--- trunk/Source/WebCore/platform/SharedBuffer.cpp 2012-07-18 04:42:55 UTC (rev 122919)
+++ trunk/Source/WebCore/platform/SharedBuffer.cpp 2012-07-18 05:58:49 UTC (rev 122920)
@@ -27,6 +27,7 @@
#include "config.h"
#include "SharedBuffer.h"
+#include "MemoryInstrumentation.h"
#include "PurgeableBuffer.h"
#include <wtf/PassOwnPtr.h>
@@ -245,6 +246,16 @@
return m_buffer;
}
+void SharedBuffer::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+ MemoryClassInfo<SharedBuffer> info(memoryObjectInfo, this, MemoryInstrumentation::Other);
+ info.addVector(m_buffer);
+ info.addVector(m_segments);
+ for (unsigned i = 0; i < m_segments.size(); ++i)
+ info.addRawBuffer(m_segments[i], segmentSize);
+ info.addMember(m_purgeableBuffer.get());
+}
+
unsigned SharedBuffer::getSomeData(const char*& someData, unsigned position) const
{
unsigned totalSize = size();
Modified: trunk/Source/WebCore/platform/SharedBuffer.h (122919 => 122920)
--- trunk/Source/WebCore/platform/SharedBuffer.h 2012-07-18 04:42:55 UTC (rev 122919)
+++ trunk/Source/WebCore/platform/SharedBuffer.h 2012-07-18 05:58:49 UTC (rev 122920)
@@ -43,6 +43,7 @@
namespace WebCore {
+class MemoryObjectInfo;
class PurgeableBuffer;
class SharedBuffer : public RefCounted<SharedBuffer> {
@@ -114,6 +115,8 @@
// }
unsigned getSomeData(const char*& data, unsigned position = 0) const;
+ void reportMemoryUsage(MemoryObjectInfo*) const;
+
private:
SharedBuffer();
SharedBuffer(size_t);