Changeset 121677 in webkit
- Timestamp:
- Jul 2, 2012 7:18:25 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r121676 r121677 1 2012-07-02 Alexei Filippov <alexeif@chromium.org> 2 3 Web Inspector: replace recursion with a stack in DOM nodes snapshot traversal. 4 https://bugs.webkit.org/show_bug.cgi?id=89889 5 6 Number of DOM nodes native snapshots can handle was limited 7 by the process stack size because of recursion used to traverse the nodes. 8 The patch changes the recursion to a stack based algorithm. 9 10 Reviewed by Yury Semikhatsky. 11 12 * dom/MemoryInstrumentation.h: 13 (MemoryInstrumentation): 14 (InstrumentedPointerBase): 15 (WebCore::MemoryInstrumentation::InstrumentedPointerBase::~InstrumentedPointerBase): 16 (InstrumentedPointer): 17 (WebCore::MemoryInstrumentation::InstrumentedPointer::InstrumentedPointer): 18 (WebCore::MemoryInstrumentation::reportInstrumentedPointer): 19 (WebCore): 20 (WebCore::::process): 21 * inspector/InspectorMemoryAgent.cpp: 22 (WebCore): 23 1 24 2012-07-02 Taiju Tsuiki <tzik@chromium.org> 2 25 -
trunk/Source/WebCore/dom/MemoryInstrumentation.h
r121658 r121677 34 34 #include <wtf/Forward.h> 35 35 #include <wtf/OwnPtr.h> 36 #include <wtf/PassOwnPtr.h> 36 37 #include <wtf/RefPtr.h> 37 38 … … 63 64 template <typename HashMapType> void reportHashMap(const HashMapType&, ObjectType); 64 65 66 protected: 67 class InstrumentedPointerBase { 68 public: 69 virtual ~InstrumentedPointerBase() { } 70 71 virtual void process(MemoryInstrumentation*) = 0; 72 }; 73 65 74 private: 66 75 friend class MemoryObjectInfo; 67 76 77 template <typename T> 78 class InstrumentedPointer : public InstrumentedPointerBase { 79 public: 80 explicit InstrumentedPointer(const T* pointer) : m_pointer(pointer) { } 81 82 virtual void process(MemoryInstrumentation*) OVERRIDE; 83 84 private: 85 const T* m_pointer; 86 }; 87 68 88 virtual void reportString(ObjectType, const String&) = 0; 69 89 virtual void countObjectSize(ObjectType, size_t) = 0; 90 virtual void deferInstrumentedPointer(PassOwnPtr<InstrumentedPointerBase>) = 0; 70 91 virtual bool visited(const void*) = 0; 71 92 }; … … 128 149 if (!object || visited(object)) 129 150 return; 130 MemoryObjectInfo memoryObjectInfo(this); 131 object->reportMemoryUsage(&memoryObjectInfo); 132 countObjectSize(memoryObjectInfo.objectType(), memoryObjectInfo.objectSize()); 151 deferInstrumentedPointer(adoptPtr(new InstrumentedPointer<T>(object))); 133 152 } 134 153 … … 142 161 } 143 162 144 145 163 template<typename HashMapType> 146 164 void MemoryInstrumentation::reportHashMap(const HashMapType& hashMap, ObjectType objectType) … … 150 168 } 151 169 170 template<typename T> 171 void MemoryInstrumentation::InstrumentedPointer<T>::process(MemoryInstrumentation* memoryInstrumentation) 172 { 173 MemoryObjectInfo memoryObjectInfo(memoryInstrumentation); 174 m_pointer->reportMemoryUsage(&memoryObjectInfo); 175 memoryInstrumentation->countObjectSize(memoryObjectInfo.objectType(), memoryObjectInfo.objectSize()); 176 } 177 152 178 } // namespace WebCore 153 179 -
trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp
r121658 r121677 55 55 #include <wtf/ArrayBufferView.h> 56 56 #include <wtf/HashSet.h> 57 #include <wtf/OwnPtr.h> 58 #include <wtf/PassOwnPtr.h> 59 #include <wtf/Vector.h> 57 60 #include <wtf/text/StringBuilder.h> 58 61 #include <wtf/text/StringImpl.h> … … 457 460 } 458 461 462 void processDeferredInstrumentedPointers() 463 { 464 while (!m_deferredInstrumentedPointers.isEmpty()) { 465 OwnPtr<InstrumentedPointerBase> pointer = m_deferredInstrumentedPointers.last().release(); 466 m_deferredInstrumentedPointers.removeLast(); 467 pointer->process(this); 468 } 469 } 470 459 471 private: 460 472 virtual void reportString(ObjectType objectType, const String& string) … … 465 477 } 466 478 467 virtual void countObjectSize(ObjectType objectType, size_t size) 479 virtual void countObjectSize(ObjectType objectType, size_t size) OVERRIDE 468 480 { 469 481 ASSERT(objectType >= 0 && objectType < LastTypeEntry); … … 471 483 } 472 484 473 virtual bool visited(const void* object) 485 virtual void deferInstrumentedPointer(PassOwnPtr<InstrumentedPointerBase> pointer) OVERRIDE 486 { 487 m_deferredInstrumentedPointers.append(pointer); 488 } 489 490 virtual bool visited(const void* object) OVERRIDE 474 491 { 475 492 return !m_visitedObjects.add(object).isNewEntry; 476 493 } 494 477 495 size_t m_totalSizes[LastTypeEntry]; 478 496 VisitedObjects& m_visitedObjects; 497 Vector<OwnPtr<InstrumentedPointerBase> > m_deferredInstrumentedPointers; 479 498 }; 480 499 … … 487 506 } 488 507 489 virtual void visitNode(Node* node) 508 virtual void visitNode(Node* node) OVERRIDE 490 509 { 491 510 if (node->document() && node->document()->frame() && m_page != node->document()->frame()->page()) … … 493 512 494 513 m_domMemoryUsage.reportInstrumentedPointer(node); 514 m_domMemoryUsage.processDeferredInstrumentedPointers(); 495 515 } 496 516
Note: See TracChangeset
for help on using the changeset viewer.