Index: src/profiler/cpu-profiler.cc |
diff --git a/src/profiler/cpu-profiler.cc b/src/profiler/cpu-profiler.cc |
index 22030bfc71ad61287c7bb156471763116506b94d..b4c764e327321122456bf3e7bb4ae511df3823d7 100644 |
--- a/src/profiler/cpu-profiler.cc |
+++ b/src/profiler/cpu-profiler.cc |
@@ -248,7 +248,8 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
rec->start = code->address(); |
rec->entry = profiles_->NewCodeEntry( |
tag, profiles_->GetFunctionName(shared->DebugName()), |
- CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name), |
+ CodeEntry::kEmptyNamePrefix, |
+ profiles_->GetName(InferScriptName(script_name, shared)), |
CpuProfileNode::kNoLineNumberInfo, CpuProfileNode::kNoColumnNumberInfo, |
NULL, code->instruction_start()); |
RecordInliningInfo(rec->entry, code); |
@@ -300,8 +301,9 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
} |
rec->entry = profiles_->NewCodeEntry( |
tag, profiles_->GetFunctionName(shared->DebugName()), |
- CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name), line, |
- column, line_table, abstract_code->instruction_start()); |
+ CodeEntry::kEmptyNamePrefix, |
+ profiles_->GetName(InferScriptName(script_name, shared)), line, column, |
+ line_table, abstract_code->instruction_start()); |
RecordInliningInfo(rec->entry, abstract_code); |
if (info) { |
rec->entry->set_inlined_function_infos(info->inlined_function_infos()); |
@@ -391,6 +393,13 @@ void CpuProfiler::SetterCallbackEvent(Name* name, Address entry_point) { |
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, |
AbstractCode* abstract_code) { |
if (!abstract_code->IsCode()) return; |