Changeset 127738 in webkit


Ignore:
Timestamp:
Sep 6, 2012 7:25:47 AM (12 years ago)
Author:
loislo@chromium.org
Message:

Web Inspector: NMI: switch to hierarchical identifiers of MemoryBlockTypes and use these identifiers in protocol.
https://bugs.webkit.org/show_bug.cgi?id=95957

Reviewed by Yury Semikhatsky.

Source/WebCore:

Now when we use string identifiers as MemoryObjectType we can use them as the identifiers for the protocol
instead of MemoryBlockNames hardcoded in InspectorMemoryAgent..
At a later stage, when each type of memory will be counted in MemoryInstrumentation
we will build the blocks hierarchy for the front-end automatically.

  • dom/MemoryInstrumentation.cpp:

(WebCore):

  • dom/MemoryInstrumentation.h:

(GenericMemoryTypes):
(WebCore::MemoryInstrumentation::addRootObject):
(WebCore::MemoryObjectInfo::reportObjectInfo):
(WebCoreMemoryTypes):

  • inspector/InspectorMemoryAgent.cpp:

(MemoryBlockName):
(WebCore):

  • inspector/MemoryInstrumentationImpl.cpp:

(WebCore::MemoryInstrumentationImpl::countObjectSize):

  • inspector/front-end/NativeMemorySnapshotView.js:

(WebInspector.MemoryBlockViewProperties._initialize):

  • loader/cache/CachedRawResource.cpp:

(WebCore::CachedRawResource::reportMemoryUsage):

  • loader/cache/CachedResource.cpp:

(WebCore::CachedResource::reportMemoryUsage):

  • loader/cache/CachedResourceHandle.cpp:

(WebCore::CachedResourceHandleBase::reportMemoryUsage):

  • platform/SharedBuffer.cpp:

(WebCore::SharedBuffer::reportMemoryUsage):

Source/WebKit/chromium:

Now when we use string identifiers as MemoryObjectType we can use them as the identifiers for the protocol
instead of MemoryBlockNames hardcoded in InspectorMemoryAgent..
At a later stage, when each memory type is counted in MemoryInstrumentation
we will build the blocks hierarchy for the front-end automatically.

  • tests/MemoryInstrumentationTest.cpp:

(WebCore::InstrumentedUndefined::InstrumentedUndefined):
(WebCore::InstrumentedUndefined::reportMemoryUsage):
(WebCore::InstrumentedDOM::InstrumentedDOM):
(WebCore::InstrumentedDOM::reportMemoryUsage):
(InstrumentedDOM):
(WebCore::TEST):

Location:
trunk/Source
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r127737 r127738  
     12012-09-06  Ilya Tikhonovsky  <loislo@chromium.org>
     2
     3        Web Inspector: NMI: switch to hierarchical identifiers of MemoryBlockTypes and use these identifiers in protocol.
     4        https://bugs.webkit.org/show_bug.cgi?id=95957
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        Now when we use string identifiers as MemoryObjectType we can use them as the identifiers for the protocol
     9        instead of MemoryBlockNames hardcoded in InspectorMemoryAgent..
     10        At a later stage, when each type of memory will be counted in MemoryInstrumentation
     11        we will build the blocks hierarchy for the front-end automatically.
     12
     13        * dom/MemoryInstrumentation.cpp:
     14        (WebCore):
     15        * dom/MemoryInstrumentation.h:
     16        (GenericMemoryTypes):
     17        (WebCore::MemoryInstrumentation::addRootObject):
     18        (WebCore::MemoryObjectInfo::reportObjectInfo):
     19        (WebCoreMemoryTypes):
     20        * inspector/InspectorMemoryAgent.cpp:
     21        (MemoryBlockName):
     22        (WebCore):
     23        * inspector/MemoryInstrumentationImpl.cpp:
     24        (WebCore::MemoryInstrumentationImpl::countObjectSize):
     25        * inspector/front-end/NativeMemorySnapshotView.js:
     26        (WebInspector.MemoryBlockViewProperties._initialize):
     27        * loader/cache/CachedRawResource.cpp:
     28        (WebCore::CachedRawResource::reportMemoryUsage):
     29        * loader/cache/CachedResource.cpp:
     30        (WebCore::CachedResource::reportMemoryUsage):
     31        * loader/cache/CachedResourceHandle.cpp:
     32        (WebCore::CachedResourceHandleBase::reportMemoryUsage):
     33        * platform/SharedBuffer.cpp:
     34        (WebCore::SharedBuffer::reportMemoryUsage):
     35
    1362012-09-06  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
    237
  • trunk/Source/WebCore/dom/MemoryInstrumentation.cpp

    r127593 r127738  
    3838namespace WebCore {
    3939
    40 MemoryObjectType GenericMemoryTypes::Other = "Other";
     40MemoryObjectType GenericMemoryTypes::Undefined = 0;
    4141
    42 MemoryObjectType WebCoreMemoryTypes::DOM = "DOM";
    43 MemoryObjectType WebCoreMemoryTypes::CSS = "CSS";
    44 MemoryObjectType WebCoreMemoryTypes::Binding = "Binding";
    45 MemoryObjectType WebCoreMemoryTypes::Loader = "Loader";
    46 MemoryObjectType WebCoreMemoryTypes::MemoryCacheStructures = "MemoryCacheStructures";
    47 MemoryObjectType WebCoreMemoryTypes::CachedResource = "CachedResource";
    48 MemoryObjectType WebCoreMemoryTypes::CachedResourceCSS = "CachedResourceCSS";
    49 MemoryObjectType WebCoreMemoryTypes::CachedResourceFont = "CachedResourceFont";
    50 MemoryObjectType WebCoreMemoryTypes::CachedResourceImage = "CachedResourceImage";
    51 MemoryObjectType WebCoreMemoryTypes::CachedResourceScript = "CachedResourceScript";
    52 MemoryObjectType WebCoreMemoryTypes::CachedResourceSVG = "CachedResourceSVG";
    53 MemoryObjectType WebCoreMemoryTypes::CachedResourceShader = "CachedResourceShader";
    54 MemoryObjectType WebCoreMemoryTypes::CachedResourceXSLT = "CachedResourceXSLT";
     42MemoryObjectType WebCoreMemoryTypes::Page = "Page";
     43MemoryObjectType WebCoreMemoryTypes::DOM = "Page.DOM";
     44MemoryObjectType WebCoreMemoryTypes::CSS = "Page.CSS";
     45MemoryObjectType WebCoreMemoryTypes::Binding = "Page.Binding";
     46MemoryObjectType WebCoreMemoryTypes::Loader = "Page.Loader";
     47
     48MemoryObjectType WebCoreMemoryTypes::MemoryCache = "MemoryCache";
     49MemoryObjectType WebCoreMemoryTypes::MemoryCacheStructures = "MemoryCache.InternalStructures";
     50MemoryObjectType WebCoreMemoryTypes::CachedResource = "MemoryCache.Resource";
     51MemoryObjectType WebCoreMemoryTypes::CachedResourceRaw = "MemoryCache.RawResource";
     52MemoryObjectType WebCoreMemoryTypes::CachedResourceCSS = "MemoryCache.CSS";
     53MemoryObjectType WebCoreMemoryTypes::CachedResourceFont = "MemoryCache.Font";
     54MemoryObjectType WebCoreMemoryTypes::CachedResourceImage = "MemoryCache.Image";
     55MemoryObjectType WebCoreMemoryTypes::CachedResourceScript = "MemoryCache.Script";
     56MemoryObjectType WebCoreMemoryTypes::CachedResourceSVG = "MemoryCache.SVG";
     57MemoryObjectType WebCoreMemoryTypes::CachedResourceShader = "MemoryCache.Shader";
     58MemoryObjectType WebCoreMemoryTypes::CachedResourceXSLT = "MemoryCache.XSLT";
    5559
    5660template<> void MemoryInstrumentationTraits::addInstrumentedObject<String>(MemoryInstrumentation* instrumentation, const String* const& string, MemoryObjectType ownerObjectType, MemoryOwningType owningType)
  • trunk/Source/WebCore/dom/MemoryInstrumentation.h

    r127593 r127738  
    5050class GenericMemoryTypes {
    5151public:
    52     static MemoryObjectType Other;
     52    static MemoryObjectType Undefined;
    5353};
    5454
     
    7070    template <typename T> void addRootObject(const T& t)
    7171    {
    72         addInstrumentedObject(t, GenericMemoryTypes::Other);
     72        addInstrumentedObject(t, GenericMemoryTypes::Undefined);
    7373        processDeferredInstrumentedPointers();
    7474    }
     
    189189        if (!m_objectSize) {
    190190            m_objectSize = actualSize ? actualSize : sizeof(T);
    191             if (objectType != GenericMemoryTypes::Other)
     191            if (objectType != GenericMemoryTypes::Undefined)
    192192                m_objectType = objectType;
    193193        }
     
    409409class WebCoreMemoryTypes {
    410410public:
     411    static MemoryObjectType Page;
    411412    static MemoryObjectType DOM;
    412413    static MemoryObjectType CSS;
    413414    static MemoryObjectType Binding;
    414415    static MemoryObjectType Loader;
     416
     417    static MemoryObjectType MemoryCache;
    415418    static MemoryObjectType MemoryCacheStructures;
    416419    static MemoryObjectType CachedResource;
     420    static MemoryObjectType CachedResourceRaw;
    417421    static MemoryObjectType CachedResourceCSS;
    418422    static MemoryObjectType CachedResourceFont;
  • trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp

    r127593 r127738  
    8484static const char processPrivateMemory[] = "ProcessPrivateMemory";
    8585
    86 static const char memoryCache[] = "MemoryCache";
    87 static const char memoryCacheStructures[] = "MemoryCacheStructures";
    88 static const char cachedResource[] = "CachedResource";
    89 static const char cachedResourceImage[] = "CachedImages";
    90 static const char cachedResourceCSS[] = "CachedCssStyleSheets";
    91 static const char cachedResourceScript[] = "CachedScripts";
    92 static const char cachedResourceXSL[] = "CachedXslStyleSheets";
    93 static const char cachedResourceFont[] = "CachedFonts";
    94 static const char cachedResourceSVG[] = "CachedSVGGraphics";
    95 static const char cachedResourceShader[] = "CachedShaders";
    96 static const char cachedResourceXSLT[] = "CachedShadersXSLT";
    97 
    9886static const char renderTreeUsed[] = "RenderTreeUsed";
    9987static const char renderTreeAllocated[] = "RenderTreeAllocated";
    100 
    101 static const char dom[] = "DOM";
    102 static const char domTreeOther[] = "DOMTreeOther";
    103 static const char domTreeDOM[] = "DOMTreeDOM";
    104 static const char domTreeCSS[] = "DOMTreeCSS";
    105 static const char domTreeBinding[] = "DOMTreeBinding";
    106 static const char domTreeLoader[] = "DOMTreeLoader";
    10788
    10889static const char domStorageCache[] = "DOMStorageCache";
     
    441422}
    442423
    443 static size_t addMemoryBlockFor(TypeBuilder::Array<InspectorMemoryBlock>* array, size_t size, const char* name)
    444 {
    445     RefPtr<InspectorMemoryBlock> result = InspectorMemoryBlock::create().setName(name);
    446     result->setSize(size);
    447     array->addItem(result);
    448     return size;
    449 }
    450 
    451424namespace {
    452425
     
    487460
    488461        RefPtr<TypeBuilder::Array<InspectorMemoryBlock> > children = TypeBuilder::Array<InspectorMemoryBlock>::create();
    489         totalSize += addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(WebCoreMemoryTypes::MemoryCacheStructures), MemoryBlockName::memoryCacheStructures);
    490         totalSize += addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(WebCoreMemoryTypes::CachedResource), MemoryBlockName::cachedResource);
    491         totalSize += addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(WebCoreMemoryTypes::CachedResourceCSS), MemoryBlockName::cachedResourceCSS);
    492         totalSize += addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(WebCoreMemoryTypes::CachedResourceFont), MemoryBlockName::cachedResourceFont);
    493         totalSize += addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(WebCoreMemoryTypes::CachedResourceImage), MemoryBlockName::cachedResourceImage);
    494         totalSize += addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(WebCoreMemoryTypes::CachedResourceScript), MemoryBlockName::cachedResourceScript);
    495         totalSize += addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(WebCoreMemoryTypes::CachedResourceSVG), MemoryBlockName::cachedResourceSVG);
    496         totalSize += addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(WebCoreMemoryTypes::CachedResourceShader), MemoryBlockName::cachedResourceShader);
    497         totalSize += addMemoryBlockFor(children.get(), m_memoryInstrumentation.totalSize(WebCoreMemoryTypes::CachedResourceXSLT), MemoryBlockName::cachedResourceXSLT);
    498 
    499         RefPtr<InspectorMemoryBlock> block = InspectorMemoryBlock::create().setName(MemoryBlockName::memoryCache);
     462        totalSize += addMemoryBlockFor(children.get(), WebCoreMemoryTypes::MemoryCacheStructures);
     463        totalSize += addMemoryBlockFor(children.get(), WebCoreMemoryTypes::CachedResourceRaw);
     464        totalSize += addMemoryBlockFor(children.get(), WebCoreMemoryTypes::CachedResourceCSS);
     465        totalSize += addMemoryBlockFor(children.get(), WebCoreMemoryTypes::CachedResourceFont);
     466        totalSize += addMemoryBlockFor(children.get(), WebCoreMemoryTypes::CachedResourceImage);
     467        totalSize += addMemoryBlockFor(children.get(), WebCoreMemoryTypes::CachedResourceScript);
     468        totalSize += addMemoryBlockFor(children.get(), WebCoreMemoryTypes::CachedResourceSVG);
     469        totalSize += addMemoryBlockFor(children.get(), WebCoreMemoryTypes::CachedResourceShader);
     470        totalSize += addMemoryBlockFor(children.get(), WebCoreMemoryTypes::CachedResourceXSLT);
     471
     472        RefPtr<InspectorMemoryBlock> block = InspectorMemoryBlock::create().setName(WebCoreMemoryTypes::MemoryCache);
    500473        block->setSize(totalSize);
    501474        block->setChildren(children.release());
     
    503476    }
    504477
    505     PassRefPtr<InspectorMemoryBlock> buildObjectForDOM() const
     478    PassRefPtr<InspectorMemoryBlock> buildObjectForPage() const
    506479    {
    507480        size_t totalSize = 0;
    508481
    509482        RefPtr<TypeBuilder::Array<InspectorMemoryBlock> > domChildren = TypeBuilder::Array<InspectorMemoryBlock>::create();
    510         totalSize += addMemoryBlockFor(domChildren.get(), m_memoryInstrumentation.totalSize(GenericMemoryTypes::Other), MemoryBlockName::domTreeOther);
    511         totalSize += addMemoryBlockFor(domChildren.get(), m_memoryInstrumentation.totalSize(WebCoreMemoryTypes::DOM), MemoryBlockName::domTreeDOM);
    512         totalSize += addMemoryBlockFor(domChildren.get(), m_memoryInstrumentation.totalSize(WebCoreMemoryTypes::CSS), MemoryBlockName::domTreeCSS);
    513         totalSize += addMemoryBlockFor(domChildren.get(), m_memoryInstrumentation.totalSize(WebCoreMemoryTypes::Binding), MemoryBlockName::domTreeBinding);
    514         totalSize += addMemoryBlockFor(domChildren.get(), m_memoryInstrumentation.totalSize(WebCoreMemoryTypes::Loader), MemoryBlockName::domTreeLoader);
    515 
    516         RefPtr<InspectorMemoryBlock> dom = InspectorMemoryBlock::create().setName(MemoryBlockName::dom);
     483        totalSize += addMemoryBlockFor(domChildren.get(), WebCoreMemoryTypes::DOM);
     484        totalSize += addMemoryBlockFor(domChildren.get(), WebCoreMemoryTypes::CSS);
     485        totalSize += addMemoryBlockFor(domChildren.get(), WebCoreMemoryTypes::Binding);
     486        totalSize += addMemoryBlockFor(domChildren.get(), WebCoreMemoryTypes::Loader);
     487
     488        RefPtr<InspectorMemoryBlock> dom = InspectorMemoryBlock::create().setName(WebCoreMemoryTypes::Page);
    517489        dom->setSize(totalSize);
    518490        dom->setChildren(domChildren.release());
     
    523495    {
    524496        children->addItem(buildObjectForMemoryCache());
    525         children->addItem(buildObjectForDOM());
     497        children->addItem(buildObjectForPage());
     498
    526499        inspectorData->addComponent(MemoryBlockName::inspectorDOMData, m_memoryInstrumentation.selfSize());
    527500    }
    528501
    529502private:
     503    size_t addMemoryBlockFor(TypeBuilder::Array<InspectorMemoryBlock>* array, MemoryObjectType typeName) const
     504    {
     505        RefPtr<InspectorMemoryBlock> result = InspectorMemoryBlock::create().setName(typeName);
     506        size_t size = m_memoryInstrumentation.totalSize(typeName);
     507        result->setSize(size);
     508        array->addItem(result);
     509        return size;
     510    }
     511
    530512    Page* m_page;
    531513    MemoryInstrumentationImpl& m_memoryInstrumentation;
  • trunk/Source/WebCore/inspector/MemoryInstrumentationImpl.cpp

    r127592 r127738  
    5353void MemoryInstrumentationImpl::countObjectSize(MemoryObjectType objectType, size_t size)
    5454{
     55    ASSERT(objectType != GenericMemoryTypes::Undefined);
    5556    TypeToSizeMap::AddResult result = m_totalSizes.add(objectType, size);
    5657    if (!result.isNewEntry)
  • trunk/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js

    r125966 r127738  
    217217    }
    218218    addBlock("hsl(  0,  0%, 100%)", "ProcessPrivateMemory", "Total");
     219    addBlock("hsl(  0,  0%,  80%)", "OwnersTypePlaceholder", "OwnersTypePlaceholder");
    219220    addBlock("hsl(  0,  0%,  80%)", "Other", "Other");
    220     addBlock("hsl(300, 30%,  80%)", "DOM", "DOM tree structures");
     221    addBlock("hsl(300, 30%,  80%)", "Page", "Page's structures");
    221222    addBlock("hsl( 90, 60%,  80%)", "JSHeapAllocated", "JavaScript heap");
    222223    addBlock("hsl( 90, 80%,  80%)", "JSHeapUsed", "Used JavaScript heap");
  • trunk/Source/WebCore/loader/cache/CachedRawResource.cpp

    r127593 r127738  
    163163void CachedRawResource::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    164164{
    165     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CachedResource);
     165    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CachedResourceRaw);
    166166    CachedResource::reportMemoryUsage(memoryObjectInfo);
    167167}
  • trunk/Source/WebCore/loader/cache/CachedResourceHandle.cpp

    r127593 r127738  
    4444void CachedResourceHandleBase::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    4545{
    46     MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CachedResource);
     46    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::MemoryCacheStructures);
    4747    info.addInstrumentedMember(m_resource);
    4848}
  • trunk/Source/WebCore/platform/SharedBuffer.cpp

    r127593 r127738  
    251251void SharedBuffer::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    252252{
    253     MemoryClassInfo info(memoryObjectInfo, this, GenericMemoryTypes::Other);
     253    MemoryClassInfo info(memoryObjectInfo, this, GenericMemoryTypes::Undefined);
    254254    info.addVector(m_buffer);
    255255    info.addVector(m_segments);
  • trunk/Source/WebKit/chromium/ChangeLog

    r127721 r127738  
     12012-09-06  Ilya Tikhonovsky  <loislo@chromium.org>
     2
     3        Web Inspector: NMI: switch to hierarchical identifiers of MemoryBlockTypes and use these identifiers in protocol.
     4        https://bugs.webkit.org/show_bug.cgi?id=95957
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        Now when we use string identifiers as MemoryObjectType we can use them as the identifiers for the protocol
     9        instead of MemoryBlockNames hardcoded in InspectorMemoryAgent..
     10        At a later stage, when each memory type is counted in MemoryInstrumentation
     11        we will build the blocks hierarchy for the front-end automatically.
     12
     13        * tests/MemoryInstrumentationTest.cpp:
     14        (WebCore::InstrumentedUndefined::InstrumentedUndefined):
     15        (WebCore::InstrumentedUndefined::reportMemoryUsage):
     16        (WebCore::InstrumentedDOM::InstrumentedDOM):
     17        (WebCore::InstrumentedDOM::reportMemoryUsage):
     18        (InstrumentedDOM):
     19        (WebCore::TEST):
     20
    1212012-09-06  Kenichi Ishibashi  <bashi@chromium.org>
    222
  • trunk/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp

    r127617 r127738  
    173173}
    174174
    175 class InstrumentedOther {
    176 public:
    177     InstrumentedOther() : m_data(0) { }
     175class InstrumentedUndefined {
     176public:
     177    InstrumentedUndefined() : m_data(0) { }
    178178
    179179    void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    180180    {
    181         MemoryClassInfo info(memoryObjectInfo, this, GenericMemoryTypes::Other);
     181        MemoryClassInfo info(memoryObjectInfo, this, GenericMemoryTypes::Undefined);
    182182    }
    183183    int m_data;
     
    186186class InstrumentedDOM {
    187187public:
    188     InstrumentedDOM() : m_instrumentedOther(adoptPtr(new InstrumentedOther)) { }
     188    InstrumentedDOM() : m_instrumentedUndefined(adoptPtr(new InstrumentedUndefined)) { }
    189189
    190190    void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
    191191    {
    192192        MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
    193         info.addInstrumentedMember(m_instrumentedOther);
    194     }
    195     OwnPtr<InstrumentedOther> m_instrumentedOther;
     193        info.addInstrumentedMember(m_instrumentedUndefined);
     194    }
     195    OwnPtr<InstrumentedUndefined> m_instrumentedUndefined;
    196196};
    197197
     
    202202    OwnPtr<InstrumentedDOM> instrumentedDOM(adoptPtr(new InstrumentedDOM));
    203203    impl.addRootObject(instrumentedDOM);
    204     EXPECT_EQ(sizeof(InstrumentedDOM) + sizeof(InstrumentedOther), impl.reportedSizeForAllTypes());
    205     EXPECT_EQ(sizeof(InstrumentedDOM) + sizeof(InstrumentedOther), impl.totalSize(WebCoreMemoryTypes::DOM));
     204    EXPECT_EQ(sizeof(InstrumentedDOM) + sizeof(InstrumentedUndefined), impl.reportedSizeForAllTypes());
     205    EXPECT_EQ(sizeof(InstrumentedDOM) + sizeof(InstrumentedUndefined), impl.totalSize(WebCoreMemoryTypes::DOM));
    206206    EXPECT_EQ(2, visitedObjects.size());
    207207}
Note: See TracChangeset for help on using the changeset viewer.