summaryrefslogtreecommitdiff
path: root/Source/WTF/wtf/text
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-09-18 15:53:33 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2012-09-18 15:53:33 +0200
commit6bbb7fbbac94d0f511a7bd0cbd50854ab643bfb2 (patch)
treed9c68d1cca0b3e352f1e438561f3e504e641a08f /Source/WTF/wtf/text
parentd0424a769059c84ae20beb3c217812792ea6726b (diff)
downloadqtwebkit-6bbb7fbbac94d0f511a7bd0cbd50854ab643bfb2.tar.gz
Imported WebKit commit c7503cef7ecb236730d1309676ab9fc723fd061d (http://svn.webkit.org/repository/webkit/trunk@128886)
New snapshot with various build fixes
Diffstat (limited to 'Source/WTF/wtf/text')
-rw-r--r--Source/WTF/wtf/text/AtomicString.cpp7
-rw-r--r--Source/WTF/wtf/text/AtomicString.h8
-rw-r--r--Source/WTF/wtf/text/CString.h2
-rw-r--r--Source/WTF/wtf/text/StringImpl.cpp21
-rw-r--r--Source/WTF/wtf/text/StringImpl.h22
-rw-r--r--Source/WTF/wtf/text/WTFString.cpp7
-rw-r--r--Source/WTF/wtf/text/WTFString.h8
7 files changed, 42 insertions, 33 deletions
diff --git a/Source/WTF/wtf/text/AtomicString.cpp b/Source/WTF/wtf/text/AtomicString.cpp
index cbb5a20ee..b91c60e80 100644
--- a/Source/WTF/wtf/text/AtomicString.cpp
+++ b/Source/WTF/wtf/text/AtomicString.cpp
@@ -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.addMember(m_string);
+}
+
} // namespace WTF
diff --git a/Source/WTF/wtf/text/AtomicString.h b/Source/WTF/wtf/text/AtomicString.h
index 01b84da65..066b0726b 100644
--- a/Source/WTF/wtf/text/AtomicString.h
+++ b/Source/WTF/wtf/text/AtomicString.h
@@ -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.
diff --git a/Source/WTF/wtf/text/CString.h b/Source/WTF/wtf/text/CString.h
index d442af782..03ab3e54a 100644
--- a/Source/WTF/wtf/text/CString.h
+++ b/Source/WTF/wtf/text/CString.h
@@ -85,7 +85,7 @@ public:
void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
typename MemoryObjectInfo::ClassInfo info(memoryObjectInfo, this);
- info.addInstrumentedMember(m_buffer);
+ info.addMember(m_buffer);
}
private:
diff --git a/Source/WTF/wtf/text/StringImpl.cpp b/Source/WTF/wtf/text/StringImpl.cpp
index a29263218..c06a966e7 100644
--- a/Source/WTF/wtf/text/StringImpl.cpp
+++ b/Source/WTF/wtf/text/StringImpl.cpp
@@ -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.addMember(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
diff --git a/Source/WTF/wtf/text/StringImpl.h b/Source/WTF/wtf/text/StringImpl.h
index a18f694be..00c6285d2 100644
--- a/Source/WTF/wtf/text/StringImpl.h
+++ b/Source/WTF/wtf/text/StringImpl.h
@@ -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.
diff --git a/Source/WTF/wtf/text/WTFString.cpp b/Source/WTF/wtf/text/WTFString.cpp
index 6f14bcf56..b89acb663 100644
--- a/Source/WTF/wtf/text/WTFString.cpp
+++ b/Source/WTF/wtf/text/WTFString.cpp
@@ -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.addMember(m_impl);
+}
+
// String Operations
static bool isCharacterAllowedInBase(UChar c, int base)
diff --git a/Source/WTF/wtf/text/WTFString.h b/Source/WTF/wtf/text/WTFString.h
index b7bd96c17..e3e13b5d8 100644
--- a/Source/WTF/wtf/text/WTFString.h
+++ b/Source/WTF/wtf/text/WTFString.h
@@ -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;