| 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 "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| 11 #include "src/base/platform/platform.h" | 11 #include "src/base/platform/platform.h" |
| 12 #include "src/bootstrapper.h" | 12 #include "src/bootstrapper.h" |
| 13 #include "src/code-stubs.h" | 13 #include "src/code-stubs.h" |
| 14 #include "src/counters.h" | 14 #include "src/counters.h" |
| 15 #include "src/deoptimizer.h" | 15 #include "src/deoptimizer.h" |
| 16 #include "src/global-handles.h" | 16 #include "src/global-handles.h" |
| 17 #include "src/interpreter/bytecodes.h" | 17 #include "src/interpreter/bytecodes.h" |
| 18 #include "src/interpreter/interpreter.h" | 18 #include "src/interpreter/interpreter.h" |
| 19 #include "src/libsampler/v8-sampler.h" | 19 #include "src/libsampler/v8-sampler.h" |
| 20 #include "src/log-inl.h" | 20 #include "src/log-inl.h" |
| 21 #include "src/log-utils.h" | 21 #include "src/log-utils.h" |
| 22 #include "src/macro-assembler.h" | 22 #include "src/macro-assembler.h" |
| 23 #include "src/perf-jit.h" | 23 #include "src/perf-jit.h" |
| 24 #include "src/profiler/cpu-profiler-inl.h" | 24 #include "src/profiler/cpu-profiler-inl.h" |
| 25 #include "src/profiler/profiler-listener.h" |
| 25 #include "src/runtime-profiler.h" | 26 #include "src/runtime-profiler.h" |
| 26 #include "src/string-stream.h" | 27 #include "src/string-stream.h" |
| 27 #include "src/vm-state-inl.h" | 28 #include "src/vm-state-inl.h" |
| 28 | 29 |
| 29 namespace v8 { | 30 namespace v8 { |
| 30 namespace internal { | 31 namespace internal { |
| 31 | 32 |
| 32 | 33 |
| 33 #define DECLARE_EVENT(ignore1, name) name, | 34 #define DECLARE_EVENT(ignore1, name) name, |
| 34 static const char* kLogEventsNames[CodeEventListener::NUMBER_OF_LOG_EVENTS] = { | 35 static const char* kLogEventsNames[CodeEventListener::NUMBER_OF_LOG_EVENTS] = { |
| (...skipping 1747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1782 } | 1783 } |
| 1783 | 1784 |
| 1784 if (FLAG_log_internal_timer_events || FLAG_prof_cpp) timer_.Start(); | 1785 if (FLAG_log_internal_timer_events || FLAG_prof_cpp) timer_.Start(); |
| 1785 | 1786 |
| 1786 if (FLAG_prof_cpp) { | 1787 if (FLAG_prof_cpp) { |
| 1787 profiler_ = new Profiler(isolate); | 1788 profiler_ = new Profiler(isolate); |
| 1788 is_logging_ = true; | 1789 is_logging_ = true; |
| 1789 profiler_->Engage(); | 1790 profiler_->Engage(); |
| 1790 } | 1791 } |
| 1791 | 1792 |
| 1793 profiler_listener_.reset(); |
| 1794 |
| 1792 if (is_logging_) { | 1795 if (is_logging_) { |
| 1793 addCodeEventListener(this); | 1796 addCodeEventListener(this); |
| 1794 } | 1797 } |
| 1795 | 1798 |
| 1796 return true; | 1799 return true; |
| 1797 } | 1800 } |
| 1798 | 1801 |
| 1799 | 1802 |
| 1800 void Logger::SetCodeEventHandler(uint32_t options, | 1803 void Logger::SetCodeEventHandler(uint32_t options, |
| 1801 JitCodeEventHandler event_handler) { | 1804 JitCodeEventHandler event_handler) { |
| 1802 if (jit_logger_) { | 1805 if (jit_logger_) { |
| 1803 removeCodeEventListener(jit_logger_); | 1806 removeCodeEventListener(jit_logger_); |
| 1804 delete jit_logger_; | 1807 delete jit_logger_; |
| 1805 jit_logger_ = NULL; | 1808 jit_logger_ = NULL; |
| 1806 } | 1809 } |
| 1807 | 1810 |
| 1808 if (event_handler) { | 1811 if (event_handler) { |
| 1809 jit_logger_ = new JitLogger(event_handler); | 1812 jit_logger_ = new JitLogger(event_handler); |
| 1810 addCodeEventListener(jit_logger_); | 1813 addCodeEventListener(jit_logger_); |
| 1811 if (options & kJitCodeEventEnumExisting) { | 1814 if (options & kJitCodeEventEnumExisting) { |
| 1812 HandleScope scope(isolate_); | 1815 HandleScope scope(isolate_); |
| 1813 LogCodeObjects(); | 1816 LogCodeObjects(); |
| 1814 LogCompiledFunctions(); | 1817 LogCompiledFunctions(); |
| 1815 } | 1818 } |
| 1816 } | 1819 } |
| 1817 } | 1820 } |
| 1818 | 1821 |
| 1822 void Logger::SetUpProfilerListener() { |
| 1823 if (!is_initialized_) return; |
| 1824 if (profiler_listener_.get() == nullptr) { |
| 1825 profiler_listener_.reset(new ProfilerListener(isolate_)); |
| 1826 } |
| 1827 addCodeEventListener(profiler_listener_.get()); |
| 1828 } |
| 1829 |
| 1830 void Logger::TearDownProfilerListener() { |
| 1831 if (profiler_listener_->HasObservers()) return; |
| 1832 removeCodeEventListener(profiler_listener_.get()); |
| 1833 } |
| 1819 | 1834 |
| 1820 sampler::Sampler* Logger::sampler() { | 1835 sampler::Sampler* Logger::sampler() { |
| 1821 return ticker_; | 1836 return ticker_; |
| 1822 } | 1837 } |
| 1823 | 1838 |
| 1824 | 1839 |
| 1825 FILE* Logger::TearDown() { | 1840 FILE* Logger::TearDown() { |
| 1826 if (!is_initialized_) return NULL; | 1841 if (!is_initialized_) return NULL; |
| 1827 is_initialized_ = false; | 1842 is_initialized_ = false; |
| 1828 | 1843 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1853 delete ll_logger_; | 1868 delete ll_logger_; |
| 1854 ll_logger_ = NULL; | 1869 ll_logger_ = NULL; |
| 1855 } | 1870 } |
| 1856 | 1871 |
| 1857 if (jit_logger_) { | 1872 if (jit_logger_) { |
| 1858 removeCodeEventListener(jit_logger_); | 1873 removeCodeEventListener(jit_logger_); |
| 1859 delete jit_logger_; | 1874 delete jit_logger_; |
| 1860 jit_logger_ = NULL; | 1875 jit_logger_ = NULL; |
| 1861 } | 1876 } |
| 1862 | 1877 |
| 1878 if (profiler_listener_.get() != nullptr) { |
| 1879 removeCodeEventListener(profiler_listener_.get()); |
| 1880 } |
| 1881 |
| 1863 return log_->Close(); | 1882 return log_->Close(); |
| 1864 } | 1883 } |
| 1865 | 1884 |
| 1866 } // namespace internal | 1885 } // namespace internal |
| 1867 } // namespace v8 | 1886 } // namespace v8 |
| OLD | NEW |