| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef MemoryInstrumentation_h | 31 #ifndef MemoryInstrumentation_h |
| 32 #define MemoryInstrumentation_h | 32 #define MemoryInstrumentation_h |
| 33 | 33 |
| 34 #include <wtf/OwnPtr.h> | 34 #include "wtf/OwnPtr.h" |
| 35 #include <wtf/PassOwnPtr.h> | 35 #include "wtf/PassOwnPtr.h" |
| 36 #include <wtf/RefPtr.h> | 36 #include "wtf/RefPtr.h" |
| 37 #include "wtf/WTFExport.h" |
| 37 | 38 |
| 38 #define DEBUG_POINTER_INSTRUMENTATION 0 | 39 #define DEBUG_POINTER_INSTRUMENTATION 0 |
| 39 | 40 |
| 40 namespace WTF { | 41 namespace WTF { |
| 41 | 42 |
| 42 class MemoryClassInfo; | 43 class MemoryClassInfo; |
| 43 class MemoryObjectInfo; | 44 class MemoryObjectInfo; |
| 44 class MemoryInstrumentation; | 45 class MemoryInstrumentation; |
| 45 | 46 |
| 46 typedef const char* MemoryObjectType; | 47 typedef const char* MemoryObjectType; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 virtual bool visited(const void*) = 0; | 87 virtual bool visited(const void*) = 0; |
| 87 virtual bool checkCountedObject(const void*) = 0; | 88 virtual bool checkCountedObject(const void*) = 0; |
| 88 | 89 |
| 89 virtual void reportNode(const MemoryObjectInfo&) = 0; | 90 virtual void reportNode(const MemoryObjectInfo&) = 0; |
| 90 virtual void reportEdge(const void* target, const char* edgeName, MemberType
) = 0; | 91 virtual void reportEdge(const void* target, const char* edgeName, MemberType
) = 0; |
| 91 virtual void reportLeaf(const MemoryObjectInfo&, const char* edgeName) = 0; | 92 virtual void reportLeaf(const MemoryObjectInfo&, const char* edgeName) = 0; |
| 92 virtual void reportBaseAddress(const void* base, const void* real) = 0; | 93 virtual void reportBaseAddress(const void* base, const void* real) = 0; |
| 93 virtual int registerString(const char*) = 0; | 94 virtual int registerString(const char*) = 0; |
| 94 }; | 95 }; |
| 95 | 96 |
| 96 class MemoryInstrumentation { | 97 class WTF_EXPORT MemoryInstrumentation { |
| 97 public: | 98 public: |
| 98 explicit MemoryInstrumentation(MemoryInstrumentationClient*); | 99 explicit MemoryInstrumentation(MemoryInstrumentationClient*); |
| 99 virtual ~MemoryInstrumentation(); | 100 virtual ~MemoryInstrumentation(); |
| 100 | 101 |
| 101 template <typename T> void addRootObject(const T& t, MemoryObjectType object
Type = 0) | 102 template <typename T> void addRootObject(const T& t, MemoryObjectType object
Type = 0) |
| 102 { | 103 { |
| 103 MemberTypeTraits<T>::addRootObject(this, t, objectType); | 104 MemberTypeTraits<T>::addRootObject(this, t, objectType); |
| 104 processDeferredObjects(); | 105 processDeferredObjects(); |
| 105 } | 106 } |
| 106 | 107 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 136 | 137 |
| 137 template <typename U> static no deduce(U*, Helper<void (BaseMixin::*)(Me
moryObjectInfo*) const, &U::reportMemoryUsage>* = 0); | 138 template <typename U> static no deduce(U*, Helper<void (BaseMixin::*)(Me
moryObjectInfo*) const, &U::reportMemoryUsage>* = 0); |
| 138 static yes deduce(...); | 139 static yes deduce(...); |
| 139 | 140 |
| 140 public: | 141 public: |
| 141 static const bool result = sizeof(yes) == sizeof(deduce((Base*)(0))); | 142 static const bool result = sizeof(yes) == sizeof(deduce((Base*)(0))); |
| 142 | 143 |
| 143 }; | 144 }; |
| 144 | 145 |
| 145 protected: | 146 protected: |
| 146 class WrapperBase { | 147 class WTF_EXPORT WrapperBase { |
| 147 public: | 148 public: |
| 148 WrapperBase(MemoryObjectType, const void* pointer); | 149 WrapperBase(MemoryObjectType, const void* pointer); |
| 149 virtual ~WrapperBase() { } | 150 virtual ~WrapperBase() { } |
| 150 void process(MemoryInstrumentation*); | 151 void process(MemoryInstrumentation*); |
| 151 void processPointer(MemoryInstrumentation*, bool isRoot); | 152 void processPointer(MemoryInstrumentation*, bool isRoot); |
| 152 void processRootObjectRef(MemoryInstrumentation*); | 153 void processRootObjectRef(MemoryInstrumentation*); |
| 153 | 154 |
| 154 protected: | 155 protected: |
| 155 virtual void callReportMemoryUsage(MemoryObjectInfo*) = 0; | 156 virtual void callReportMemoryUsage(MemoryObjectInfo*) = 0; |
| 156 const void* m_pointer; | 157 const void* m_pointer; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 #if COMPILER(MSVC) | 242 #if COMPILER(MSVC) |
| 242 template <typename T> struct FN { | 243 template <typename T> struct FN { |
| 243 static char* fn() { return const_cast<char*>(__FUNCTION__); } | 244 static char* fn() { return const_cast<char*>(__FUNCTION__); } |
| 244 }; | 245 }; |
| 245 | 246 |
| 246 template <typename T> char* fn() { return FN<T>::fn(); } | 247 template <typename T> char* fn() { return FN<T>::fn(); } |
| 247 #else | 248 #else |
| 248 template <typename T> char* fn() { return const_cast<char*>(__PRETTY_FUNCTION__)
; } | 249 template <typename T> char* fn() { return const_cast<char*>(__PRETTY_FUNCTION__)
; } |
| 249 #endif | 250 #endif |
| 250 | 251 |
| 251 class MemoryClassInfo { | 252 class WTF_EXPORT MemoryClassInfo { |
| 252 public: | 253 public: |
| 253 template<typename T> | 254 template<typename T> |
| 254 MemoryClassInfo(MemoryObjectInfo* memoryObjectInfo, const T* pointer, Memory
ObjectType objectType = 0, size_t actualSize = sizeof(T)) | 255 MemoryClassInfo(MemoryObjectInfo* memoryObjectInfo, const T* pointer, Memory
ObjectType objectType = 0, size_t actualSize = sizeof(T)) |
| 255 : m_memoryObjectInfo(memoryObjectInfo) | 256 : m_memoryObjectInfo(memoryObjectInfo) |
| 256 , m_memoryInstrumentation(0) | 257 , m_memoryInstrumentation(0) |
| 257 , m_objectType(0) | 258 , m_objectType(0) |
| 258 , m_skipMembers(false) | 259 , m_skipMembers(false) |
| 259 { | 260 { |
| 260 init(pointer, fn<T>(), objectType, actualSize); | 261 init(pointer, fn<T>(), objectType, actualSize); |
| 261 } | 262 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 void reportMemoryUsage(const ParsedURL*, MemoryObjectInfo*); | 390 void reportMemoryUsage(const ParsedURL*, MemoryObjectInfo*); |
| 390 | 391 |
| 391 class URLString; | 392 class URLString; |
| 392 void reportMemoryUsage(const URLString*, MemoryObjectInfo*); | 393 void reportMemoryUsage(const URLString*, MemoryObjectInfo*); |
| 393 | 394 |
| 394 } // namespace WTF | 395 } // namespace WTF |
| 395 | 396 |
| 396 using WTF::MemoryReporterTag; | 397 using WTF::MemoryReporterTag; |
| 397 | 398 |
| 398 #endif // !defined(MemoryInstrumentation_h) | 399 #endif // !defined(MemoryInstrumentation_h) |
| OLD | NEW |