Chromium Code Reviews| Index: src/log.cc |
| diff --git a/src/log.cc b/src/log.cc |
| index d26279bb24ad03e9098683adbda34794b06505c9..77572cc3c02fce2760a2a624815dfd34aeccdb81 100644 |
| --- a/src/log.cc |
| +++ b/src/log.cc |
| @@ -54,6 +54,12 @@ static const char* const kLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = { |
| #undef DECLARE_EVENT |
| +#define PROFILER_LOG(Call) \ |
| + CpuProfiler* cpu_profiler = isolate_->cpu_profiler(); \ |
| + if (cpu_profiler->is_profiling()) { \ |
| + cpu_profiler->Call; \ |
| + } |
| + |
| // ComputeMarker must only be used when SharedFunctionInfo is known. |
| static const char* ComputeMarker(Code* code) { |
| switch (code->kind()) { |
| @@ -543,7 +549,7 @@ class JitLogger : public CodeEventLogger { |
| public: |
| explicit JitLogger(JitCodeEventHandler code_event_handler); |
| - void CodeMovedEvent(Address from, Address to); |
| + void CodeMoveEvent(Address from, Address to); |
| void CodeDeleteEvent(Address from); |
| void AddCodeLinePosInfoEvent( |
| void* jit_handler_data, |
| @@ -588,7 +594,7 @@ void JitLogger::LogRecordedBuffer(Code* code, |
| } |
| -void JitLogger::CodeMovedEvent(Address from, Address to) { |
| +void JitLogger::CodeMoveEvent(Address from, Address to) { |
| Code* from_code = Code::cast(HeapObject::FromAddress(from)); |
| JitCodeEvent event; |
| @@ -1209,7 +1215,7 @@ void Logger::DeleteEventStatic(const char* name, void* object) { |
| void Logger::CallbackEventInternal(const char* prefix, Name* name, |
| Address entry_point) { |
| - if (!log_->IsEnabled() || !FLAG_log_code) return; |
|
yurys
2013/07/22 07:39:41
What's the reason for this rearrangement here an i
loislo
2013/07/22 09:31:42
No special reason. I just made it consistent with
|
| + if (!FLAG_log_code || !log_->IsEnabled()) return; |
| Log::MessageBuilder msg(log_); |
| msg.Append("%s,%s,-2,", |
| kLogEventsNames[CODE_CREATION_EVENT], |
| @@ -1235,19 +1241,22 @@ void Logger::CallbackEventInternal(const char* prefix, Name* name, |
| void Logger::CallbackEvent(Name* name, Address entry_point) { |
| - if (!log_->IsEnabled() || !FLAG_log_code) return; |
| + PROFILER_LOG(CallbackEvent(name, entry_point)); |
| + if (!FLAG_log_code || !log_->IsEnabled()) return; |
| CallbackEventInternal("", name, entry_point); |
| } |
| void Logger::GetterCallbackEvent(Name* name, Address entry_point) { |
| - if (!log_->IsEnabled() || !FLAG_log_code) return; |
| + PROFILER_LOG(GetterCallbackEvent(name, entry_point)); |
| + if (!FLAG_log_code || !log_->IsEnabled()) return; |
| CallbackEventInternal("get ", name, entry_point); |
| } |
| void Logger::SetterCallbackEvent(Name* name, Address entry_point) { |
| - if (!log_->IsEnabled() || !FLAG_log_code) return; |
| + PROFILER_LOG(SetterCallbackEvent(name, entry_point)); |
| + if (!FLAG_log_code || !log_->IsEnabled()) return; |
| CallbackEventInternal("set ", name, entry_point); |
| } |
| @@ -1268,11 +1277,10 @@ static void AppendCodeCreateHeader(Log::MessageBuilder* msg, |
| void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| Code* code, |
| const char* comment) { |
| - if (!is_logging_code_events()) return; |
|
yurys
2013/07/22 07:39:41
It checked for logging_nesting_ > 0; now there is
loislo
2013/07/22 09:31:42
We already have this check in the macro LOG_CODE_E
yurys
2013/07/22 09:39:30
I disagree, now all these calls will be executed i
|
| - |
| JIT_LOG(CodeCreateEvent(tag, code, comment)); |
| LL_LOG(CodeCreateEvent(tag, code, comment)); |
| CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, comment)); |
| + PROFILER_LOG(CodeCreateEvent(tag, code, comment)); |
| if (!FLAG_log_code || !log_->IsEnabled()) return; |
| Log::MessageBuilder msg(log_); |
| @@ -1286,11 +1294,10 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| Code* code, |
| Name* name) { |
| - if (!is_logging_code_events()) return; |
| - |
| JIT_LOG(CodeCreateEvent(tag, code, name)); |
| LL_LOG(CodeCreateEvent(tag, code, name)); |
| CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, name)); |
| + PROFILER_LOG(CodeCreateEvent(tag, code, name)); |
| if (!FLAG_log_code || !log_->IsEnabled()) return; |
| Log::MessageBuilder msg(log_); |
| @@ -1312,11 +1319,10 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| SharedFunctionInfo* shared, |
| CompilationInfo* info, |
| Name* name) { |
| - if (!is_logging_code_events()) return; |
| - |
| JIT_LOG(CodeCreateEvent(tag, code, shared, info, name)); |
| LL_LOG(CodeCreateEvent(tag, code, shared, info, name)); |
| CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, shared, info, name)); |
| + PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, name)); |
| if (!FLAG_log_code || !log_->IsEnabled()) return; |
| if (code == isolate_->builtins()->builtin( |
| @@ -1348,11 +1354,10 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| SharedFunctionInfo* shared, |
| CompilationInfo* info, |
| Name* source, int line) { |
| - if (!is_logging_code_events()) return; |
| - |
| JIT_LOG(CodeCreateEvent(tag, code, shared, info, source, line)); |
| LL_LOG(CodeCreateEvent(tag, code, shared, info, source, line)); |
| CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, shared, info, source, line)); |
| + PROFILER_LOG(CodeCreateEvent(tag, code, shared, info, source, line)); |
| if (!FLAG_log_code || !log_->IsEnabled()) return; |
| Log::MessageBuilder msg(log_); |
| @@ -1378,11 +1383,10 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| Code* code, |
| int args_count) { |
| - if (!is_logging_code_events()) return; |
| - |
| JIT_LOG(CodeCreateEvent(tag, code, args_count)); |
| LL_LOG(CodeCreateEvent(tag, code, args_count)); |
| CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, args_count)); |
| + PROFILER_LOG(CodeCreateEvent(tag, code, args_count)); |
| if (!FLAG_log_code || !log_->IsEnabled()) return; |
| Log::MessageBuilder msg(log_); |
| @@ -1394,6 +1398,7 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| void Logger::CodeMovingGCEvent() { |
| + PROFILER_LOG(CodeMovingGCEvent()); |
| if (!log_->IsEnabled() || !FLAG_ll_prof) return; |
| LL_LOG(CodeMovingGCEvent()); |
| OS::SignalCodeMovingGC(); |
| @@ -1401,11 +1406,10 @@ void Logger::CodeMovingGCEvent() { |
| void Logger::RegExpCodeCreateEvent(Code* code, String* source) { |
| - if (!is_logging_code_events()) return; |
| - |
| JIT_LOG(RegExpCodeCreateEvent(code, source)); |
| LL_LOG(RegExpCodeCreateEvent(code, source)); |
| CODE_ADDRESS_MAP_LOG(RegExpCodeCreateEvent(code, source)); |
| + PROFILER_LOG(RegExpCodeCreateEvent(code, source)); |
| if (!FLAG_log_code || !log_->IsEnabled()) return; |
| Log::MessageBuilder msg(log_); |
| @@ -1419,21 +1423,23 @@ void Logger::RegExpCodeCreateEvent(Code* code, String* source) { |
| void Logger::CodeMoveEvent(Address from, Address to) { |
| - JIT_LOG(CodeMovedEvent(from, to)); |
| - if (!log_->IsEnabled()) return; |
| + JIT_LOG(CodeMoveEvent(from, to)); |
| LL_LOG(CodeMoveEvent(from, to)); |
| CODE_ADDRESS_MAP_LOG(CodeMoveEvent(from, to)); |
| + PROFILER_LOG(CodeMoveEvent(from, to)); |
| + if (!log_->IsEnabled()) return; |
| + |
| MoveEventInternal(CODE_MOVE_EVENT, from, to); |
| } |
| void Logger::CodeDeleteEvent(Address from) { |
| JIT_LOG(CodeDeleteEvent(from)); |
| - if (!log_->IsEnabled()) return; |
| LL_LOG(CodeDeleteEvent(from)); |
| CODE_ADDRESS_MAP_LOG(CodeDeleteEvent(from)); |
| + PROFILER_LOG(CodeDeleteEvent(from)); |
| - if (!log_->IsEnabled() || !FLAG_log_code) return; |
| + if (!FLAG_log_code || !log_->IsEnabled()) return; |
| Log::MessageBuilder msg(log_); |
| msg.Append("%s,", kLogEventsNames[CODE_DELETE_EVENT]); |
| msg.AppendAddress(from); |
| @@ -1498,6 +1504,7 @@ void Logger::SnapshotPositionEvent(Address addr, int pos) { |
| void Logger::SharedFunctionInfoMoveEvent(Address from, Address to) { |
| + PROFILER_LOG(SharedFunctionInfoMoveEvent(from, to)); |
| MoveEventInternal(SHARED_FUNC_MOVE_EVENT, from, to); |
| } |
| @@ -1505,7 +1512,7 @@ void Logger::SharedFunctionInfoMoveEvent(Address from, Address to) { |
| void Logger::MoveEventInternal(LogEventsAndTags event, |
| Address from, |
| Address to) { |
| - if (!log_->IsEnabled() || !FLAG_log_code) return; |
| + if (!FLAG_log_code || !log_->IsEnabled()) return; |
| Log::MessageBuilder msg(log_); |
| msg.Append("%s,", kLogEventsNames[event]); |
| msg.AppendAddress(from); |