Changeset 128300 in webkit
- Timestamp:
- Sep 12, 2012 5:50:10 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r128284 r128300 1 2012-09-12 Ilya Tikhonovsky <loislo@chromium.org> 2 3 Web Inspector: NMI move String* instrumentation to wtf. 4 https://bugs.webkit.org/show_bug.cgi?id=96405 5 6 Reviewed by Yury Semikhatsky. 7 8 This instrumentation is solving the problem with substrings and removes traits based code which is hard to upstream. 9 10 Tested by webkit_unit_tests. 11 12 * wtf/text/AtomicString.h: 13 (AtomicString): 14 (WTF::AtomicString::reportMemoryUsage): 15 * wtf/text/StringImpl.h: 16 (StringImpl): 17 (WTF::StringImpl::reportMemoryUsage): 18 * wtf/text/WTFString.h: 19 (String): 20 (WTF::String::reportMemoryUsage): 21 1 22 2012-09-12 Sheriff Bot <webkit.review.bot@gmail.com> 2 23 -
trunk/Source/WTF/wtf/MemoryInstrumentation.h
r128284 r128300 44 44 typedef const char* MemoryObjectType; 45 45 46 class GenericMemoryTypes {47 public:48 static MemoryObjectType Undefined;49 };50 51 46 enum MemoryOwningType { 52 47 byPointer, … … 66 61 template <typename T> void addRootObject(const T& t) 67 62 { 68 addInstrumentedObject(t, GenericMemoryTypes::Undefined);63 addInstrumentedObject(t, 0); 69 64 processDeferredInstrumentedPointers(); 70 65 } … … 185 180 if (!m_objectSize) { 186 181 m_objectSize = actualSize ? actualSize : sizeof(T); 187 if (objectType != GenericMemoryTypes::Undefined)182 if (objectType) 188 183 m_objectType = objectType; 189 184 } … … 198 193 public: 199 194 template<typename T> 200 MemoryClassInfo(MemoryObjectInfo* memoryObjectInfo, const T*, MemoryObjectType objectType = GenericMemoryTypes::Undefined, size_t actualSize = 0)195 MemoryClassInfo(MemoryObjectInfo* memoryObjectInfo, const T*, MemoryObjectType objectType = 0, size_t actualSize = 0) 201 196 : m_memoryObjectInfo(memoryObjectInfo) 202 197 , m_memoryInstrumentation(memoryObjectInfo->memoryInstrumentation()) -
trunk/Source/WTF/wtf/text/AtomicString.h
r128284 r128300 155 155 void show() const; 156 156 #endif 157 158 template<typename MemoryObjectInfo> 159 void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 160 { 161 typename MemoryObjectInfo::ClassInfo info(memoryObjectInfo, this); 162 info.addInstrumentedMember(m_string); 163 } 164 157 165 private: 158 166 // The explicit constructors with AtomicString::ConstructFromLiteral must be used for literals. -
trunk/Source/WTF/wtf/text/StringImpl.h
r128284 r128300 715 715 ALWAYS_INLINE static StringStats& stringStats() { return m_stringStats; } 716 716 #endif 717 718 template<typename MemoryObjectInfo> 719 void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 720 { 721 size_t selfSize = sizeof(StringImpl); 722 723 // Count size used by internal buffer but skip strings that were constructed from literals. 724 if ((m_hashAndFlags & BufferInternal) && !hasTerminatingNullCharacter()) 725 // Three cases are covered here: 726 // 1) a normal 8-bit string with internal storage (BufferInternal) 727 // 2) a normal 16-bit string with internal storage (BufferInternal) 728 // 3) empty unique string with length = 0 (BufferInternal) 729 selfSize += m_length * (m_hashAndFlags & s_hashFlag8BitBuffer ? sizeof(LChar) : sizeof(UChar)); 730 731 typename MemoryObjectInfo::ClassInfo info(memoryObjectInfo, this, 0, selfSize); 732 733 if (m_hashAndFlags & BufferSubstring) 734 info.addInstrumentedMember(m_substringBuffer); 735 else if (m_hashAndFlags & s_hashFlagHas16BitShadow) // Substring never has its own shadow. 736 info.addRawBuffer(m_copyData16, (m_length + (hasTerminatingNullCharacter() ? 1 : 0)) * sizeof(UChar)); 737 } 738 717 739 private: 718 740 // This number must be at least 2 to avoid sharing empty, null as well as 1 character strings from SmallStrings. -
trunk/Source/WTF/wtf/text/WTFString.h
r128284 r128300 454 454 return 0; 455 455 return (*m_impl)[index]; 456 } 457 458 template<typename MemoryObjectInfo> 459 void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 460 { 461 typename MemoryObjectInfo::ClassInfo info(memoryObjectInfo, this); 462 info.addInstrumentedMember(m_impl); 456 463 } 457 464 -
trunk/Source/WebCore/ChangeLog
r128298 r128300 1 2012-09-12 Ilya Tikhonovsky <loislo@chromium.org> 2 3 4 Web Inspector: NMI move String* instrumentation to wtf. 5 https://bugs.webkit.org/show_bug.cgi?id=96405 6 7 Reviewed by Yury Semikhatsky. 8 9 This instrumentation is solving the problem with substrings and removes traits based code which is hard to upstream. 10 11 * dom/WebCoreMemoryInstrumentation.cpp: 12 (WebCore): 13 * dom/WebCoreMemoryInstrumentation.h: 14 (WebCore): 15 1 16 2012-08-20 Philippe Normand <pnormand@igalia.com> 2 17 -
trunk/Source/WebCore/dom/WebCoreMemoryInstrumentation.cpp
r128284 r128300 38 38 namespace WebCore { 39 39 40 MemoryObjectType GenericMemoryTypes::Undefined = 0;41 42 40 MemoryObjectType WebCoreMemoryTypes::Page = "Page"; 43 41 MemoryObjectType WebCoreMemoryTypes::DOM = "Page.DOM"; … … 58 56 MemoryObjectType WebCoreMemoryTypes::CachedResourceXSLT = "MemoryCache.XSLT"; 59 57 60 template<> void MemoryInstrumentationTraits::addInstrumentedObject<String>(MemoryInstrumentation* instrumentation, const String* const& string, MemoryObjectType ownerObjectType, MemoryOwningType owningType)61 {62 MemoryInstrumentationTraits::addInstrumentedObject<const String>(instrumentation, string, ownerObjectType, owningType);63 }64 65 template<> void MemoryInstrumentationTraits::addInstrumentedObject<const String>(MemoryInstrumentation* instrumentation, const String* const& string, MemoryObjectType ownerObjectType, MemoryOwningType owningType)66 {67 if (!string || instrumentation->visited(string))68 return;69 if (owningType == byPointer)70 instrumentation->countObjectSize(ownerObjectType, sizeof(String));71 instrumentation->addInstrumentedObject(string->impl(), ownerObjectType);72 }73 74 template<> void MemoryInstrumentationTraits::addInstrumentedObject<StringImpl>(MemoryInstrumentation* instrumentation, const StringImpl* const& stringImpl, MemoryObjectType ownerObjectType, MemoryOwningType owningType)75 {76 MemoryInstrumentationTraits::addInstrumentedObject<const StringImpl>(instrumentation, stringImpl, ownerObjectType, owningType);77 }78 79 template<> void MemoryInstrumentationTraits::addInstrumentedObject<const StringImpl>(MemoryInstrumentation* instrumentation, const StringImpl* const& stringImpl, MemoryObjectType ownerObjectType, MemoryOwningType)80 {81 if (!stringImpl || instrumentation->visited(stringImpl))82 return;83 instrumentation->countObjectSize(ownerObjectType, stringImpl->sizeInBytes());84 }85 86 58 template<> void MemoryInstrumentationTraits::addInstrumentedObject<KURL>(MemoryInstrumentation* instrumentation, const KURL* const& url, MemoryObjectType ownerObjectType, MemoryOwningType owningType) 87 59 { … … 100 72 } 101 73 102 template<> void MemoryInstrumentationTraits::addInstrumentedObject<AtomicString>(MemoryInstrumentation* instrumentation, const AtomicString* const& atomicString, MemoryObjectType ownerObjectType, MemoryOwningType owningType)103 {104 MemoryInstrumentationTraits::addInstrumentedObject<const AtomicString>(instrumentation, atomicString, ownerObjectType, owningType);105 }106 107 template<> void MemoryInstrumentationTraits::addInstrumentedObject<const AtomicString>(MemoryInstrumentation* instrumentation, const AtomicString* const& atomicString, MemoryObjectType ownerObjectType, MemoryOwningType owningType)108 {109 MemoryInstrumentationTraits::addInstrumentedObject<const String>(instrumentation, reinterpret_cast<const String* const>(atomicString), ownerObjectType, owningType);110 }111 112 74 } // namespace WebCore -
trunk/Source/WebCore/dom/WebCoreMemoryInstrumentation.h
r128284 r128300 43 43 template<> void MemoryInstrumentationTraits::addInstrumentedObject<const KURL>(MemoryInstrumentation*, const KURL* const&, MemoryObjectType, MemoryOwningType); 44 44 45 template<> void MemoryInstrumentationTraits::addInstrumentedObject<String>(MemoryInstrumentation*, const String* const&, MemoryObjectType, MemoryOwningType);46 template<> void MemoryInstrumentationTraits::addInstrumentedObject<const String>(MemoryInstrumentation*, const String* const&, MemoryObjectType, MemoryOwningType);47 48 template<> void MemoryInstrumentationTraits::addInstrumentedObject<StringImpl>(MemoryInstrumentation*, const StringImpl* const&, MemoryObjectType, MemoryOwningType);49 template<> void MemoryInstrumentationTraits::addInstrumentedObject<const StringImpl>(MemoryInstrumentation*, const StringImpl* const&, MemoryObjectType, MemoryOwningType);50 51 template<> void MemoryInstrumentationTraits::addInstrumentedObject<AtomicString>(MemoryInstrumentation*, const AtomicString* const&, MemoryObjectType, MemoryOwningType);52 template<> void MemoryInstrumentationTraits::addInstrumentedObject<const AtomicString>(MemoryInstrumentation*, const AtomicString* const&, MemoryObjectType, MemoryOwningType);53 54 55 45 // Link time guards with no body. 56 46 template<> void MemoryInstrumentationTraits::addObject<KURL>(MemoryInstrumentation*, const KURL* const&, MemoryObjectType, MemoryOwningType); 57 47 template<> void MemoryInstrumentationTraits::addObject<const KURL>(MemoryInstrumentation*, const KURL* const&, MemoryObjectType, MemoryOwningType); 58 59 template<> void MemoryInstrumentationTraits::addObject<String>(MemoryInstrumentation*, const String* const&, MemoryObjectType, MemoryOwningType);60 template<> void MemoryInstrumentationTraits::addObject<const String>(MemoryInstrumentation*, const String* const&, MemoryObjectType, MemoryOwningType);61 62 template<> void MemoryInstrumentationTraits::addObject<StringImpl>(MemoryInstrumentation*, const StringImpl* const&, MemoryObjectType, MemoryOwningType);63 template<> void MemoryInstrumentationTraits::addObject<const StringImpl>(MemoryInstrumentation*, const StringImpl* const&, MemoryObjectType, MemoryOwningType);64 65 template<> void MemoryInstrumentationTraits::addObject<AtomicString>(MemoryInstrumentation*, const AtomicString* const&, MemoryObjectType, MemoryOwningType);66 template<> void MemoryInstrumentationTraits::addObject<const AtomicString>(MemoryInstrumentation*, const AtomicString* const&, MemoryObjectType, MemoryOwningType);67 48 68 49 class WebCoreMemoryTypes { -
trunk/Source/WebCore/inspector/MemoryInstrumentationImpl.cpp
r128284 r128300 53 53 void MemoryInstrumentationImpl::countObjectSize(MemoryObjectType objectType, size_t size) 54 54 { 55 ASSERT(objectType != GenericMemoryTypes::Undefined);55 ASSERT(objectType); 56 56 TypeToSizeMap::AddResult result = m_totalSizes.add(objectType, size); 57 57 if (!result.isNewEntry) -
trunk/Source/WebCore/platform/SharedBuffer.cpp
r128284 r128300 251 251 void SharedBuffer::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 252 252 { 253 MemoryClassInfo info(memoryObjectInfo, this , GenericMemoryTypes::Undefined);253 MemoryClassInfo info(memoryObjectInfo, this); 254 254 info.addVector(m_buffer); 255 255 info.addVector(m_segments); -
trunk/Source/WebKit/chromium/ChangeLog
r128299 r128300 1 2012-09-12 Ilya Tikhonovsky <loislo@chromium.org> 2 3 Web Inspector: NMI move String* instrumentation to wtf. 4 https://bugs.webkit.org/show_bug.cgi?id=96405 5 6 Reviewed by Yury Semikhatsky. 7 8 This instrumentation is solving the problem with substrings and removes traits based code which is hard to upstream. 9 10 Tested by webkit_unit_tests. 11 12 * tests/MemoryInstrumentationTest.cpp: 13 (WebCore::TEST): 14 1 15 2012-09-12 Philippe Liard <pliard@google.com> 2 16 -
trunk/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp
r128284 r128300 180 180 void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 181 181 { 182 MemoryClassInfo info(memoryObjectInfo, this , GenericMemoryTypes::Undefined);182 MemoryClassInfo info(memoryObjectInfo, this); 183 183 } 184 184 int m_data; … … 246 246 MemoryInstrumentationImpl impl(visitedObjects); 247 247 StringOwnerInstrumented stringOwnerInstrumented; 248 stringOwnerInstrumented.m_name.characters(); // Force 16bit shadow creation. 248 249 impl.addRootObject(stringOwnerInstrumented); 249 EXPECT_EQ(s tringOwnerInstrumented.m_name.impl()->sizeInBytes(), impl.reportedSizeForAllTypes());250 EXPECT_EQ(sizeof(StringImpl) + stringOwnerInstrumented.m_name.length() * 2, impl.reportedSizeForAllTypes()); 250 251 EXPECT_EQ(2, visitedObjects.size()); 251 252 }
Note: See TracChangeset
for help on using the changeset viewer.