Diff
Modified: trunk/Source/WTF/ChangeLog (128278 => 128279)
--- trunk/Source/WTF/ChangeLog 2012-09-12 09:10:06 UTC (rev 128278)
+++ trunk/Source/WTF/ChangeLog 2012-09-12 09:13:23 UTC (rev 128279)
@@ -1,3 +1,29 @@
+2012-09-12 Ilya Tikhonovsky <loi...@chromium.org>
+
+ Web Inspector: NMI move String* instrumentation to wtf.
+ https://bugs.webkit.org/show_bug.cgi?id=96405
+
+ Reviewed by Yury Semikhatsky.
+
+ This instrumentation is solving the problem with substrings and removes traits based code which is hard to upstream.
+
+ Tested by webkit_unit_tests.
+
+ * wtf/MemoryInstrumentation.h:
+ (WebCore):
+ (WebCore::MemoryInstrumentation::addRootObject):
+ (WebCore::MemoryObjectInfo::reportObjectInfo):
+ (WebCore::MemoryClassInfo::MemoryClassInfo):
+ * wtf/text/AtomicString.h:
+ (AtomicString):
+ (WTF::AtomicString::reportMemoryUsage):
+ * wtf/text/StringImpl.h:
+ (StringImpl):
+ (WTF::StringImpl::reportMemoryUsage):
+ * wtf/text/WTFString.h:
+ (String):
+ (WTF::String::reportMemoryUsage):
+
2012-09-11 Michael Saboff <msab...@apple.com>
Build fixed for http://trac.webkit.org/changeset/128243
Modified: trunk/Source/WTF/wtf/MemoryInstrumentation.h (128278 => 128279)
--- trunk/Source/WTF/wtf/MemoryInstrumentation.h 2012-09-12 09:10:06 UTC (rev 128278)
+++ trunk/Source/WTF/wtf/MemoryInstrumentation.h 2012-09-12 09:13:23 UTC (rev 128279)
@@ -43,11 +43,6 @@
typedef const char* MemoryObjectType;
-class GenericMemoryTypes {
-public:
- static MemoryObjectType Undefined;
-};
-
enum MemoryOwningType {
byPointer,
byReference
@@ -65,7 +60,7 @@
template <typename T> void addRootObject(const T& t)
{
- addInstrumentedObject(t, GenericMemoryTypes::Undefined);
+ addInstrumentedObject(t, 0);
processDeferredInstrumentedPointers();
}
@@ -184,7 +179,7 @@
{
if (!m_objectSize) {
m_objectSize = actualSize ? actualSize : sizeof(T);
- if (objectType != GenericMemoryTypes::Undefined)
+ if (!objectType)
m_objectType = objectType;
}
}
@@ -197,7 +192,7 @@
class MemoryClassInfo {
public:
template<typename T>
- MemoryClassInfo(MemoryObjectInfo* memoryObjectInfo, const T*, MemoryObjectType objectType = GenericMemoryTypes::Undefined, size_t actualSize = 0)
+ MemoryClassInfo(MemoryObjectInfo* memoryObjectInfo, const T*, MemoryObjectType objectType = 0, size_t actualSize = 0)
: m_memoryObjectInfo(memoryObjectInfo)
, m_memoryInstrumentation(memoryObjectInfo->memoryInstrumentation())
{
Modified: trunk/Source/WTF/wtf/text/AtomicString.h (128278 => 128279)
--- trunk/Source/WTF/wtf/text/AtomicString.h 2012-09-12 09:10:06 UTC (rev 128278)
+++ trunk/Source/WTF/wtf/text/AtomicString.h 2012-09-12 09:13:23 UTC (rev 128279)
@@ -154,6 +154,14 @@
#ifndef NDEBUG
void show() const;
#endif
+
+ template<typename MemoryObjectInfo>
+ void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+ {
+ typename MemoryObjectInfo::ClassInfo info(memoryObjectInfo, this);
+ info.addInstrumentedMember(m_string);
+ }
+
private:
// The explicit constructors with AtomicString::ConstructFromLiteral must be used for literals.
AtomicString(ASCIILiteral);
Modified: trunk/Source/WTF/wtf/text/StringImpl.h (128278 => 128279)
--- trunk/Source/WTF/wtf/text/StringImpl.h 2012-09-12 09:10:06 UTC (rev 128278)
+++ trunk/Source/WTF/wtf/text/StringImpl.h 2012-09-12 09:13:23 UTC (rev 128279)
@@ -714,6 +714,28 @@
#ifdef STRING_STATS
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));
+ }
+
private:
// This number must be at least 2 to avoid sharing empty, null as well as 1 character strings from SmallStrings.
static const unsigned s_copyCharsInlineCutOff = 20;
Modified: trunk/Source/WTF/wtf/text/WTFString.h (128278 => 128279)
--- trunk/Source/WTF/wtf/text/WTFString.h 2012-09-12 09:10:06 UTC (rev 128278)
+++ trunk/Source/WTF/wtf/text/WTFString.h 2012-09-12 09:13:23 UTC (rev 128279)
@@ -455,6 +455,13 @@
return (*m_impl)[index];
}
+ template<typename MemoryObjectInfo>
+ void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
+ {
+ typename MemoryObjectInfo::ClassInfo info(memoryObjectInfo, this);
+ info.addInstrumentedMember(m_impl);
+ }
+
private:
RefPtr<StringImpl> m_impl;
};
Modified: trunk/Source/WebCore/ChangeLog (128278 => 128279)
--- trunk/Source/WebCore/ChangeLog 2012-09-12 09:10:06 UTC (rev 128278)
+++ trunk/Source/WebCore/ChangeLog 2012-09-12 09:13:23 UTC (rev 128279)
@@ -1,3 +1,26 @@
+2012-09-12 Ilya Tikhonovsky <loi...@chromium.org>
+
+ Web Inspector: NMI move String* instrumentation to wtf.
+ https://bugs.webkit.org/show_bug.cgi?id=96405
+
+ Reviewed by Yury Semikhatsky.
+
+ This instrumentation is solving the problem with substrings and removes traits based code which is hard to upstream.
+
+ * dom/WebCoreMemoryInstrumentation.cpp:
+ (WebCore):
+ * dom/WebCoreMemoryInstrumentation.h:
+ (WebCore):
+
+ * dom/WebCoreMemoryInstrumentation.cpp:
+ (WebCore):
+ * dom/WebCoreMemoryInstrumentation.h:
+ (WebCore):
+ * inspector/MemoryInstrumentationImpl.cpp:
+ (WebCore::MemoryInstrumentationImpl::countObjectSize):
+ * platform/SharedBuffer.cpp:
+ (WebCore::SharedBuffer::reportMemoryUsage):
+
2012-09-12 Kenneth Rohde Christiansen <kenn...@webkit.org>
Unreviewed EFL build fix.
Modified: trunk/Source/WebCore/dom/WebCoreMemoryInstrumentation.cpp (128278 => 128279)
--- trunk/Source/WebCore/dom/WebCoreMemoryInstrumentation.cpp 2012-09-12 09:10:06 UTC (rev 128278)
+++ trunk/Source/WebCore/dom/WebCoreMemoryInstrumentation.cpp 2012-09-12 09:13:23 UTC (rev 128279)
@@ -37,8 +37,6 @@
namespace WebCore {
-MemoryObjectType GenericMemoryTypes::Undefined = 0;
-
MemoryObjectType WebCoreMemoryTypes::Page = "Page";
MemoryObjectType WebCoreMemoryTypes::DOM = "Page.DOM";
MemoryObjectType WebCoreMemoryTypes::CSS = "Page.CSS";
@@ -57,32 +55,6 @@
MemoryObjectType WebCoreMemoryTypes::CachedResourceShader = "MemoryCache.Shader";
MemoryObjectType WebCoreMemoryTypes::CachedResourceXSLT = "MemoryCache.XSLT";
-template<> void MemoryInstrumentationTraits::addInstrumentedObject<String>(MemoryInstrumentation* instrumentation, const String* const& string, MemoryObjectType ownerObjectType, MemoryOwningType owningType)
-{
- 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)
- 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);
-}
-
-template<> void MemoryInstrumentationTraits::addInstrumentedObject<const StringImpl>(MemoryInstrumentation* instrumentation, const StringImpl* const& stringImpl, MemoryObjectType ownerObjectType, MemoryOwningType)
-{
- if (!stringImpl || instrumentation->visited(stringImpl))
- return;
- instrumentation->countObjectSize(ownerObjectType, stringImpl->sizeInBytes());
-}
-
template<> void MemoryInstrumentationTraits::addInstrumentedObject<KURL>(MemoryInstrumentation* instrumentation, const KURL* const& url, MemoryObjectType ownerObjectType, MemoryOwningType owningType)
{
MemoryInstrumentationTraits::addInstrumentedObject<const KURL>(instrumentation, url, ownerObjectType, owningType);
@@ -99,14 +71,4 @@
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);
-}
-
-template<> void MemoryInstrumentationTraits::addInstrumentedObject<const AtomicString>(MemoryInstrumentation* instrumentation, const AtomicString* const& atomicString, MemoryObjectType ownerObjectType, MemoryOwningType owningType)
-{
- MemoryInstrumentationTraits::addInstrumentedObject<const String>(instrumentation, reinterpret_cast<const String* const>(atomicString), ownerObjectType, owningType);
-}
-
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/WebCoreMemoryInstrumentation.h (128278 => 128279)
--- trunk/Source/WebCore/dom/WebCoreMemoryInstrumentation.h 2012-09-12 09:10:06 UTC (rev 128278)
+++ trunk/Source/WebCore/dom/WebCoreMemoryInstrumentation.h 2012-09-12 09:13:23 UTC (rev 128279)
@@ -42,29 +42,10 @@
template<> void MemoryInstrumentationTraits::addInstrumentedObject<KURL>(MemoryInstrumentation*, const KURL* const&, MemoryObjectType, MemoryOwningType);
template<> void MemoryInstrumentationTraits::addInstrumentedObject<const KURL>(MemoryInstrumentation*, const KURL* const&, MemoryObjectType, MemoryOwningType);
-template<> void MemoryInstrumentationTraits::addInstrumentedObject<String>(MemoryInstrumentation*, const String* const&, MemoryObjectType, MemoryOwningType);
-template<> void MemoryInstrumentationTraits::addInstrumentedObject<const String>(MemoryInstrumentation*, const String* const&, MemoryObjectType, MemoryOwningType);
-
-template<> void MemoryInstrumentationTraits::addInstrumentedObject<StringImpl>(MemoryInstrumentation*, const StringImpl* const&, MemoryObjectType, MemoryOwningType);
-template<> void MemoryInstrumentationTraits::addInstrumentedObject<const StringImpl>(MemoryInstrumentation*, const StringImpl* const&, MemoryObjectType, MemoryOwningType);
-
-template<> void MemoryInstrumentationTraits::addInstrumentedObject<AtomicString>(MemoryInstrumentation*, const AtomicString* const&, MemoryObjectType, MemoryOwningType);
-template<> void MemoryInstrumentationTraits::addInstrumentedObject<const AtomicString>(MemoryInstrumentation*, const AtomicString* const&, MemoryObjectType, MemoryOwningType);
-
-
// Link time guards with no body.
template<> void MemoryInstrumentationTraits::addObject<KURL>(MemoryInstrumentation*, const KURL* const&, MemoryObjectType, MemoryOwningType);
template<> void MemoryInstrumentationTraits::addObject<const KURL>(MemoryInstrumentation*, const KURL* const&, MemoryObjectType, MemoryOwningType);
-template<> void MemoryInstrumentationTraits::addObject<String>(MemoryInstrumentation*, const String* const&, MemoryObjectType, MemoryOwningType);
-template<> void MemoryInstrumentationTraits::addObject<const String>(MemoryInstrumentation*, const String* const&, MemoryObjectType, MemoryOwningType);
-
-template<> void MemoryInstrumentationTraits::addObject<StringImpl>(MemoryInstrumentation*, const StringImpl* const&, MemoryObjectType, MemoryOwningType);
-template<> void MemoryInstrumentationTraits::addObject<const StringImpl>(MemoryInstrumentation*, const StringImpl* const&, MemoryObjectType, MemoryOwningType);
-
-template<> void MemoryInstrumentationTraits::addObject<AtomicString>(MemoryInstrumentation*, const AtomicString* const&, MemoryObjectType, MemoryOwningType);
-template<> void MemoryInstrumentationTraits::addObject<const AtomicString>(MemoryInstrumentation*, const AtomicString* const&, MemoryObjectType, MemoryOwningType);
-
class WebCoreMemoryTypes {
public:
static MemoryObjectType Page;
Modified: trunk/Source/WebCore/inspector/MemoryInstrumentationImpl.cpp (128278 => 128279)
--- trunk/Source/WebCore/inspector/MemoryInstrumentationImpl.cpp 2012-09-12 09:10:06 UTC (rev 128278)
+++ trunk/Source/WebCore/inspector/MemoryInstrumentationImpl.cpp 2012-09-12 09:13:23 UTC (rev 128279)
@@ -52,7 +52,7 @@
void MemoryInstrumentationImpl::countObjectSize(MemoryObjectType objectType, size_t size)
{
- ASSERT(objectType != GenericMemoryTypes::Undefined);
+ ASSERT(objectType);
TypeToSizeMap::AddResult result = m_totalSizes.add(objectType, size);
if (!result.isNewEntry)
result.iterator->second += size;
Modified: trunk/Source/WebCore/platform/SharedBuffer.cpp (128278 => 128279)
--- trunk/Source/WebCore/platform/SharedBuffer.cpp 2012-09-12 09:10:06 UTC (rev 128278)
+++ trunk/Source/WebCore/platform/SharedBuffer.cpp 2012-09-12 09:13:23 UTC (rev 128279)
@@ -250,7 +250,7 @@
void SharedBuffer::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, GenericMemoryTypes::Undefined);
+ MemoryClassInfo info(memoryObjectInfo, this);
info.addVector(m_buffer);
info.addVector(m_segments);
for (unsigned i = 0; i < m_segments.size(); ++i)
Modified: trunk/Source/WebKit/chromium/ChangeLog (128278 => 128279)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-09-12 09:10:06 UTC (rev 128278)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-09-12 09:13:23 UTC (rev 128279)
@@ -1,3 +1,18 @@
+2012-09-12 Ilya Tikhonovsky <loi...@chromium.org>
+
+ Web Inspector: NMI move String* instrumentation to wtf.
+ https://bugs.webkit.org/show_bug.cgi?id=96405
+
+ Reviewed by Yury Semikhatsky.
+
+ This instrumentation is solving the problem with substrings and removes traits based code which is hard to upstream.
+
+ Tested by webkit_unit_tests.
+
+ * tests/MemoryInstrumentationTest.cpp:
+ (WebCore::InstrumentedUndefined::reportMemoryUsage):
+ (WebCore::TEST):
+
2012-09-12 Jochen Eisinger <joc...@chromium.org>
[chromium] consumable user gesture count off for input events
Modified: trunk/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp (128278 => 128279)
--- trunk/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp 2012-09-12 09:10:06 UTC (rev 128278)
+++ trunk/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp 2012-09-12 09:13:23 UTC (rev 128279)
@@ -179,7 +179,7 @@
void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
{
- MemoryClassInfo info(memoryObjectInfo, this, GenericMemoryTypes::Undefined);
+ MemoryClassInfo info(memoryObjectInfo, this);
}
int m_data;
};
@@ -245,8 +245,9 @@
VisitedObjects visitedObjects;
MemoryInstrumentationImpl impl(visitedObjects);
StringOwnerInstrumented stringOwnerInstrumented;
+ stringOwnerInstrumented.m_name.characters(); // Force 16bit shadow creation.
impl.addRootObject(stringOwnerInstrumented);
- EXPECT_EQ(stringOwnerInstrumented.m_name.impl()->sizeInBytes(), impl.reportedSizeForAllTypes());
+ EXPECT_EQ(sizeof(StringImpl) + stringOwnerInstrumented.m_name.length() * 2, impl.reportedSizeForAllTypes());
EXPECT_EQ(2, visitedObjects.size());
}