Chromium Code Reviews| Index: src/log.cc | 
| diff --git a/src/log.cc b/src/log.cc | 
| index 6d88a535dc78f4ce10ce7a578d56d1b7b32b4e7c..877c6b8e961f574f5078002cba54a2b789b05d69 100644 | 
| --- a/src/log.cc | 
| +++ b/src/log.cc | 
| @@ -1063,6 +1063,9 @@ void Logger::ApiNamedSecurityCheck(Object* key) { | 
| void Logger::SharedLibraryEvent(const std::string& library_path, | 
| uintptr_t start, | 
| uintptr_t end) { | 
| + codeEventHandler()->SharedLibrary(library_path, | 
| + (const void*)start, | 
| + (const void*)end); | 
| if (!log_->IsEnabled() || !FLAG_prof) return; | 
| Log::MessageBuilder msg(log_); | 
| msg.Append("shared-library,\"%s\",0x%08" V8PRIxPTR ",0x%08" V8PRIxPTR "\n", | 
| @@ -1353,9 +1356,16 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, | 
| if (!FLAG_log_code || !log_->IsEnabled()) return; | 
| Log::MessageBuilder msg(log_); | 
| AppendCodeCreateHeader(&msg, tag, code); | 
| + msg.StartSubstring(); | 
| msg.AppendDoubleQuotedString(comment); | 
| + msg.EndSubstring(); | 
| msg.Append('\n'); | 
| msg.WriteToLogFile(); | 
| + std::string code_name; | 
| + msg.GetSubstring(&code_name); | 
| + codeEventHandler()->Create((const void*)code->address(), | 
| 
 
Jarin
2014/08/26 08:23:57
If you are interested in the address of actual cod
 
 | 
| + (const int)code->ExecutableSize(), | 
| + code_name); | 
| } | 
| @@ -1370,6 +1380,7 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, | 
| if (!FLAG_log_code || !log_->IsEnabled()) return; | 
| Log::MessageBuilder msg(log_); | 
| AppendCodeCreateHeader(&msg, tag, code); | 
| + msg.StartSubstring(); | 
| if (name->IsString()) { | 
| msg.Append('"'); | 
| msg.AppendDetailed(String::cast(name), false); | 
| @@ -1377,8 +1388,14 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, | 
| } else { | 
| msg.AppendSymbolName(Symbol::cast(name)); | 
| } | 
| + msg.EndSubstring(); | 
| msg.Append('\n'); | 
| msg.WriteToLogFile(); | 
| + std::string code_name; | 
| + msg.GetSubstring(&code_name); | 
| + codeEventHandler()->Create((const void*)code->address(), | 
| + (const int)code->ExecutableSize(), | 
| + code_name); | 
| } | 
| @@ -1398,6 +1415,7 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, | 
| Log::MessageBuilder msg(log_); | 
| AppendCodeCreateHeader(&msg, tag, code); | 
| + msg.StartSubstring(); | 
| if (name->IsString()) { | 
| SmartArrayPointer<char> str = | 
| String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 
| @@ -1405,11 +1423,17 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, | 
| } else { | 
| msg.AppendSymbolName(Symbol::cast(name)); | 
| } | 
| + msg.EndSubstring(); | 
| msg.Append(','); | 
| msg.AppendAddress(shared->address()); | 
| msg.Append(",%s", ComputeMarker(code)); | 
| msg.Append('\n'); | 
| msg.WriteToLogFile(); | 
| + std::string code_name; | 
| + msg.GetSubstring(&code_name); | 
| + codeEventHandler()->Create((const void*)code->address(), | 
| + (const int)code->ExecutableSize(), | 
| + code_name); | 
| } | 
| @@ -1430,6 +1454,7 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, | 
| if (!FLAG_log_code || !log_->IsEnabled()) return; | 
| Log::MessageBuilder msg(log_); | 
| AppendCodeCreateHeader(&msg, tag, code); | 
| + msg.StartSubstring(); | 
| SmartArrayPointer<char> name = | 
| shared->DebugName()->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 
| msg.Append("\"%s ", name.get()); | 
| @@ -1440,11 +1465,18 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, | 
| } else { | 
| msg.AppendSymbolName(Symbol::cast(source)); | 
| } | 
| - msg.Append(":%d:%d\",", line, column); | 
| + msg.Append(":%d:%d\"", line, column); | 
| + msg.EndSubstring(); | 
| + msg.Append(","); | 
| msg.AppendAddress(shared->address()); | 
| msg.Append(",%s", ComputeMarker(code)); | 
| msg.Append('\n'); | 
| msg.WriteToLogFile(); | 
| + std::string code_name; | 
| + msg.GetSubstring(&code_name); | 
| + codeEventHandler()->Create((const void*)code->address(), | 
| + (const int)code->ExecutableSize(), | 
| + code_name); | 
| } | 
| @@ -1459,9 +1491,16 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, | 
| if (!FLAG_log_code || !log_->IsEnabled()) return; | 
| Log::MessageBuilder msg(log_); | 
| AppendCodeCreateHeader(&msg, tag, code); | 
| + msg.StartSubstring(); | 
| msg.Append("\"args_count: %d\"", args_count); | 
| + msg.EndSubstring(); | 
| msg.Append('\n'); | 
| msg.WriteToLogFile(); | 
| + std::string code_name; | 
| + msg.GetSubstring(&code_name); | 
| + codeEventHandler()->Create((const void*)code->address(), | 
| + (const int)code->ExecutableSize(), | 
| + code_name); | 
| } | 
| @@ -1502,17 +1541,25 @@ void Logger::RegExpCodeCreateEvent(Code* code, String* source) { | 
| if (!FLAG_log_code || !log_->IsEnabled()) return; | 
| Log::MessageBuilder msg(log_); | 
| AppendCodeCreateHeader(&msg, REG_EXP_TAG, code); | 
| + msg.StartSubstring(); | 
| msg.Append('"'); | 
| msg.AppendDetailed(source, false); | 
| msg.Append('"'); | 
| + msg.EndSubstring(); | 
| msg.Append('\n'); | 
| msg.WriteToLogFile(); | 
| + std::string code_name; | 
| + msg.GetSubstring(&code_name); | 
| + codeEventHandler()->Create((const void*)code->address(), | 
| + (const int)code->ExecutableSize(), | 
| + code_name); | 
| } | 
| void Logger::CodeMoveEvent(Address from, Address to) { | 
| PROFILER_LOG(CodeMoveEvent(from, to)); | 
| - | 
| + codeEventHandler()->Move((const void*)from, | 
| + (const void*)to); | 
| if (!is_logging_code_events()) return; | 
| CALL_LISTENERS(CodeMoveEvent(from, to)); | 
| MoveEventInternal(CODE_MOVE_EVENT, from, to); | 
| @@ -1521,6 +1568,7 @@ void Logger::CodeMoveEvent(Address from, Address to) { | 
| void Logger::CodeDeleteEvent(Address from) { | 
| PROFILER_LOG(CodeDeleteEvent(from)); | 
| + codeEventHandler()->Delete((const void*)from); | 
| 
 
Jarin
2014/08/26 08:23:57
I think this is never called.
 
 | 
| if (!is_logging_code_events()) return; | 
| CALL_LISTENERS(CodeDeleteEvent(from)); | 
| @@ -2086,11 +2134,23 @@ void Logger::SetCodeEventHandler(uint32_t options, | 
| } | 
| +void Logger::SetCodeEventHandler(v8::CodeEventHandler* handler) { | 
| + code_event_handler_ = handler; | 
| +} | 
| + | 
| + | 
| Sampler* Logger::sampler() { | 
| return ticker_; | 
| } | 
| +CodeEventHandler* Logger::codeEventHandler() { | 
| + if (code_event_handler_ == NULL) | 
| + code_event_handler_ = new StubCodeEventHandler(); | 
| + return code_event_handler_; | 
| +} | 
| + | 
| + | 
| FILE* Logger::TearDown() { | 
| if (!is_initialized_) return NULL; | 
| is_initialized_ = false; |