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" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 277 |
278 void PerfBasicLogger::LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo*, | 278 void PerfBasicLogger::LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo*, |
279 const char* name, int length) { | 279 const char* name, int length) { |
280 if (FLAG_perf_basic_prof_only_functions && | 280 if (FLAG_perf_basic_prof_only_functions && |
281 (code->kind() != AbstractCode::FUNCTION && | 281 (code->kind() != AbstractCode::FUNCTION && |
282 code->kind() != AbstractCode::INTERPRETED_FUNCTION && | 282 code->kind() != AbstractCode::INTERPRETED_FUNCTION && |
283 code->kind() != AbstractCode::OPTIMIZED_FUNCTION)) { | 283 code->kind() != AbstractCode::OPTIMIZED_FUNCTION)) { |
284 return; | 284 return; |
285 } | 285 } |
286 | 286 |
287 base::OS::FPrint(perf_output_handle_, "%p %x %.*s\n", | 287 base::OS::FPrint(perf_output_handle_, "%llx %x %.*s\n", |
288 code->instruction_start(), code->instruction_size(), length, | 288 reinterpret_cast<uint64_t>(code->instruction_start()), |
289 name); | 289 code->instruction_size(), length, name); |
290 } | 290 } |
291 | 291 |
| 292 |
292 // Low-level logging support. | 293 // Low-level logging support. |
293 #define LL_LOG(Call) if (ll_logger_) ll_logger_->Call; | 294 #define LL_LOG(Call) if (ll_logger_) ll_logger_->Call; |
294 | 295 |
295 class LowLevelLogger : public CodeEventLogger { | 296 class LowLevelLogger : public CodeEventLogger { |
296 public: | 297 public: |
297 explicit LowLevelLogger(const char* file_name); | 298 explicit LowLevelLogger(const char* file_name); |
298 ~LowLevelLogger() override; | 299 ~LowLevelLogger() override; |
299 | 300 |
300 void CodeMoveEvent(AbstractCode* from, Address to) override; | 301 void CodeMoveEvent(AbstractCode* from, Address to) override; |
301 void CodeDisableOptEvent(AbstractCode* code, | 302 void CodeDisableOptEvent(AbstractCode* code, |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 if (!log_->IsEnabled()) return; | 782 if (!log_->IsEnabled()) return; |
782 Log::MessageBuilder msg(log_); | 783 Log::MessageBuilder msg(log_); |
783 msg.Append("%s,%d", name, value); | 784 msg.Append("%s,%d", name, value); |
784 msg.WriteToLogFile(); | 785 msg.WriteToLogFile(); |
785 } | 786 } |
786 | 787 |
787 | 788 |
788 void Logger::UncheckedIntPtrTEvent(const char* name, intptr_t value) { | 789 void Logger::UncheckedIntPtrTEvent(const char* name, intptr_t value) { |
789 if (!log_->IsEnabled()) return; | 790 if (!log_->IsEnabled()) return; |
790 Log::MessageBuilder msg(log_); | 791 Log::MessageBuilder msg(log_); |
791 msg.Append("%s,%" V8PRIdPTR, name, value); | 792 msg.Append("%s,%" V8_PTR_PREFIX "d", name, value); |
792 msg.WriteToLogFile(); | 793 msg.WriteToLogFile(); |
793 } | 794 } |
794 | 795 |
795 | 796 |
796 void Logger::HandleEvent(const char* name, Object** location) { | 797 void Logger::HandleEvent(const char* name, Object** location) { |
797 if (!log_->IsEnabled() || !FLAG_log_handles) return; | 798 if (!log_->IsEnabled() || !FLAG_log_handles) return; |
798 Log::MessageBuilder msg(log_); | 799 Log::MessageBuilder msg(log_); |
799 msg.Append("%s,%p", name, location); | 800 msg.Append("%s,0x%" V8PRIxPTR, name, location); |
800 msg.WriteToLogFile(); | 801 msg.WriteToLogFile(); |
801 } | 802 } |
802 | 803 |
803 | 804 |
804 // ApiEvent is private so all the calls come from the Logger class. It is the | 805 // ApiEvent is private so all the calls come from the Logger class. It is the |
805 // caller's responsibility to ensure that log is enabled and that | 806 // caller's responsibility to ensure that log is enabled and that |
806 // FLAG_log_api is true. | 807 // FLAG_log_api is true. |
807 void Logger::ApiEvent(const char* format, ...) { | 808 void Logger::ApiEvent(const char* format, ...) { |
808 DCHECK(log_->IsEnabled() && FLAG_log_api); | 809 DCHECK(log_->IsEnabled() && FLAG_log_api); |
809 Log::MessageBuilder msg(log_); | 810 Log::MessageBuilder msg(log_); |
(...skipping 20 matching lines...) Expand all Loading... |
830 library_path.c_str(), start, end); | 831 library_path.c_str(), start, end); |
831 msg.WriteToLogFile(); | 832 msg.WriteToLogFile(); |
832 } | 833 } |
833 | 834 |
834 | 835 |
835 void Logger::CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta) { | 836 void Logger::CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta) { |
836 PROFILER_LOG(CodeDeoptEvent(code, pc, fp_to_sp_delta)); | 837 PROFILER_LOG(CodeDeoptEvent(code, pc, fp_to_sp_delta)); |
837 if (!log_->IsEnabled() || !FLAG_log_internal_timer_events) return; | 838 if (!log_->IsEnabled() || !FLAG_log_internal_timer_events) return; |
838 Log::MessageBuilder msg(log_); | 839 Log::MessageBuilder msg(log_); |
839 int since_epoch = static_cast<int>(timer_.Elapsed().InMicroseconds()); | 840 int since_epoch = static_cast<int>(timer_.Elapsed().InMicroseconds()); |
840 msg.Append("code-deopt,%d,%d", since_epoch, code->CodeSize()); | 841 msg.Append("code-deopt,%ld,%d", since_epoch, code->CodeSize()); |
841 msg.WriteToLogFile(); | 842 msg.WriteToLogFile(); |
842 } | 843 } |
843 | 844 |
844 | 845 |
845 void Logger::CurrentTimeEvent() { | 846 void Logger::CurrentTimeEvent() { |
846 if (!log_->IsEnabled()) return; | 847 if (!log_->IsEnabled()) return; |
847 DCHECK(FLAG_log_timer_events || FLAG_prof_cpp); | 848 DCHECK(FLAG_log_timer_events || FLAG_prof_cpp); |
848 Log::MessageBuilder msg(log_); | 849 Log::MessageBuilder msg(log_); |
849 int since_epoch = static_cast<int>(timer_.Elapsed().InMicroseconds()); | 850 int since_epoch = static_cast<int>(timer_.Elapsed().InMicroseconds()); |
850 msg.Append("current-time,%d", since_epoch); | 851 msg.Append("current-time,%ld", since_epoch); |
851 msg.WriteToLogFile(); | 852 msg.WriteToLogFile(); |
852 } | 853 } |
853 | 854 |
854 | 855 |
855 void Logger::TimerEvent(Logger::StartEnd se, const char* name) { | 856 void Logger::TimerEvent(Logger::StartEnd se, const char* name) { |
856 if (!log_->IsEnabled()) return; | 857 if (!log_->IsEnabled()) return; |
857 DCHECK(FLAG_log_internal_timer_events); | 858 DCHECK(FLAG_log_internal_timer_events); |
858 Log::MessageBuilder msg(log_); | 859 Log::MessageBuilder msg(log_); |
859 int since_epoch = static_cast<int>(timer_.Elapsed().InMicroseconds()); | 860 int since_epoch = static_cast<int>(timer_.Elapsed().InMicroseconds()); |
860 const char* format = (se == START) ? "timer-event-start,\"%s\",%ld" | 861 const char* format = (se == START) ? "timer-event-start,\"%s\",%ld" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 | 1001 |
1001 void Logger::ApiEntryCall(const char* name) { | 1002 void Logger::ApiEntryCall(const char* name) { |
1002 if (!log_->IsEnabled() || !FLAG_log_api) return; | 1003 if (!log_->IsEnabled() || !FLAG_log_api) return; |
1003 ApiEvent("api,%s", name); | 1004 ApiEvent("api,%s", name); |
1004 } | 1005 } |
1005 | 1006 |
1006 | 1007 |
1007 void Logger::NewEvent(const char* name, void* object, size_t size) { | 1008 void Logger::NewEvent(const char* name, void* object, size_t size) { |
1008 if (!log_->IsEnabled() || !FLAG_log) return; | 1009 if (!log_->IsEnabled() || !FLAG_log) return; |
1009 Log::MessageBuilder msg(log_); | 1010 Log::MessageBuilder msg(log_); |
1010 msg.Append("new,%s,%p,%u", name, object, static_cast<unsigned int>(size)); | 1011 msg.Append("new,%s,0x%" V8PRIxPTR ",%u", name, object, |
| 1012 static_cast<unsigned int>(size)); |
1011 msg.WriteToLogFile(); | 1013 msg.WriteToLogFile(); |
1012 } | 1014 } |
1013 | 1015 |
1014 | 1016 |
1015 void Logger::DeleteEvent(const char* name, void* object) { | 1017 void Logger::DeleteEvent(const char* name, void* object) { |
1016 if (!log_->IsEnabled() || !FLAG_log) return; | 1018 if (!log_->IsEnabled() || !FLAG_log) return; |
1017 Log::MessageBuilder msg(log_); | 1019 Log::MessageBuilder msg(log_); |
1018 msg.Append("delete,%s,%p", name, object); | 1020 msg.Append("delete,%s,0x%" V8PRIxPTR, name, object); |
1019 msg.WriteToLogFile(); | 1021 msg.WriteToLogFile(); |
1020 } | 1022 } |
1021 | 1023 |
1022 | 1024 |
1023 void Logger::CallbackEventInternal(const char* prefix, Name* name, | 1025 void Logger::CallbackEventInternal(const char* prefix, Name* name, |
1024 Address entry_point) { | 1026 Address entry_point) { |
1025 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1027 if (!FLAG_log_code || !log_->IsEnabled()) return; |
1026 Log::MessageBuilder msg(log_); | 1028 Log::MessageBuilder msg(log_); |
1027 msg.Append("%s,%s,-2,", | 1029 msg.Append("%s,%s,-2,", |
1028 kLogEventsNames[CODE_CREATION_EVENT], | 1030 kLogEventsNames[CODE_CREATION_EVENT], |
1029 kLogEventsNames[CALLBACK_TAG]); | 1031 kLogEventsNames[CALLBACK_TAG]); |
1030 msg.AppendAddress(entry_point); | 1032 msg.AppendAddress(entry_point); |
1031 if (name->IsString()) { | 1033 if (name->IsString()) { |
1032 base::SmartArrayPointer<char> str = | 1034 base::SmartArrayPointer<char> str = |
1033 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1035 String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1034 msg.Append(",1,\"%s%s\"", prefix, str.get()); | 1036 msg.Append(",1,\"%s%s\"", prefix, str.get()); |
1035 } else { | 1037 } else { |
1036 Symbol* symbol = Symbol::cast(name); | 1038 Symbol* symbol = Symbol::cast(name); |
1037 if (symbol->name()->IsUndefined()) { | 1039 if (symbol->name()->IsUndefined()) { |
1038 msg.Append(",1,symbol(hash %x)", symbol->Hash()); | 1040 msg.Append(",1,symbol(hash %x)", prefix, symbol->Hash()); |
1039 } else { | 1041 } else { |
1040 base::SmartArrayPointer<char> str = | 1042 base::SmartArrayPointer<char> str = |
1041 String::cast(symbol->name()) | 1043 String::cast(symbol->name()) |
1042 ->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1044 ->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1043 msg.Append(",1,symbol(\"%s%s\" hash %x)", prefix, str.get(), | 1045 msg.Append(",1,symbol(\"%s\" hash %x)", prefix, str.get(), |
1044 symbol->Hash()); | 1046 symbol->Hash()); |
1045 } | 1047 } |
1046 } | 1048 } |
1047 msg.WriteToLogFile(); | 1049 msg.WriteToLogFile(); |
1048 } | 1050 } |
1049 | 1051 |
1050 | 1052 |
1051 void Logger::CallbackEvent(Name* name, Address entry_point) { | 1053 void Logger::CallbackEvent(Name* name, Address entry_point) { |
1052 PROFILER_LOG(CallbackEvent(name, entry_point)); | 1054 PROFILER_LOG(CallbackEvent(name, entry_point)); |
1053 CallbackEventInternal("", name, entry_point); | 1055 CallbackEventInternal("", name, entry_point); |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1377 DeleteArray(parameter_string); | 1379 DeleteArray(parameter_string); |
1378 msg.WriteToLogFile(); | 1380 msg.WriteToLogFile(); |
1379 } | 1381 } |
1380 | 1382 |
1381 | 1383 |
1382 void Logger::TickEvent(TickSample* sample, bool overflow) { | 1384 void Logger::TickEvent(TickSample* sample, bool overflow) { |
1383 if (!log_->IsEnabled() || !FLAG_prof_cpp) return; | 1385 if (!log_->IsEnabled() || !FLAG_prof_cpp) return; |
1384 Log::MessageBuilder msg(log_); | 1386 Log::MessageBuilder msg(log_); |
1385 msg.Append("%s,", kLogEventsNames[TICK_EVENT]); | 1387 msg.Append("%s,", kLogEventsNames[TICK_EVENT]); |
1386 msg.AppendAddress(sample->pc); | 1388 msg.AppendAddress(sample->pc); |
1387 msg.Append(",%d", static_cast<int>(timer_.Elapsed().InMicroseconds())); | 1389 msg.Append(",%ld", static_cast<int>(timer_.Elapsed().InMicroseconds())); |
1388 if (sample->has_external_callback) { | 1390 if (sample->has_external_callback) { |
1389 msg.Append(",1,"); | 1391 msg.Append(",1,"); |
1390 msg.AppendAddress(sample->external_callback_entry); | 1392 msg.AppendAddress(sample->external_callback_entry); |
1391 } else { | 1393 } else { |
1392 msg.Append(",0,"); | 1394 msg.Append(",0,"); |
1393 msg.AppendAddress(sample->tos); | 1395 msg.AppendAddress(sample->tos); |
1394 } | 1396 } |
1395 msg.Append(",%d", static_cast<int>(sample->state)); | 1397 msg.Append(",%d", static_cast<int>(sample->state)); |
1396 if (overflow) { | 1398 if (overflow) { |
1397 msg.Append(",overflow"); | 1399 msg.Append(",overflow"); |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1848 removeCodeEventListener(jit_logger_); | 1850 removeCodeEventListener(jit_logger_); |
1849 delete jit_logger_; | 1851 delete jit_logger_; |
1850 jit_logger_ = NULL; | 1852 jit_logger_ = NULL; |
1851 } | 1853 } |
1852 | 1854 |
1853 return log_->Close(); | 1855 return log_->Close(); |
1854 } | 1856 } |
1855 | 1857 |
1856 } // namespace internal | 1858 } // namespace internal |
1857 } // namespace v8 | 1859 } // namespace v8 |
OLD | NEW |