Web Inspector: NMI: convert template versions of String*::reportMemoryUsage functions...
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Sep 2012 14:08:27 +0000 (14:08 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Sep 2012 14:08:27 +0000 (14:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=96759

Reviewed by Yury Semikhatsky.

Now when MemoryInstrumentation.h is a part of WTF we can move reportMemoryUsage functions to cpp file.

* wtf/text/AtomicString.cpp:
(WTF::AtomicString::reportMemoryUsage):
(WTF):
* wtf/text/AtomicString.h:
(WTF):
(AtomicString):
* wtf/text/StringImpl.cpp:
(WTF::StringImpl::reportMemoryUsage):
(WTF):
* wtf/text/StringImpl.h:
(WTF):
(StringImpl):
* wtf/text/WTFString.cpp:
(WTF::String::reportMemoryUsage):
(WTF):
* wtf/text/WTFString.h:
(WTF):
(String):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@128609 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/text/AtomicString.cpp
Source/WTF/wtf/text/AtomicString.h
Source/WTF/wtf/text/StringImpl.cpp
Source/WTF/wtf/text/StringImpl.h
Source/WTF/wtf/text/WTFString.cpp
Source/WTF/wtf/text/WTFString.h

index 1f6af6b..c8d6e06 100644 (file)
@@ -1,5 +1,33 @@
 2012-09-14  Ilya Tikhonovsky  <loislo@chromium.org>
 
+        Web Inspector: NMI: convert template versions of String*::reportMemoryUsage functions to normal functions.
+        https://bugs.webkit.org/show_bug.cgi?id=96759
+
+        Reviewed by Yury Semikhatsky.
+
+        Now when MemoryInstrumentation.h is a part of WTF we can move reportMemoryUsage functions to cpp file.
+
+        * wtf/text/AtomicString.cpp:
+        (WTF::AtomicString::reportMemoryUsage):
+        (WTF):
+        * wtf/text/AtomicString.h:
+        (WTF):
+        (AtomicString):
+        * wtf/text/StringImpl.cpp:
+        (WTF::StringImpl::reportMemoryUsage):
+        (WTF):
+        * wtf/text/StringImpl.h:
+        (WTF):
+        (StringImpl):
+        * wtf/text/WTFString.cpp:
+        (WTF::String::reportMemoryUsage):
+        (WTF):
+        * wtf/text/WTFString.h:
+        (WTF):
+        (String):
+
+2012-09-14  Ilya Tikhonovsky  <loislo@chromium.org>
+
         Web Inspector: NMI: remove current traits helper class because it is customizing the instrumentation at a wrong place and is not necessary at the moment.
         https://bugs.webkit.org/show_bug.cgi?id=96737
 
index cbb5a20..d626792 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "StringHash.h"
 #include <wtf/HashSet.h>
+#include <wtf/MemoryInstrumentation.h>
 #include <wtf/Threading.h>
 #include <wtf/WTFThreadData.h>
 #include <wtf/unicode/UTF8.h>
@@ -435,4 +436,10 @@ void AtomicString::show() const
 }
 #endif
 
+void AtomicString::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this);
+    info.addInstrumentedMember(m_string);
+}
+
 } // namespace WTF
index 01b84da..066b072 100644 (file)
@@ -35,6 +35,7 @@
 namespace WTF {
 
 struct AtomicStringHash;
+class MemoryObjectInfo;
 
 class AtomicString {
 public:
@@ -158,12 +159,7 @@ public:
     void show() const;
 #endif
 
-    template<typename MemoryObjectInfo>
-    void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
-    {
-        typename MemoryObjectInfo::ClassInfo info(memoryObjectInfo, this);
-        info.addInstrumentedMember(m_string);
-    }
+    WTF_EXPORT_STRING_API void reportMemoryUsage(MemoryObjectInfo*) const;
 
 private:
     // The explicit constructors with AtomicString::ConstructFromLiteral must be used for literals.
index a292632..d69ecaa 100644 (file)
@@ -28,6 +28,7 @@
 #include "AtomicString.h"
 #include "StringBuffer.h"
 #include "StringHash.h"
+#include <wtf/MemoryInstrumentation.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/WTFThreadData.h>
 #include <wtf/unicode/CharacterNames.h>
@@ -1791,4 +1792,24 @@ size_t StringImpl::sizeInBytes() const
     return size + sizeof(*this);
 }
 
+void StringImpl::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    size_t selfSize = sizeof(StringImpl);
+
+        // Count size used by internal buffer but skip strings that were constructed from literals.
+    if ((m_hashAndFlags & BufferInternal) && !hasTerminatingNullCharacter())
+        // Three cases are covered here:
+        // 1) a normal 8-bit string with internal storage (BufferInternal)
+        // 2) a normal 16-bit string with internal storage (BufferInternal)
+        // 3) empty unique string with length = 0 (BufferInternal)
+        selfSize += m_length * (m_hashAndFlags & s_hashFlag8BitBuffer ? sizeof(LChar) : sizeof(UChar));
+
+    MemoryClassInfo info(memoryObjectInfo, this, 0, selfSize);
+
+    if (m_hashAndFlags & BufferSubstring)
+        info.addInstrumentedMember(m_substringBuffer);
+    else if (m_hashAndFlags & s_hashFlagHas16BitShadow) // Substring never has its own shadow.
+        info.addRawBuffer(m_copyData16, (m_length + (hasTerminatingNullCharacter() ? 1 : 0)) * sizeof(UChar));
+}
+
 } // namespace WTF
index a18f694..00c6285 100644 (file)
@@ -60,6 +60,7 @@ template<typename CharacterType> struct HashAndCharactersTranslator;
 struct HashAndUTF8CharactersTranslator;
 struct LCharBufferTranslator;
 struct CharBufferFromLiteralDataTranslator;
+class MemoryObjectInfo;
 struct SubstringTranslator;
 struct UCharBufferTranslator;
 
@@ -715,26 +716,7 @@ public:
     ALWAYS_INLINE static StringStats& stringStats() { return m_stringStats; }
 #endif
 
-    template<typename MemoryObjectInfo>
-    void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
-    {
-        size_t selfSize = sizeof(StringImpl);
-
-        // Count size used by internal buffer but skip strings that were constructed from literals.
-        if ((m_hashAndFlags & BufferInternal) && !hasTerminatingNullCharacter())
-            // Three cases are covered here:
-            // 1) a normal 8-bit string with internal storage (BufferInternal)
-            // 2) a normal 16-bit string with internal storage (BufferInternal)
-            // 3) empty unique string with length = 0 (BufferInternal)
-            selfSize += m_length * (m_hashAndFlags & s_hashFlag8BitBuffer ? sizeof(LChar) : sizeof(UChar));
-
-        typename MemoryObjectInfo::ClassInfo info(memoryObjectInfo, this, 0, selfSize);
-
-        if (m_hashAndFlags & BufferSubstring)
-            info.addInstrumentedMember(m_substringBuffer);
-        else if (m_hashAndFlags & s_hashFlagHas16BitShadow) // Substring never has its own shadow.
-            info.addRawBuffer(m_copyData16, (m_length + (hasTerminatingNullCharacter() ? 1 : 0)) * sizeof(UChar));
-    }
+    WTF_EXPORT_STRING_API void reportMemoryUsage(MemoryObjectInfo*) const;
 
 private:
     // This number must be at least 2 to avoid sharing empty, null as well as 1 character strings from SmallStrings.
index 6f14bcf..bf7dbc3 100644 (file)
@@ -27,6 +27,7 @@
 #include <wtf/ASCIICType.h>
 #include <wtf/DataLog.h>
 #include <wtf/MathExtras.h>
+#include <wtf/MemoryInstrumentation.h>
 #include <wtf/text/CString.h>
 #include <wtf/StringExtras.h>
 #include <wtf/Vector.h>
@@ -820,6 +821,12 @@ String String::fromUTF8WithLatin1Fallback(const LChar* string, size_t size)
     return utf8;
 }
 
+void String::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+{
+    MemoryClassInfo info(memoryObjectInfo, this);
+    info.addInstrumentedMember(m_impl);
+}
+
 // String Operations
 
 static bool isCharacterAllowedInBase(UChar c, int base)
index b7bd96c..e3e13b5 100644 (file)
@@ -58,6 +58,7 @@ namespace WebKit {
 namespace WTF {
 
 class CString;
+class MemoryObjectInfo;
 struct StringHash;
 
 // Declarations of string operations
@@ -455,12 +456,7 @@ public:
         return (*m_impl)[index];
     }
 
-    template<typename MemoryObjectInfo>
-    void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
-    {
-        typename MemoryObjectInfo::ClassInfo info(memoryObjectInfo, this);
-        info.addInstrumentedMember(m_impl);
-    }
+    WTF_EXPORT_STRING_API void reportMemoryUsage(MemoryObjectInfo*) const;
 
 private:
     RefPtr<StringImpl> m_impl;