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

Unified Diff: src/d8.cc

Issue 2183923004: Reland [Tracing] V8 Tracing Controller (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix CHECK_EQ undefined behavior in test-tracing to be determinstic Created 4 years, 5 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/d8.h ('k') | src/libplatform/default-platform.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 4d3f1a41cea46e91be1322e462bcc8e5ce6cd8a1..e3772556d2701409cb13b8ee77a8d6865fd5a2c3 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -35,6 +35,7 @@
#include "src/ostreams.h"
#include "include/libplatform/libplatform.h"
+#include "include/libplatform/v8-tracing.h"
#ifndef V8_SHARED
#include "src/api.h"
#include "src/base/cpu.h"
@@ -1991,6 +1992,9 @@ bool Shell::SetOptions(int argc, char* argv[]) {
return false;
}
argv[i] = NULL;
+ } else if (strcmp(argv[i], "--enable-tracing") == 0) {
+ options.trace_enabled = true;
+ argv[i] = NULL;
}
}
@@ -2407,6 +2411,7 @@ static void DumpHeapConstants(i::Isolate* isolate) {
int Shell::Main(int argc, char* argv[]) {
+ std::ofstream trace_file;
#if (defined(_WIN32) || defined(_WIN64))
UINT new_flags =
SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX;
@@ -2474,6 +2479,29 @@ int Shell::Main(int argc, char* argv[]) {
Initialize(isolate);
PerIsolateData data(isolate);
+ if (options.trace_enabled) {
+ trace_file.open("v8_trace.json");
+ platform::tracing::TracingController* tracing_controller =
+ new platform::tracing::TracingController();
+ platform::tracing::TraceBuffer* trace_buffer =
+ platform::tracing::TraceBuffer::CreateTraceBufferRingBuffer(
+ platform::tracing::TraceBuffer::kRingBufferChunks,
+ platform::tracing::TraceWriter::CreateJSONTraceWriter(
+ trace_file));
+ platform::tracing::TraceConfig* trace_config;
+ trace_config = new platform::tracing::TraceConfig();
+ trace_config->AddIncludedCategory("v8");
+ tracing_controller->Initialize(trace_buffer);
+ tracing_controller->StartTracing(trace_config);
+#ifndef V8_SHARED
+ if (!i::FLAG_verify_predictable) {
+ platform::SetTracingController(g_platform, tracing_controller);
+ }
+#else
+ platform::SetTracingController(g_platform, tracing_controller);
+#endif
+ }
+
#ifndef V8_SHARED
if (options.dump_heap_constants) {
DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate));
« no previous file with comments | « src/d8.h ('k') | src/libplatform/default-platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698