OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 #include "src/log.h" | 5 #include "src/log.h" |
6 | 6 |
7 #include <cstdarg> | 7 #include <cstdarg> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
| 10 #include "include/v8-sampler.h" |
10 #include "src/bailout-reason.h" | 11 #include "src/bailout-reason.h" |
11 #include "src/base/platform/platform.h" | 12 #include "src/base/platform/platform.h" |
12 #include "src/bootstrapper.h" | 13 #include "src/bootstrapper.h" |
13 #include "src/code-stubs.h" | 14 #include "src/code-stubs.h" |
14 #include "src/deoptimizer.h" | 15 #include "src/deoptimizer.h" |
15 #include "src/global-handles.h" | 16 #include "src/global-handles.h" |
16 #include "src/log-inl.h" | 17 #include "src/log-inl.h" |
17 #include "src/log-utils.h" | 18 #include "src/log-utils.h" |
18 #include "src/macro-assembler.h" | 19 #include "src/macro-assembler.h" |
19 #include "src/profiler/cpu-profiler.h" | 20 #include "src/profiler/cpu-profiler.h" |
20 #include "src/runtime-profiler.h" | 21 #include "src/runtime-profiler.h" |
21 #include "src/string-stream.h" | 22 #include "src/string-stream.h" |
22 #include "src/vm-state-inl.h" | 23 #include "src/vm-state-inl.h" |
| 24 #include <iostream> |
23 | 25 |
24 namespace v8 { | 26 namespace v8 { |
25 namespace internal { | 27 namespace internal { |
26 | 28 |
27 | 29 |
28 #define DECLARE_EVENT(ignore1, name) name, | 30 #define DECLARE_EVENT(ignore1, name) name, |
29 static const char* const kLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = { | 31 static const char* const kLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = { |
30 LOG_EVENTS_AND_TAGS_LIST(DECLARE_EVENT) | 32 LOG_EVENTS_AND_TAGS_LIST(DECLARE_EVENT) |
31 }; | 33 }; |
32 #undef DECLARE_EVENT | 34 #undef DECLARE_EVENT |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 | 669 |
668 // Tells whether we are currently recording tick samples. | 670 // Tells whether we are currently recording tick samples. |
669 bool paused_; | 671 bool paused_; |
670 }; | 672 }; |
671 | 673 |
672 | 674 |
673 // | 675 // |
674 // Ticker used to provide ticks to the profiler and the sliding state | 676 // Ticker used to provide ticks to the profiler and the sliding state |
675 // window. | 677 // window. |
676 // | 678 // |
677 class Ticker: public Sampler { | 679 class Ticker: public V8Sampler { |
678 public: | 680 public: |
679 Ticker(Isolate* isolate, int interval): | 681 Ticker(Isolate* isolate): |
680 Sampler(isolate, interval), | 682 V8Sampler(reinterpret_cast<v8::Isolate*>(isolate)), |
681 profiler_(NULL) {} | 683 profiler_(NULL) {} |
682 | 684 |
683 ~Ticker() { if (IsActive()) Stop(); } | 685 ~Ticker() { if (IsActive()) Stop(); } |
684 | 686 |
685 virtual void Tick(TickSample* sample) { | 687 virtual void Tick(TickSample* sample) { |
686 if (profiler_) profiler_->Insert(sample); | 688 if (profiler_) profiler_->Insert(sample); |
687 } | 689 } |
688 | 690 |
689 void SetProfiler(Profiler* profiler) { | 691 void SetProfiler(Profiler* profiler) { |
690 DCHECK(profiler_ == NULL); | 692 DCHECK(profiler_ == NULL); |
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1833 if (FLAG_perf_basic_prof) { | 1835 if (FLAG_perf_basic_prof) { |
1834 perf_basic_logger_ = new PerfBasicLogger(); | 1836 perf_basic_logger_ = new PerfBasicLogger(); |
1835 addCodeEventListener(perf_basic_logger_); | 1837 addCodeEventListener(perf_basic_logger_); |
1836 } | 1838 } |
1837 | 1839 |
1838 if (FLAG_ll_prof) { | 1840 if (FLAG_ll_prof) { |
1839 ll_logger_ = new LowLevelLogger(log_file_name.str().c_str()); | 1841 ll_logger_ = new LowLevelLogger(log_file_name.str().c_str()); |
1840 addCodeEventListener(ll_logger_); | 1842 addCodeEventListener(ll_logger_); |
1841 } | 1843 } |
1842 | 1844 |
1843 ticker_ = new Ticker(isolate, kSamplingIntervalMs); | 1845 ticker_ = new Ticker(isolate); |
1844 | 1846 |
1845 if (Log::InitLogAtStart()) { | 1847 if (Log::InitLogAtStart()) { |
1846 is_logging_ = true; | 1848 is_logging_ = true; |
1847 } | 1849 } |
1848 | 1850 |
1849 if (FLAG_log_internal_timer_events || FLAG_prof_cpp) timer_.Start(); | 1851 if (FLAG_log_internal_timer_events || FLAG_prof_cpp) timer_.Start(); |
1850 | 1852 |
1851 if (FLAG_prof_cpp) { | 1853 if (FLAG_prof_cpp) { |
1852 profiler_ = new Profiler(isolate); | 1854 profiler_ = new Profiler(isolate); |
1853 is_logging_ = true; | 1855 is_logging_ = true; |
(...skipping 17 matching lines...) Expand all Loading... |
1871 addCodeEventListener(jit_logger_); | 1873 addCodeEventListener(jit_logger_); |
1872 if (options & kJitCodeEventEnumExisting) { | 1874 if (options & kJitCodeEventEnumExisting) { |
1873 HandleScope scope(isolate_); | 1875 HandleScope scope(isolate_); |
1874 LogCodeObjects(); | 1876 LogCodeObjects(); |
1875 LogCompiledFunctions(); | 1877 LogCompiledFunctions(); |
1876 } | 1878 } |
1877 } | 1879 } |
1878 } | 1880 } |
1879 | 1881 |
1880 | 1882 |
1881 Sampler* Logger::sampler() { | 1883 // Sampler* Logger::sampler() { |
| 1884 V8Sampler* Logger::sampler() { |
1882 return ticker_; | 1885 return ticker_; |
1883 } | 1886 } |
1884 | 1887 |
1885 | 1888 |
1886 FILE* Logger::TearDown() { | 1889 FILE* Logger::TearDown() { |
1887 if (!is_initialized_) return NULL; | 1890 if (!is_initialized_) return NULL; |
1888 is_initialized_ = false; | 1891 is_initialized_ = false; |
1889 | 1892 |
1890 // Stop the profiler before closing the file. | 1893 // Stop the profiler before closing the file. |
1891 if (profiler_ != NULL) { | 1894 if (profiler_ != NULL) { |
(...skipping 21 matching lines...) Expand all Loading... |
1913 removeCodeEventListener(jit_logger_); | 1916 removeCodeEventListener(jit_logger_); |
1914 delete jit_logger_; | 1917 delete jit_logger_; |
1915 jit_logger_ = NULL; | 1918 jit_logger_ = NULL; |
1916 } | 1919 } |
1917 | 1920 |
1918 return log_->Close(); | 1921 return log_->Close(); |
1919 } | 1922 } |
1920 | 1923 |
1921 } // namespace internal | 1924 } // namespace internal |
1922 } // namespace v8 | 1925 } // namespace v8 |
OLD | NEW |