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):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121658
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-06-28 Yury Semikhatsky <yurys@chromium.org>
+
+ 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):
+
2012-07-01 Christophe Dumez <christophe.dumez@intel.com>
[EFL] Add Gamepad support
class ExternalArrayVisitor;
class ExternalStringVisitor;
+class MemoryInstrumentation;
class NodeWrapperVisitor;
class Page;
class ScriptObject;
static bool hasHeapProfiler() { return false; }
// FIXME: Implement this counter for JSC. See bug 73936 for more details.
static void visitNodeWrappers(NodeWrapperVisitor*) { }
+ // FIXME: Support these methods for JSC. See bug 90358.
static void visitExternalStrings(ExternalStringVisitor*) { }
static void visitExternalArrays(ExternalArrayVisitor*) { }
+ static void collectBindingMemoryInfo(MemoryInstrumentation*) { }
static size_t profilerSnapshotsSize() { return 0; }
};
#include "DOMDataStore.h"
#include "DOMData.h"
+#include "MemoryInstrumentation.h"
#include "V8Binding.h"
#include <wtf/MainThread.h>
return 0;
}
+void DOMDataStore::reportMemoryUsage(MemoryInstrumentation* instrumentation)
+{
+ instrumentation->reportPointer(this, MemoryInstrumentation::Binding);
+ domNodeMap().reportMemoryUsage(instrumentation);
+ activeDomNodeMap().reportMemoryUsage(instrumentation);
+ domObjectMap().reportMemoryUsage(instrumentation);
+ activeDomObjectMap().reportMemoryUsage(instrumentation);
+}
+
// Called when the object is near death (not reachable from JS roots).
// It is time to remove the entry from the table and dispose the handle.
void DOMDataStore::weakDOMObjectCallback(v8::Persistent<v8::Value> v8Object, void* domObject)
class DOMData;
class DOMDataStore;
+ class MemoryInstrumentation;
typedef WTF::Vector<DOMDataStore*> DOMDataList;
static void weakActiveDOMObjectCallback(v8::Persistent<v8::Value> v8Object, void* domObject);
static void weakNodeCallback(v8::Persistent<v8::Value> v8Object, void* domObject);
+ void reportMemoryUsage(MemoryInstrumentation*);
+
protected:
static void weakDOMObjectCallback(v8::Persistent<v8::Value> v8Object, void* domObject);
#define IntrusiveDOMWrapperMap_h
#include "DOMDataStore.h"
+#include "MemoryInstrumentation.h"
#include "V8Node.h"
namespace WebCore {
visitEntries(store, chunk->m_entries, chunk->m_entries + CHUNK_SIZE, visitor);
}
+ void reportMemoryUsage(MemoryInstrumentation* instrumentation)
+ {
+ for (Chunk* chunk = m_chunks; chunk; chunk = chunk->m_previous)
+ instrumentation->reportPointer(chunk, MemoryInstrumentation::Binding);
+ }
+
private:
struct Chunk {
explicit Chunk(Chunk* previous) : m_previous(previous) { }
m_table.clear();
}
+ virtual void reportMemoryUsage(MemoryInstrumentation* instrumentation) OVERRIDE
+ {
+ instrumentation->reportPointer(this, MemoryInstrumentation::Binding);
+ m_table.reportMemoryUsage(instrumentation);
+ }
+
private:
static int const numberOfEntries = (1 << 10) - 1;
#include "ScriptProfiler.h"
#include "BindingVisitors.h"
+#include "MemoryInstrumentation.h"
#include "RetainedDOMInfo.h"
#include "ScriptObject.h"
#include "V8ArrayBufferView.h"
}
+void ScriptProfiler::collectBindingMemoryInfo(MemoryInstrumentation* instrumentation)
+{
+ V8BindingPerIsolateData* data = V8BindingPerIsolateData::current();
+ if (!data)
+ return;
+ data->reportMemoryUsage(instrumentation);
+}
+
size_t ScriptProfiler::profilerSnapshotsSize()
{
return v8::HeapProfiler::GetMemorySizeUsedByProfiler();
class ExternalArrayVisitor;
class ExternalStringVisitor;
+class MemoryInstrumentation;
class NodeWrapperVisitor;
class Page;
class ScriptObject;
static void visitNodeWrappers(NodeWrapperVisitor*);
static void visitExternalStrings(ExternalStringVisitor*);
static void visitExternalArrays(ExternalArrayVisitor*);
+ static void collectBindingMemoryInfo(MemoryInstrumentation*);
static size_t profilerSnapshotsSize();
};
#include "BindingVisitors.h"
#include "DOMStringList.h"
#include "Element.h"
+#include "MemoryInstrumentation.h"
#include "PlatformString.h"
#include "QualifiedName.h"
#include "V8DOMStringList.h"
isolate->SetData(0);
}
+void V8BindingPerIsolateData::reportMemoryUsage(MemoryInstrumentation* instrumentation)
+{
+ instrumentation->reportPointer(this, MemoryInstrumentation::Binding);
+ instrumentation->reportHashMap(m_rawTemplates, MemoryInstrumentation::Binding);
+ instrumentation->reportHashMap(m_templates, MemoryInstrumentation::Binding);
+ m_stringCache.reportMemoryUsage(instrumentation);
+ for (size_t i = 0; i < m_domDataList.size(); i++)
+ m_domDataList[i]->reportMemoryUsage(instrumentation);
+}
// WebCoreStringResource is a helper class for v8ExternalString. It is used
// to manage the life-cycle of the underlying buffer of the external string.
toStringTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(constructorToString));
return toStringTemplate;
}
+
+void StringCache::reportMemoryUsage(MemoryInstrumentation* instrumentation)
+{
+ instrumentation->reportHashMap(m_stringCache, MemoryInstrumentation::Binding);
+}
PassRefPtr<DOMStringList> v8ValueToWebCoreDOMStringList(v8::Handle<v8::Value> value)
{
class EventListener;
class EventTarget;
class ExternalStringVisitor;
+ class MemoryInstrumentation;
// FIXME: Remove V8Binding.
class V8Binding {
void remove(StringImpl*);
+ void reportMemoryUsage(MemoryInstrumentation*);
+
private:
v8::Local<v8::String> v8ExternalStringSlow(StringImpl*, v8::Isolate*);
GCEventData& gcEventData() { return m_gcEventData; }
+ void reportMemoryUsage(MemoryInstrumentation*);
+
private:
explicit V8BindingPerIsolateData(v8::Isolate*);
~V8BindingPerIsolateData();
#ifndef V8DOMMap_h
#define V8DOMMap_h
+#include "MemoryInstrumentation.h"
#include <wtf/HashMap.h>
#include <wtf/OwnPtr.h>
#include <v8.h>
namespace WebCore {
class DOMDataStore;
class Node;
+ class MemoryInstrumentation;
template <class KeyType, class ValueType> class AbstractWeakReferenceMap {
public:
virtual void clear() = 0;
v8::WeakReferenceCallback weakReferenceCallback() { return m_weakReferenceCallback; }
+
+ virtual void reportMemoryUsage(MemoryInstrumentation*) = 0;
+
private:
v8::WeakReferenceCallback m_weakReferenceCallback;
};
visitor->endMap();
}
+ virtual void reportMemoryUsage(MemoryInstrumentation* instrumentation) OVERRIDE
+ {
+ instrumentation->reportHashMap(m_map, MemoryInstrumentation::Binding);
+ }
+
protected:
HashMap<KeyType*, ValueType*> m_map;
};
Other,
DOM,
CSS,
+ Binding,
LastTypeEntry
};
return;
countObjectSize(objectType, sizeof(T));
}
+ template <typename HashMapType> void reportHashMap(const HashMapType&, ObjectType);
private:
friend class MemoryObjectInfo;
object.reportMemoryUsage(&memoryObjectInfo);
}
+
+template<typename HashMapType>
+void MemoryInstrumentation::reportHashMap(const HashMapType& hashMap, ObjectType objectType)
+{
+ size_t size = sizeof(HashMapType) + hashMap.capacity() * sizeof(typename HashMapType::ValueType);
+ countObjectSize(objectType, size);
+}
+
} // namespace WebCore
#endif // !defined(MemoryInstrumentation_h)
static const char domTreeOther[] = "DOMTreeOther";
static const char domTreeDOM[] = "DOMTreeDOM";
static const char domTreeCSS[] = "DOMTreeCSS";
+static const char domTreeBinding[] = "DOMTreeBinding";
}
namespace {
addMemoryBlockFor(domChildren.get(), m_totalSizes[Other], MemoryBlockName::domTreeOther);
addMemoryBlockFor(domChildren.get(), m_totalSizes[DOM], MemoryBlockName::domTreeDOM);
addMemoryBlockFor(domChildren.get(), m_totalSizes[CSS], MemoryBlockName::domTreeCSS);
+ addMemoryBlockFor(domChildren.get(), m_totalSizes[Binding], MemoryBlockName::domTreeBinding);
RefPtr<InspectorMemoryBlock> dom = InspectorMemoryBlock::create().setName(MemoryBlockName::dom);
dom->setSize(totalSize);
m_domMemoryUsage.reportInstrumentedPointer(node);
}
+ void visitBindings()
+ {
+ ScriptProfiler::collectBindingMemoryInfo(&m_domMemoryUsage);
+ }
+
PassRefPtr<InspectorMemoryBlock> dumpStatistics() { return m_domMemoryUsage.dumpStatistics(); }
private:
domTreesIterator.visitNode(doc);
}
+ domTreesIterator.visitBindings();
+
return domTreesIterator.dumpStatistics();
}