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 <stdarg.h> | 5 #include "src/log.h" |
| 6 |
| 7 #include <cstdarg> |
| 8 #include <sstream> |
6 | 9 |
7 #include "src/v8.h" | 10 #include "src/v8.h" |
8 | 11 |
9 #include "src/bailout-reason.h" | 12 #include "src/bailout-reason.h" |
10 #include "src/base/platform/platform.h" | 13 #include "src/base/platform/platform.h" |
11 #include "src/bootstrapper.h" | 14 #include "src/bootstrapper.h" |
12 #include "src/code-stubs.h" | 15 #include "src/code-stubs.h" |
13 #include "src/cpu-profiler.h" | 16 #include "src/cpu-profiler.h" |
14 #include "src/deoptimizer.h" | 17 #include "src/deoptimizer.h" |
15 #include "src/global-handles.h" | 18 #include "src/global-handles.h" |
16 #include "src/log.h" | |
17 #include "src/log-utils.h" | 19 #include "src/log-utils.h" |
18 #include "src/macro-assembler.h" | 20 #include "src/macro-assembler.h" |
19 #include "src/perf-jit.h" | 21 #include "src/perf-jit.h" |
20 #include "src/runtime-profiler.h" | 22 #include "src/runtime-profiler.h" |
21 #include "src/serialize.h" | 23 #include "src/serialize.h" |
22 #include "src/string-stream.h" | 24 #include "src/string-stream.h" |
23 #include "src/vm-state-inl.h" | 25 #include "src/vm-state-inl.h" |
24 | 26 |
25 namespace v8 { | 27 namespace v8 { |
26 namespace internal { | 28 namespace internal { |
(...skipping 1751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1778 PROFILE(isolate_, GetterCallbackEvent(name, getter_entry)); | 1780 PROFILE(isolate_, GetterCallbackEvent(name, getter_entry)); |
1779 } | 1781 } |
1780 Address setter_entry = v8::ToCData<Address>(ai->setter()); | 1782 Address setter_entry = v8::ToCData<Address>(ai->setter()); |
1781 if (setter_entry != 0) { | 1783 if (setter_entry != 0) { |
1782 PROFILE(isolate_, SetterCallbackEvent(name, setter_entry)); | 1784 PROFILE(isolate_, SetterCallbackEvent(name, setter_entry)); |
1783 } | 1785 } |
1784 } | 1786 } |
1785 } | 1787 } |
1786 | 1788 |
1787 | 1789 |
1788 static void AddIsolateIdIfNeeded(OStream& os, // NOLINT | 1790 static void AddIsolateIdIfNeeded(std::ostream& os, // NOLINT |
1789 Isolate* isolate) { | 1791 Isolate* isolate) { |
1790 if (FLAG_logfile_per_isolate) os << "isolate-" << isolate << "-"; | 1792 if (FLAG_logfile_per_isolate) os << "isolate-" << isolate << "-"; |
1791 } | 1793 } |
1792 | 1794 |
1793 | 1795 |
1794 static void PrepareLogFileName(OStream& os, // NOLINT | 1796 static void PrepareLogFileName(std::ostream& os, // NOLINT |
1795 Isolate* isolate, const char* file_name) { | 1797 Isolate* isolate, const char* file_name) { |
1796 AddIsolateIdIfNeeded(os, isolate); | 1798 AddIsolateIdIfNeeded(os, isolate); |
1797 for (const char* p = file_name; *p; p++) { | 1799 for (const char* p = file_name; *p; p++) { |
1798 if (*p == '%') { | 1800 if (*p == '%') { |
1799 p++; | 1801 p++; |
1800 switch (*p) { | 1802 switch (*p) { |
1801 case '\0': | 1803 case '\0': |
1802 // If there's a % at the end of the string we back up | 1804 // If there's a % at the end of the string we back up |
1803 // one character so we can escape the loop properly. | 1805 // one character so we can escape the loop properly. |
1804 p--; | 1806 p--; |
(...skipping 24 matching lines...) Expand all Loading... |
1829 bool Logger::SetUp(Isolate* isolate) { | 1831 bool Logger::SetUp(Isolate* isolate) { |
1830 // Tests and EnsureInitialize() can call this twice in a row. It's harmless. | 1832 // Tests and EnsureInitialize() can call this twice in a row. It's harmless. |
1831 if (is_initialized_) return true; | 1833 if (is_initialized_) return true; |
1832 is_initialized_ = true; | 1834 is_initialized_ = true; |
1833 | 1835 |
1834 // --ll-prof implies --log-code and --log-snapshot-positions. | 1836 // --ll-prof implies --log-code and --log-snapshot-positions. |
1835 if (FLAG_ll_prof) { | 1837 if (FLAG_ll_prof) { |
1836 FLAG_log_snapshot_positions = true; | 1838 FLAG_log_snapshot_positions = true; |
1837 } | 1839 } |
1838 | 1840 |
1839 OStringStream log_file_name; | 1841 std::ostringstream log_file_name; |
1840 PrepareLogFileName(log_file_name, isolate, FLAG_logfile); | 1842 PrepareLogFileName(log_file_name, isolate, FLAG_logfile); |
1841 log_->Initialize(log_file_name.c_str()); | 1843 log_->Initialize(log_file_name.str().c_str()); |
1842 | 1844 |
1843 | 1845 |
1844 if (FLAG_perf_basic_prof) { | 1846 if (FLAG_perf_basic_prof) { |
1845 perf_basic_logger_ = new PerfBasicLogger(); | 1847 perf_basic_logger_ = new PerfBasicLogger(); |
1846 addCodeEventListener(perf_basic_logger_); | 1848 addCodeEventListener(perf_basic_logger_); |
1847 } | 1849 } |
1848 | 1850 |
1849 if (FLAG_perf_jit_prof) { | 1851 if (FLAG_perf_jit_prof) { |
1850 perf_jit_logger_ = new PerfJitLogger(); | 1852 perf_jit_logger_ = new PerfJitLogger(); |
1851 addCodeEventListener(perf_jit_logger_); | 1853 addCodeEventListener(perf_jit_logger_); |
1852 } | 1854 } |
1853 | 1855 |
1854 if (FLAG_ll_prof) { | 1856 if (FLAG_ll_prof) { |
1855 ll_logger_ = new LowLevelLogger(log_file_name.c_str()); | 1857 ll_logger_ = new LowLevelLogger(log_file_name.str().c_str()); |
1856 addCodeEventListener(ll_logger_); | 1858 addCodeEventListener(ll_logger_); |
1857 } | 1859 } |
1858 | 1860 |
1859 ticker_ = new Ticker(isolate, kSamplingIntervalMs); | 1861 ticker_ = new Ticker(isolate, kSamplingIntervalMs); |
1860 | 1862 |
1861 if (Log::InitLogAtStart()) { | 1863 if (Log::InitLogAtStart()) { |
1862 is_logging_ = true; | 1864 is_logging_ = true; |
1863 } | 1865 } |
1864 | 1866 |
1865 if (FLAG_prof) { | 1867 if (FLAG_prof) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1934 if (jit_logger_) { | 1936 if (jit_logger_) { |
1935 removeCodeEventListener(jit_logger_); | 1937 removeCodeEventListener(jit_logger_); |
1936 delete jit_logger_; | 1938 delete jit_logger_; |
1937 jit_logger_ = NULL; | 1939 jit_logger_ = NULL; |
1938 } | 1940 } |
1939 | 1941 |
1940 return log_->Close(); | 1942 return log_->Close(); |
1941 } | 1943 } |
1942 | 1944 |
1943 } } // namespace v8::internal | 1945 } } // namespace v8::internal |
OLD | NEW |