Chromium Code Reviews| Index: src/d8.cc |
| diff --git a/src/d8.cc b/src/d8.cc |
| index 611b3b570b1a4448cf5feae7dd13174e3934e289..4b1103a1905049b7ef2b344e0f7238f8a75bf860 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" |
| @@ -1996,6 +1997,12 @@ 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; |
| + } else if (strncmp(argv[i], "--trace-config=", 15) == 0) { |
| + options.trace_config = argv[i] + 15; |
| + argv[i] = NULL; |
| } |
| } |
| @@ -2412,6 +2419,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; |
| @@ -2479,6 +2487,38 @@ int Shell::Main(int argc, char* argv[]) { |
| Initialize(isolate); |
| PerIsolateData data(isolate); |
| + if (options.trace_enabled) { |
|
Yang
2016/07/21 11:26:55
Can we factor out all of this into a new function?
fmeawad
2016/07/26 09:08:09
It is now much simpler as we removed the trace_con
|
| + 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; |
| + if (options.trace_config) { |
| + int size = 0; |
| + char* trace_config_str = |
|
Yang
2016/07/21 11:26:55
Is this string going to be deleted anywhere? It lo
fmeawad
2016/07/26 09:08:09
Removed with the removal of the JSON config for no
|
| + ReadChars(nullptr, options.trace_config, &size); |
| + trace_config = |
| + platform::tracing::TraceConfig::CreateTraceConfigFromJSON( |
| + isolate, trace_config_str); |
| + } else { |
| + trace_config = |
| + platform::tracing::TraceConfig::CreateDefaultTraceConfig(); |
| + } |
| + 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)); |