Title: [129637] trunk/Source
Revision
129637
Author
[email protected]
Date
2012-09-26 07:10:50 -0700 (Wed, 26 Sep 2012)

Log Message

Web Inspector: extract HashSet instrumentation from core NMI code and put it into MemoryInstrumentationHashSet.h
https://bugs.webkit.org/show_bug.cgi?id=97198

Reviewed by Yury Semikhatsky.

Current implementation has overloads for HashSet.
This prevents us from instrumenting complex cases like Vector<HashSet<...> >.

Source/WebCore:

* css/CSSCursorImageValue.cpp:
(WebCore::CSSCursorImageValue::reportDescendantMemoryUsage):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::Features::reportMemoryUsage):
(WebCore::StyleResolver::collectMatchingRulesForList):
* dom/Document.cpp:
(WebCore::Document::reportMemoryUsage):
* dom/DocumentEventQueue.cpp:
(WebCore::DocumentEventQueue::reportMemoryUsage):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::reportMemoryUsage):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::reportMemoryUsage):
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::reportMemoryUsage):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::reportMemoryUsage):

Source/WebKit/chromium:

* tests/MemoryInstrumentationTest.cpp:
(WebCore::TEST):
(WebCore):

Source/WTF:

* GNUmakefile.list.am:
* WTF.gypi:
* WTF.pro:
* WTF.vcproj/WTF.vcproj:
* WTF.xcodeproj/project.pbxproj:
* wtf/HashSet.h:
(WTF):
(HashSet):
* wtf/HashTable.h:
(WTF):
(HashTable):
* wtf/MemoryInstrumentation.h:
(WTF::MemoryClassInfo::addCollectionElements):
(WTF::MemoryClassInfo::addHashCountedSet):
* wtf/MemoryInstrumentationHashSet.h: Added.
(WTF):
(WTF::reportMemoryUsage):
* wtf/MemoryInstrumentationHashTable.h: Added.
(WTF):
(WTF::reportMemoryUsage):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (129636 => 129637)


--- trunk/Source/WTF/ChangeLog	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WTF/ChangeLog	2012-09-26 14:10:50 UTC (rev 129637)
@@ -1,3 +1,34 @@
+2012-09-25  Ilya Tikhonovsky  <[email protected]>
+
+        Web Inspector: extract HashSet instrumentation from core NMI code and put it into MemoryInstrumentationHashSet.h
+        https://bugs.webkit.org/show_bug.cgi?id=97198
+
+        Reviewed by Yury Semikhatsky.
+
+        Current implementation has overloads for HashSet.
+        This prevents us from instrumenting complex cases like Vector<HashSet<...> >.
+
+        * GNUmakefile.list.am:
+        * WTF.gypi:
+        * WTF.pro:
+        * WTF.vcproj/WTF.vcproj:
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/HashSet.h:
+        (WTF):
+        (HashSet):
+        * wtf/HashTable.h:
+        (WTF):
+        (HashTable):
+        * wtf/MemoryInstrumentation.h:
+        (WTF::MemoryClassInfo::addCollectionElements):
+        (WTF::MemoryClassInfo::addHashCountedSet):
+        * wtf/MemoryInstrumentationHashSet.h: Added.
+        (WTF):
+        (WTF::reportMemoryUsage):
+        * wtf/MemoryInstrumentationHashTable.h: Added.
+        (WTF):
+        (WTF::reportMemoryUsage):
+
 2012-09-26  Yury Semikhatsky  <[email protected]>
 
         Web Inspector: compare objects counted by the memory instrumentation with those allocated in the heap

Modified: trunk/Source/WTF/GNUmakefile.list.am (129636 => 129637)


--- trunk/Source/WTF/GNUmakefile.list.am	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WTF/GNUmakefile.list.am	2012-09-26 14:10:50 UTC (rev 129637)
@@ -80,6 +80,8 @@
     Source/WTF/wtf/MediaTime.h \
     Source/WTF/wtf/MediaTime.cpp \
     Source/WTF/wtf/MemoryInstrumentation.h \
+    Source/WTF/wtf/MemoryInstrumentationHashSet.h \
+    Source/WTF/wtf/MemoryInstrumentationHashTable.h \
     Source/WTF/wtf/MemoryInstrumentationVector.h \
     Source/WTF/wtf/MessageQueue.h \
     Source/WTF/wtf/MetaAllocator.cpp \

Modified: trunk/Source/WTF/WTF.gypi (129636 => 129637)


--- trunk/Source/WTF/WTF.gypi	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WTF/WTF.gypi	2012-09-26 14:10:50 UTC (rev 129637)
@@ -50,6 +50,8 @@
             'wtf/MainThread.h',
             'wtf/MathExtras.h',
             'wtf/MemoryInstrumentation.h',
+            'wtf/MemoryInstrumentationHashSet.h',
+            'wtf/MemoryInstrumentationHashTable.h',
             'wtf/MemoryInstrumentationVector.h',
             'wtf/MessageQueue.h',
             'wtf/NonCopyingSort.h',

Modified: trunk/Source/WTF/WTF.pro (129636 => 129637)


--- trunk/Source/WTF/WTF.pro	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WTF/WTF.pro	2012-09-26 14:10:50 UTC (rev 129637)
@@ -87,6 +87,8 @@
     MD5.h \
     MediaTime.h \
     MemoryInstrumentation.h \
+    MemoryInstrumentationHashSet.h \
+    MemoryInstrumentationHashTable.h \
     MemoryInstrumentationVector.h \
     MessageQueue.h \
     MetaAllocator.h \

Modified: trunk/Source/WTF/WTF.vcproj/WTF.vcproj (129636 => 129637)


--- trunk/Source/WTF/WTF.vcproj/WTF.vcproj	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WTF/WTF.vcproj/WTF.vcproj	2012-09-26 14:10:50 UTC (rev 129637)
@@ -905,6 +905,14 @@
 			>
 		</File>
 		<File
+		        RelativePath="..\wtf\MemoryInstrumentationHashSet.h"
+			>
+		</File>
+		<File
+		        RelativePath="..\wtf\MemoryInstrumentationHashTable.h"
+			>
+		</File>
+		<File
 		        RelativePath="..\wtf\MemoryInstrumentationVector.h"
 			>
 		</File>

Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (129636 => 129637)


--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2012-09-26 14:10:50 UTC (rev 129637)
@@ -40,6 +40,8 @@
 		2CCD892A15C0390200285083 /* GregorianDateTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CCD892915C0390200285083 /* GregorianDateTime.cpp */; };
 		4330F38F15745B0500AAFA8F /* URLString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4330F38E15745B0500AAFA8F /* URLString.cpp */; };
 		4F0321BC156AA8D1006EBAF6 /* BitArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F0321BB156AA8D1006EBAF6 /* BitArray.h */; };
+		4F0BABBB1611D5F500023F66 /* MemoryInstrumentationHashTable.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F0BABBA1611D5F500023F66 /* MemoryInstrumentationHashTable.h */; };
+		4F1B2DB6160B44AA00586559 /* MemoryInstrumentationHashSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F1B2DB5160B44AA00586559 /* MemoryInstrumentationHashSet.h */; };
 		4F1D115415FF11BE0026E908 /* MemoryInstrumentation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F1D115315FF11BE0026E908 /* MemoryInstrumentation.h */; };
 		4FCB710A160A1A07008425EC /* MemoryInstrumentationVector.h in Headers */ = {isa = PBXBuildFile; fileRef = 4FCB7109160A1A07008425EC /* MemoryInstrumentationVector.h */; };
 		7E29C33E15FFD79B00516D61 /* ObjcRuntimeExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E29C33D15FFD79B00516D61 /* ObjcRuntimeExtras.h */; };
@@ -309,6 +311,8 @@
 		2CCD892915C0390200285083 /* GregorianDateTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GregorianDateTime.cpp; sourceTree = "<group>"; };
 		4330F38E15745B0500AAFA8F /* URLString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URLString.cpp; sourceTree = "<group>"; };
 		4F0321BB156AA8D1006EBAF6 /* BitArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BitArray.h; sourceTree = "<group>"; };
+		4F0BABBA1611D5F500023F66 /* MemoryInstrumentationHashTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryInstrumentationHashTable.h; sourceTree = "<group>"; };
+		4F1B2DB5160B44AA00586559 /* MemoryInstrumentationHashSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryInstrumentationHashSet.h; sourceTree = "<group>"; };
 		4F1D115315FF11BE0026E908 /* MemoryInstrumentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryInstrumentation.h; sourceTree = "<group>"; };
 		4FCB7109160A1A07008425EC /* MemoryInstrumentationVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryInstrumentationVector.h; sourceTree = "<group>"; };
 		5D247B6214689B8600E78B76 /* libWTF.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libWTF.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -692,6 +696,8 @@
 				CD5497AA15857D0300B5BC30 /* MediaTime.cpp */,
 				CD5497AB15857D0300B5BC30 /* MediaTime.h */,
 				4F1D115315FF11BE0026E908 /* MemoryInstrumentation.h */,
+				4F1B2DB5160B44AA00586559 /* MemoryInstrumentationHashSet.h */,
+				4F0BABBA1611D5F500023F66 /* MemoryInstrumentationHashTable.h */,
 				4FCB7109160A1A07008425EC /* MemoryInstrumentationVector.h */,
 				A8A472CC151A825B004123FF /* MessageQueue.h */,
 				A8A472CD151A825B004123FF /* MetaAllocator.cpp */,
@@ -1145,6 +1151,8 @@
 				26E6C20A1609037300CA6AF4 /* URLUtilInternal.h in Headers */,
 				26E6C20D1609037300CA6AF4 /* URLUtil.h in Headers */,
 				4FCB710A160A1A07008425EC /* MemoryInstrumentationVector.h in Headers */,
+				4F1B2DB6160B44AA00586559 /* MemoryInstrumentationHashSet.h in Headers */,
+				4F0BABBB1611D5F500023F66 /* MemoryInstrumentationHashTable.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: trunk/Source/WTF/wtf/HashSet.h (129636 => 129637)


--- trunk/Source/WTF/wtf/HashSet.h	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WTF/wtf/HashSet.h	2012-09-26 14:10:50 UTC (rev 129637)
@@ -27,6 +27,7 @@
 namespace WTF {
 
     struct IdentityExtractor;
+    class MemoryObjectInfo;
     
     template<typename Value, typename HashFunctions, typename Traits> class HashSet;
     template<typename Value, typename HashFunctions, typename Traits>
@@ -96,6 +97,7 @@
     private:
         friend void deleteAllValues<>(const HashSet&);
         friend void fastDeleteAllValues<>(const HashSet&);
+        template<typename V, typename H, typename T> friend void reportMemoryUsage(const HashSet<V, H, T>* const&, MemoryObjectInfo*);
 
         HashTableType m_impl;
     };

Modified: trunk/Source/WTF/wtf/HashTable.h (129636 => 129637)


--- trunk/Source/WTF/wtf/HashTable.h	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WTF/wtf/HashTable.h	2012-09-26 14:10:50 UTC (rev 129637)
@@ -307,6 +307,8 @@
         bool isNewEntry;
     };
 
+    class MemoryObjectInfo;
+
     template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
     class HashTable {
     public:
@@ -484,6 +486,8 @@
         static const int m_maxLoad = 2;
         static const int m_minLoad = 6;
 
+        template<typename K, typename V, typename E, typename H, typename T, typename KT> friend void reportMemoryUsage(const HashTable<K, V, E, H, T, KT>* const&, MemoryObjectInfo*);
+
         ValueType* m_table;
         int m_tableSize;
         int m_tableSizeMask;

Modified: trunk/Source/WTF/wtf/MemoryInstrumentation.h (129636 => 129637)


--- trunk/Source/WTF/wtf/MemoryInstrumentation.h	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WTF/wtf/MemoryInstrumentation.h	2012-09-26 14:10:50 UTC (rev 129637)
@@ -147,7 +147,6 @@
 
     template<typename T> void addObject(const T& t, MemoryObjectType ownerObjectType) { OwningTraits<T>::addObject(this, t, ownerObjectType); }
     template<typename HashMapType> void addHashMap(const HashMapType&, MemoryObjectType, bool contentOnly = false);
-    template<typename HashSetType> void addHashSet(const HashSetType&, MemoryObjectType, bool contentOnly = false);
     template<typename CollectionType> void addInstrumentedCollection(const CollectionType&, MemoryObjectType, bool contentOnly = false);
     template<typename MapType> void addInstrumentedMapEntries(const MapType&, MemoryObjectType);
     template<typename MapType> void addInstrumentedMapValues(const MapType&, MemoryObjectType);
@@ -192,11 +191,19 @@
     }
 
     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 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 addHashCountedSet(const HashSetType& set) { m_memoryInstrumentation->addHashSet(set, m_objectType, true); }
-    template<typename HashSetType> void addInstrumentedHashSet(const HashSetType& set) { m_memoryInstrumentation->addInstrumentedCollection(set, m_objectType, true); }
+    template<typename HashSetType> void addHashCountedSet(const HashSetType& set) { m_memoryInstrumentation->addHashMap(set, m_objectType, true); }
     template<typename MapType> void addInstrumentedMapEntries(const MapType& map) { m_memoryInstrumentation->addInstrumentedMapEntries(map, m_objectType); }
     template<typename MapType> void addInstrumentedMapValues(const MapType& map) { m_memoryInstrumentation->addInstrumentedMapValues(map, m_objectType); }
     template<typename ListHashSetType> void addListHashSet(const ListHashSetType& set) { m_memoryInstrumentation->addListHashSet(set, m_objectType, true); }
@@ -258,14 +265,6 @@
     countObjectSize(ownerObjectType, calculateContainerSize(hashMap, contentOnly));
 }
 
-template<typename HashSetType>
-void MemoryInstrumentation::addHashSet(const HashSetType& hashSet, MemoryObjectType ownerObjectType, bool contentOnly)
-{
-    if (visited(&hashSet))
-        return;
-    countObjectSize(ownerObjectType, calculateContainerSize(hashSet, contentOnly));
-}
-
 template<typename CollectionType>
 void MemoryInstrumentation::addInstrumentedCollection(const CollectionType& collection, MemoryObjectType ownerObjectType, bool contentOnly)
 {

Copied: trunk/Source/WTF/wtf/MemoryInstrumentationHashSet.h (from rev 129636, trunk/Source/WTF/wtf/MemoryInstrumentationVector.h) (0 => 129637)


--- trunk/Source/WTF/wtf/MemoryInstrumentationHashSet.h	                        (rev 0)
+++ trunk/Source/WTF/wtf/MemoryInstrumentationHashSet.h	2012-09-26 14:10:50 UTC (rev 129637)
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+#ifndef MemoryInstrumentationHashSet_h
+#define MemoryInstrumentationHashSet_h
+
+#include <wtf/MemoryInstrumentationHashTable.h>
+#include <wtf/text/StringHash.h>
+
+namespace WTF {
+
+template<typename ValueArg, typename HashArg, typename TraitsArg>
+void reportMemoryUsage(const HashSet<ValueArg, HashArg, TraitsArg>* const& hashSet, MemoryObjectInfo* memoryObjectInfo)
+{
+    MemoryClassInfo info(memoryObjectInfo, hashSet);
+    info.addMember(hashSet->m_impl);
+    info.addCollectionElements(hashSet->begin(), hashSet->end());
+}
+
+}
+
+#endif // !defined(MemoryInstrumentationHashSet_h)

Copied: trunk/Source/WTF/wtf/MemoryInstrumentationHashTable.h (from rev 129636, trunk/Source/WTF/wtf/MemoryInstrumentationVector.h) (0 => 129637)


--- trunk/Source/WTF/wtf/MemoryInstrumentationHashTable.h	                        (rev 0)
+++ trunk/Source/WTF/wtf/MemoryInstrumentationHashTable.h	2012-09-26 14:10:50 UTC (rev 129637)
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+#ifndef MemoryInstrumentationHashTable_h
+#define MemoryInstrumentationHashTable_h
+
+#include <wtf/MemoryInstrumentation.h>
+
+namespace WTF {
+
+template<typename Key, typename Value, typename Extractor, typename HashFunctions, typename Traits, typename KeyTraits>
+void reportMemoryUsage(const HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>* const& hashTable, MemoryObjectInfo* memoryObjectInfo)
+{
+    MemoryClassInfo info(memoryObjectInfo, hashTable);
+    info.addRawBuffer(hashTable->m_table, sizeof(typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::ValueType) * hashTable->capacity());
+}
+
+}
+
+#endif // !defined(MemoryInstrumentationHashTable_h)

Modified: trunk/Source/WTF/wtf/MemoryInstrumentationVector.h (129636 => 129637)


--- trunk/Source/WTF/wtf/MemoryInstrumentationVector.h	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WTF/wtf/MemoryInstrumentationVector.h	2012-09-26 14:10:50 UTC (rev 129637)
@@ -37,23 +37,12 @@
 namespace WTF {
 
 template<typename T, size_t inlineCapacity>
-void instrumentVectorValues(MemoryClassInfo& info, const Vector<T, inlineCapacity>* const& vector)
-{
-    for (size_t i = 0; i < vector->size(); ++i)
-        info.addMember(vector->at(i));
-}
-
-template<size_t inlineCapacity> void instrumentVectorValues(MemoryClassInfo&, const Vector<int, inlineCapacity>* const&) { }
-template<size_t inlineCapacity> void instrumentVectorValues(MemoryClassInfo&, const Vector<char, inlineCapacity>* const&) { }
-template<size_t inlineCapacity> void instrumentVectorValues(MemoryClassInfo&, const Vector<char*, inlineCapacity>* const&) { }
-
-template<typename T, size_t inlineCapacity>
 void reportMemoryUsage(const Vector<T, inlineCapacity>* const& vector, MemoryObjectInfo* memoryObjectInfo)
 {
     MemoryClassInfo info(memoryObjectInfo, vector);
     if (inlineCapacity < vector->capacity())
         info.addRawBuffer(vector->data(), vector->capacity() * sizeof(T));
-    instrumentVectorValues(info, vector);
+    info.addCollectionElements(vector->begin(), vector->end());
 }
 
 }

Modified: trunk/Source/WebCore/ChangeLog (129636 => 129637)


--- trunk/Source/WebCore/ChangeLog	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WebCore/ChangeLog	2012-09-26 14:10:50 UTC (rev 129637)
@@ -1,3 +1,31 @@
+2012-09-25  Ilya Tikhonovsky  <[email protected]>
+
+        Web Inspector: extract HashSet instrumentation from core NMI code and put it into MemoryInstrumentationHashSet.h
+        https://bugs.webkit.org/show_bug.cgi?id=97198
+
+        Reviewed by Yury Semikhatsky.
+
+        Current implementation has overloads for HashSet.
+        This prevents us from instrumenting complex cases like Vector<HashSet<...> >.
+
+        * css/CSSCursorImageValue.cpp:
+        (WebCore::CSSCursorImageValue::reportDescendantMemoryUsage):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::Features::reportMemoryUsage):
+        (WebCore::StyleResolver::collectMatchingRulesForList):
+        * dom/Document.cpp:
+        (WebCore::Document::reportMemoryUsage):
+        * dom/DocumentEventQueue.cpp:
+        (WebCore::DocumentEventQueue::reportMemoryUsage):
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::reportMemoryUsage):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::reportMemoryUsage):
+        * loader/cache/CachedResource.cpp:
+        (WebCore::CachedResource::reportMemoryUsage):
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::reportMemoryUsage):
+
 2012-09-26  Dominik Röttsches  <[email protected]>
 
         [soup] Obey setTimeoutInterval in soup backend

Modified: trunk/Source/WebCore/css/CSSCursorImageValue.cpp (129636 => 129637)


--- trunk/Source/WebCore/css/CSSCursorImageValue.cpp	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WebCore/css/CSSCursorImageValue.cpp	2012-09-26 14:10:50 UTC (rev 129637)
@@ -26,6 +26,7 @@
 #include "TreeScope.h"
 #include "WebCoreMemoryInstrumentation.h"
 #include <wtf/MathExtras.h>
+#include <wtf/MemoryInstrumentationHashSet.h>
 #include <wtf/UnusedParam.h>
 #include <wtf/text/WTFString.h>
 
@@ -138,7 +139,7 @@
     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
     CSSImageValue::reportDescendantMemoryUsage(memoryObjectInfo);
 #if ENABLE(SVG)
-    info.addInstrumentedHashSet(m_referencedElements);
+    info.addMember(m_referencedElements);
 #endif
 }
 

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (129636 => 129637)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2012-09-26 14:10:50 UTC (rev 129637)
@@ -126,6 +126,7 @@
 #include "WebKitCSSTransformValue.h"
 #include "WebKitFontFamilyNames.h"
 #include "XMLNames.h"
+#include <wtf/MemoryInstrumentationHashSet.h>
 #include <wtf/MemoryInstrumentationVector.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/Vector.h>
@@ -745,8 +746,8 @@
 void StyleResolver::Features::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
-    info.addHashSet(idsInRules);
-    info.addHashSet(attrsInRules);
+    info.addMember(idsInRules);
+    info.addMember(attrsInRules);
     info.addMember(siblingRules);
     info.addMember(uncommonAttributeRules);
 }
@@ -5790,7 +5791,7 @@
     info.addMember(m_viewportDependentMediaQueryResults);
     info.addHashMap(m_styleRuleToCSSOMWrapperMap);
     info.addInstrumentedMapEntries(m_styleRuleToCSSOMWrapperMap);
-    info.addInstrumentedHashSet(m_styleSheetCSSOMWrapperSet);
+    info.addMember(m_styleSheetCSSOMWrapperSet);
 #if ENABLE(CSS_FILTERS) && ENABLE(SVG)
     info.addHashMap(m_pendingSVGDocuments);
 #endif

Modified: trunk/Source/WebCore/dom/Document.cpp (129636 => 129637)


--- trunk/Source/WebCore/dom/Document.cpp	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WebCore/dom/Document.cpp	2012-09-26 14:10:50 UTC (rev 129637)
@@ -109,6 +109,7 @@
 #include "Language.h"
 #include "Localizer.h"
 #include "Logging.h"
+#include "MediaCanStartListener.h"
 #include "MediaQueryList.h"
 #include "MediaQueryMatcher.h"
 #include "MouseEventWithHitTestResults.h"
@@ -174,6 +175,7 @@
 #include <wtf/CurrentTime.h>
 #include <wtf/HashFunctions.h>
 #include <wtf/MainThread.h>
+#include <wtf/MemoryInstrumentationHashSet.h>
 #include <wtf/MemoryInstrumentationVector.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/StdLibExtras.h>
@@ -5865,8 +5867,8 @@
 void Document::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
 {
     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
+    ContainerNode::reportMemoryUsage(memoryObjectInfo);
     info.addMember(m_styleResolver);
-    ContainerNode::reportMemoryUsage(memoryObjectInfo);
     info.addMember(m_customFonts);
     info.addMember(m_url);
     info.addMember(m_baseURL);
@@ -5876,12 +5878,16 @@
     info.addMember(m_firstPartyForCookies);
     info.addMember(m_documentURI);
     info.addMember(m_baseTarget);
+    info.addMember(m_docType);
+    info.addMember(m_implementation);
+    info.addMember(m_elemSheet);
     info.addMember(m_frame);
     info.addMember(m_cachedResourceLoader);
-    info.addMember(m_elemSheet);
     info.addMember(m_styleSheetCollection);
-    info.addHashSet(m_nodeIterators);
-    info.addHashSet(m_ranges);
+    info.addMember(m_styleSheetList);
+    info.addMember(m_formController);
+    info.addMember(m_nodeIterators);
+    info.addMember(m_ranges);
     info.addMember(m_title.string());
     info.addMember(m_rawTitle.string());
     info.addMember(m_xmlEncoding);
@@ -5894,12 +5900,12 @@
 #endif
     info.addHashMap(m_cssCanvasElements);
     info.addMember(m_iconURLs);
-    info.addHashSet(m_documentSuspensionCallbackElements);
-    info.addHashSet(m_mediaVolumeCallbackElements);
-    info.addHashSet(m_privateBrowsingStateChangedElements);
+    info.addMember(m_documentSuspensionCallbackElements);
+    info.addMember(m_mediaVolumeCallbackElements);
+    info.addMember(m_privateBrowsingStateChangedElements);
     info.addHashMap(m_elementsByAccessKey);
     info.addMember(m_eventQueue);
-    info.addHashSet(m_mediaCanStartListeners);
+    info.addMember(m_mediaCanStartListeners);
     info.addMember(m_pendingTasks);
 }
 

Modified: trunk/Source/WebCore/dom/DocumentEventQueue.cpp (129636 => 129637)


--- trunk/Source/WebCore/dom/DocumentEventQueue.cpp	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WebCore/dom/DocumentEventQueue.cpp	2012-09-26 14:10:50 UTC (rev 129637)
@@ -35,6 +35,7 @@
 #include "ScriptExecutionContext.h"
 #include "SuspendableTimer.h"
 #include "WebCoreMemoryInstrumentation.h"
+#include <wtf/MemoryInstrumentationHashSet.h>
 
 namespace WebCore {
     
@@ -112,8 +113,8 @@
 {
     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
     info.addMember(m_pendingEventTimer);
-    info.addInstrumentedHashSet(m_queuedEvents);
-    info.addInstrumentedHashSet(m_nodesWithQueuedScrollEvents);
+    info.addMember(m_queuedEvents);
+    info.addMember(m_nodesWithQueuedScrollEvents);
 }
 
 bool DocumentEventQueue::cancelEvent(Event* event)

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (129636 => 129637)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2012-09-26 14:10:50 UTC (rev 129637)
@@ -53,6 +53,7 @@
 #include "TextResourceDecoder.h"
 #include "WebCoreMemoryInstrumentation.h"
 #include <wtf/Assertions.h>
+#include <wtf/MemoryInstrumentationHashSet.h>
 #include <wtf/MemoryInstrumentationVector.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
@@ -363,9 +364,9 @@
     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader);
     info.addMember(m_frame);
     info.addMember(m_mainResourceLoader);
-    info.addInstrumentedHashSet(m_subresourceLoaders);
-    info.addInstrumentedHashSet(m_multipartSubresourceLoaders);
-    info.addInstrumentedHashSet(m_plugInStreamLoaders);
+    info.addMember(m_subresourceLoaders);
+    info.addMember(m_multipartSubresourceLoaders);
+    info.addMember(m_plugInStreamLoaders);
     info.addMember(m_substituteData);
     info.addMember(m_pageTitle.string());
     info.addMember(m_overrideEncoding);
@@ -377,7 +378,7 @@
     info.addMember(m_lastCheckedRequest);
     info.addMember(m_responses);
     info.addHashMap(m_pendingSubstituteResources);
-    info.addInstrumentedHashSet(m_resourcesClientKnowsAbout);
+    info.addMember(m_resourcesClientKnowsAbout);
     info.addMember(m_resourcesLoadedFromMemoryCacheForClientNotification);
     info.addMember(m_clientRedirectSourceForHistory);
     info.addMember(m_mainResourceData);

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (129636 => 129637)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2012-09-26 14:10:50 UTC (rev 129637)
@@ -102,6 +102,7 @@
 #include "WindowFeatures.h"
 #include "XMLDocumentParser.h"
 #include <wtf/CurrentTime.h>
+#include <wtf/MemoryInstrumentationHashSet.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
@@ -3279,7 +3280,7 @@
     info.addMember(m_provisionalDocumentLoader);
     info.addMember(m_policyDocumentLoader);
     info.addMember(m_outgoingReferrer);
-    info.addInstrumentedHashSet(m_openedFrames);
+    info.addMember(m_openedFrames);
 }
 
 bool FrameLoaderClient::hasHTMLView() const

Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (129636 => 129637)


--- trunk/Source/WebCore/loader/cache/CachedResource.cpp	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp	2012-09-26 14:10:50 UTC (rev 129637)
@@ -44,6 +44,7 @@
 #include "WebCoreMemoryInstrumentation.h"
 #include <wtf/CurrentTime.h>
 #include <wtf/MathExtras.h>
+#include <wtf/MemoryInstrumentationHashSet.h>
 #include <wtf/RefCountedLeakCounter.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/text/CString.h>
@@ -804,7 +805,7 @@
 {
     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CachedResource);
     info.addMember(m_resourceRequest);
-    info.addHashSet(m_clients);
+    info.addMember(m_clients);
     info.addMember(m_accept);
     info.addMember(m_loader);
     info.addMember(m_response);
@@ -817,7 +818,7 @@
     info.addMember(m_owningCachedResourceLoader);
     info.addMember(m_resourceToRevalidate);
     info.addMember(m_proxyResource);
-    info.addInstrumentedHashSet(m_handlesToRevalidate);
+    info.addMember(m_handlesToRevalidate);
 
     if (m_purgeableData && !m_purgeableData->wasPurged())
         info.addRawBuffer(m_purgeableData.get(), m_purgeableData->size());

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (129636 => 129637)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2012-09-26 14:10:50 UTC (rev 129637)
@@ -48,6 +48,7 @@
 #include "ResourceLoadScheduler.h"
 #include "SecurityOrigin.h"
 #include "Settings.h"
+#include <wtf/MemoryInstrumentationHashSet.h>
 #include <wtf/UnusedParam.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
@@ -900,7 +901,7 @@
         info.addMember(i->first);
         info.addMember(i->second);
     }
-    info.addHashSet(m_validatedURLs);
+    info.addMember(m_validatedURLs);
     if (m_preloads)
         info.addListHashSet(*m_preloads);
     info.addMember(m_pendingPreloads);

Modified: trunk/Source/WebKit/chromium/ChangeLog (129636 => 129637)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-09-26 14:10:50 UTC (rev 129637)
@@ -1,3 +1,17 @@
+2012-09-25  Ilya Tikhonovsky  <[email protected]>
+
+        Web Inspector: extract HashSet instrumentation from core NMI code and put it into MemoryInstrumentationHashSet.h
+        https://bugs.webkit.org/show_bug.cgi?id=97198
+
+        Reviewed by Yury Semikhatsky.
+
+        Current implementation has overloads for HashSet.
+        This prevents us from instrumenting complex cases like Vector<HashSet<...> >.
+
+        * tests/MemoryInstrumentationTest.cpp:
+        (WebCore::TEST):
+        (WebCore):
+
 2012-09-25  Andrey Kosyakov  <[email protected]>
 
         Web Inspector: [chromium] add a test for inspector overlay update frequency

Modified: trunk/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp (129636 => 129637)


--- trunk/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp	2012-09-26 14:08:26 UTC (rev 129636)
+++ trunk/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp	2012-09-26 14:10:50 UTC (rev 129637)
@@ -37,11 +37,13 @@
 #include <gtest/gtest.h>
 
 #include <wtf/HashSet.h>
+#include <wtf/MemoryInstrumentationHashSet.h>
 #include <wtf/MemoryInstrumentationVector.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
 #include <wtf/text/AtomicString.h>
 #include <wtf/text/CString.h>
+#include <wtf/text/StringHash.h>
 #include <wtf/text/StringImpl.h>
 #include <wtf/text/WTFString.h>
 
@@ -439,5 +441,21 @@
     EXPECT_EQ(count + 2, (size_t)visitedObjects.size());
 }
 
+TEST(MemoryInstrumentationTest, hashSetWithInstrumentedType)
+{
+    VisitedObjects visitedObjects;
+    MemoryInstrumentationImpl impl(visitedObjects);
+
+    typedef HashSet<String> ValueType;
+    OwnPtr<ValueType> value = adoptPtr(new ValueType());
+    size_t count = 10;
+    for (size_t i = 0; i < count; ++i)
+        value->add(String::number(i));
+    InstrumentedOwner<ValueType* > root(value.get());
+    impl.addRootObject(root);
+    EXPECT_EQ(sizeof(ValueType) + sizeof(String) * value->capacity() + sizeof(StringImpl) * value->size(), impl.reportedSizeForAllTypes());
+    EXPECT_EQ(count + 2, (size_t)visitedObjects.size());
+}
+
 } // namespace
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to