Commit 92d13a12 authored by Jaroslav Sevcik's avatar Jaroslav Sevcik Committed by Commit Bot

[profiler] Add script name to v8.log with --log-source-code.

This also changes logging of code address to Code::instruction_start rather
than Code::address().

Bug: v8:6239
Change-Id: I4ef975630574e23409123468a3f7fb8fe6ad39e7
Reviewed-on: https://chromium-review.googlesource.com/605887Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Jaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47266}
parent e6f5a80f
...@@ -850,7 +850,7 @@ void Logger::CodeDeoptEvent(Code* code, DeoptKind kind, Address pc, ...@@ -850,7 +850,7 @@ void Logger::CodeDeoptEvent(Code* code, DeoptKind kind, Address pc,
? static_cast<int>(timer_.Elapsed().InMicroseconds()) ? static_cast<int>(timer_.Elapsed().InMicroseconds())
: -1; : -1;
msg.Append("code-deopt,%d,%d,", since_epoch, code->CodeSize()); msg.Append("code-deopt,%d,%d,", since_epoch, code->CodeSize());
msg.AppendAddress(code->address()); msg.AppendAddress(code->instruction_start());
// Deoptimization position. // Deoptimization position.
std::ostringstream deopt_location; std::ostringstream deopt_location;
...@@ -1053,8 +1053,8 @@ void AppendCodeCreateHeader(Log::MessageBuilder* msg, ...@@ -1053,8 +1053,8 @@ void AppendCodeCreateHeader(Log::MessageBuilder* msg,
? static_cast<int>(timer->Elapsed().InMicroseconds()) ? static_cast<int>(timer->Elapsed().InMicroseconds())
: -1; : -1;
msg->Append("%d,", timestamp); msg->Append("%d,", timestamp);
msg->AppendAddress(code->address()); msg->AppendAddress(code->instruction_start());
msg->Append(",%d,", code->ExecutableSize()); msg->Append(",%d,", code->instruction_size());
} }
} // namespace } // namespace
...@@ -1155,6 +1155,16 @@ void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, ...@@ -1155,6 +1155,16 @@ void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
String* source_code = String::cast(source_object); String* source_code = String::cast(source_object);
os << "script," << script_id << ",\""; os << "script," << script_id << ",\"";
msg.AppendUnbufferedCString(os.str().c_str()); msg.AppendUnbufferedCString(os.str().c_str());
// Log the script name.
if (script->name()->IsString()) {
msg.AppendUnbufferedHeapString(String::cast(script->name()));
msg.AppendUnbufferedCString("\",\"");
} else {
msg.AppendUnbufferedCString("<unknown>\",\"");
}
// Log the source code.
msg.AppendUnbufferedHeapString(source_code); msg.AppendUnbufferedHeapString(source_code);
os.str(""); os.str("");
os << "\"" << std::endl; os << "\"" << std::endl;
...@@ -1184,8 +1194,8 @@ void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, ...@@ -1184,8 +1194,8 @@ void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
// <function-id> is an index into the <fns> function table // <function-id> is an index into the <fns> function table
// <fns> is the function table encoded as a sequence of strings // <fns> is the function table encoded as a sequence of strings
// S<shared-function-info-address> // S<shared-function-info-address>
os << "code-source-info," << static_cast<void*>(code->address()) << "," os << "code-source-info," << static_cast<void*>(code->instruction_start())
<< script_id << "," << shared->start_position() << "," << "," << script_id << "," << shared->start_position() << ","
<< shared->end_position() << ","; << shared->end_position() << ",";
SourcePositionTableIterator iterator(code->source_position_table()); SourcePositionTableIterator iterator(code->source_position_table());
......
...@@ -1025,8 +1025,11 @@ function unescapeString(s) { ...@@ -1025,8 +1025,11 @@ function unescapeString(s) {
return s.join(""); return s.join("");
} }
JsonProfile.prototype.addScriptSource = function(script, source) { JsonProfile.prototype.addScriptSource = function(script, url, source) {
this.scripts_[script] = unescapeString(source); this.scripts_[script] = {
name : unescapeString(url),
source : unescapeString(source)
};
}; };
......
...@@ -120,7 +120,7 @@ function TickProcessor( ...@@ -120,7 +120,7 @@ function TickProcessor(
parsers: [parseInt, parseInt, parseInt, parseInt, null, null, null], parsers: [parseInt, parseInt, parseInt, parseInt, null, null, null],
processor: this.processCodeSourceInfo }, processor: this.processCodeSourceInfo },
'script': { 'script': {
parsers: [parseInt, null], parsers: [parseInt, null, null],
processor: this.processCodeScript }, processor: this.processCodeScript },
'sfi-move': { parsers: [parseInt, parseInt], 'sfi-move': { parsers: [parseInt, parseInt],
processor: this.processFunctionMove }, processor: this.processFunctionMove },
...@@ -330,8 +330,8 @@ TickProcessor.prototype.processCodeSourceInfo = function( ...@@ -330,8 +330,8 @@ TickProcessor.prototype.processCodeSourceInfo = function(
endPos, sourcePositions, inliningPositions, inlinedFunctions); endPos, sourcePositions, inliningPositions, inlinedFunctions);
}; };
TickProcessor.prototype.processCodeScript = function(script, source) { TickProcessor.prototype.processCodeScript = function(script, url, source) {
this.profile_.addScriptSource(script, source); this.profile_.addScriptSource(script, url, source);
}; };
TickProcessor.prototype.processFunctionMove = function(from, to) { TickProcessor.prototype.processFunctionMove = function(from, to) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment