Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: src/profiler/cpu-profiler.cc

Issue 1796353002: Provide better script names in CPU profiler. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/profiler/cpu-profiler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/profiler/cpu-profiler.h" 5 #include "src/profiler/cpu-profiler.h"
6 6
7 #include "src/debug/debug.h" 7 #include "src/debug/debug.h"
8 #include "src/deoptimizer.h" 8 #include "src/deoptimizer.h"
9 #include "src/frames-inl.h" 9 #include "src/frames-inl.h"
10 #include "src/locked-queue-inl.h" 10 #include "src/locked-queue-inl.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 241
242 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, 242 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
243 AbstractCode* code, 243 AbstractCode* code,
244 SharedFunctionInfo* shared, 244 SharedFunctionInfo* shared,
245 CompilationInfo* info, Name* script_name) { 245 CompilationInfo* info, Name* script_name) {
246 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 246 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
247 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 247 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
248 rec->start = code->address(); 248 rec->start = code->address();
249 rec->entry = profiles_->NewCodeEntry( 249 rec->entry = profiles_->NewCodeEntry(
250 tag, profiles_->GetFunctionName(shared->DebugName()), 250 tag, profiles_->GetFunctionName(shared->DebugName()),
251 CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name), 251 CodeEntry::kEmptyNamePrefix,
252 profiles_->GetName(InferScriptName(script_name, shared)),
252 CpuProfileNode::kNoLineNumberInfo, CpuProfileNode::kNoColumnNumberInfo, 253 CpuProfileNode::kNoLineNumberInfo, CpuProfileNode::kNoColumnNumberInfo,
253 NULL, code->instruction_start()); 254 NULL, code->instruction_start());
254 RecordInliningInfo(rec->entry, code); 255 RecordInliningInfo(rec->entry, code);
255 if (info) { 256 if (info) {
256 rec->entry->set_inlined_function_infos(info->inlined_function_infos()); 257 rec->entry->set_inlined_function_infos(info->inlined_function_infos());
257 } 258 }
258 rec->entry->FillFunctionInfo(shared); 259 rec->entry->FillFunctionInfo(shared);
259 rec->size = code->ExecutableSize(); 260 rec->size = code->ExecutableSize();
260 processor_->Enqueue(evt_rec); 261 processor_->Enqueue(evt_rec);
261 } 262 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 bytecode->source_position_table()); 294 bytecode->source_position_table());
294 for (; !it.done(); it.Advance()) { 295 for (; !it.done(); it.Advance()) {
295 int line_number = script->GetLineNumber(it.source_position()) + 1; 296 int line_number = script->GetLineNumber(it.source_position()) + 1;
296 int pc_offset = it.bytecode_offset() + BytecodeArray::kHeaderSize; 297 int pc_offset = it.bytecode_offset() + BytecodeArray::kHeaderSize;
297 line_table->SetPosition(pc_offset, line_number); 298 line_table->SetPosition(pc_offset, line_number);
298 } 299 }
299 } 300 }
300 } 301 }
301 rec->entry = profiles_->NewCodeEntry( 302 rec->entry = profiles_->NewCodeEntry(
302 tag, profiles_->GetFunctionName(shared->DebugName()), 303 tag, profiles_->GetFunctionName(shared->DebugName()),
303 CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name), line, 304 CodeEntry::kEmptyNamePrefix,
304 column, line_table, abstract_code->instruction_start()); 305 profiles_->GetName(InferScriptName(script_name, shared)), line, column,
306 line_table, abstract_code->instruction_start());
305 RecordInliningInfo(rec->entry, abstract_code); 307 RecordInliningInfo(rec->entry, abstract_code);
306 if (info) { 308 if (info) {
307 rec->entry->set_inlined_function_infos(info->inlined_function_infos()); 309 rec->entry->set_inlined_function_infos(info->inlined_function_infos());
308 } 310 }
309 rec->entry->FillFunctionInfo(shared); 311 rec->entry->FillFunctionInfo(shared);
310 rec->size = abstract_code->ExecutableSize(); 312 rec->size = abstract_code->ExecutableSize();
311 processor_->Enqueue(evt_rec); 313 processor_->Enqueue(evt_rec);
312 } 314 }
313 315
314 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, 316 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 386 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
385 rec->start = entry_point; 387 rec->start = entry_point;
386 rec->entry = profiles_->NewCodeEntry( 388 rec->entry = profiles_->NewCodeEntry(
387 Logger::CALLBACK_TAG, 389 Logger::CALLBACK_TAG,
388 profiles_->GetName(name), 390 profiles_->GetName(name),
389 "set "); 391 "set ");
390 rec->size = 1; 392 rec->size = 1;
391 processor_->Enqueue(evt_rec); 393 processor_->Enqueue(evt_rec);
392 } 394 }
393 395
396 Name* CpuProfiler::InferScriptName(Name* name, SharedFunctionInfo* info) {
397 if (name->IsString() && String::cast(name)->length()) return name;
398 if (!info->script()->IsScript()) return name;
399 Object* source_url = Script::cast(info->script())->source_url();
400 return source_url->IsName() ? Name::cast(source_url) : name;
401 }
402
394 void CpuProfiler::RecordInliningInfo(CodeEntry* entry, 403 void CpuProfiler::RecordInliningInfo(CodeEntry* entry,
395 AbstractCode* abstract_code) { 404 AbstractCode* abstract_code) {
396 if (!abstract_code->IsCode()) return; 405 if (!abstract_code->IsCode()) return;
397 Code* code = abstract_code->GetCode(); 406 Code* code = abstract_code->GetCode();
398 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; 407 if (code->kind() != Code::OPTIMIZED_FUNCTION) return;
399 DeoptimizationInputData* deopt_input_data = 408 DeoptimizationInputData* deopt_input_data =
400 DeoptimizationInputData::cast(code->deoptimization_data()); 409 DeoptimizationInputData::cast(code->deoptimization_data());
401 int deopt_count = deopt_input_data->DeoptCount(); 410 int deopt_count = deopt_input_data->DeoptCount();
402 for (int i = 0; i < deopt_count; i++) { 411 for (int i = 0; i < deopt_count; i++) {
403 int pc_offset = deopt_input_data->Pc(i)->value(); 412 int pc_offset = deopt_input_data->Pc(i)->value();
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 Builtins::Name id = static_cast<Builtins::Name>(i); 587 Builtins::Name id = static_cast<Builtins::Name>(i);
579 rec->start = builtins->builtin(id)->address(); 588 rec->start = builtins->builtin(id)->address();
580 rec->builtin_id = id; 589 rec->builtin_id = id;
581 processor_->Enqueue(evt_rec); 590 processor_->Enqueue(evt_rec);
582 } 591 }
583 } 592 }
584 593
585 594
586 } // namespace internal 595 } // namespace internal
587 } // namespace v8 596 } // namespace v8
OLDNEW
« no previous file with comments | « src/profiler/cpu-profiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698