Changeset 124017 in webkit
- Timestamp:
- Jul 30, 2012 5:59:12 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r123999 r124017 1106 1106 dom/IdTargetObserverRegistry.cpp 1107 1107 dom/KeyboardEvent.cpp 1108 dom/MemoryInstrumentation.cpp 1108 1109 dom/MessageChannel.cpp 1109 1110 dom/MessageEvent.cpp -
trunk/Source/WebCore/ChangeLog
r124016 r124017 1 2012-07-26 Yury Semikhatsky <yurys@chromium.org> 2 3 Web Inspector: make MemoryInstrumentation methods private 4 https://bugs.webkit.org/show_bug.cgi?id=92379 5 6 Reviewed by Vsevolod Vlasov. 7 8 MemoryInstrumentation was refactored. 9 - All reporting methods on MemoryInstrumentation except add*Object are 10 private to enforce MemoryClassInfo usage. 11 - MemoryInstrumentation::Add*Member methods renamed to Add*Object 12 - String reporting is implemented directly in the MemoryInstrumentation, 13 not in its descendants. 14 15 * CMakeLists.txt: 16 * GNUmakefile.list.am: 17 * WebCore.gypi: 18 * WebCore.vcproj/WebCore.vcproj: 19 * WebCore.xcodeproj/project.pbxproj: 20 * bindings/v8/ScriptProfiler.cpp: 21 (WebCore::ScriptProfiler::collectBindingMemoryInfo): 22 * dom/MemoryInstrumentation.cpp: Added. 23 (WebCore): 24 (WebCore::MemoryInstrumentation::addString): 25 * dom/MemoryInstrumentation.h: 26 (WebCore::MemoryInstrumentation::addInstrumentedObject): 27 (WebCore::MemoryInstrumentation::addObject): 28 (MemoryInstrumentation): 29 (InstrumentedPointerBase): 30 (WebCore::MemoryInstrumentation::InstrumentedPointerBase::~InstrumentedPointerBase): 31 (InstrumentedPointer): 32 (WebCore::MemoryInstrumentation::InstrumentedPointer::InstrumentedPointer): 33 (WebCore::MemoryInstrumentation::OwningTraits::addInstrumentedObject): 34 (WebCore::MemoryInstrumentation::OwningTraits::addObject): 35 (WebCore::MemoryInstrumentation::addInstrumentedObjectImpl): 36 (WebCore::MemoryClassInfo::addInstrumentedMember): 37 (WebCore::MemoryClassInfo::addMember): 38 (WebCore): 39 (WebCore::MemoryInstrumentation::addObjectImpl): 40 (WebCore::MemoryInstrumentation::addInstrumentedCollection): 41 (WebCore::MemoryInstrumentation::calculateContainerSize): 42 * inspector/InspectorMemoryAgent.cpp: 43 (WebCore): 44 1 45 2012-07-30 Alexander Pavlov <apavlov@chromium.org> 2 46 -
trunk/Source/WebCore/GNUmakefile.list.am
r123966 r124017 1966 1966 Source/WebCore/dom/KeyboardEvent.cpp \ 1967 1967 Source/WebCore/dom/KeyboardEvent.h \ 1968 Source/WebCore/dom/MemoryInstrumentation.cpp \ 1968 1969 Source/WebCore/dom/MemoryInstrumentation.h \ 1969 1970 Source/WebCore/dom/MessageChannel.cpp \ -
trunk/Source/WebCore/Target.pri
r123830 r124017 413 413 dom/IdTargetObserverRegistry.cpp \ 414 414 dom/KeyboardEvent.cpp \ 415 dom/MemoryInstrumentation.cpp \ 415 416 dom/MessageChannel.cpp \ 416 417 dom/MessageEvent.cpp \ -
trunk/Source/WebCore/WebCore.gypi
r123969 r124017 5200 5200 'dom/IdTargetObserverRegistry.h', 5201 5201 'dom/KeyboardEvent.cpp', 5202 'dom/MemoryInstrumentation.cpp', 5202 5203 'dom/MemoryInstrumentation.h', 5203 5204 'dom/MessageChannel.cpp', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r123830 r124017 51532 51532 </File> 51533 51533 <File 51534 RelativePath="..\dom\MemoryInstrumentation.cpp" 51535 > 51536 </File> 51537 <File 51534 51538 RelativePath="..\dom\MemoryInstrumentation.h" 51535 51539 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r123830 r124017 6176 6176 F39BE95C12673BF400E0A674 /* ScriptArguments.h in Headers */ = {isa = PBXBuildFile; fileRef = F39BE95A12673BF400E0A674 /* ScriptArguments.h */; }; 6177 6177 F3ABFE0C130E9DA000E7F7D1 /* InstrumentingAgents.h in Headers */ = {isa = PBXBuildFile; fileRef = F3ABFE0B130E9DA000E7F7D1 /* InstrumentingAgents.h */; }; 6178 F3BFC9D315C177EC004244E5 /* MemoryInstrumentation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3BFC9D215C177EC004244E5 /* MemoryInstrumentation.cpp */; }; 6178 6179 F3D461481161D53200CA0D09 /* JSErrorHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3D461461161D53200CA0D09 /* JSErrorHandler.cpp */; }; 6179 6180 F3D461491161D53200CA0D09 /* JSErrorHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D461471161D53200CA0D09 /* JSErrorHandler.h */; }; … … 13500 13501 F39BE95A12673BF400E0A674 /* ScriptArguments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptArguments.h; sourceTree = "<group>"; }; 13501 13502 F3ABFE0B130E9DA000E7F7D1 /* InstrumentingAgents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InstrumentingAgents.h; sourceTree = "<group>"; }; 13503 F3BFC9D215C177EC004244E5 /* MemoryInstrumentation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryInstrumentation.cpp; sourceTree = "<group>"; }; 13502 13504 F3D461461161D53200CA0D09 /* JSErrorHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSErrorHandler.cpp; sourceTree = "<group>"; }; 13503 13505 F3D461471161D53200CA0D09 /* JSErrorHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSErrorHandler.h; sourceTree = "<group>"; }; … … 21575 21577 BC9A6145146859D9006057FD /* make_event_factory.pl */, 21576 21578 BC9A6146146859D9006057FD /* make_names.pl */, 21579 F3BFC9D215C177EC004244E5 /* MemoryInstrumentation.cpp */, 21577 21580 4F32BB1A14FA85AA00F6C1A3 /* MemoryInstrumentation.h */, 21578 21581 E1ADECCD0E76AD8B004A1A5E /* MessageChannel.cpp */, … … 27515 27518 BCB16C170979C3BD00467741 /* MemoryCache.cpp in Sources */, 27516 27519 9FFE3E7A11B59C5D0037874E /* MemoryInfo.cpp in Sources */, 27520 F3BFC9D315C177EC004244E5 /* MemoryInstrumentation.cpp in Sources */, 27517 27521 657EDA081385CB97004E0645 /* MemoryPressureHandler.cpp in Sources */, 27518 27522 657EDA0B1385CBD8004E0645 /* MemoryPressureHandlerMac.mm in Sources */, -
trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp
r122717 r124017 224 224 { 225 225 V8BindingPerIsolateData* data = V8BindingPerIsolateData::current(); 226 instrumentation->addInstrumented Member(data);226 instrumentation->addInstrumentedObject(data); 227 227 } 228 228 -
trunk/Source/WebCore/dom/MemoryInstrumentation.h
r123726 r124017 31 31 #ifndef MemoryInstrumentation_h 32 32 #define MemoryInstrumentation_h 33 #include <stdio.h>34 33 35 34 #include <wtf/Assertions.h> … … 56 55 }; 57 56 58 template <typename T> void addInstrumentedMember(const T& t) 59 { 60 OwningTraits<T>::addInstrumentedMember(this, t); 61 } 62 63 template <typename T> void addMember(const T& t, ObjectType objectType) 64 { 65 OwningTraits<T>::addMember(this, t, objectType); 66 } 67 57 template <typename T> void addInstrumentedObject(const T& t) 58 { 59 OwningTraits<T>::addInstrumentedObject(this, t); 60 } 61 62 template <typename Container> static size_t calculateContainerSize(const Container&, bool contentOnly = false); 63 64 protected: 65 class InstrumentedPointerBase { 66 public: 67 virtual ~InstrumentedPointerBase() { } 68 virtual void process(MemoryInstrumentation*) = 0; 69 }; 70 71 virtual void countObjectSize(ObjectType, size_t) = 0; 72 virtual void deferInstrumentedPointer(PassOwnPtr<InstrumentedPointerBase>) = 0; 73 virtual bool visited(const void*) = 0; 74 75 private: 76 template <typename T> friend class MemoryClassInfo; 77 template <typename T> class InstrumentedPointer : public InstrumentedPointerBase { 78 public: 79 explicit InstrumentedPointer(const T* pointer) : m_pointer(pointer) { } 80 virtual void process(MemoryInstrumentation*) OVERRIDE; 81 82 private: 83 const T* m_pointer; 84 }; 85 86 template <typename T> void addObject(const T& t, ObjectType objectType) 87 { 88 OwningTraits<T>::addObject(this, t, objectType); 89 } 90 void addString(const String&, ObjectType); 68 91 template <typename HashMapType> void addHashMap(const HashMapType&, ObjectType, bool contentOnly = false); 69 92 template <typename HashSetType> void addHashSet(const HashSetType&, ObjectType, bool contentOnly = false); … … 78 101 } 79 102 80 protected:81 103 enum OwningType { 82 104 byPointer, … … 86 108 template <typename T> 87 109 struct OwningTraits { // Default byReference implementation. 88 static void addInstrumented Member(MemoryInstrumentation* instrumentation, const T& t) { instrumentation->addInstrumentedMemberImpl(&t, byReference); }89 static void add Member(MemoryInstrumentation* instrumentation, const T& t, MemoryInstrumentation::ObjectType objectType) { instrumentation->addMemberImpl(&t, objectType, byReference); }110 static void addInstrumentedObject(MemoryInstrumentation* instrumentation, const T& t) { instrumentation->addInstrumentedObjectImpl(&t, byReference); } 111 static void addObject(MemoryInstrumentation* instrumentation, const T& t, MemoryInstrumentation::ObjectType objectType) { instrumentation->addObjectImpl(&t, objectType, byReference); } 90 112 }; 91 113 92 114 template <typename T> 93 115 struct OwningTraits<T*> { // Custom byPointer implementation. 94 static void addInstrumentedMember(MemoryInstrumentation* instrumentation, const T* const& t) { instrumentation->addInstrumentedMemberImpl(t, byPointer); } 95 static void addMember(MemoryInstrumentation* instrumentation, const T* const& t, MemoryInstrumentation::ObjectType objectType) { instrumentation->addMemberImpl(t, objectType, byPointer); } 96 }; 97 98 template <typename T> void addInstrumentedMemberImpl(const T* const&, OwningType); 99 template <typename T> void addInstrumentedMemberImpl(const OwnPtr<T>* const& object, MemoryInstrumentation::OwningType owningType) { addInstrumentedMemberImpl(object->get(), owningType); } 100 template <typename T> void addInstrumentedMemberImpl(const RefPtr<T>* const& object, MemoryInstrumentation::OwningType owningType) { addInstrumentedMemberImpl(object->get(), owningType); } 101 102 template <typename T> 103 void addMemberImpl(const T* const& object, ObjectType objectType, OwningType owningType) 104 { 105 if (!object || visited(object)) 106 return; 107 if (owningType == byReference) 108 return; 109 countObjectSize(objectType, sizeof(T)); 110 } 111 112 class InstrumentedPointerBase { 113 public: 114 virtual ~InstrumentedPointerBase() { } 115 116 virtual void process(MemoryInstrumentation*) = 0; 117 }; 118 119 template <typename Container> 120 size_t calculateContainerSize(const Container& container, bool contentOnly = false) 121 { 122 return (contentOnly ? 0 : sizeof(container)) + container.capacity() * sizeof(typename Container::ValueType); 123 } 124 125 private: 126 template <typename T> friend class MemoryClassInfo; 127 template <typename T> 128 class InstrumentedPointer : public InstrumentedPointerBase { 129 public: 130 explicit InstrumentedPointer(const T* pointer) : m_pointer(pointer) { } 131 132 virtual void process(MemoryInstrumentation*) OVERRIDE; 133 134 private: 135 const T* m_pointer; 136 }; 137 138 virtual void addString(const String&, ObjectType) = 0; 139 virtual void countObjectSize(ObjectType, size_t) = 0; 140 virtual void deferInstrumentedPointer(PassOwnPtr<InstrumentedPointerBase>) = 0; 141 virtual bool visited(const void*) = 0; 116 static void addInstrumentedObject(MemoryInstrumentation* instrumentation, const T* const& t) { instrumentation->addInstrumentedObjectImpl(t, byPointer); } 117 static void addObject(MemoryInstrumentation* instrumentation, const T* const& t, MemoryInstrumentation::ObjectType objectType) { instrumentation->addObjectImpl(t, objectType, byPointer); } 118 }; 119 120 template <typename T> void addInstrumentedObjectImpl(const T* const&, OwningType); 121 template <typename T> void addInstrumentedObjectImpl(const OwnPtr<T>* const&, OwningType); 122 template <typename T> void addInstrumentedObjectImpl(const RefPtr<T>* const&, OwningType); 123 124 template <typename T> void addObjectImpl(const T* const&, ObjectType, OwningType); 142 125 }; 143 126 … … 171 154 }; 172 155 173 // Link time guard for string members. They produce link error is a string is reported via addMember.174 template <> void MemoryInstrumentation::addMemberImpl<AtomicString>(const AtomicString* const&, MemoryInstrumentation::ObjectType, MemoryInstrumentation::OwningType);175 template <> void MemoryInstrumentation::addMemberImpl<String>(const String* const&, MemoryInstrumentation::ObjectType, MemoryInstrumentation::OwningType);176 177 178 template <typename T>179 void MemoryInstrumentation::addInstrumentedMemberImpl(const T* const& object, MemoryInstrumentation::OwningType owningType)180 {181 if (!object || visited(object))182 return;183 if (owningType == byReference) {184 MemoryObjectInfo memoryObjectInfo(this);185 object->reportMemoryUsage(&memoryObjectInfo);186 } else187 deferInstrumentedPointer(adoptPtr(new InstrumentedPointer<T>(object)));188 }189 190 191 156 template <typename T> 192 157 class MemoryClassInfo { … … 202 167 template <typename P> void visitBaseClass(const P* ptr) { ptr->P::reportMemoryUsage(m_memoryObjectInfo); } 203 168 204 template <typename M> void addInstrumentedMember(const M& member) { m_memoryInstrumentation->addInstrumented Member(member); }205 template <typename M> void addMember(const M& member) { m_memoryInstrumentation->add Member(member, m_objectType); }169 template <typename M> void addInstrumentedMember(const M& member) { m_memoryInstrumentation->addInstrumentedObject(member); } 170 template <typename M> void addMember(const M& member) { m_memoryInstrumentation->addObject(member, m_objectType); } 206 171 207 172 template <typename HashMapType> void addHashMap(const HashMapType& map) { m_memoryInstrumentation->addHashMap(map, m_objectType, true); } … … 222 187 }; 223 188 189 template <typename T> 190 void MemoryInstrumentation::addInstrumentedObjectImpl(const T* const& object, OwningType owningType) 191 { 192 if (!object || visited(object)) 193 return; 194 if (owningType == byReference) { 195 MemoryObjectInfo memoryObjectInfo(this); 196 object->reportMemoryUsage(&memoryObjectInfo); 197 } else 198 deferInstrumentedPointer(adoptPtr(new InstrumentedPointer<T>(object))); 199 } 200 201 template <typename T> 202 void MemoryInstrumentation::addInstrumentedObjectImpl(const OwnPtr<T>* const& object, OwningType owningType) 203 { 204 addInstrumentedObjectImpl(object->get(), owningType); 205 } 206 207 template <typename T> 208 void MemoryInstrumentation::addInstrumentedObjectImpl(const RefPtr<T>* const& object, OwningType owningType) 209 { 210 addInstrumentedObjectImpl(object->get(), owningType); 211 } 212 213 // Link time guard for string members. They produce link error is a string is reported via addObject. 214 template <> void MemoryInstrumentation::addObjectImpl<AtomicString>(const AtomicString* const&, MemoryInstrumentation::ObjectType, MemoryInstrumentation::OwningType); 215 template <> void MemoryInstrumentation::addObjectImpl<String>(const String* const&, MemoryInstrumentation::ObjectType, MemoryInstrumentation::OwningType); 216 217 template <typename T> 218 void MemoryInstrumentation::addObjectImpl(const T* const& object, ObjectType objectType, OwningType owningType) 219 { 220 if (!object || visited(object)) 221 return; 222 if (owningType == byReference) 223 return; 224 countObjectSize(objectType, sizeof(T)); 225 } 226 224 227 template<typename HashMapType> 225 228 void MemoryInstrumentation::addHashMap(const HashMapType& hashMap, ObjectType objectType, bool contentOnly) … … 246 249 typename CollectionType::const_iterator end = collection.end(); 247 250 for (typename CollectionType::const_iterator i = collection.begin(); i != end; ++i) 248 addInstrumented Member(*i);251 addInstrumentedObject(*i); 249 252 } 250 253 … … 264 267 return; 265 268 countObjectSize(objectType, calculateContainerSize(vector, contentOnly)); 269 } 270 271 template <typename Container> 272 size_t MemoryInstrumentation::calculateContainerSize(const Container& container, bool contentOnly) 273 { 274 return (contentOnly ? 0 : sizeof(container)) + container.capacity() * sizeof(typename Container::ValueType); 266 275 } 267 276 -
trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp
r124006 r124017 486 486 487 487 private: 488 virtual void addString(const String& string, ObjectType objectType)489 {490 if (string.isNull() || visited(string.impl()))491 return;492 countObjectSize(objectType, string.impl()->sizeInBytes());493 }494 495 488 virtual void countObjectSize(ObjectType objectType, size_t size) OVERRIDE 496 489 { … … 527 520 return; 528 521 529 m_domMemoryUsage.addInstrumented Member(node);522 m_domMemoryUsage.addInstrumentedObject(node); 530 523 m_domMemoryUsage.processDeferredInstrumentedPointers(); 531 524 } … … 533 526 void visitFrame(Frame* frame) 534 527 { 535 m_domMemoryUsage.addInstrumented Member(frame);528 m_domMemoryUsage.addInstrumentedObject(frame); 536 529 m_domMemoryUsage.processDeferredInstrumentedPointers(); 537 530 }
Note: See TracChangeset
for help on using the changeset viewer.