RESOLVED FIXED 98005
Web Inspector: provide memory instrumentation for HashMap
https://bugs.webkit.org/show_bug.cgi?id=98005
Summary Web Inspector: provide memory instrumentation for HashMap
Yury Semikhatsky
Reported 2012-10-01 02:20:44 PDT
Currently the HashMap support consists of MemoryInstrumentation::addHashMap/addInstrumentedMapEntries/addInstrumentedMapValues which should be called if we want to instrument HashMap internals. This approach is error prone. We should detect HashMap type automatically instead and collect data for the map content if it is instrumented.
Attachments
Patch (34.34 KB, patch)
2012-10-01 02:44 PDT, Yury Semikhatsky
no flags
Patch (40.56 KB, patch)
2012-10-01 05:32 PDT, Yury Semikhatsky
pfeldman: review+
buildbot: commit-queue-
Yury Semikhatsky
Comment 1 2012-10-01 02:44:48 PDT
Yury Semikhatsky
Comment 2 2012-10-01 02:46:16 PDT
(In reply to comment #1) > Created an attachment (id=166433) [details] > Patch No XCode project changes in this patch. Will add them later.
Build Bot
Comment 3 2012-10-01 03:14:38 PDT
Ilya Tikhonovsky
Comment 4 2012-10-01 03:15:24 PDT
View in context: https://bugs.webkit.org/attachment.cgi?id=166433&action=review > Source/WTF/wtf/MemoryInstrumentation.h:159 > template<typename HashMapType> void addHashMap(const HashMapType&, MemoryObjectType, bool contentOnly = false); unnecessary line > Source/WTF/wtf/MemoryInstrumentation.h:215 > template<typename HashSetType> void addHashCountedSet(const HashSetType& set) { m_memoryInstrumentation->addHashMap(set, m_objectType, true); } addMember? > Source/WTF/wtf/MemoryInstrumentationHashMap.h:70 > + // Check if type is convertible to integer to handle enum keys and values. > + SequenceMemoryInstrumentationTraits<typename Conditional<IsConvertibleToInteger<KeyArg>::value, int, KeyArg>::Type>::reportMemoryUsage(hashMap->begin().keys(), hashMap->end().keys(), info); > + SequenceMemoryInstrumentationTraits<typename Conditional<IsConvertibleToInteger<MappedArg>::value, int, MappedArg>::Type>::reportMemoryUsage(hashMap->begin().values(), hashMap->end().values(), info); > +// SequenceMemoryInstrumentationTraits<KeyArg>::reportMemoryUsage(hashMap->begin().keys(), hashMap->end().keys(), info); > +// SequenceMemoryInstrumentationTraits<MappedArg>::reportMemoryUsage(hashMap->begin().values(), hashMap->end().values(), info); please remove commented code. Is IsConvertibleToInteger works correctly for classes which have operator int()? the code hashMap->begin().keys(), hashMap->end().keys() looks strange. I'd prefer hashMap->keys().begin(); etc. > Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp:534 > +TEST(MemoryInstrumentationTest, hashMapWithWnumKeysAndInstrumentedValues) typo: WithEnum
Yury Semikhatsky
Comment 5 2012-10-01 05:32:53 PDT
Yury Semikhatsky
Comment 6 2012-10-01 05:36:17 PDT
(In reply to comment #4) > View in context: https://bugs.webkit.org/attachment.cgi?id=166433&action=review > > > Source/WTF/wtf/MemoryInstrumentation.h:159 > > template<typename HashMapType> void addHashMap(const HashMapType&, MemoryObjectType, bool contentOnly = false); > > unnecessary line > > > Source/WTF/wtf/MemoryInstrumentation.h:215 > > template<typename HashSetType> void addHashCountedSet(const HashSetType& set) { m_memoryInstrumentation->addHashMap(set, m_objectType, true); } > > addMember? > We need to get rid of addHashCountedSet method which I'm planning to do in a separate patch. I changed the name of addHashMap to addCountedSet to reflect that it is only used for HashCountedSet instrumentation. > > Source/WTF/wtf/MemoryInstrumentationHashMap.h:70 > > + // Check if type is convertible to integer to handle enum keys and values. > > + SequenceMemoryInstrumentationTraits<typename Conditional<IsConvertibleToInteger<KeyArg>::value, int, KeyArg>::Type>::reportMemoryUsage(hashMap->begin().keys(), hashMap->end().keys(), info); > > + SequenceMemoryInstrumentationTraits<typename Conditional<IsConvertibleToInteger<MappedArg>::value, int, MappedArg>::Type>::reportMemoryUsage(hashMap->begin().values(), hashMap->end().values(), info); > > +// SequenceMemoryInstrumentationTraits<KeyArg>::reportMemoryUsage(hashMap->begin().keys(), hashMap->end().keys(), info); > > +// SequenceMemoryInstrumentationTraits<MappedArg>::reportMemoryUsage(hashMap->begin().values(), hashMap->end().values(), info); > > please remove commented code. > Done. > Is IsConvertibleToInteger works correctly for classes which have operator int()? > No. It fails for such classes stored by value. Added a test for tracking this. I think we may live with that rare case. > the code hashMap->begin().keys(), hashMap->end().keys() looks strange. I'd prefer hashMap->keys().begin(); etc. > > > Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp:534 > > +TEST(MemoryInstrumentationTest, hashMapWithWnumKeysAndInstrumentedValues) > > typo: WithEnum Fixed.
Build Bot
Comment 7 2012-10-01 06:02:06 PDT
Ilya Tikhonovsky
Comment 8 2012-10-01 06:14:28 PDT
Comment on attachment 166456 [details] Patch lgtm
Yury Semikhatsky
Comment 9 2012-10-01 07:27:04 PDT
(In reply to comment #7) > (From update of attachment 166456 [details]) > Attachment 166456 [details] did not pass win-ews (win): > Output: http://queues.webkit.org/results/14075908 The build error on Windows should disappear after http://trac.webkit.org/changeset/130047
Yury Semikhatsky
Comment 10 2012-10-01 07:46:20 PDT
WebKit Review Bot
Comment 11 2012-10-01 09:25:36 PDT
Re-opened since this is blocked by bug 98041
Note You need to log in before you can comment on or make changes to this bug.