OLD | NEW |
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 Loading... |
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" | |
39 #ifndef V8_SHARED | 38 #ifndef V8_SHARED |
40 #include "src/api.h" | 39 #include "src/api.h" |
41 #include "src/base/cpu.h" | 40 #include "src/base/cpu.h" |
42 #include "src/base/logging.h" | 41 #include "src/base/logging.h" |
43 #include "src/base/platform/platform.h" | 42 #include "src/base/platform/platform.h" |
44 #include "src/base/sys-info.h" | 43 #include "src/base/sys-info.h" |
45 #include "src/basic-block-profiler.h" | 44 #include "src/basic-block-profiler.h" |
46 #include "src/interpreter/interpreter.h" | 45 #include "src/interpreter/interpreter.h" |
47 #include "src/snapshot/natives.h" | 46 #include "src/snapshot/natives.h" |
48 #include "src/utils.h" | 47 #include "src/utils.h" |
(...skipping 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 options.compile_options = v8::ScriptCompiler::kProduceCodeCache; | 1989 options.compile_options = v8::ScriptCompiler::kProduceCodeCache; |
1991 } else if (strncmp(value, "=parse", 7) == 0) { | 1990 } else if (strncmp(value, "=parse", 7) == 0) { |
1992 options.compile_options = v8::ScriptCompiler::kProduceParserCache; | 1991 options.compile_options = v8::ScriptCompiler::kProduceParserCache; |
1993 } else if (strncmp(value, "=none", 6) == 0) { | 1992 } else if (strncmp(value, "=none", 6) == 0) { |
1994 options.compile_options = v8::ScriptCompiler::kNoCompileOptions; | 1993 options.compile_options = v8::ScriptCompiler::kNoCompileOptions; |
1995 } else { | 1994 } else { |
1996 printf("Unknown option to --cache.\n"); | 1995 printf("Unknown option to --cache.\n"); |
1997 return false; | 1996 return false; |
1998 } | 1997 } |
1999 argv[i] = NULL; | 1998 argv[i] = NULL; |
2000 } else if (strcmp(argv[i], "--enable-tracing") == 0) { | |
2001 options.trace_enabled = true; | |
2002 argv[i] = NULL; | |
2003 } | 1999 } |
2004 } | 2000 } |
2005 | 2001 |
2006 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); | 2002 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); |
2007 | 2003 |
2008 // Set up isolated source groups. | 2004 // Set up isolated source groups. |
2009 options.isolate_sources = new SourceGroup[options.num_isolates]; | 2005 options.isolate_sources = new SourceGroup[options.num_isolates]; |
2010 SourceGroup* current = options.isolate_sources; | 2006 SourceGroup* current = options.isolate_sources; |
2011 current->Begin(argv, 1); | 2007 current->Begin(argv, 1); |
2012 for (int i = 1; i < argc; i++) { | 2008 for (int i = 1; i < argc; i++) { |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2409 printf(" (\"%s\", 0x%05" V8PRIxPTR "): \"%s\",\n", sname, p, n); | 2405 printf(" (\"%s\", 0x%05" V8PRIxPTR "): \"%s\",\n", sname, p, n); |
2410 } | 2406 } |
2411 } | 2407 } |
2412 printf("}\n"); | 2408 printf("}\n"); |
2413 #undef ROOT_LIST_CASE | 2409 #undef ROOT_LIST_CASE |
2414 } | 2410 } |
2415 #endif // !V8_SHARED | 2411 #endif // !V8_SHARED |
2416 | 2412 |
2417 | 2413 |
2418 int Shell::Main(int argc, char* argv[]) { | 2414 int Shell::Main(int argc, char* argv[]) { |
2419 std::ofstream trace_file; | |
2420 #if (defined(_WIN32) || defined(_WIN64)) | 2415 #if (defined(_WIN32) || defined(_WIN64)) |
2421 UINT new_flags = | 2416 UINT new_flags = |
2422 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; | 2417 SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; |
2423 UINT existing_flags = SetErrorMode(new_flags); | 2418 UINT existing_flags = SetErrorMode(new_flags); |
2424 SetErrorMode(existing_flags | new_flags); | 2419 SetErrorMode(existing_flags | new_flags); |
2425 #if defined(_MSC_VER) | 2420 #if defined(_MSC_VER) |
2426 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); | 2421 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); |
2427 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); | 2422 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); |
2428 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); | 2423 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); |
2429 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); | 2424 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2477 create_params.create_histogram_callback = CreateHistogram; | 2472 create_params.create_histogram_callback = CreateHistogram; |
2478 create_params.add_histogram_sample_callback = AddHistogramSample; | 2473 create_params.add_histogram_sample_callback = AddHistogramSample; |
2479 } | 2474 } |
2480 #endif | 2475 #endif |
2481 Isolate* isolate = Isolate::New(create_params); | 2476 Isolate* isolate = Isolate::New(create_params); |
2482 { | 2477 { |
2483 Isolate::Scope scope(isolate); | 2478 Isolate::Scope scope(isolate); |
2484 Initialize(isolate); | 2479 Initialize(isolate); |
2485 PerIsolateData data(isolate); | 2480 PerIsolateData data(isolate); |
2486 | 2481 |
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 | |
2510 #ifndef V8_SHARED | 2482 #ifndef V8_SHARED |
2511 if (options.dump_heap_constants) { | 2483 if (options.dump_heap_constants) { |
2512 DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate)); | 2484 DumpHeapConstants(reinterpret_cast<i::Isolate*>(isolate)); |
2513 return 0; | 2485 return 0; |
2514 } | 2486 } |
2515 #endif | 2487 #endif |
2516 | 2488 |
2517 if (options.stress_opt || options.stress_deopt) { | 2489 if (options.stress_opt || options.stress_deopt) { |
2518 Testing::SetStressRunType(options.stress_opt | 2490 Testing::SetStressRunType(options.stress_opt |
2519 ? Testing::kStressTypeOpt | 2491 ? Testing::kStressTypeOpt |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2581 } | 2553 } |
2582 | 2554 |
2583 } // namespace v8 | 2555 } // namespace v8 |
2584 | 2556 |
2585 | 2557 |
2586 #ifndef GOOGLE3 | 2558 #ifndef GOOGLE3 |
2587 int main(int argc, char* argv[]) { | 2559 int main(int argc, char* argv[]) { |
2588 return v8::Shell::Main(argc, argv); | 2560 return v8::Shell::Main(argc, argv); |
2589 } | 2561 } |
2590 #endif | 2562 #endif |
OLD | NEW |