Commit db0e2582 authored by loislo@chromium.org's avatar loislo@chromium.org

Web Inspector: NMI: extract overloaded instrumentation members for WebCore...

Web Inspector: NMI: extract overloaded instrumentation members for WebCore classes from core NMI code.
https://bugs.webkit.org/show_bug.cgi?id=95834

Reviewed by Yury Semikhatsky.

I'd like to remove custom instrumentation methods from MemoryInstrumentation class
before upstreaming it to WTF. I've done it with help of MemoryInstrumentationTraits template helper.

Unfortunately it is not possible to use template class because mac-ews bot reports warning: redundant redeclaration of 'something' in same scope.
I've found that it is an old problem in gcc that is forced by -Wredundant-decls flag on the bot. See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15867

* dom/MemoryInstrumentation.cpp:
(WebCore::::addInstrumentedObject):
(WebCore):
* dom/MemoryInstrumentation.h:
(WebCore):
(MemoryInstrumentationTraits):
(MemoryInstrumentation):
(WebCore::MemoryInstrumentation::InstrumentedPointer::InstrumentedPointer):
(InstrumentedPointer):
(WebCore::MemoryInstrumentation::addObject):
(WebCore::MemoryInstrumentation::addInstrumentedObject):
(WebCore::MemoryInstrumentation::addRawBuffer):
(WebCore::MemoryInstrumentation::OwningTraits::addInstrumentedObject):
(WebCore::MemoryInstrumentation::OwningTraits::addObject):
(WebCore::::addInstrumentedObject):
(WebCore::::addObject):
(WebCore::MemoryObjectInfo::MemoryObjectInfo):
(WebCore::MemoryObjectInfo::objectType):
(WebCore::MemoryObjectInfo::reportObjectInfo):
(MemoryObjectInfo):
(WebCore::MemoryClassInfo::MemoryClassInfo):
(MemoryClassInfo):
(WebCore::MemoryInstrumentation::addInstrumentedObjectImpl):
(WebCore::MemoryInstrumentation::addObjectImpl):
(WebCore::MemoryInstrumentation::addHashMap):
(WebCore::MemoryInstrumentation::addHashSet):
(WebCore::MemoryInstrumentation::addInstrumentedCollection):
(WebCore::MemoryInstrumentation::addInstrumentedMapEntries):
(WebCore::MemoryInstrumentation::addInstrumentedMapValues):
(WebCore::MemoryInstrumentation::addListHashSet):
(WebCore::MemoryInstrumentation::addVector):
* inspector/MemoryInstrumentationImpl.cpp:
(WebCore::MemoryInstrumentationImpl::countObjectSize):
* inspector/MemoryInstrumentationImpl.h:
(WebCore::MemoryInstrumentationImpl::totalSize):
(MemoryInstrumentationImpl):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@127592 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2aee45ff
2012-09-05 Ilya Tikhonovsky <loislo@chromium.org>
Web Inspector: NMI: extract overloaded instrumentation members for WebCore classes from core NMI code.
https://bugs.webkit.org/show_bug.cgi?id=95834
Reviewed by Yury Semikhatsky.
I'd like to remove custom instrumentation methods from MemoryInstrumentation class
before upstreaming it to WTF. I've done it with help of MemoryInstrumentationTraits template helper.
Unfortunately it is not possible to use template class because mac-ews bot reports warning: redundant redeclaration of 'something' in same scope.
I've found that it is an old problem in gcc that is forced by -Wredundant-decls flag on the bot. See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15867
* dom/MemoryInstrumentation.cpp:
(WebCore::::addInstrumentedObject):
(WebCore):
* dom/MemoryInstrumentation.h:
(WebCore):
(MemoryInstrumentationTraits):
(MemoryInstrumentation):
(WebCore::MemoryInstrumentation::InstrumentedPointer::InstrumentedPointer):
(InstrumentedPointer):
(WebCore::MemoryInstrumentation::addObject):
(WebCore::MemoryInstrumentation::addInstrumentedObject):
(WebCore::MemoryInstrumentation::addRawBuffer):
(WebCore::MemoryInstrumentation::OwningTraits::addInstrumentedObject):
(WebCore::MemoryInstrumentation::OwningTraits::addObject):
(WebCore::::addInstrumentedObject):
(WebCore::::addObject):
(WebCore::MemoryObjectInfo::MemoryObjectInfo):
(WebCore::MemoryObjectInfo::objectType):
(WebCore::MemoryObjectInfo::reportObjectInfo):
(MemoryObjectInfo):
(WebCore::MemoryClassInfo::MemoryClassInfo):
(MemoryClassInfo):
(WebCore::MemoryInstrumentation::addInstrumentedObjectImpl):
(WebCore::MemoryInstrumentation::addObjectImpl):
(WebCore::MemoryInstrumentation::addHashMap):
(WebCore::MemoryInstrumentation::addHashSet):
(WebCore::MemoryInstrumentation::addInstrumentedCollection):
(WebCore::MemoryInstrumentation::addInstrumentedMapEntries):
(WebCore::MemoryInstrumentation::addInstrumentedMapValues):
(WebCore::MemoryInstrumentation::addListHashSet):
(WebCore::MemoryInstrumentation::addVector):
* inspector/MemoryInstrumentationImpl.cpp:
(WebCore::MemoryInstrumentationImpl::countObjectSize):
* inspector/MemoryInstrumentationImpl.h:
(WebCore::MemoryInstrumentationImpl::totalSize):
(MemoryInstrumentationImpl):
2012-09-05 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
[Qt] Build fix on OS X
......@@ -37,51 +37,71 @@
namespace WebCore {
const char* MemoryInstrumentation::Other = "Other";
const char* MemoryInstrumentation::DOM = "DOM";
const char* MemoryInstrumentation::CSS = "CSS";
const char* MemoryInstrumentation::Binding = "Binding";
const char* MemoryInstrumentation::Loader = "Loader";
const char* MemoryInstrumentation::MemoryCacheStructures = "MemoryCacheStructures";
const char* MemoryInstrumentation::CachedResource = "CachedResource";
const char* MemoryInstrumentation::CachedResourceCSS = "CachedResourceCSS";
const char* MemoryInstrumentation::CachedResourceFont = "CachedResourceFont";
const char* MemoryInstrumentation::CachedResourceImage = "CachedResourceImage";
const char* MemoryInstrumentation::CachedResourceScript = "CachedResourceScript";
const char* MemoryInstrumentation::CachedResourceSVG = "CachedResourceSVG";
const char* MemoryInstrumentation::CachedResourceShader = "CachedResourceShader";
const char* MemoryInstrumentation::CachedResourceXSLT = "CachedResourceXSLT";
MemoryObjectType MemoryInstrumentation::Other = "Other";
MemoryObjectType MemoryInstrumentation::DOM = "DOM";
MemoryObjectType MemoryInstrumentation::CSS = "CSS";
MemoryObjectType MemoryInstrumentation::Binding = "Binding";
MemoryObjectType MemoryInstrumentation::Loader = "Loader";
MemoryObjectType MemoryInstrumentation::MemoryCacheStructures = "MemoryCacheStructures";
MemoryObjectType MemoryInstrumentation::CachedResource = "CachedResource";
MemoryObjectType MemoryInstrumentation::CachedResourceCSS = "CachedResourceCSS";
MemoryObjectType MemoryInstrumentation::CachedResourceFont = "CachedResourceFont";
MemoryObjectType MemoryInstrumentation::CachedResourceImage = "CachedResourceImage";
MemoryObjectType MemoryInstrumentation::CachedResourceScript = "CachedResourceScript";
MemoryObjectType MemoryInstrumentation::CachedResourceSVG = "CachedResourceSVG";
MemoryObjectType MemoryInstrumentation::CachedResourceShader = "CachedResourceShader";
MemoryObjectType MemoryInstrumentation::CachedResourceXSLT = "CachedResourceXSLT";
void MemoryInstrumentation::addInstrumentedObjectImpl(const String* const& string, ObjectType objectType, OwningType owningType)
template<> void MemoryInstrumentationTraits::addInstrumentedObject<String>(MemoryInstrumentation* instrumentation, const String* const& string, MemoryObjectType ownerObjectType, MemoryOwningType owningType)
{
if (!string || visited(string))
MemoryInstrumentationTraits::addInstrumentedObject<const String>(instrumentation, string, ownerObjectType, owningType);
}
template<> void MemoryInstrumentationTraits::addInstrumentedObject<const String>(MemoryInstrumentation* instrumentation, const String* const& string, MemoryObjectType ownerObjectType, MemoryOwningType owningType)
{
if (!string || instrumentation->visited(string))
return;
if (owningType == byPointer)
countObjectSize(objectType, sizeof(String));
addInstrumentedObjectImpl(string->impl(), objectType, byPointer);
instrumentation->countObjectSize(ownerObjectType, sizeof(String));
instrumentation->addInstrumentedObject(string->impl(), ownerObjectType);
}
template<> void MemoryInstrumentationTraits::addInstrumentedObject<StringImpl>(MemoryInstrumentation* instrumentation, const StringImpl* const& stringImpl, MemoryObjectType ownerObjectType, MemoryOwningType owningType)
{
MemoryInstrumentationTraits::addInstrumentedObject<const StringImpl>(instrumentation, stringImpl, ownerObjectType, owningType);
}
void MemoryInstrumentation::addInstrumentedObjectImpl(const StringImpl* const& stringImpl, ObjectType objectType, OwningType)
template<> void MemoryInstrumentationTraits::addInstrumentedObject<const StringImpl>(MemoryInstrumentation* instrumentation, const StringImpl* const& stringImpl, MemoryObjectType ownerObjectType, MemoryOwningType)
{
if (!stringImpl || visited(stringImpl))
if (!stringImpl || instrumentation->visited(stringImpl))
return;
countObjectSize(objectType, stringImpl->sizeInBytes());
instrumentation->countObjectSize(ownerObjectType, stringImpl->sizeInBytes());
}
void MemoryInstrumentation::addInstrumentedObjectImpl(const KURL* const& url, ObjectType objectType, OwningType owningType)
template<> void MemoryInstrumentationTraits::addInstrumentedObject<KURL>(MemoryInstrumentation* instrumentation, const KURL* const& url, MemoryObjectType ownerObjectType, MemoryOwningType owningType)
{
if (!url || visited(url))
MemoryInstrumentationTraits::addInstrumentedObject<const KURL>(instrumentation, url, ownerObjectType, owningType);
}
template<> void MemoryInstrumentationTraits::addInstrumentedObject<const KURL>(MemoryInstrumentation* instrumentation, const KURL* const& url, MemoryObjectType ownerObjectType, MemoryOwningType owningType)
{
if (!url || instrumentation->visited(url))
return;
if (owningType == byPointer)
countObjectSize(objectType, sizeof(KURL));
addInstrumentedObject(url->string(), objectType);
instrumentation->countObjectSize(ownerObjectType, sizeof(KURL));
instrumentation->addInstrumentedObject(url->string(), ownerObjectType);
if (url->innerURL())
addInstrumentedObject(url->innerURL(), objectType);
instrumentation->addInstrumentedObject(url->innerURL(), ownerObjectType);
}
template<> void MemoryInstrumentationTraits::addInstrumentedObject<AtomicString>(MemoryInstrumentation* instrumentation, const AtomicString* const& atomicString, MemoryObjectType ownerObjectType, MemoryOwningType owningType)
{
MemoryInstrumentationTraits::addInstrumentedObject<const AtomicString>(instrumentation, atomicString, ownerObjectType, owningType);
}
void MemoryInstrumentation::addInstrumentedObjectImpl(const AtomicString* const& atomicString, ObjectType objectType, OwningType owningType)
template<> void MemoryInstrumentationTraits::addInstrumentedObject<const AtomicString>(MemoryInstrumentation* instrumentation, const AtomicString* const& atomicString, MemoryObjectType ownerObjectType, MemoryOwningType owningType)
{
addInstrumentedObjectImpl(reinterpret_cast<const String* const>(atomicString), objectType, owningType);
MemoryInstrumentationTraits::addInstrumentedObject<const String>(instrumentation, reinterpret_cast<const String* const>(atomicString), ownerObjectType, owningType);
}
} // namespace WebCore
This diff is collapsed.
......@@ -50,7 +50,7 @@ void MemoryInstrumentationImpl::processDeferredInstrumentedPointers()
}
}
void MemoryInstrumentationImpl::countObjectSize(ObjectType objectType, size_t size)
void MemoryInstrumentationImpl::countObjectSize(MemoryObjectType objectType, size_t size)
{
TypeToSizeMap::AddResult result = m_totalSizes.add(objectType, size);
if (!result.isNewEntry)
......
......@@ -46,7 +46,7 @@ public:
explicit MemoryInstrumentationImpl(VisitedObjects&);
size_t selfSize() const;
size_t totalSize(ObjectType objectType) const
size_t totalSize(MemoryObjectType objectType) const
{
TypeToSizeMap::const_iterator i = m_totalSizes.find(objectType);
return i == m_totalSizes.end() ? 0 : i->second;
......@@ -61,12 +61,12 @@ public:
}
private:
virtual void countObjectSize(ObjectType, size_t) OVERRIDE;
virtual void countObjectSize(MemoryObjectType, size_t) OVERRIDE;
virtual void deferInstrumentedPointer(PassOwnPtr<InstrumentedPointerBase>) OVERRIDE;
virtual bool visited(const void*) OVERRIDE;
virtual void processDeferredInstrumentedPointers() OVERRIDE;
typedef HashMap<ObjectType, size_t> TypeToSizeMap;
typedef HashMap<MemoryObjectType, size_t> TypeToSizeMap;
TypeToSizeMap m_totalSizes;
VisitedObjects& m_visitedObjects;
Vector<OwnPtr<InstrumentedPointerBase> > m_deferredInstrumentedPointers;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment