Commit 3521ffa5 authored by alph's avatar alph Committed by Commit bot

Provide better script names in CPU profiler.

Use script_url when the script name is not available.

BUG=chromium:463108
LOG=N

Review URL: https://codereview.chromium.org/1796353002

Cr-Commit-Position: refs/heads/master@{#34793}
parent 9cda962b
...@@ -248,7 +248,8 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, ...@@ -248,7 +248,8 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
rec->start = code->address(); rec->start = code->address();
rec->entry = profiles_->NewCodeEntry( rec->entry = profiles_->NewCodeEntry(
tag, profiles_->GetFunctionName(shared->DebugName()), tag, profiles_->GetFunctionName(shared->DebugName()),
CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name), CodeEntry::kEmptyNamePrefix,
profiles_->GetName(InferScriptName(script_name, shared)),
CpuProfileNode::kNoLineNumberInfo, CpuProfileNode::kNoColumnNumberInfo, CpuProfileNode::kNoLineNumberInfo, CpuProfileNode::kNoColumnNumberInfo,
NULL, code->instruction_start()); NULL, code->instruction_start());
RecordInliningInfo(rec->entry, code); RecordInliningInfo(rec->entry, code);
...@@ -300,8 +301,9 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, ...@@ -300,8 +301,9 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
} }
rec->entry = profiles_->NewCodeEntry( rec->entry = profiles_->NewCodeEntry(
tag, profiles_->GetFunctionName(shared->DebugName()), tag, profiles_->GetFunctionName(shared->DebugName()),
CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name), line, CodeEntry::kEmptyNamePrefix,
column, line_table, abstract_code->instruction_start()); profiles_->GetName(InferScriptName(script_name, shared)), line, column,
line_table, abstract_code->instruction_start());
RecordInliningInfo(rec->entry, abstract_code); RecordInliningInfo(rec->entry, abstract_code);
if (info) { if (info) {
rec->entry->set_inlined_function_infos(info->inlined_function_infos()); rec->entry->set_inlined_function_infos(info->inlined_function_infos());
...@@ -391,6 +393,13 @@ void CpuProfiler::SetterCallbackEvent(Name* name, Address entry_point) { ...@@ -391,6 +393,13 @@ void CpuProfiler::SetterCallbackEvent(Name* name, Address entry_point) {
processor_->Enqueue(evt_rec); processor_->Enqueue(evt_rec);
} }
Name* CpuProfiler::InferScriptName(Name* name, SharedFunctionInfo* info) {
if (name->IsString() && String::cast(name)->length()) return name;
if (!info->script()->IsScript()) return name;
Object* source_url = Script::cast(info->script())->source_url();
return source_url->IsName() ? Name::cast(source_url) : name;
}
void CpuProfiler::RecordInliningInfo(CodeEntry* entry, void CpuProfiler::RecordInliningInfo(CodeEntry* entry,
AbstractCode* abstract_code) { AbstractCode* abstract_code) {
if (!abstract_code->IsCode()) return; if (!abstract_code->IsCode()) return;
......
...@@ -259,6 +259,7 @@ class CpuProfiler : public CodeEventListener { ...@@ -259,6 +259,7 @@ class CpuProfiler : public CodeEventListener {
void ResetProfiles(); void ResetProfiles();
void LogBuiltins(); void LogBuiltins();
void RecordInliningInfo(CodeEntry* entry, AbstractCode* abstract_code); void RecordInliningInfo(CodeEntry* entry, AbstractCode* abstract_code);
Name* InferScriptName(Name* name, SharedFunctionInfo* info);
Isolate* isolate_; Isolate* isolate_;
base::TimeDelta sampling_interval_; base::TimeDelta sampling_interval_;
......
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