Changeset 124334 in webkit


Ignore:
Timestamp:
Aug 1, 2012 7:38:01 AM (12 years ago)
Author:
loislo@chromium.org
Message:

Web Inspector: test native memory instrumentation code with help of unittests
https://bugs.webkit.org/show_bug.cgi?id=92743

Reviewed by Yury Semikhatsky.

Source/WebCore:

Test a part of existing Native Memory Instrumentation code with help of unit tests.
6 tests were added and two bugs were fixed.
a drive-by improvement: the method MemoryInstrumentation::addInstrumentedObject
was marked as private and addRootObject was introduced instead of it.
The new function also calls processDeferedPointers.

  • bindings/v8/ScriptProfiler.cpp:

(WebCore::ScriptProfiler::collectBindingMemoryInfo):

  • dom/MemoryInstrumentation.h:

(WebCore::MemoryInstrumentation::addRootObject):
(MemoryInstrumentation):
(WebCore::MemoryInstrumentation::addInstrumentedObject):
(WebCore::MemoryInstrumentation::addInstrumentedObjectImpl):
(WebCore):
(WebCore::MemoryInstrumentation::addObjectImpl):

  • inspector/InspectorMemoryAgent.cpp:

(WebCore):

  • inspector/MemoryInstrumentationImpl.h:

(MemoryInstrumentationImpl):

Source/WebKit/chromium:

Test a part of existing Native Memory Instrumentation code with help of unit tests.
6 tests were added and two bugs were fixed.

  • WebKit.gypi:
  • tests/MemoryInstrumentationTest.cpp: Added.

(WebCore):
(MemoryInstrumentationImpl):
(WebCore::MemoryInstrumentationImpl::MemoryInstrumentationImpl):
(WebCore::MemoryInstrumentationImpl::reportedSize):
(WebCore::MemoryInstrumentationImpl::countObjectSize):
(WebCore::MemoryInstrumentationImpl::processDeferredInstrumentedPointers):
(NotInstrumented):
(Instrumented):
(WebCore::Instrumented::Instrumented):
(WebCore::Instrumented::~Instrumented):
(WebCore::Instrumented::reportMemoryUsage):
(WebCore::TEST):
(InstrumentedWithOwnPtr):
(WebCore::InstrumentedWithOwnPtr::InstrumentedWithOwnPtr):
(WebCore::InstrumentedWithOwnPtr::reportMemoryUsage):

Location:
trunk/Source
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r124333 r124334  
     12012-08-01  Ilya Tikhonovsky  <loislo@chromium.org>
     2
     3        Web Inspector: test native memory instrumentation code with help of unittests
     4        https://bugs.webkit.org/show_bug.cgi?id=92743
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        Test a part of existing Native Memory Instrumentation code with help of unit tests.
     9        6 tests were added and two bugs were fixed.
     10        a drive-by improvement: the method MemoryInstrumentation::addInstrumentedObject
     11        was marked as private and addRootObject was introduced instead of it.
     12        The new function also calls processDeferedPointers.
     13
     14        * bindings/v8/ScriptProfiler.cpp:
     15        (WebCore::ScriptProfiler::collectBindingMemoryInfo):
     16        * dom/MemoryInstrumentation.h:
     17        (WebCore::MemoryInstrumentation::addRootObject):
     18        (MemoryInstrumentation):
     19        (WebCore::MemoryInstrumentation::addInstrumentedObject):
     20        (WebCore::MemoryInstrumentation::addInstrumentedObjectImpl):
     21        (WebCore):
     22        (WebCore::MemoryInstrumentation::addObjectImpl):
     23        * inspector/InspectorMemoryAgent.cpp:
     24        (WebCore):
     25        * inspector/MemoryInstrumentationImpl.h:
     26        (MemoryInstrumentationImpl):
     27
    1282012-08-01  Sudarsana Nagineni  <sudarsana.nagineni@linux.intel.com>
    229
  • trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp

    r124017 r124334  
    224224{
    225225    V8BindingPerIsolateData* data = V8BindingPerIsolateData::current();
    226     instrumentation->addInstrumentedObject(data);
     226    instrumentation->addRootObject(data);
    227227}
    228228
  • trunk/Source/WebCore/dom/MemoryInstrumentation.h

    r124330 r124334  
    5555    };
    5656
    57     template <typename T> void addInstrumentedObject(const T& t)
    58     {
    59         OwningTraits<T>::addInstrumentedObject(this, t);
     57    template <typename T> void addRootObject(const T& t)
     58    {
     59        addInstrumentedObject(t);
     60        processDeferredInstrumentedPointers();
    6061    }
    6162
     
    6970    };
    7071
     72private:
    7173    virtual void countObjectSize(ObjectType, size_t) = 0;
    7274    virtual void deferInstrumentedPointer(PassOwnPtr<InstrumentedPointerBase>) = 0;
    7375    virtual bool visited(const void*) = 0;
    74 
    75 private:
     76    virtual void processDeferredInstrumentedPointers() = 0;
     77
    7678    template <typename T> friend class MemoryClassInfo;
    7779    template <typename T> class InstrumentedPointer : public InstrumentedPointerBase {
     
    8991    }
    9092    void addString(const String&, ObjectType);
     93    template <typename T> void addInstrumentedObject(const T& t) { OwningTraits<T>::addInstrumentedObject(this, t); }
    9194    template <typename HashMapType> void addHashMap(const HashMapType&, ObjectType, bool contentOnly = false);
    9295    template <typename HashSetType> void addHashSet(const HashSetType&, ObjectType, bool contentOnly = false);
     
    123126
    124127    template <typename T> void addObjectImpl(const T* const&, ObjectType, OwningType);
     128    template <typename T> void addObjectImpl(const OwnPtr<T>* const&, ObjectType, OwningType);
     129    template <typename T> void addObjectImpl(const RefPtr<T>* const&, ObjectType, OwningType);
    125130};
    126131
     
    203208
    204209template <typename T>
    205 void MemoryInstrumentation::addInstrumentedObjectImpl(const OwnPtr<T>* const& object, OwningType owningType)
    206 {
    207     addInstrumentedObjectImpl(object->get(), owningType);
    208 }
    209 
    210 template <typename T>
    211 void MemoryInstrumentation::addInstrumentedObjectImpl(const RefPtr<T>* const& object, OwningType owningType)
    212 {
    213     addInstrumentedObjectImpl(object->get(), owningType);
     210void MemoryInstrumentation::addInstrumentedObjectImpl(const OwnPtr<T>* const& object, OwningType)
     211{
     212    addInstrumentedObjectImpl(object->get(), byPointer);
     213}
     214
     215template <typename T>
     216void MemoryInstrumentation::addInstrumentedObjectImpl(const RefPtr<T>* const& object, OwningType)
     217{
     218    addInstrumentedObjectImpl(object->get(), byPointer);
     219}
     220
     221template <typename T>
     222void MemoryInstrumentation::addObjectImpl(const OwnPtr<T>* const& object, ObjectType objectType, OwningType)
     223{
     224    addObjectImpl(object->get(), objectType, byPointer);
     225}
     226
     227template <typename T>
     228void MemoryInstrumentation::addObjectImpl(const RefPtr<T>* const& object, ObjectType objectType, OwningType)
     229{
     230    addObjectImpl(object->get(), objectType, byPointer);
    214231}
    215232
  • trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp

    r124332 r124334  
    444444namespace {
    445445
    446 
    447446class DOMTreesIterator : public NodeWrapperVisitor {
    448447public:
     
    458457            return;
    459458
    460         m_domMemoryUsage.addInstrumentedObject(node);
    461         m_domMemoryUsage.processDeferredInstrumentedPointers();
     459        m_domMemoryUsage.addRootObject(node);
    462460    }
    463461
    464462    void visitFrame(Frame* frame)
    465463    {
    466         m_domMemoryUsage.addInstrumentedObject(frame);
    467         m_domMemoryUsage.processDeferredInstrumentedPointers();
     464        m_domMemoryUsage.addRootObject(frame);
    468465    }
    469466
     
    471468    {
    472469        ScriptProfiler::collectBindingMemoryInfo(&m_domMemoryUsage);
    473         m_domMemoryUsage.processDeferredInstrumentedPointers();
    474470    }
    475471
     
    480476        size_t totalSize = 0;
    481477        for (int i = MemoryInstrumentation::Other; i < MemoryInstrumentation::LastTypeEntry; ++i)
    482             totalSize += m_domMemoryUsage.totalTypeSize(static_cast<MemoryInstrumentation::ObjectType>(i));
     478            totalSize += m_domMemoryUsage.totalSize(static_cast<MemoryInstrumentation::ObjectType>(i));
    483479
    484480        RefPtr<TypeBuilder::Array<InspectorMemoryBlock> > domChildren = TypeBuilder::Array<InspectorMemoryBlock>::create();
    485         addMemoryBlockFor(domChildren.get(), m_domMemoryUsage.totalTypeSize(MemoryInstrumentation::Other), MemoryBlockName::domTreeOther);
    486         addMemoryBlockFor(domChildren.get(), m_domMemoryUsage.totalTypeSize(MemoryInstrumentation::DOM), MemoryBlockName::domTreeDOM);
    487         addMemoryBlockFor(domChildren.get(), m_domMemoryUsage.totalTypeSize(MemoryInstrumentation::CSS), MemoryBlockName::domTreeCSS);
    488         addMemoryBlockFor(domChildren.get(), m_domMemoryUsage.totalTypeSize(MemoryInstrumentation::Binding), MemoryBlockName::domTreeBinding);
    489         addMemoryBlockFor(domChildren.get(), m_domMemoryUsage.totalTypeSize(MemoryInstrumentation::Loader), MemoryBlockName::domTreeLoader);
     481        addMemoryBlockFor(domChildren.get(), m_domMemoryUsage.totalSize(MemoryInstrumentation::Other), MemoryBlockName::domTreeOther);
     482        addMemoryBlockFor(domChildren.get(), m_domMemoryUsage.totalSize(MemoryInstrumentation::DOM), MemoryBlockName::domTreeDOM);
     483        addMemoryBlockFor(domChildren.get(), m_domMemoryUsage.totalSize(MemoryInstrumentation::CSS), MemoryBlockName::domTreeCSS);
     484        addMemoryBlockFor(domChildren.get(), m_domMemoryUsage.totalSize(MemoryInstrumentation::Binding), MemoryBlockName::domTreeBinding);
     485        addMemoryBlockFor(domChildren.get(), m_domMemoryUsage.totalSize(MemoryInstrumentation::Loader), MemoryBlockName::domTreeLoader);
    490486
    491487        RefPtr<InspectorMemoryBlock> dom = InspectorMemoryBlock::create().setName(MemoryBlockName::dom);
  • trunk/Source/WebCore/inspector/MemoryInstrumentationImpl.h

    r124306 r124334  
    4545    explicit MemoryInstrumentationImpl(VisitedObjects&);
    4646
    47     void processDeferredInstrumentedPointers();
    4847    size_t selfSize() const;
    49     size_t totalTypeSize(ObjectType objectType)
     48    size_t totalSize(ObjectType objectType) const
    5049    {
    5150        ASSERT(objectType >= 0 && objectType < LastTypeEntry);
    5251        return m_totalSizes[objectType];
     52    }
     53
     54    size_t reportedSizeForAllTypes() const
     55    {
     56        size_t size = 0;
     57        for (int i = 0; i < LastTypeEntry; ++i)
     58            size += m_totalSizes[i];
     59        return size;
    5360    }
    5461
     
    5764    virtual void deferInstrumentedPointer(PassOwnPtr<InstrumentedPointerBase>) OVERRIDE;
    5865    virtual bool visited(const void*) OVERRIDE;
     66    virtual void processDeferredInstrumentedPointers() OVERRIDE;
    5967
    6068    size_t m_totalSizes[LastTypeEntry];
  • trunk/Source/WebKit/chromium/ChangeLog

    r124332 r124334  
     12012-08-01  Ilya Tikhonovsky  <loislo@chromium.org>
     2
     3        Web Inspector: test native memory instrumentation code with help of unittests
     4        https://bugs.webkit.org/show_bug.cgi?id=92743
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        Test a part of existing Native Memory Instrumentation code with help of unit tests.
     9        6 tests were added and two bugs were fixed.
     10
     11        * WebKit.gypi:
     12        * tests/MemoryInstrumentationTest.cpp: Added.
     13        (WebCore):
     14        (MemoryInstrumentationImpl):
     15        (WebCore::MemoryInstrumentationImpl::MemoryInstrumentationImpl):
     16        (WebCore::MemoryInstrumentationImpl::reportedSize):
     17        (WebCore::MemoryInstrumentationImpl::countObjectSize):
     18        (WebCore::MemoryInstrumentationImpl::processDeferredInstrumentedPointers):
     19        (NotInstrumented):
     20        (Instrumented):
     21        (WebCore::Instrumented::Instrumented):
     22        (WebCore::Instrumented::~Instrumented):
     23        (WebCore::Instrumented::reportMemoryUsage):
     24        (WebCore::TEST):
     25        (InstrumentedWithOwnPtr):
     26        (WebCore::InstrumentedWithOwnPtr::InstrumentedWithOwnPtr):
     27        (WebCore::InstrumentedWithOwnPtr::reportMemoryUsage):
     28
    1292012-08-01  Alexei Filippov  <alexeif@chromium.org>
    230
  • trunk/Source/WebKit/chromium/WebKit.gypi

    r123856 r124334  
    127127            'tests/LocalizedNumberICUTest.cpp',
    128128            'tests/MemoryInfo.cpp',
     129            'tests/MemoryInstrumentationTest.cpp',
    129130            'tests/MockCCQuadCuller.h',
    130131            'tests/OpaqueRectTrackingContentLayerDelegateTest.cpp',
Note: See TracChangeset for help on using the changeset viewer.