Changeset 137893 in webkit
- Timestamp:
- Dec 17, 2012 3:35:31 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r137892 r137893 1 2012-12-17 Ilya Tikhonovsky <loislo@chromium.org> 2 3 Unreviewed, rolling out r137892. 4 http://trac.webkit.org/changeset/137892 5 https://bugs.webkit.org/show_bug.cgi?id=105026 6 7 it broke compilation on windows 8 9 * wtf/MemoryInstrumentation.h: 10 (WTF::MemoryInstrumentation::selectInstrumentationMethod): 11 (MemoryInstrumentation): 12 (WTF::MemoryInstrumentation::reportObjectMemoryUsage): 13 (WTF::reportMemoryUsage): 14 1 15 2012-12-14 Ilya Tikhonovsky <loislo@chromium.org> 2 16 -
trunk/Source/WTF/wtf/MemoryInstrumentation.h
r137892 r137893 117 117 template<typename T> friend void reportMemoryUsage(const T*, MemoryObjectInfo*); 118 118 119 template <typename Type> 120 class IsInstrumented { 121 class yes { 122 char m; 123 }; 124 125 class no { 126 yes m[2]; 127 }; 128 129 struct Mixin { 130 void reportMemoryUsage(MemoryObjectInfo*) const { } 131 }; 132 133 struct Derived : public Type, public Mixin { }; 134 template <typename T, T t> class Helper { }; 135 136 template <typename U> static no deduce(U*, Helper<void (Mixin::*)(MemoryObjectInfo*) const, &U::reportMemoryUsage>* = 0); 137 static yes deduce(...); 138 139 public: 140 static const bool result = sizeof(yes) == sizeof(deduce((Derived*)(0))); 141 142 }; 143 144 template <bool> 145 struct InstrumentationSelector { 146 template <typename T> static void reportObjectMemoryUsage(const T*, MemoryObjectInfo*); 147 }; 148 119 template<typename T> static void selectInstrumentationMethod(const T* object, MemoryObjectInfo* memoryObjectInfo) 120 { 121 // If there is reportMemoryUsage method on the object, call it. 122 // Otherwise count only object's self size. 123 reportObjectMemoryUsage<T, void (T::*)(MemoryObjectInfo*) const>(object, memoryObjectInfo, 0); 124 } 125 126 template<typename Type, Type Ptr> struct MemberHelperStruct; 127 template<typename T, typename Type> 128 static void reportObjectMemoryUsage(const T* object, MemoryObjectInfo* memoryObjectInfo, MemberHelperStruct<Type, &T::reportMemoryUsage>*) 129 { 130 object->reportMemoryUsage(memoryObjectInfo); 131 } 132 133 template<typename T, typename Type> 134 static void reportObjectMemoryUsage(const T* object, MemoryObjectInfo* memoryObjectInfo, ...) 135 { 136 callReportObjectInfo(memoryObjectInfo, object, 0, sizeof(T)); 137 } 149 138 WTF_EXPORT_PRIVATE static void callReportObjectInfo(MemoryObjectInfo*, const void* pointer, MemoryObjectType, size_t objectSize); 150 139 … … 200 189 MemoryInstrumentationClient* m_client; 201 190 }; 202 203 template <>204 template <typename T>205 void MemoryInstrumentation::InstrumentationSelector<true>::reportObjectMemoryUsage(const T* object, MemoryObjectInfo* memoryObjectInfo)206 {207 object->reportMemoryUsage(memoryObjectInfo);208 }209 210 template <>211 template <typename T>212 void MemoryInstrumentation::InstrumentationSelector<false>::reportObjectMemoryUsage(const T* object, MemoryObjectInfo* memoryObjectInfo)213 {214 callReportObjectInfo(memoryObjectInfo, object, 0, sizeof(T));215 }216 191 217 192 class MemoryClassInfo { … … 250 225 void reportMemoryUsage(const T* object, MemoryObjectInfo* memoryObjectInfo) 251 226 { 252 MemoryInstrumentation:: InstrumentationSelector<MemoryInstrumentation::IsInstrumented<T>::result>::reportObjectMemoryUsage(object, memoryObjectInfo);227 MemoryInstrumentation::selectInstrumentationMethod<T>(object, memoryObjectInfo); 253 228 } 254 229 -
trunk/Tools/ChangeLog
r137892 r137893 1 2012-12-17 Ilya Tikhonovsky <loislo@chromium.org> 2 3 Unreviewed, rolling out r137892. 4 http://trac.webkit.org/changeset/137892 5 https://bugs.webkit.org/show_bug.cgi?id=105026 6 7 it broke compilation on windows 8 9 * TestWebKitAPI/Tests/WTF/MemoryInstrumentationTest.cpp: 10 1 11 2012-12-14 Ilya Tikhonovsky <loislo@chromium.org> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WTF/MemoryInstrumentationTest.cpp
r137892 r137893 873 873 EXPECT_EQ(1, client.linkCount()); 874 874 } 875 876 class DerivedClass : public Instrumented {877 public:878 size_t m_member;879 };880 881 TEST(MemoryInstrumentationTest, detectBaseClassInstrumentation)882 {883 OwnPtr<DerivedClass> instance = adoptPtr(new DerivedClass());884 885 InstrumentationTestHelper helper;886 helper.addRootObject(instance.get(), TestType);887 EXPECT_EQ(sizeof(Instrumented) + sizeof(NotInstrumented), helper.reportedSizeForAllTypes());888 EXPECT_EQ(2u, helper.visitedObjects());889 }890 891 875 } // namespace 892 876
Note: See TracChangeset
for help on using the changeset viewer.