Bug 92743 - Web Inspector: test native memory instrumentation code with help of unittests
Summary: Web Inspector: test native memory instrumentation code with help of unittests
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Ilya Tikhonovsky
URL:
Keywords:
Depends on: 92879
Blocks: 87262
  Show dependency treegraph
 
Reported: 2012-07-31 05:25 PDT by Ilya Tikhonovsky
Modified: 2012-08-02 09:31 PDT (History)
15 users (show)

See Also:


Attachments
Patch (16.73 KB, patch)
2012-07-31 05:36 PDT, Ilya Tikhonovsky
no flags Details | Formatted Diff | Diff
Patch (16.91 KB, patch)
2012-07-31 05:57 PDT, Ilya Tikhonovsky
no flags Details | Formatted Diff | Diff
Patch (17.37 KB, patch)
2012-08-01 06:08 PDT, Ilya Tikhonovsky
no flags Details | Formatted Diff | Diff
Patch (18.17 KB, patch)
2012-08-01 06:49 PDT, Ilya Tikhonovsky
yurys: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ilya Tikhonovsky 2012-07-31 05:25:14 PDT
There is unittests framework in WebKit
It is a part of chromium port.
The instrumentation code is a bit tricky and I want to test it.
Comment 1 Ilya Tikhonovsky 2012-07-31 05:36:35 PDT
Created attachment 155507 [details]
Patch
Comment 2 Build Bot 2012-07-31 05:54:41 PDT
Comment on attachment 155507 [details]
Patch

Attachment 155507 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/13390739
Comment 3 Ilya Tikhonovsky 2012-07-31 05:57:48 PDT
Created attachment 155510 [details]
Patch
Comment 4 Yury Semikhatsky 2012-07-31 06:09:29 PDT
Comment on attachment 155510 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=155507&action=review

> Source/WebCore/ChangeLog:11
> +        was parked as private and addRootObject was introduced instead of it.

typo: parked -> marked

> Source/WebCore/dom/MemoryInstrumentation.h:-57
> -    template <typename T> void addInstrumentedObject(const T& t)

I'd leave the old name as the object may well be referenced by several other objects.

> Source/WebCore/dom/MemoryInstrumentation.h:219
> +    void MemoryInstrumentation::addObjectImpl(const OwnPtr<T>* const& object, ObjectType objectType, OwningType owningType)

Wrong alignment.

> Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp:7
> + * 1.  Redistributions of source code must retain the above copyright

Please use license header like in http://trac.webkit.org/browser/trunk/Source/WebKit/chromium/tests/ClipboardChromiumTest.cpp, it is a bit different.

> Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp:26
> +

No empty line.

> Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp:44
> +    MemoryInstrumentationImpl(VisitedObjects& visitedObjects) : m_visitedObjects(visitedObjects)

This way we have two implementations of MemoryInstrumentation which are almost identical. Let's move the implementation into MemoryInstrumentation.cpp and add a factory method to MemoryInstrumentation that would create its instance.
Comment 5 Ilya Tikhonovsky 2012-08-01 06:08:49 PDT
Created attachment 155793 [details]
Patch
Comment 6 Ilya Tikhonovsky 2012-08-01 06:15:26 PDT
(In reply to comment #4)
> (From update of attachment 155510 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=155507&action=review
> 
> > Source/WebCore/ChangeLog:11
> > +        was parked as private and addRootObject was introduced instead of it.
> 
> typo: parked -> marked

done

> 
> > Source/WebCore/dom/MemoryInstrumentation.h:-57
> > -    template <typename T> void addInstrumentedObject(const T& t)
> 
> I'd leave the old name as the object may well be referenced by several other objects.

It is the same situationas in js snapshot. Many objects could have links to the window object but that does not prevent it to be the root object.

> 
> > Source/WebCore/dom/MemoryInstrumentation.h:219
> > +    void MemoryInstrumentation::addObjectImpl(const OwnPtr<T>* const& object, ObjectType objectType, OwningType owningType)
> 
> Wrong alignment.

done

> 
> > Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp:7
> > + * 1.  Redistributions of source code must retain the above copyright
> 
> Please use license header like in http://trac.webkit.org/browser/trunk/Source/WebKit/chromium/tests/ClipboardChromiumTest.cpp, it is a bit different.

done

> 
> > Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp:26
> > +
> 
> No empty line.

done

> 
> > Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp:44
> > +    MemoryInstrumentationImpl(VisitedObjects& visitedObjects) : m_visitedObjects(visitedObjects)
> 
> This way we have two implementations of MemoryInstrumentation which are almost identical. Let's move the implementation into MemoryInstrumentation.cpp and add a factory method to MemoryInstrumentation that would create its instance.

landed as r124306
Comment 7 Yury Semikhatsky 2012-08-01 06:43:19 PDT
Comment on attachment 155793 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=155793&action=review

> Source/WebCore/dom/MemoryInstrumentation.h:59
>          OwningTraits<T>::addInstrumentedObject(this, t);

addInstrumentedObject(this, t)

> Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp:48
> +class MemoryInstrumentationImpl : public MemoryInstrumentation {

Please reuse existing MemoryInstrumentationImpl.
Comment 8 Ilya Tikhonovsky 2012-08-01 06:49:27 PDT
Created attachment 155799 [details]
Patch
Comment 9 Yury Semikhatsky 2012-08-01 07:18:56 PDT
Comment on attachment 155799 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=155799&action=review

> Source/WebCore/inspector/MemoryInstrumentationImpl.h:54
> +    size_t reportedSize() const

reportedSizeForAllTypes?

> Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp:46
> +

Please remove 1 blank like

> Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp:85
> +TEST(MemoryInstrumentationTest, ptrVsRef)

Split this into two tests.

> Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp:90
> +        Instrumented* instrumented = new Instrumented;

You may need adoptPtr(new Instrumented).leakPtr() to make some scripts happy.

> Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp:100
> +        impl.addRootObject(instrumented);

If it is a root object, its size shouldn't be reported yet.
Comment 10 Ilya Tikhonovsky 2012-08-01 07:38:22 PDT
Committed r124334: <http://trac.webkit.org/changeset/124334>
Comment 11 WebKit Review Bot 2012-08-01 10:09:29 PDT
Re-opened since this is blocked by 92879
Comment 12 Ilya Tikhonovsky 2012-08-01 23:32:50 PDT
Committed r124412: <http://trac.webkit.org/changeset/124412>