Changeset 121658 in webkit


Ignore:
Timestamp:
Jul 2, 2012 12:04:41 AM (12 years ago)
Author:
yurys@chromium.org
Message:

Web Inspector: add v8 bindings memory info to the native memory graph
https://bugs.webkit.org/show_bug.cgi?id=90149

Reviewed by Pavel Feldman.

Size of V8 binding maps is now reported on the memory chart.

  • bindings/js/ScriptProfiler.h:

(WebCore::ScriptProfiler::collectBindingMemoryInfo):

  • bindings/v8/DOMDataStore.cpp:

(WebCore::DOMDataStore::reportMemoryUsage):
(WebCore):

  • bindings/v8/DOMDataStore.h:

(WebCore):
(DOMDataStore):

  • bindings/v8/IntrusiveDOMWrapperMap.h:

(WebCore::ChunkedTable::reportMemoryUsage):
(ChunkedTable):

  • bindings/v8/ScriptProfiler.cpp:

(WebCore::ScriptProfiler::collectBindingMemoryInfo):
(WebCore):

  • bindings/v8/ScriptProfiler.h:

(WebCore):
(ScriptProfiler):

  • bindings/v8/V8Binding.cpp:

(WebCore::V8BindingPerIsolateData::reportMemoryUsage):
(WebCore):
(WebCore::StringCache::reportMemoryUsage):

  • bindings/v8/V8Binding.h:

(WebCore):
(StringCache):
(V8BindingPerIsolateData):

  • bindings/v8/V8DOMMap.h:

(WebCore):
(AbstractWeakReferenceMap):

  • dom/MemoryInstrumentation.h:

(MemoryInstrumentation):
(WebCore):
(WebCore::MemoryInstrumentation::reportHashMap): added a method for reporting
size of a HashMap.

  • inspector/InspectorMemoryAgent.cpp:

(MemoryBlockName):
(WebCore):
(WebCore::domTreeInfo):

Location:
trunk/Source/WebCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r121657 r121658  
     12012-06-28  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Web Inspector: add v8 bindings memory info to the native memory graph
     4        https://bugs.webkit.org/show_bug.cgi?id=90149
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Size of V8 binding maps is now reported on the memory chart.
     9
     10        * bindings/js/ScriptProfiler.h:
     11        (WebCore::ScriptProfiler::collectBindingMemoryInfo):
     12        * bindings/v8/DOMDataStore.cpp:
     13        (WebCore::DOMDataStore::reportMemoryUsage):
     14        (WebCore):
     15        * bindings/v8/DOMDataStore.h:
     16        (WebCore):
     17        (DOMDataStore):
     18        * bindings/v8/IntrusiveDOMWrapperMap.h:
     19        (WebCore::ChunkedTable::reportMemoryUsage):
     20        (ChunkedTable):
     21        * bindings/v8/ScriptProfiler.cpp:
     22        (WebCore::ScriptProfiler::collectBindingMemoryInfo):
     23        (WebCore):
     24        * bindings/v8/ScriptProfiler.h:
     25        (WebCore):
     26        (ScriptProfiler):
     27        * bindings/v8/V8Binding.cpp:
     28        (WebCore::V8BindingPerIsolateData::reportMemoryUsage):
     29        (WebCore):
     30        (WebCore::StringCache::reportMemoryUsage):
     31        * bindings/v8/V8Binding.h:
     32        (WebCore):
     33        (StringCache):
     34        (V8BindingPerIsolateData):
     35        * bindings/v8/V8DOMMap.h:
     36        (WebCore):
     37        (AbstractWeakReferenceMap):
     38        * dom/MemoryInstrumentation.h:
     39        (MemoryInstrumentation):
     40        (WebCore):
     41        (WebCore::MemoryInstrumentation::reportHashMap): added a method for reporting
     42        size of a HashMap.
     43        * inspector/InspectorMemoryAgent.cpp:
     44        (MemoryBlockName):
     45        (WebCore):
     46        (WebCore::domTreeInfo):
     47
    1482012-07-01  Christophe Dumez  <christophe.dumez@intel.com>
    249
  • trunk/Source/WebCore/bindings/js/ScriptProfiler.h

    r121144 r121658  
    3939class ExternalArrayVisitor;
    4040class ExternalStringVisitor;
     41class MemoryInstrumentation;
    4142class NodeWrapperVisitor;
    4243class Page;
     
    7677    // FIXME: Implement this counter for JSC. See bug 73936 for more details.
    7778    static void visitNodeWrappers(NodeWrapperVisitor*) { }
     79    // FIXME: Support these methods for JSC. See bug 90358.
    7880    static void visitExternalStrings(ExternalStringVisitor*) { }
    7981    static void visitExternalArrays(ExternalArrayVisitor*) { }
     82    static void collectBindingMemoryInfo(MemoryInstrumentation*) { }
    8083    static size_t profilerSnapshotsSize() { return 0; }
    8184};
  • trunk/Source/WebCore/bindings/v8/DOMDataStore.cpp

    r113806 r121658  
    3333
    3434#include "DOMData.h"
     35#include "MemoryInstrumentation.h"
    3536#include "V8Binding.h"
    3637#include <wtf/MainThread.h>
     
    119120}
    120121
     122void DOMDataStore::reportMemoryUsage(MemoryInstrumentation* instrumentation)
     123{
     124    instrumentation->reportPointer(this, MemoryInstrumentation::Binding);
     125    domNodeMap().reportMemoryUsage(instrumentation);
     126    activeDomNodeMap().reportMemoryUsage(instrumentation);
     127    domObjectMap().reportMemoryUsage(instrumentation);
     128    activeDomObjectMap().reportMemoryUsage(instrumentation);
     129}
     130
    121131// Called when the object is near death (not reachable from JS roots).
    122132// It is time to remove the entry from the table and dispose the handle.
  • trunk/Source/WebCore/bindings/v8/DOMDataStore.h

    r113806 r121658  
    4848    class DOMData;
    4949    class DOMDataStore;
     50    class MemoryInstrumentation;
    5051
    5152    typedef WTF::Vector<DOMDataStore*> DOMDataList;
     
    8788        static void weakNodeCallback(v8::Persistent<v8::Value> v8Object, void* domObject);
    8889
     90        void reportMemoryUsage(MemoryInstrumentation*);
     91
    8992    protected:
    9093        static void weakDOMObjectCallback(v8::Persistent<v8::Value> v8Object, void* domObject);
  • trunk/Source/WebCore/bindings/v8/IntrusiveDOMWrapperMap.h

    r95901 r121658  
    3333
    3434#include "DOMDataStore.h"
     35#include "MemoryInstrumentation.h"
    3536#include "V8Node.h"
    3637
     
    102103    }
    103104
     105    void reportMemoryUsage(MemoryInstrumentation* instrumentation)
     106    {
     107        for (Chunk* chunk = m_chunks; chunk; chunk = chunk->m_previous)
     108            instrumentation->reportPointer(chunk, MemoryInstrumentation::Binding);
     109    }
     110
    104111  private:
    105112    struct Chunk {
     
    177184    }
    178185
     186    virtual void reportMemoryUsage(MemoryInstrumentation* instrumentation) OVERRIDE
     187    {
     188        instrumentation->reportPointer(this, MemoryInstrumentation::Binding);
     189        m_table.reportMemoryUsage(instrumentation);
     190    }
     191
    179192private:
    180193    static int const numberOfEntries = (1 << 10) - 1;
  • trunk/Source/WebCore/bindings/v8/ScriptProfiler.cpp

    r121144 r121658  
    3434
    3535#include "BindingVisitors.h"
     36#include "MemoryInstrumentation.h"
    3637#include "RetainedDOMInfo.h"
    3738#include "ScriptObject.h"
     
    220221}
    221222
     223void ScriptProfiler::collectBindingMemoryInfo(MemoryInstrumentation* instrumentation)
     224{
     225    V8BindingPerIsolateData* data = V8BindingPerIsolateData::current();
     226    if (!data)
     227        return;
     228    data->reportMemoryUsage(instrumentation);
     229}
     230
    222231size_t ScriptProfiler::profilerSnapshotsSize()
    223232{
  • trunk/Source/WebCore/bindings/v8/ScriptProfiler.h

    r121144 r121658  
    4343class ExternalArrayVisitor;
    4444class ExternalStringVisitor;
     45class MemoryInstrumentation;
    4546class NodeWrapperVisitor;
    4647class Page;
     
    8283    static void visitExternalStrings(ExternalStringVisitor*);
    8384    static void visitExternalArrays(ExternalArrayVisitor*);
     85    static void collectBindingMemoryInfo(MemoryInstrumentation*);
    8486    static size_t profilerSnapshotsSize();
    8587};
  • trunk/Source/WebCore/bindings/v8/V8Binding.cpp

    r121538 r121658  
    3535#include "DOMStringList.h"
    3636#include "Element.h"
     37#include "MemoryInstrumentation.h"
    3738#include "PlatformString.h"
    3839#include "QualifiedName.h"
     
    9091}
    9192
    92 
     93void V8BindingPerIsolateData::reportMemoryUsage(MemoryInstrumentation* instrumentation)
     94{
     95    instrumentation->reportPointer(this, MemoryInstrumentation::Binding);
     96    instrumentation->reportHashMap(m_rawTemplates, MemoryInstrumentation::Binding);
     97    instrumentation->reportHashMap(m_templates, MemoryInstrumentation::Binding);
     98    m_stringCache.reportMemoryUsage(instrumentation);
     99
     100    for (size_t i = 0; i < m_domDataList.size(); i++)
     101        m_domDataList[i]->reportMemoryUsage(instrumentation);
     102}
    93103
    94104// WebCoreStringResource is a helper class for v8ExternalString. It is used
     
    577587    return toStringTemplate;
    578588}
     589
     590void StringCache::reportMemoryUsage(MemoryInstrumentation* instrumentation)
     591{
     592    instrumentation->reportHashMap(m_stringCache, MemoryInstrumentation::Binding);
     593}
    579594   
    580595PassRefPtr<DOMStringList> v8ValueToWebCoreDOMStringList(v8::Handle<v8::Value> value)
  • trunk/Source/WebCore/bindings/v8/V8Binding.h

    r121554 r121658  
    5050    class EventTarget;
    5151    class ExternalStringVisitor;
     52    class MemoryInstrumentation;
    5253
    5354    // FIXME: Remove V8Binding.
     
    7879
    7980        void remove(StringImpl*);
     81
     82        void reportMemoryUsage(MemoryInstrumentation*);
    8083
    8184    private:
     
    214217
    215218        GCEventData& gcEventData() { return m_gcEventData; }
     219
     220        void reportMemoryUsage(MemoryInstrumentation*);
    216221
    217222    private:
  • trunk/Source/WebCore/bindings/v8/V8DOMMap.h

    r115495 r121658  
    3232#define V8DOMMap_h
    3333
     34#include "MemoryInstrumentation.h"
    3435#include <wtf/HashMap.h>
    3536#include <wtf/OwnPtr.h>
     
    3940    class DOMDataStore;
    4041    class Node;
     42    class MemoryInstrumentation;
    4143
    4244    template <class KeyType, class ValueType> class AbstractWeakReferenceMap {
     
    6264
    6365        v8::WeakReferenceCallback weakReferenceCallback() { return m_weakReferenceCallback; }
     66
     67        virtual void reportMemoryUsage(MemoryInstrumentation*) = 0;
     68
    6469    private:
    6570        v8::WeakReferenceCallback m_weakReferenceCallback;
     
    130135        }
    131136
     137        virtual void reportMemoryUsage(MemoryInstrumentation* instrumentation) OVERRIDE
     138        {
     139            instrumentation->reportHashMap(m_map, MemoryInstrumentation::Binding);
     140        }
     141
    132142    protected:
    133143        HashMap<KeyType*, ValueType*> m_map;
  • trunk/Source/WebCore/dom/MemoryInstrumentation.h

    r121530 r121658  
    4848        DOM,
    4949        CSS,
     50        Binding,
    5051        LastTypeEntry
    5152    };
     
    6061        countObjectSize(objectType, sizeof(T));
    6162    }
     63    template <typename HashMapType> void reportHashMap(const HashMapType&, ObjectType);
    6264
    6365private:
     
    140142}
    141143
     144
     145template<typename HashMapType>
     146void MemoryInstrumentation::reportHashMap(const HashMapType& hashMap, ObjectType objectType)
     147{
     148    size_t size = sizeof(HashMapType) + hashMap.capacity() * sizeof(typename HashMapType::ValueType);
     149    countObjectSize(objectType, size);
     150}
     151
    142152} // namespace WebCore
    143153
  • trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp

    r121530 r121658  
    9191static const char domTreeDOM[] = "DOMTreeDOM";
    9292static const char domTreeCSS[] = "DOMTreeCSS";
     93static const char domTreeBinding[] = "DOMTreeBinding";
    9394}
    9495
     
    448449        addMemoryBlockFor(domChildren.get(), m_totalSizes[DOM], MemoryBlockName::domTreeDOM);
    449450        addMemoryBlockFor(domChildren.get(), m_totalSizes[CSS], MemoryBlockName::domTreeCSS);
     451        addMemoryBlockFor(domChildren.get(), m_totalSizes[Binding], MemoryBlockName::domTreeBinding);
    450452
    451453        RefPtr<InspectorMemoryBlock> dom = InspectorMemoryBlock::create().setName(MemoryBlockName::dom);
     
    493495    }
    494496
     497    void visitBindings()
     498    {
     499        ScriptProfiler::collectBindingMemoryInfo(&m_domMemoryUsage);
     500    }
     501
    495502    PassRefPtr<InspectorMemoryBlock> dumpStatistics() { return m_domMemoryUsage.dumpStatistics(); }
    496503
     
    512519            domTreesIterator.visitNode(doc);
    513520    }
     521
     522    domTreesIterator.visitBindings();
    514523
    515524    return domTreesIterator.dumpStatistics();
Note: See TracChangeset for help on using the changeset viewer.