Commit 77b6497f authored by yurys@chromium.org's avatar yurys@chromium.org
Browse files

Remove MemoryInstrumentation::addCollectionElements

https://bugs.webkit.org/show_bug.cgi?id=98245

Reviewed by Vsevolod Vlasov.

Removed MemoryInstrumentation::addCollectionElements and switched all call sites
to reportSequenceMemoryUsage.

Drive-by fix: removed some unused methods on MemoryInstrumentation.

* wtf/MemoryInstrumentation.h:
* wtf/MemoryInstrumentationHashSet.h:
(WTF::reportMemoryUsage):
* wtf/MemoryInstrumentationSequence.h:
(WTF::SequenceMemoryInstrumentationTraits::reportMemoryUsage):
* wtf/MemoryInstrumentationVector.h:
(WTF::reportMemoryUsage):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130272 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent daa671fb
2012-10-03 Yury Semikhatsky <yurys@chromium.org>
Remove MemoryInstrumentation::addCollectionElements
https://bugs.webkit.org/show_bug.cgi?id=98245
Reviewed by Vsevolod Vlasov.
Removed MemoryInstrumentation::addCollectionElements and switched all call sites
to reportSequenceMemoryUsage.
Drive-by fix: removed some unused methods on MemoryInstrumentation.
* wtf/MemoryInstrumentation.h:
* wtf/MemoryInstrumentationHashSet.h:
(WTF::reportMemoryUsage):
* wtf/MemoryInstrumentationSequence.h:
(WTF::SequenceMemoryInstrumentationTraits::reportMemoryUsage):
* wtf/MemoryInstrumentationVector.h:
(WTF::reportMemoryUsage):
2012-10-02 Yury Semikhatsky <yurys@chromium.org>
Provide memory instrumentation for HashCountedSet
......
......@@ -156,8 +156,6 @@ private:
};
template<typename T> void addObject(const T& t, MemoryObjectType ownerObjectType) { OwningTraits<T>::addObject(this, t, ownerObjectType); }
template<typename HashCountedSetType> void addHashCountedSet(const HashCountedSetType&, MemoryObjectType, bool contentOnly = false);
template<typename CollectionType> void addInstrumentedCollection(const CollectionType&, MemoryObjectType, bool contentOnly = false);
template<typename ListHashSetType> void addListHashSet(const ListHashSetType&, MemoryObjectType, bool contentOnly = false);
void addRawBuffer(const void* const& buffer, MemoryObjectType ownerObjectType, size_t size)
{
......@@ -201,18 +199,6 @@ public:
}
template<typename M> void addMember(const M& member) { m_memoryInstrumentation->addObject(member, m_objectType); }
template<typename I> void addCollectionElements(I iterator, I end)
{
while (iterator != end) {
addMember(*iterator);
++iterator;
}
}
void addCollectionElements(char* const*, char* const*) { }
void addCollectionElements(const char*, const char*) { }
void addCollectionElements(const int*, const int*) { }
template<typename HashSetType> void addHashCountedSet(const HashSetType& set) { m_memoryInstrumentation->addHashCountedSet(set, m_objectType, true); }
template<typename ListHashSetType> void addListHashSet(const ListHashSetType& set) { m_memoryInstrumentation->addListHashSet(set, m_objectType, true); }
void addRawBuffer(const void* const& buffer, size_t size) { m_memoryInstrumentation->addRawBuffer(buffer, m_objectType, size); }
void addPrivateBuffer(size_t size) { m_memoryInstrumentation->countObjectSize(m_objectType, size); }
......@@ -265,25 +251,6 @@ void MemoryInstrumentation::addObjectImpl(const RefPtr<T>* const& object, Memory
addObjectImpl(object->get(), ownerObjectType, byPointer);
}
template<typename HashCountedSetType>
void MemoryInstrumentation::addHashCountedSet(const HashCountedSetType& hashCountedSet, MemoryObjectType ownerObjectType, bool contentOnly)
{
if (visited(&hashCountedSet))
return;
countObjectSize(ownerObjectType, calculateContainerSize(hashCountedSet, contentOnly));
}
template<typename CollectionType>
void MemoryInstrumentation::addInstrumentedCollection(const CollectionType& collection, MemoryObjectType ownerObjectType, bool contentOnly)
{
if (visited(&collection))
return;
countObjectSize(ownerObjectType, calculateContainerSize(collection, contentOnly));
typename CollectionType::const_iterator end = collection.end();
for (typename CollectionType::const_iterator i = collection.begin(); i != end; ++i)
addObject(*i, ownerObjectType);
}
template<typename ListHashSetType>
void MemoryInstrumentation::addListHashSet(const ListHashSetType& hashSet, MemoryObjectType ownerObjectType, bool contentOnly)
{
......
......@@ -32,7 +32,7 @@
#define MemoryInstrumentationHashSet_h
#include <wtf/HashSet.h>
#include <wtf/MemoryInstrumentation.h>
#include <wtf/MemoryInstrumentationSequence.h>
namespace WTF {
......@@ -41,7 +41,7 @@ void reportMemoryUsage(const HashSet<ValueArg, HashArg, TraitsArg>* const& hashS
{
MemoryClassInfo info(memoryObjectInfo, hashSet);
info.addPrivateBuffer(sizeof(typename HashTable<ValueArg, ValueArg, IdentityExtractor, HashArg, TraitsArg, TraitsArg>::ValueType) * hashSet->capacity());
info.addCollectionElements(hashSet->begin(), hashSet->end());
reportSequenceMemoryUsage<ValueArg, typename HashSet<ValueArg, HashArg, TraitsArg>::const_iterator>(hashSet->begin(), hashSet->end(), info);
}
}
......
......@@ -40,7 +40,10 @@ template<typename ValueType>
struct SequenceMemoryInstrumentationTraits {
template <typename I> static void reportMemoryUsage(I iterator, I end, MemoryClassInfo& info)
{
info.addCollectionElements(iterator, end);
while (iterator != end) {
info.addMember(*iterator);
++iterator;
}
}
};
......@@ -52,6 +55,10 @@ template<> struct SequenceMemoryInstrumentationTraits<void*> {
template <typename I> static void reportMemoryUsage(I, I, MemoryClassInfo&) { }
};
template<> struct SequenceMemoryInstrumentationTraits<char*> {
template <typename I> static void reportMemoryUsage(I, I, MemoryClassInfo&) { }
};
template<typename ValueType, typename I> void reportSequenceMemoryUsage(I begin, I end, MemoryClassInfo& info)
{
// Check if type is convertible to integer to handle iteration through enum values.
......
......@@ -31,7 +31,7 @@
#ifndef MemoryInstrumentationVector_h
#define MemoryInstrumentationVector_h
#include <wtf/MemoryInstrumentation.h>
#include <wtf/MemoryInstrumentationSequence.h>
#include <wtf/Vector.h>
namespace WTF {
......@@ -42,7 +42,7 @@ void reportMemoryUsage(const Vector<T, inlineCapacity>* const& vector, MemoryObj
MemoryClassInfo info(memoryObjectInfo, vector);
if (inlineCapacity < vector->capacity())
info.addRawBuffer(vector->data(), vector->capacity() * sizeof(T));
info.addCollectionElements(vector->begin(), vector->end());
reportSequenceMemoryUsage<T, typename Vector<T, inlineCapacity>::const_iterator>(vector->begin(), vector->end(), info);
}
}
......
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