Changeset 127571 in webkit
- Timestamp:
- Sep 5, 2012 2:19:46 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r127568 r127571 1 2012-09-04 Ilya Tikhonovsky <loislo@chromium.org> 2 3 Web Inspector: NMI: replace ObjectType enum with static const char* string identifiers. 4 https://bugs.webkit.org/show_bug.cgi?id=95739 5 6 Reviewed by Yury Semikhatsky. 7 8 When we go deeper into different parts of browser like skia, chromium itself etc. 9 we can't use a single enum for all reported object types. 10 The current idea is to use plain simple strings as ObjectType identifiers. 11 In the future patches we will extract these identifiers into separate class or namespace 12 and and split it between components. 13 14 * dom/MemoryInstrumentation.cpp: 15 (WebCore): 16 * dom/MemoryInstrumentation.h: 17 (MemoryInstrumentation): 18 * inspector/InspectorMemoryAgent.cpp: 19 (WebCore::addMemoryBlockFor): 20 (WebCore): 21 * inspector/MemoryInstrumentationImpl.cpp: 22 (WebCore::MemoryInstrumentationImpl::MemoryInstrumentationImpl): 23 (WebCore::MemoryInstrumentationImpl::countObjectSize): 24 * inspector/MemoryInstrumentationImpl.h: 25 (WebCore::MemoryInstrumentationImpl::totalSize): 26 (WebCore::MemoryInstrumentationImpl::reportedSizeForAllTypes): 27 (MemoryInstrumentationImpl): 28 1 29 2012-09-05 Patrick Gansterer <paroga@webkit.org> 2 30 -
trunk/Source/WebCore/dom/MemoryInstrumentation.cpp
r126154 r127571 38 38 namespace WebCore { 39 39 40 const char* MemoryInstrumentation::Other = "Other"; 41 const char* MemoryInstrumentation::DOM = "DOM"; 42 const char* MemoryInstrumentation::CSS = "CSS"; 43 const char* MemoryInstrumentation::Binding = "Binding"; 44 const char* MemoryInstrumentation::Loader = "Loader"; 45 const char* MemoryInstrumentation::MemoryCacheStructures = "MemoryCacheStructures"; 46 const char* MemoryInstrumentation::CachedResource = "CachedResource"; 47 const char* MemoryInstrumentation::CachedResourceCSS = "CachedResourceCSS"; 48 const char* MemoryInstrumentation::CachedResourceFont = "CachedResourceFont"; 49 const char* MemoryInstrumentation::CachedResourceImage = "CachedResourceImage"; 50 const char* MemoryInstrumentation::CachedResourceScript = "CachedResourceScript"; 51 const char* MemoryInstrumentation::CachedResourceSVG = "CachedResourceSVG"; 52 const char* MemoryInstrumentation::CachedResourceShader = "CachedResourceShader"; 53 const char* MemoryInstrumentation::CachedResourceXSLT = "CachedResourceXSLT"; 54 40 55 void MemoryInstrumentation::addInstrumentedObjectImpl(const String* const& string, ObjectType objectType, OwningType owningType) 41 56 { -
trunk/Source/WebCore/dom/MemoryInstrumentation.h
r126926 r127571 49 49 virtual ~MemoryInstrumentation() { } 50 50 51 enum ObjectType { 52 Other, 53 DOM, 54 CSS, 55 Binding, 56 Loader, 57 MemoryCacheStructures, 58 CachedResource, 59 CachedResourceCSS, 60 CachedResourceFont, 61 CachedResourceImage, 62 CachedResourceScript, 63 CachedResourceSVG, 64 CachedResourceShader, 65 CachedResourceXSLT, 66 LastTypeEntry 67 }; 51 typedef const char* ObjectType; 52 53 static const char* Other; 54 static const char* DOM; 55 static const char* CSS; 56 static const char* Binding; 57 static const char* Loader; 58 static const char* MemoryCacheStructures; 59 static const char* CachedResource; 60 static const char* CachedResourceCSS; 61 static const char* CachedResourceFont; 62 static const char* CachedResourceImage; 63 static const char* CachedResourceScript; 64 static const char* CachedResourceSVG; 65 static const char* CachedResourceShader; 66 static const char* CachedResourceXSLT; 68 67 69 68 template <typename T> void addRootObject(const T& t) -
trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp
r127443 r127571 441 441 } 442 442 443 static voidaddMemoryBlockFor(TypeBuilder::Array<InspectorMemoryBlock>* array, size_t size, const char* name)443 static size_t addMemoryBlockFor(TypeBuilder::Array<InspectorMemoryBlock>* array, size_t size, const char* name) 444 444 { 445 445 RefPtr<InspectorMemoryBlock> result = InspectorMemoryBlock::create().setName(name); 446 446 result->setSize(size); 447 447 array->addItem(result); 448 return size; 448 449 } 449 450 … … 485 486 size_t totalSize = 0; 486 487 487 COMPILE_ASSERT(MemoryInstrumentation::LastTypeEntry == MemoryInstrumentation::CachedResourceXSLT + 1, object_type_enum_was_changed_please_fix_the_implementation);488 for (int i = MemoryInstrumentation::MemoryCacheStructures; i < MemoryInstrumentation::LastTypeEntry; ++i)489 totalSize += m_memoryInstrumentation.totalSize(static_cast<MemoryInstrumentation::ObjectType>(i));490 491 488 RefPtr<TypeBuilder::Array<InspectorMemoryBlock> > children = TypeBuilder::Array<InspectorMemoryBlock>::create(); 492 addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::MemoryCacheStructures), MemoryBlockName::memoryCacheStructures);493 addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::CachedResource), MemoryBlockName::cachedResource);494 addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::CachedResourceCSS), MemoryBlockName::cachedResourceCSS);495 addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::CachedResourceFont), MemoryBlockName::cachedResourceFont);496 addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::CachedResourceImage), MemoryBlockName::cachedResourceImage);497 addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::CachedResourceScript), MemoryBlockName::cachedResourceScript);498 addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::CachedResourceSVG), MemoryBlockName::cachedResourceSVG);499 addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::CachedResourceShader), MemoryBlockName::cachedResourceShader);500 addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::CachedResourceXSLT), MemoryBlockName::cachedResourceXSLT);489 totalSize += addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::MemoryCacheStructures), MemoryBlockName::memoryCacheStructures); 490 totalSize += addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::CachedResource), MemoryBlockName::cachedResource); 491 totalSize += addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::CachedResourceCSS), MemoryBlockName::cachedResourceCSS); 492 totalSize += addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::CachedResourceFont), MemoryBlockName::cachedResourceFont); 493 totalSize += addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::CachedResourceImage), MemoryBlockName::cachedResourceImage); 494 totalSize += addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::CachedResourceScript), MemoryBlockName::cachedResourceScript); 495 totalSize += addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::CachedResourceSVG), MemoryBlockName::cachedResourceSVG); 496 totalSize += addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::CachedResourceShader), MemoryBlockName::cachedResourceShader); 497 totalSize += addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::CachedResourceXSLT), MemoryBlockName::cachedResourceXSLT); 501 498 502 499 RefPtr<InspectorMemoryBlock> block = InspectorMemoryBlock::create().setName(MemoryBlockName::memoryCache); … … 509 506 { 510 507 size_t totalSize = 0; 511 for (int i = MemoryInstrumentation::Other; i < MemoryInstrumentation::MemoryCacheStructures; ++i)512 totalSize += m_memoryInstrumentation.totalSize(static_cast<MemoryInstrumentation::ObjectType>(i));513 508 514 509 RefPtr<TypeBuilder::Array<InspectorMemoryBlock> > domChildren = TypeBuilder::Array<InspectorMemoryBlock>::create(); 515 addMemoryBlockFor(domChildren.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::Other), MemoryBlockName::domTreeOther);516 addMemoryBlockFor(domChildren.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::DOM), MemoryBlockName::domTreeDOM);517 addMemoryBlockFor(domChildren.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::CSS), MemoryBlockName::domTreeCSS);518 addMemoryBlockFor(domChildren.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::Binding), MemoryBlockName::domTreeBinding);519 addMemoryBlockFor(domChildren.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::Loader), MemoryBlockName::domTreeLoader);510 totalSize += addMemoryBlockFor(domChildren.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::Other), MemoryBlockName::domTreeOther); 511 totalSize += addMemoryBlockFor(domChildren.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::DOM), MemoryBlockName::domTreeDOM); 512 totalSize += addMemoryBlockFor(domChildren.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::CSS), MemoryBlockName::domTreeCSS); 513 totalSize += addMemoryBlockFor(domChildren.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::Binding), MemoryBlockName::domTreeBinding); 514 totalSize += addMemoryBlockFor(domChildren.get(), m_memoryInstrumentation.totalSize(MemoryInstrumentation::Loader), MemoryBlockName::domTreeLoader); 520 515 521 516 RefPtr<InspectorMemoryBlock> dom = InspectorMemoryBlock::create().setName(MemoryBlockName::dom); -
trunk/Source/WebCore/inspector/MemoryInstrumentationImpl.cpp
r124306 r127571 40 40 : m_visitedObjects(visitedObjects) 41 41 { 42 for (int i = 0; i < LastTypeEntry; ++i)43 m_totalSizes[i] = 0;44 42 } 45 43 … … 55 53 void MemoryInstrumentationImpl::countObjectSize(ObjectType objectType, size_t size) 56 54 { 57 ASSERT(objectType >= 0 && objectType < LastTypeEntry); 58 m_totalSizes[objectType] += size; 55 TypeToSizeMap::AddResult result = m_totalSizes.add(objectType, size); 56 if (!result.isNewEntry) 57 result.iterator->second += size; 59 58 } 60 59 -
trunk/Source/WebCore/inspector/MemoryInstrumentationImpl.h
r124412 r127571 34 34 #include "MemoryInstrumentation.h" 35 35 36 #include <wtf/HashMap.h> 36 37 #include <wtf/HashSet.h> 37 38 #include <wtf/Vector.h> … … 48 49 size_t totalSize(ObjectType objectType) const 49 50 { 50 ASSERT(objectType >= 0 && objectType < LastTypeEntry);51 return m_totalSizes[objectType];51 TypeToSizeMap::const_iterator i = m_totalSizes.find(objectType); 52 return i == m_totalSizes.end() ? 0 : i->second; 52 53 } 53 54 … … 55 56 { 56 57 size_t size = 0; 57 for ( int i = 0; i < LastTypeEntry; ++i)58 size += m_totalSizes[i];58 for (TypeToSizeMap::const_iterator i = m_totalSizes.begin(); i != m_totalSizes.end(); ++i) 59 size += i->second; 59 60 return size; 60 61 } … … 66 67 virtual void processDeferredInstrumentedPointers() OVERRIDE; 67 68 68 size_t m_totalSizes[LastTypeEntry]; 69 typedef HashMap<ObjectType, size_t> TypeToSizeMap; 70 TypeToSizeMap m_totalSizes; 69 71 VisitedObjects& m_visitedObjects; 70 72 Vector<OwnPtr<InstrumentedPointerBase> > m_deferredInstrumentedPointers; -
trunk/Source/WebKit/chromium/ChangeLog
r127558 r127571 1 2012-09-04 Ilya Tikhonovsky <loislo@chromium.org> 2 3 Web Inspector: NMI: replace ObjectType enum with static const char* string identifiers. 4 https://bugs.webkit.org/show_bug.cgi?id=95739 5 6 Reviewed by Yury Semikhatsky. 7 8 When we go deeper into different parts of browser like skia, chromium itself etc. 9 we can't use a single enum for all reported object types. 10 The current idea is to use plain simple strings as ObjectType identifiers. 11 In the future patches we will extract these identifiers into separate class or namespace 12 and and split it between components. 13 14 * tests/MemoryInstrumentationTest.cpp: 15 (WebCore::TEST): 16 (WebCore): 17 1 18 2012-09-04 Keishi Hattori <keishi@webkit.org> 2 19 -
trunk/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp
r126154 r127571 256 256 } 257 257 258 TEST(MemoryInstrumentationTest, speedTest) 259 { 260 VisitedObjects visitedObjects; 261 MemoryInstrumentationImpl impl(visitedObjects); 262 NonVirtualInstrumented nonVirtualInstrumented; 263 for (unsigned i = 0; i < 10000000; ++i) { 264 impl.addRootObject(&nonVirtualInstrumented); 265 visitedObjects.clear(); 266 } 267 } 268 258 269 } // namespace 259 270
Note: See TracChangeset
for help on using the changeset viewer.