Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Unified Diff: Source/bindings/v8/ScriptProfiler.cpp

Issue 14373016: DevTools: [HeapProfiler] Provide API for heap objects tracking info. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: description was slightly changed Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/bindings/v8/ScriptProfiler.cpp
diff --git a/Source/bindings/v8/ScriptProfiler.cpp b/Source/bindings/v8/ScriptProfiler.cpp
index 3215b6c7f97e34f478d2770806bb4df3c5668e1d..63b4a89b5529625b43e6a7750b696beed467a13c 100644
--- a/Source/bindings/v8/ScriptProfiler.cpp
+++ b/Source/bindings/v8/ScriptProfiler.cpp
@@ -43,6 +43,7 @@
#include "core/inspector/BindingVisitors.h"
#include <v8-profiler.h>
+#include <v8.h>
#include "wtf/ThreadSpecific.h"
@@ -199,6 +200,54 @@ private:
} // namespace
+void ScriptProfiler::startTrackingHeapObjects()
+{
+ v8::Isolate::GetCurrent()->GetHeapProfiler()->StartTrackingHeapObjects();
+}
+
+namespace {
+
+class HeapStatsStream : public v8::OutputStream {
+public:
+ HeapStatsStream(ScriptProfiler::OutputStream* stream) : m_stream(stream) { }
+ virtual void EndOfStream() OVERRIDE { }
+
+ virtual WriteResult WriteAsciiChunk(char* data, int size) OVERRIDE
+ {
+ ASSERT(false);
+ return kAbort;
+ }
+
+ virtual WriteResult WriteHeapStatsChunk(v8::HeapStatsUpdate* updateData, int count) OVERRIDE
+ {
+ Vector<uint32_t> rawData(count * 3);
+ for (int i = 0; i < count; ++i) {
+ int offset = i * 3;
+ rawData[offset] = updateData[i].index;
+ rawData[offset + 1] = updateData[i].count;
+ rawData[offset + 2] = updateData[i].size;
+ }
+ m_stream->write(rawData.data(), count * 3);
yurys 2013/04/25 12:23:15 count * 3 -> rawData.size()
loislo 2013/04/25 13:33:56 Done.
+ return kContinue;
+ }
+
+private:
+ ScriptProfiler::OutputStream* m_stream;
+};
+
+}
+
+unsigned ScriptProfiler::requestHeapStatsUpdate(ScriptProfiler::OutputStream* stream)
+{
+ HeapStatsStream heapStatsStream(stream);
+ return v8::Isolate::GetCurrent()->GetHeapProfiler()->GetHeapStats(&heapStatsStream);
+}
+
+void ScriptProfiler::stopTrackingHeapObjects()
+{
+ v8::Isolate::GetCurrent()->GetHeapProfiler()->StopTrackingHeapObjects();
+}
+
// FIXME: This method should receive a ScriptState, from which we should retrieve an Isolate.
PassRefPtr<ScriptHeapSnapshot> ScriptProfiler::takeHeapSnapshot(const String& title, HeapSnapshotProgress* control)
{

Powered by Google App Engine
This is Rietveld 408576698