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

Side by Side Diff: src/d8.cc

Issue 2137013006: [Tracing] V8 Tracing Controller (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add Setters for TraceConfig categories Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « src/d8.h ('k') | src/libplatform/default-platform.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 // Defined when linking against shared lib on Windows. 6 // Defined when linking against shared lib on Windows.
7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED)
8 #define V8_SHARED 8 #define V8_SHARED
9 #endif 9 #endif
10 10
(...skipping 17 matching lines...) Expand all
28 #endif // V8_SHARED 28 #endif // V8_SHARED
29 29
30 #ifdef ENABLE_VTUNE_JIT_INTERFACE 30 #ifdef ENABLE_VTUNE_JIT_INTERFACE
31 #include "src/third_party/vtune/v8-vtune.h" 31 #include "src/third_party/vtune/v8-vtune.h"
32 #endif 32 #endif
33 33
34 #include "src/d8.h" 34 #include "src/d8.h"
35 #include "src/ostreams.h" 35 #include "src/ostreams.h"
36 36
37 #include "include/libplatform/libplatform.h" 37 #include "include/libplatform/libplatform.h"
38 #include "include/libplatform/v8-tracing.h"
38 #ifndef V8_SHARED 39 #ifndef V8_SHARED
39 #include "src/api.h" 40 #include "src/api.h"
40 #include "src/base/cpu.h" 41 #include "src/base/cpu.h"
41 #include "src/base/logging.h" 42 #include "src/base/logging.h"
42 #include "src/base/platform/platform.h" 43 #include "src/base/platform/platform.h"
43 #include "src/base/sys-info.h" 44 #include "src/base/sys-info.h"
44 #include "src/basic-block-profiler.h" 45 #include "src/basic-block-profiler.h"
45 #include "src/interpreter/interpreter.h" 46 #include "src/interpreter/interpreter.h"
46 #include "src/snapshot/natives.h" 47 #include "src/snapshot/natives.h"
47 #include "src/utils.h" 48 #include "src/utils.h"
(...skipping 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 options.compile_options = v8::ScriptCompiler::kProduceCodeCache; 1990 options.compile_options = v8::ScriptCompiler::kProduceCodeCache;
1990 } else if (strncmp(value, "=parse", 7) == 0) { 1991 } else if (strncmp(value, "=parse", 7) == 0) {
1991 options.compile_options = v8::ScriptCompiler::kProduceParserCache; 1992 options.compile_options = v8::ScriptCompiler::kProduceParserCache;
1992 } else if (strncmp(value, "=none", 6) == 0) { 1993 } else if (strncmp(value, "=none", 6) == 0) {
1993 options.compile_options = v8::ScriptCompiler::kNoCompileOptions; 1994 options.compile_options = v8::ScriptCompiler::kNoCompileOptions;
1994 } else { 1995 } else {
1995 printf("Unknown option to --cache.\n"); 1996 printf("Unknown option to --cache.\n");
1996 return false; 1997 return false;
1997 } 1998 }
1998 argv[i] = NULL; 1999 argv[i] = NULL;
2000 } else if (strcmp(argv[i], "--enable-tracing") == 0) {
2001 options.trace_enabled = true;
2002 argv[i] = NULL;
1999 } 2003 }
2000 } 2004 }
2001 2005
2002 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); 2006 v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
2003 2007
2004 // Set up isolated source groups. 2008 // Set up isolated source groups.
2005 options.isolate_sources = new SourceGroup[options.num_isolates]; 2009 options.isolate_sources = new SourceGroup[options.num_isolates];
2006 SourceGroup* current = options.isolate_sources; 2010 SourceGroup* current = options.isolate_sources;
2007 current->Begin(argv, 1); 2011 current->Begin(argv, 1);
2008 for (int i = 1; i < argc; i++) { 2012 for (int i = 1; i < argc; i++) {
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
2405 printf(" (\"%s\", 0x%05" V8PRIxPTR "): \"%s\",\n", sname, p, n); 2409 printf(" (\"%s\", 0x%05" V8PRIxPTR "): \"%s\",\n", sname, p, n);
2406 } 2410 }
2407 } 2411 }
2408 printf("}\n"); 2412 printf("}\n");
2409 #undef ROOT_LIST_CASE 2413 #undef ROOT_LIST_CASE
2410 } 2414 }
2411 #endif // !V8_SHARED 2415 #endif // !V8_SHARED
2412 2416
2413 2417
2414 int Shell::Main(int argc, char* argv[]) { 2418 int Shell::Main(int argc, char* argv[]) {
2419 std::ofstream trace_file;
2415 #if (defined(_WIN32) || defined(_WIN64)) 2420 #if (defined(_WIN32) || defined(_WIN64))
2416 UINT new_flags = 2421 UINT new_flags =
2417 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; 2422 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX;
2418 UINT existing_flags = SetErrorMode(new_flags); 2423 UINT existing_flags = SetErrorMode(new_flags);
2419 SetErrorMode(existing_flags | new_flags); 2424 SetErrorMode(existing_flags | new_flags);
2420 #if defined(_MSC_VER) 2425 #if defined(_MSC_VER)
2421 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); 2426 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
2422 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); 2427 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
2423 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); 2428 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
2424 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); 2429 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2472 create_params.create_histogram_callback = CreateHistogram; 2477 create_params.create_histogram_callback = CreateHistogram;
2473 create_params.add_histogram_sample_callback = AddHistogramSample; 2478 create_params.add_histogram_sample_callback = AddHistogramSample;
2474 } 2479 }
2475 #endif 2480 #endif
2476 Isolate* isolate = Isolate::New(create_params); 2481 Isolate* isolate = Isolate::New(create_params);
2477 { 2482 {
2478 Isolate::Scope scope(isolate); 2483 Isolate::Scope scope(isolate);
2479 Initialize(isolate); 2484 Initialize(isolate);
2480 PerIsolateData data(isolate); 2485 PerIsolateData data(isolate);
2481 2486
2487 if (options.trace_enabled) {
2488 trace_file.open("v8_trace.json");
2489 platform::tracing::TracingController* tracing_controller =
2490 new platform::tracing::TracingController();
2491 platform::tracing::TraceBuffer* trace_buffer =
2492 platform::tracing::TraceBuffer::CreateTraceBufferRingBuffer(
2493 platform::tracing::TraceBuffer::kRingBufferChunks,
2494 platform::tracing::TraceWriter::CreateJSONTraceWriter(
2495 trace_file));
2496 platform::tracing::TraceConfig* trace_config;
2497 trace_config = new platform::tracing::TraceConfig();
2498 trace_config->AddIncludedCategory("v8");
2499 tracing_controller->Initialize(trace_buffer);
2500 tracing_controller->StartTracing(trace_config);
2501 #ifndef V8_SHARED
2502 if (!i::FLAG_verify_predictable) {
2503 platform::SetTracingController(g_platform, tracing_controller);
2504 }
2505 #else
2506 platform::SetTracingController(g_platform, tracing_controller);
2507 #endif
2508 }
2509
2482 #ifndef V8_SHARED 2510 #ifndef V8_SHARED
2483 if (options.dump_heap_constants) { 2511 if (options.dump_heap_constants) {
2484 DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate)); 2512 DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate));
2485 return 0; 2513 return 0;
2486 } 2514 }
2487 #endif 2515 #endif
2488 2516
2489 if (options.stress_opt || options.stress_deopt) { 2517 if (options.stress_opt || options.stress_deopt) {
2490 Testing::SetStressRunType(options.stress_opt 2518 Testing::SetStressRunType(options.stress_opt
2491 ? Testing::kStressTypeOpt 2519 ? Testing::kStressTypeOpt
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2553 } 2581 }
2554 2582
2555 } // namespace v8 2583 } // namespace v8
2556 2584
2557 2585
2558 #ifndef GOOGLE3 2586 #ifndef GOOGLE3
2559 int main(int argc, char* argv[]) { 2587 int main(int argc, char* argv[]) {
2560 return v8::Shell::Main(argc, argv); 2588 return v8::Shell::Main(argc, argv);
2561 } 2589 }
2562 #endif 2590 #endif
OLDNEW
« 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