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

Unified Diff: src/d8.cc

Issue 8055029: Add experimental support for tracing the state of the VM heap to a file Base URL: http://v8.googlecode.com/svn/branches/experimental/heap-visualization/
Patch Set: Created 9 years, 3 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
« no previous file with comments | « src/api.cc ('k') | src/execution.cc » ('j') | src/spaces.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
===================================================================
--- src/d8.cc (revision 9457)
+++ src/d8.cc (working copy)
@@ -112,6 +112,27 @@
}
+class FileHeapVisualizer : public v8::HeapVisualizer {
+ public:
+ explicit FileHeapVisualizer(const char* path) {
+ file_ = i::OS::FOpen(path, "w");
+ }
+
+ ~FileHeapVisualizer() {
+ if (file_ != NULL) fclose(file_);
+ }
+
+ void Write(const char* buf, int len) {
+ fwrite(reinterpret_cast<const void*>(buf), 1, len, file_);
+ }
+
+ bool open_succeeded() { return file_ != NULL; }
+
+ private:
+ FILE* file_;
+};
+
+
CounterMap* Shell::counter_map_;
i::OS::MemoryMappedFile* Shell::counters_file_ = NULL;
CounterCollection Shell::local_counters_;
@@ -635,7 +656,6 @@
}
#endif // V8_SHARED
-
#ifdef COMPRESS_STARTUP_DATA_BZ2
class BZip2Decompressor : public v8::StartupDataDecompressor {
public:
@@ -1264,6 +1284,17 @@
}
#endif // V8_SHARED
}
+
+ if (i::FLAG_trace_heap) {
+ FileHeapVisualizer* visualizer =
+ new FileHeapVisualizer(i::FLAG_trace_heap_file);
+ if (visualizer->open_succeeded()) {
+ RegisterHeapVisualizer(visualizer);
+ } else {
+ delete visualizer;
+ }
+ }
+
{
Context::Scope cscope(context);
options.isolate_sources[0].Execute();
« no previous file with comments | « src/api.cc ('k') | src/execution.cc » ('j') | src/spaces.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698