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

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 getter for more attributes of TraceObject 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 unified diff | Download patch
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;
2003 } else if (strncmp(argv[i], "--trace-config=", 15) == 0) {
2004 options.trace_config = argv[i] + 15;
2005 argv[i] = NULL;
1999 } 2006 }
2000 } 2007 }
2001 2008
2002 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); 2009 v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
2003 2010
2004 // Set up isolated source groups. 2011 // Set up isolated source groups.
2005 options.isolate_sources = new SourceGroup[options.num_isolates]; 2012 options.isolate_sources = new SourceGroup[options.num_isolates];
2006 SourceGroup* current = options.isolate_sources; 2013 SourceGroup* current = options.isolate_sources;
2007 current->Begin(argv, 1); 2014 current->Begin(argv, 1);
2008 for (int i = 1; i < argc; i++) { 2015 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); 2412 printf(" (\"%s\", 0x%05" V8PRIxPTR "): \"%s\",\n", sname, p, n);
2406 } 2413 }
2407 } 2414 }
2408 printf("}\n"); 2415 printf("}\n");
2409 #undef ROOT_LIST_CASE 2416 #undef ROOT_LIST_CASE
2410 } 2417 }
2411 #endif // !V8_SHARED 2418 #endif // !V8_SHARED
2412 2419
2413 2420
2414 int Shell::Main(int argc, char* argv[]) { 2421 int Shell::Main(int argc, char* argv[]) {
2422 std::ofstream trace_file;
2415 #if (defined(_WIN32) || defined(_WIN64)) 2423 #if (defined(_WIN32) || defined(_WIN64))
2416 UINT new_flags = 2424 UINT new_flags =
2417 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; 2425 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX;
2418 UINT existing_flags = SetErrorMode(new_flags); 2426 UINT existing_flags = SetErrorMode(new_flags);
2419 SetErrorMode(existing_flags | new_flags); 2427 SetErrorMode(existing_flags | new_flags);
2420 #if defined(_MSC_VER) 2428 #if defined(_MSC_VER)
2421 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); 2429 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
2422 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); 2430 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
2423 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); 2431 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
2424 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); 2432 _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; 2480 create_params.create_histogram_callback = CreateHistogram;
2473 create_params.add_histogram_sample_callback = AddHistogramSample; 2481 create_params.add_histogram_sample_callback = AddHistogramSample;
2474 } 2482 }
2475 #endif 2483 #endif
2476 Isolate* isolate = Isolate::New(create_params); 2484 Isolate* isolate = Isolate::New(create_params);
2477 { 2485 {
2478 Isolate::Scope scope(isolate); 2486 Isolate::Scope scope(isolate);
2479 Initialize(isolate); 2487 Initialize(isolate);
2480 PerIsolateData data(isolate); 2488 PerIsolateData data(isolate);
2481 2489
2490 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
2491 trace_file.open("v8_trace.json");
2492 platform::tracing::TracingController* tracing_controller =
2493 new platform::tracing::TracingController();
2494 platform::tracing::TraceBuffer* trace_buffer =
2495 platform::tracing::TraceBuffer::CreateTraceBufferRingBuffer(
2496 platform::tracing::TraceBuffer::kRingBufferChunks,
2497 platform::tracing::TraceWriter::CreateJSONTraceWriter(
2498 trace_file));
2499 platform::tracing::TraceConfig* trace_config;
2500 if (options.trace_config) {
2501 int size = 0;
2502 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
2503 ReadChars(nullptr, options.trace_config, &size);
2504 trace_config =
2505 platform::tracing::TraceConfig::CreateTraceConfigFromJSON(
2506 isolate, trace_config_str);
2507 } else {
2508 trace_config =
2509 platform::tracing::TraceConfig::CreateDefaultTraceConfig();
2510 }
2511 tracing_controller->Initialize(trace_buffer);
2512 tracing_controller->StartTracing(trace_config);
2513 #ifndef V8_SHARED
2514 if (!i::FLAG_verify_predictable) {
2515 platform::SetTracingController(g_platform, tracing_controller);
2516 }
2517 #else
2518 platform::SetTracingController(g_platform, tracing_controller);
2519 #endif
2520 }
2521
2482 #ifndef V8_SHARED 2522 #ifndef V8_SHARED
2483 if (options.dump_heap_constants) { 2523 if (options.dump_heap_constants) {
2484 DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate)); 2524 DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate));
2485 return 0; 2525 return 0;
2486 } 2526 }
2487 #endif 2527 #endif
2488 2528
2489 if (options.stress_opt || options.stress_deopt) { 2529 if (options.stress_opt || options.stress_deopt) {
2490 Testing::SetStressRunType(options.stress_opt 2530 Testing::SetStressRunType(options.stress_opt
2491 ? Testing::kStressTypeOpt 2531 ? Testing::kStressTypeOpt
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2553 } 2593 }
2554 2594
2555 } // namespace v8 2595 } // namespace v8
2556 2596
2557 2597
2558 #ifndef GOOGLE3 2598 #ifndef GOOGLE3
2559 int main(int argc, char* argv[]) { 2599 int main(int argc, char* argv[]) {
2560 return v8::Shell::Main(argc, argv); 2600 return v8::Shell::Main(argc, argv);
2561 } 2601 }
2562 #endif 2602 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698