Changeset 121530 in webkit
- Timestamp:
- Jun 29, 2012 1:46:04 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r121529 r121530 1 2012-06-26 Yury Semikhatsky <yurys@chromium.org> 2 3 Web Inspector: add character data to the DOM section of native memory view 4 https://bugs.webkit.org/show_bug.cgi?id=89968 5 6 Reviewed by Vsevolod Vlasov. 7 8 Count strings referenced from CharacterData node and its descendants 9 as part of the DOM tree structures in the native memory view. 10 11 * dom/CharacterData.cpp: 12 (WebCore::CharacterData::reportMemoryUsage): 13 (WebCore): 14 * dom/CharacterData.h: 15 (CharacterData): 16 * dom/MemoryInstrumentation.h: 17 (MemoryInstrumentation): 18 (WebCore::MemoryObjectInfo::reportString): 19 (MemoryObjectInfo): 20 * inspector/InspectorMemoryAgent.cpp: 21 (WebCore): 22 (WebCore::domTreeInfo): 23 (WebCore::jsExternalResourcesInfo): 24 (WebCore::InspectorMemoryAgent::getProcessMemoryDistribution): 25 * inspector/front-end/NativeMemorySnapshotView.js: 26 (WebInspector.MemoryBlockViewProperties._initialize): 27 1 28 2012-06-29 Eric Seidel <eric@webkit.org> 2 29 -
trunk/Source/WebCore/dom/CharacterData.cpp
r119705 r121530 27 27 #include "ExceptionCode.h" 28 28 #include "InspectorInstrumentation.h" 29 #include "MemoryInstrumentation.h" 29 30 #include "MutationEvent.h" 30 31 #include "MutationObserverInterestGroup.h" … … 93 94 } 94 95 96 void CharacterData::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 97 { 98 memoryObjectInfo->reportObjectInfo(this, MemoryInstrumentation::DOM); 99 Node::reportMemoryUsage(memoryObjectInfo); 100 memoryObjectInfo->reportString(m_data); 101 } 102 95 103 void CharacterData::appendData(const String& data, ExceptionCode&) 96 104 { -
trunk/Source/WebCore/dom/CharacterData.h
r113312 r121530 48 48 unsigned parserAppendData(const UChar*, unsigned dataLength, unsigned lengthLimit); 49 49 50 virtual void reportMemoryUsage(MemoryObjectInfo*) const; 51 50 52 protected: 51 53 CharacterData(Document* document, const String& text, ConstructionType type) -
trunk/Source/WebCore/dom/MemoryInstrumentation.h
r121022 r121530 32 32 #define MemoryInstrumentation_h 33 33 34 #include <wtf/Forward.h> 34 35 #include <wtf/OwnPtr.h> 35 36 #include <wtf/RefPtr.h> … … 63 64 friend class MemoryObjectInfo; 64 65 66 virtual void reportString(ObjectType, const String&) = 0; 65 67 virtual void countObjectSize(ObjectType, size_t) = 0; 66 68 virtual bool visited(const void*) = 0; … … 105 107 } 106 108 109 void reportString(const String& string) 110 { 111 m_memoryInstrumentation->reportString(objectType(), string); 112 } 113 107 114 MemoryInstrumentation::ObjectType objectType() const { return m_objectType; } 108 115 size_t objectSize() const { return m_objectSize; } -
trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp
r121144 r121530 56 56 #include <wtf/HashSet.h> 57 57 #include <wtf/text/StringBuilder.h> 58 #include <wtf/text/StringImpl.h> 59 #include <wtf/text/WTFString.h> 58 60 59 61 using WebCore::TypeBuilder::Memory::DOMGroup; … … 93 95 namespace { 94 96 97 typedef HashSet<const void*> VisitedObjects; 98 95 99 String nodeName(Node* node) 96 100 { … … 102 106 size_t stringSize(StringImpl* string) 103 107 { 108 // TODO: support substrings 104 109 size_t size = string->length(); 105 if (!string->is8Bit()) 110 if (string->is8Bit()) { 111 if (string->has16BitShadow()) { 112 size += 2 * size; 113 if (string->hasTerminatingNullCharacter()) 114 size += 2; 115 } 116 } else 106 117 size *= 2; 107 118 return size + sizeof(*string); … … 316 327 class ExternalResourceVisitor : public ExternalStringVisitor, public ExternalArrayVisitor { 317 328 public: 318 ExternalResourceVisitor() 319 : m_jsExternalStringSize(0) 329 explicit ExternalResourceVisitor(VisitedObjects& visitedObjects) 330 : m_visitedObjects(visitedObjects) 331 , m_jsExternalStringSize(0) 320 332 , m_externalArraySize(0) 321 333 { } … … 328 340 { 329 341 ArrayBuffer* buffer = bufferView->buffer().get(); 330 if (m_ arrayBuffers.add(buffer).isNewEntry)342 if (m_visitedObjects.add(buffer).isNewEntry) 331 343 m_externalArraySize += buffer->byteLength(); 332 344 } 333 345 virtual void visitJSExternalString(StringImpl* string) 334 346 { 335 int size = stringSize(string); 336 m_jsExternalStringSize += size; 337 } 338 347 if (m_visitedObjects.add(string).isNewEntry) 348 m_jsExternalStringSize += stringSize(string); 349 } 350 351 VisitedObjects& m_visitedObjects; 339 352 size_t m_jsExternalStringSize; 340 353 size_t m_externalArraySize; 341 HashSet<ArrayBuffer*> m_arrayBuffers;342 354 }; 343 355 … … 419 431 class MemoryInstrumentationImpl : public MemoryInstrumentation { 420 432 public: 421 MemoryInstrumentationImpl() 433 explicit MemoryInstrumentationImpl(VisitedObjects& visitedObjects) 434 : m_visitedObjects(visitedObjects) 422 435 { 423 436 for (int i = 0; i < LastTypeEntry; ++i) … … 443 456 444 457 private: 458 virtual void reportString(ObjectType objectType, const String& string) 459 { 460 if (visited(string.impl())) 461 return; 462 countObjectSize(objectType, stringSize(string.impl())); 463 } 464 445 465 virtual void countObjectSize(ObjectType objectType, size_t size) 446 466 { … … 454 474 } 455 475 size_t m_totalSizes[LastTypeEntry]; 456 typedef HashSet<const void*> VisitedObjects; 457 VisitedObjects m_visitedObjects; 476 VisitedObjects& m_visitedObjects; 458 477 }; 459 478 460 479 class DOMTreesIterator : public NodeWrapperVisitor { 461 480 public: 462 explicit DOMTreesIterator(Page* page) : m_page(page) { } 481 DOMTreesIterator(Page* page, VisitedObjects& visitedObjects) 482 : m_page(page) 483 , m_domMemoryUsage(visitedObjects) 484 { 485 } 463 486 464 487 virtual void visitNode(Node* node) … … 479 502 } 480 503 481 static PassRefPtr<InspectorMemoryBlock> domTreeInfo(Page* page )482 { 483 DOMTreesIterator domTreesIterator(page );504 static PassRefPtr<InspectorMemoryBlock> domTreeInfo(Page* page, VisitedObjects& visitedObjects) 505 { 506 DOMTreesIterator domTreesIterator(page, visitedObjects); 484 507 ScriptProfiler::visitNodeWrappers(&domTreesIterator); 485 508 … … 514 537 } 515 538 516 static PassRefPtr<InspectorMemoryBlock> jsExternalResourcesInfo( )517 { 518 ExternalResourceVisitor visitor ;539 static PassRefPtr<InspectorMemoryBlock> jsExternalResourcesInfo(VisitedObjects& visitedObjects) 540 { 541 ExternalResourceVisitor visitor(visitedObjects); 519 542 ScriptProfiler::visitExternalStrings(&visitor); 520 543 ScriptProfiler::visitExternalArrays(&visitor); … … 543 566 processMemory->setSize(privateBytes); 544 567 568 VisitedObjects visitedObjects; 545 569 RefPtr<TypeBuilder::Array<InspectorMemoryBlock> > children = TypeBuilder::Array<InspectorMemoryBlock>::create(); 546 570 children->addItem(jsHeapInfo()); 547 children->addItem(jsExternalResourcesInfo());548 571 children->addItem(inspectorData()); 549 572 children->addItem(memoryCacheInfo()); 550 573 children->addItem(renderTreeInfo(m_page)); // TODO: collect for all pages? 551 children->addItem(domTreeInfo(m_page)); // TODO: collect for all pages? 574 children->addItem(domTreeInfo(m_page, visitedObjects)); // TODO: collect for all pages? 575 children->addItem(jsExternalResourcesInfo(visitedObjects)); 552 576 processMemory->setChildren(children); 553 577 } -
trunk/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js
r121144 r121530 217 217 addBlock("hsl( 0, 0%, 100%)", "ProcessPrivateMemory", "Total"); 218 218 addBlock("hsl( 0, 0%, 80%)", "Other", "Other"); 219 addBlock("hsl(300, 30%, 80%)", "DOM", "DOM tree structures"); 219 220 addBlock("hsl( 90, 60%, 80%)", "JSHeapAllocated", "JavaScript heap"); 220 221 addBlock("hsl( 90, 80%, 80%)", "JSHeapUsed", "Used JavaScript heap");
Note: See TracChangeset
for help on using the changeset viewer.