Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (124016 => 124017)
--- trunk/Source/WebCore/CMakeLists.txt 2012-07-30 12:51:04 UTC (rev 124016)
+++ trunk/Source/WebCore/CMakeLists.txt 2012-07-30 12:59:12 UTC (rev 124017)
@@ -1105,6 +1105,7 @@
dom/IdTargetObserver.cpp
dom/IdTargetObserverRegistry.cpp
dom/KeyboardEvent.cpp
+ dom/MemoryInstrumentation.cpp
dom/MessageChannel.cpp
dom/MessageEvent.cpp
dom/MessagePortChannel.cpp
Modified: trunk/Source/WebCore/ChangeLog (124016 => 124017)
--- trunk/Source/WebCore/ChangeLog 2012-07-30 12:51:04 UTC (rev 124016)
+++ trunk/Source/WebCore/ChangeLog 2012-07-30 12:59:12 UTC (rev 124017)
@@ -1,3 +1,47 @@
+2012-07-26 Yury Semikhatsky <yu...@chromium.org>
+
+ Web Inspector: make MemoryInstrumentation methods private
+ https://bugs.webkit.org/show_bug.cgi?id=92379
+
+ Reviewed by Vsevolod Vlasov.
+
+ MemoryInstrumentation was refactored.
+ - All reporting methods on MemoryInstrumentation except add*Object are
+ private to enforce MemoryClassInfo usage.
+ - MemoryInstrumentation::Add*Member methods renamed to Add*Object
+ - String reporting is implemented directly in the MemoryInstrumentation,
+ not in its descendants.
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/v8/ScriptProfiler.cpp:
+ (WebCore::ScriptProfiler::collectBindingMemoryInfo):
+ * dom/MemoryInstrumentation.cpp: Added.
+ (WebCore):
+ (WebCore::MemoryInstrumentation::addString):
+ * dom/MemoryInstrumentation.h:
+ (WebCore::MemoryInstrumentation::addInstrumentedObject):
+ (WebCore::MemoryInstrumentation::addObject):
+ (MemoryInstrumentation):
+ (InstrumentedPointerBase):
+ (WebCore::MemoryInstrumentation::InstrumentedPointerBase::~InstrumentedPointerBase):
+ (InstrumentedPointer):
+ (WebCore::MemoryInstrumentation::InstrumentedPointer::InstrumentedPointer):
+ (WebCore::MemoryInstrumentation::OwningTraits::addInstrumentedObject):
+ (WebCore::MemoryInstrumentation::OwningTraits::addObject):
+ (WebCore::MemoryInstrumentation::addInstrumentedObjectImpl):
+ (WebCore::MemoryClassInfo::addInstrumentedMember):
+ (WebCore::MemoryClassInfo::addMember):
+ (WebCore):
+ (WebCore::MemoryInstrumentation::addObjectImpl):
+ (WebCore::MemoryInstrumentation::addInstrumentedCollection):
+ (WebCore::MemoryInstrumentation::calculateContainerSize):
+ * inspector/InspectorMemoryAgent.cpp:
+ (WebCore):
+
2012-07-30 Alexander Pavlov <apav...@chromium.org>
Web Inspector: [Styles] No color swatch for the SVG "fill" and "stroke" property values
Modified: trunk/Source/WebCore/GNUmakefile.list.am (124016 => 124017)
--- trunk/Source/WebCore/GNUmakefile.list.am 2012-07-30 12:51:04 UTC (rev 124016)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2012-07-30 12:59:12 UTC (rev 124017)
@@ -1965,6 +1965,7 @@
Source/WebCore/dom/HashChangeEvent.h \
Source/WebCore/dom/KeyboardEvent.cpp \
Source/WebCore/dom/KeyboardEvent.h \
+ Source/WebCore/dom/MemoryInstrumentation.cpp \
Source/WebCore/dom/MemoryInstrumentation.h \
Source/WebCore/dom/MessageChannel.cpp \
Source/WebCore/dom/MessageChannel.h \
Modified: trunk/Source/WebCore/Target.pri (124016 => 124017)
--- trunk/Source/WebCore/Target.pri 2012-07-30 12:51:04 UTC (rev 124016)
+++ trunk/Source/WebCore/Target.pri 2012-07-30 12:59:12 UTC (rev 124017)
@@ -412,6 +412,7 @@
dom/IdTargetObserver.cpp \
dom/IdTargetObserverRegistry.cpp \
dom/KeyboardEvent.cpp \
+ dom/MemoryInstrumentation.cpp \
dom/MessageChannel.cpp \
dom/MessageEvent.cpp \
dom/MessagePort.cpp \
Modified: trunk/Source/WebCore/WebCore.gypi (124016 => 124017)
--- trunk/Source/WebCore/WebCore.gypi 2012-07-30 12:51:04 UTC (rev 124016)
+++ trunk/Source/WebCore/WebCore.gypi 2012-07-30 12:59:12 UTC (rev 124017)
@@ -5199,6 +5199,7 @@
'dom/IdTargetObserverRegistry.cpp',
'dom/IdTargetObserverRegistry.h',
'dom/KeyboardEvent.cpp',
+ 'dom/MemoryInstrumentation.cpp',
'dom/MemoryInstrumentation.h',
'dom/MessageChannel.cpp',
'dom/MessageChannel.h',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (124016 => 124017)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-07-30 12:51:04 UTC (rev 124016)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-07-30 12:59:12 UTC (rev 124017)
@@ -51531,6 +51531,10 @@
>
</File>
<File
+ RelativePath="..\dom\MemoryInstrumentation.cpp"
+ >
+ </File>
+ <File
RelativePath="..\dom\MemoryInstrumentation.h"
>
</File>
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (124016 => 124017)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-07-30 12:51:04 UTC (rev 124016)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-07-30 12:59:12 UTC (rev 124017)
@@ -6175,6 +6175,7 @@
F39BE95B12673BF400E0A674 /* ScriptArguments.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F39BE95912673BF400E0A674 /* ScriptArguments.cpp */; };
F39BE95C12673BF400E0A674 /* ScriptArguments.h in Headers */ = {isa = PBXBuildFile; fileRef = F39BE95A12673BF400E0A674 /* ScriptArguments.h */; };
F3ABFE0C130E9DA000E7F7D1 /* InstrumentingAgents.h in Headers */ = {isa = PBXBuildFile; fileRef = F3ABFE0B130E9DA000E7F7D1 /* InstrumentingAgents.h */; };
+ F3BFC9D315C177EC004244E5 /* MemoryInstrumentation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3BFC9D215C177EC004244E5 /* MemoryInstrumentation.cpp */; };
F3D461481161D53200CA0D09 /* JSErrorHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3D461461161D53200CA0D09 /* JSErrorHandler.cpp */; };
F3D461491161D53200CA0D09 /* JSErrorHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D461471161D53200CA0D09 /* JSErrorHandler.h */; };
F3D4C47812E07663003DA150 /* InspectorDOMDebuggerAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3D4C47612E07663003DA150 /* InspectorDOMDebuggerAgent.cpp */; };
@@ -13499,6 +13500,7 @@
F39BE95912673BF400E0A674 /* ScriptArguments.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptArguments.cpp; sourceTree = "<group>"; };
F39BE95A12673BF400E0A674 /* ScriptArguments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptArguments.h; sourceTree = "<group>"; };
F3ABFE0B130E9DA000E7F7D1 /* InstrumentingAgents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InstrumentingAgents.h; sourceTree = "<group>"; };
+ F3BFC9D215C177EC004244E5 /* MemoryInstrumentation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryInstrumentation.cpp; sourceTree = "<group>"; };
F3D461461161D53200CA0D09 /* JSErrorHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSErrorHandler.cpp; sourceTree = "<group>"; };
F3D461471161D53200CA0D09 /* JSErrorHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSErrorHandler.h; sourceTree = "<group>"; };
F3D4C47612E07663003DA150 /* InspectorDOMDebuggerAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorDOMDebuggerAgent.cpp; sourceTree = "<group>"; };
@@ -21574,6 +21576,7 @@
BC9A6144146859D9006057FD /* make_dom_exceptions.pl */,
BC9A6145146859D9006057FD /* make_event_factory.pl */,
BC9A6146146859D9006057FD /* make_names.pl */,
+ F3BFC9D215C177EC004244E5 /* MemoryInstrumentation.cpp */,
4F32BB1A14FA85AA00F6C1A3 /* MemoryInstrumentation.h */,
E1ADECCD0E76AD8B004A1A5E /* MessageChannel.cpp */,
E1ADECCC0E76AD8B004A1A5E /* MessageChannel.h */,
@@ -27514,6 +27517,7 @@
D3AA10F3123A98AA0092152B /* MediaQueryMatcher.cpp in Sources */,
BCB16C170979C3BD00467741 /* MemoryCache.cpp in Sources */,
9FFE3E7A11B59C5D0037874E /* MemoryInfo.cpp in Sources */,
+ F3BFC9D315C177EC004244E5 /* MemoryInstrumentation.cpp in Sources */,
657EDA081385CB97004E0645 /* MemoryPressureHandler.cpp in Sources */,
657EDA0B1385CBD8004E0645 /* MemoryPressureHandlerMac.mm in Sources */,
D6FDAEF3149C06190037B1E3 /* MemoryUsageSupport.cpp in Sources */,
Modified: trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp (124016 => 124017)
--- trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp 2012-07-30 12:51:04 UTC (rev 124016)
+++ trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp 2012-07-30 12:59:12 UTC (rev 124017)
@@ -223,7 +223,7 @@
void ScriptProfiler::collectBindingMemoryInfo(MemoryInstrumentation* instrumentation)
{
V8BindingPerIsolateData* data = ""
- instrumentation->addInstrumentedMember(data);
+ instrumentation->addInstrumentedObject(data);
}
size_t ScriptProfiler::profilerSnapshotsSize()
Added: trunk/Source/WebCore/dom/MemoryInstrumentation.cpp (0 => 124017)
--- trunk/Source/WebCore/dom/MemoryInstrumentation.cpp (rev 0)
+++ trunk/Source/WebCore/dom/MemoryInstrumentation.cpp 2012-07-30 12:59:12 UTC (rev 124017)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MemoryInstrumentation.h"
+
+#include <wtf/text/StringImpl.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+void MemoryInstrumentation::addString(const String& string, ObjectType objectType)
+{
+ if (string.isNull() || visited(string.impl()))
+ return;
+ countObjectSize(objectType, string.impl()->sizeInBytes());
+}
+
+} // namespace WebCore
Property changes on: trunk/Source/WebCore/dom/MemoryInstrumentation.cpp
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/dom/MemoryInstrumentation.h (124016 => 124017)
--- trunk/Source/WebCore/dom/MemoryInstrumentation.h 2012-07-30 12:51:04 UTC (rev 124016)
+++ trunk/Source/WebCore/dom/MemoryInstrumentation.h 2012-07-30 12:59:12 UTC (rev 124017)
@@ -30,7 +30,6 @@
#ifndef MemoryInstrumentation_h
#define MemoryInstrumentation_h
-#include <stdio.h>
#include <wtf/Assertions.h>
#include <wtf/Forward.h>
@@ -55,16 +54,40 @@
LastTypeEntry
};
- template <typename T> void addInstrumentedMember(const T& t)
+ template <typename T> void addInstrumentedObject(const T& t)
{
- OwningTraits<T>::addInstrumentedMember(this, t);
+ OwningTraits<T>::addInstrumentedObject(this, t);
}
- template <typename T> void addMember(const T& t, ObjectType objectType)
+ template <typename Container> static size_t calculateContainerSize(const Container&, bool contentOnly = false);
+
+protected:
+ class InstrumentedPointerBase {
+ public:
+ virtual ~InstrumentedPointerBase() { }
+ virtual void process(MemoryInstrumentation*) = 0;
+ };
+
+ virtual void countObjectSize(ObjectType, size_t) = 0;
+ virtual void deferInstrumentedPointer(PassOwnPtr<InstrumentedPointerBase>) = 0;
+ virtual bool visited(const void*) = 0;
+
+private:
+ template <typename T> friend class MemoryClassInfo;
+ template <typename T> class InstrumentedPointer : public InstrumentedPointerBase {
+ public:
+ explicit InstrumentedPointer(const T* pointer) : m_pointer(pointer) { }
+ virtual void process(MemoryInstrumentation*) OVERRIDE;
+
+ private:
+ const T* m_pointer;
+ };
+
+ template <typename T> void addObject(const T& t, ObjectType objectType)
{
- OwningTraits<T>::addMember(this, t, objectType);
+ OwningTraits<T>::addObject(this, t, objectType);
}
-
+ void addString(const String&, ObjectType);
template <typename HashMapType> void addHashMap(const HashMapType&, ObjectType, bool contentOnly = false);
template <typename HashSetType> void addHashSet(const HashSetType&, ObjectType, bool contentOnly = false);
template <typename CollectionType> void addInstrumentedCollection(const CollectionType&, ObjectType, bool contentOnly = false);
@@ -77,7 +100,6 @@
countObjectSize(objectType, size);
}
-protected:
enum OwningType {
byPointer,
byReference
@@ -85,60 +107,21 @@
template <typename T>
struct OwningTraits { // Default byReference implementation.
- static void addInstrumentedMember(MemoryInstrumentation* instrumentation, const T& t) { instrumentation->addInstrumentedMemberImpl(&t, byReference); }
- static void addMember(MemoryInstrumentation* instrumentation, const T& t, MemoryInstrumentation::ObjectType objectType) { instrumentation->addMemberImpl(&t, objectType, byReference); }
+ static void addInstrumentedObject(MemoryInstrumentation* instrumentation, const T& t) { instrumentation->addInstrumentedObjectImpl(&t, byReference); }
+ static void addObject(MemoryInstrumentation* instrumentation, const T& t, MemoryInstrumentation::ObjectType objectType) { instrumentation->addObjectImpl(&t, objectType, byReference); }
};
template <typename T>
struct OwningTraits<T*> { // Custom byPointer implementation.
- static void addInstrumentedMember(MemoryInstrumentation* instrumentation, const T* const& t) { instrumentation->addInstrumentedMemberImpl(t, byPointer); }
- static void addMember(MemoryInstrumentation* instrumentation, const T* const& t, MemoryInstrumentation::ObjectType objectType) { instrumentation->addMemberImpl(t, objectType, byPointer); }
+ static void addInstrumentedObject(MemoryInstrumentation* instrumentation, const T* const& t) { instrumentation->addInstrumentedObjectImpl(t, byPointer); }
+ static void addObject(MemoryInstrumentation* instrumentation, const T* const& t, MemoryInstrumentation::ObjectType objectType) { instrumentation->addObjectImpl(t, objectType, byPointer); }
};
- 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 addInstrumentedObjectImpl(const T* const&, OwningType);
+ template <typename T> void addInstrumentedObjectImpl(const OwnPtr<T>* const&, OwningType);
+ template <typename T> void addInstrumentedObjectImpl(const RefPtr<T>* const&, OwningType);
- template <typename T>
- void addMemberImpl(const T* const& object, ObjectType objectType, OwningType owningType)
- {
- if (!object || visited(object))
- return;
- if (owningType == byReference)
- return;
- countObjectSize(objectType, sizeof(T));
- }
-
- class InstrumentedPointerBase {
- public:
- virtual ~InstrumentedPointerBase() { }
-
- virtual void process(MemoryInstrumentation*) = 0;
- };
-
- template <typename Container>
- size_t calculateContainerSize(const Container& container, bool contentOnly = false)
- {
- return (contentOnly ? 0 : sizeof(container)) + container.capacity() * sizeof(typename Container::ValueType);
- }
-
-private:
- template <typename T> friend class MemoryClassInfo;
- template <typename T>
- class InstrumentedPointer : public InstrumentedPointerBase {
- public:
- explicit InstrumentedPointer(const T* pointer) : m_pointer(pointer) { }
-
- virtual void process(MemoryInstrumentation*) OVERRIDE;
-
- private:
- const T* m_pointer;
- };
-
- virtual void addString(const String&, ObjectType) = 0;
- virtual void countObjectSize(ObjectType, size_t) = 0;
- virtual void deferInstrumentedPointer(PassOwnPtr<InstrumentedPointerBase>) = 0;
- virtual bool visited(const void*) = 0;
+ template <typename T> void addObjectImpl(const T* const&, ObjectType, OwningType);
};
class MemoryObjectInfo {
@@ -170,25 +153,7 @@
size_t m_objectSize;
};
-// Link time guard for string members. They produce link error is a string is reported via addMember.
-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)
-{
- if (!object || visited(object))
- return;
- if (owningType == byReference) {
- MemoryObjectInfo memoryObjectInfo(this);
- object->reportMemoryUsage(&memoryObjectInfo);
- } else
- deferInstrumentedPointer(adoptPtr(new InstrumentedPointer<T>(object)));
-}
-
-
-template <typename T>
class MemoryClassInfo {
public:
MemoryClassInfo(MemoryObjectInfo* memoryObjectInfo, const T* ptr, MemoryInstrumentation::ObjectType objectType, size_t extraObjectSize = 0)
@@ -201,8 +166,8 @@
template <typename P> void visitBaseClass(const P* ptr) { ptr->P::reportMemoryUsage(m_memoryObjectInfo); }
- template <typename M> void addInstrumentedMember(const M& member) { m_memoryInstrumentation->addInstrumentedMember(member); }
- template <typename M> void addMember(const M& member) { m_memoryInstrumentation->addMember(member, m_objectType); }
+ template <typename M> void addInstrumentedMember(const M& member) { m_memoryInstrumentation->addInstrumentedObject(member); }
+ template <typename M> void addMember(const M& member) { m_memoryInstrumentation->addObject(member, m_objectType); }
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); }
@@ -221,6 +186,44 @@
MemoryInstrumentation::ObjectType m_objectType;
};
+template <typename T>
+void MemoryInstrumentation::addInstrumentedObjectImpl(const T* const& object, OwningType owningType)
+{
+ if (!object || visited(object))
+ return;
+ if (owningType == byReference) {
+ MemoryObjectInfo memoryObjectInfo(this);
+ object->reportMemoryUsage(&memoryObjectInfo);
+ } else
+ deferInstrumentedPointer(adoptPtr(new InstrumentedPointer<T>(object)));
+}
+
+template <typename T>
+void MemoryInstrumentation::addInstrumentedObjectImpl(const OwnPtr<T>* const& object, OwningType owningType)
+{
+ addInstrumentedObjectImpl(object->get(), owningType);
+}
+
+template <typename T>
+void MemoryInstrumentation::addInstrumentedObjectImpl(const RefPtr<T>* const& object, OwningType owningType)
+{
+ addInstrumentedObjectImpl(object->get(), owningType);
+}
+
+// Link time guard for string members. They produce link error is a string is reported via addObject.
+template <> void MemoryInstrumentation::addObjectImpl<AtomicString>(const AtomicString* const&, MemoryInstrumentation::ObjectType, MemoryInstrumentation::OwningType);
+template <> void MemoryInstrumentation::addObjectImpl<String>(const String* const&, MemoryInstrumentation::ObjectType, MemoryInstrumentation::OwningType);
+
+template <typename T>
+void MemoryInstrumentation::addObjectImpl(const T* const& object, ObjectType objectType, OwningType owningType)
+{
+ if (!object || visited(object))
+ return;
+ if (owningType == byReference)
+ return;
+ countObjectSize(objectType, sizeof(T));
+}
+
template<typename HashMapType>
void MemoryInstrumentation::addHashMap(const HashMapType& hashMap, ObjectType objectType, bool contentOnly)
{
@@ -245,7 +248,7 @@
countObjectSize(objectType, calculateContainerSize(collection, contentOnly));
typename CollectionType::const_iterator end = collection.end();
for (typename CollectionType::const_iterator i = collection.begin(); i != end; ++i)
- addInstrumentedMember(*i);
+ addInstrumentedObject(*i);
}
template<typename ListHashSetType>
@@ -265,6 +268,12 @@
countObjectSize(objectType, calculateContainerSize(vector, contentOnly));
}
+template <typename Container>
+size_t MemoryInstrumentation::calculateContainerSize(const Container& container, bool contentOnly)
+{
+ return (contentOnly ? 0 : sizeof(container)) + container.capacity() * sizeof(typename Container::ValueType);
+}
+
template<typename T>
void MemoryInstrumentation::InstrumentedPointer<T>::process(MemoryInstrumentation* memoryInstrumentation)
{
Modified: trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp (124016 => 124017)
--- trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp 2012-07-30 12:51:04 UTC (rev 124016)
+++ trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp 2012-07-30 12:59:12 UTC (rev 124017)
@@ -485,13 +485,6 @@
}
private:
- virtual void addString(const String& string, ObjectType objectType)
- {
- if (string.isNull() || visited(string.impl()))
- return;
- countObjectSize(objectType, string.impl()->sizeInBytes());
- }
-
virtual void countObjectSize(ObjectType objectType, size_t size) OVERRIDE
{
ASSERT(objectType >= 0 && objectType < LastTypeEntry);
@@ -526,13 +519,13 @@
if (node->document() && node->document()->frame() && m_page != node->document()->frame()->page())
return;
- m_domMemoryUsage.addInstrumentedMember(node);
+ m_domMemoryUsage.addInstrumentedObject(node);
m_domMemoryUsage.processDeferredInstrumentedPointers();
}
void visitFrame(Frame* frame)
{
- m_domMemoryUsage.addInstrumentedMember(frame);
+ m_domMemoryUsage.addInstrumentedObject(frame);
m_domMemoryUsage.processDeferredInstrumentedPointers();
}