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

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

Issue 1973993002: [compiler] Profiler reconstructs inlined frames for deopts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix build. Created 4 years, 7 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') | src/profiler/cpu-profiler-inl.h » ('j') | 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 line_table->SetPosition(pc_offset, line_number); 300 line_table->SetPosition(pc_offset, line_number);
301 } 301 }
302 } 302 }
303 } 303 }
304 rec->entry = profiles_->NewCodeEntry( 304 rec->entry = profiles_->NewCodeEntry(
305 tag, profiles_->GetFunctionName(shared->DebugName()), 305 tag, profiles_->GetFunctionName(shared->DebugName()),
306 CodeEntry::kEmptyNamePrefix, 306 CodeEntry::kEmptyNamePrefix,
307 profiles_->GetName(InferScriptName(script_name, shared)), line, column, 307 profiles_->GetName(InferScriptName(script_name, shared)), line, column,
308 line_table, abstract_code->instruction_start()); 308 line_table, abstract_code->instruction_start());
309 RecordInliningInfo(rec->entry, abstract_code); 309 RecordInliningInfo(rec->entry, abstract_code);
310 if (info) { 310 RecordDeoptInlinedFrames(rec->entry, abstract_code);
311 rec->entry->set_inlined_function_infos(info->inlined_function_infos());
312 }
313 rec->entry->FillFunctionInfo(shared); 311 rec->entry->FillFunctionInfo(shared);
314 rec->size = abstract_code->ExecutableSize(); 312 rec->size = abstract_code->ExecutableSize();
315 processor_->Enqueue(evt_rec); 313 processor_->Enqueue(evt_rec);
316 } 314 }
317 315
318 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, 316 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
319 AbstractCode* code, int args_count) { 317 AbstractCode* code, int args_count) {
320 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 318 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
321 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 319 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
322 rec->start = code->address(); 320 rec->start = code->address();
(...skipping 23 matching lines...) Expand all
346 processor_->Enqueue(evt_rec); 344 processor_->Enqueue(evt_rec);
347 } 345 }
348 346
349 void CpuProfiler::CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta) { 347 void CpuProfiler::CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta) {
350 CodeEventsContainer evt_rec(CodeEventRecord::CODE_DEOPT); 348 CodeEventsContainer evt_rec(CodeEventRecord::CODE_DEOPT);
351 CodeDeoptEventRecord* rec = &evt_rec.CodeDeoptEventRecord_; 349 CodeDeoptEventRecord* rec = &evt_rec.CodeDeoptEventRecord_;
352 Deoptimizer::DeoptInfo info = Deoptimizer::GetDeoptInfo(code, pc); 350 Deoptimizer::DeoptInfo info = Deoptimizer::GetDeoptInfo(code, pc);
353 rec->start = code->address(); 351 rec->start = code->address();
354 rec->deopt_reason = Deoptimizer::GetDeoptReason(info.deopt_reason); 352 rec->deopt_reason = Deoptimizer::GetDeoptReason(info.deopt_reason);
355 rec->position = info.position; 353 rec->position = info.position;
356 rec->inlining_id = info.inlining_id; 354 rec->deopt_id = info.deopt_id;
357 processor_->Enqueue(evt_rec); 355 processor_->Enqueue(evt_rec);
358 processor_->AddDeoptStack(isolate_, pc, fp_to_sp_delta); 356 processor_->AddDeoptStack(isolate_, pc, fp_to_sp_delta);
359 } 357 }
360 358
361 void CpuProfiler::GetterCallbackEvent(Name* name, Address entry_point) { 359 void CpuProfiler::GetterCallbackEvent(Name* name, Address entry_point) {
362 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 360 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
363 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 361 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
364 rec->start = entry_point; 362 rec->start = entry_point;
365 rec->entry = profiles_->NewCodeEntry( 363 rec->entry = profiles_->NewCodeEntry(
366 Logger::CALLBACK_TAG, 364 Logger::CALLBACK_TAG,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 inline_entry->FillFunctionInfo(shared_info); 441 inline_entry->FillFunctionInfo(shared_info);
444 inline_stack.push_back(inline_entry); 442 inline_stack.push_back(inline_entry);
445 } 443 }
446 if (!inline_stack.empty()) { 444 if (!inline_stack.empty()) {
447 entry->AddInlineStack(pc_offset, inline_stack); 445 entry->AddInlineStack(pc_offset, inline_stack);
448 DCHECK(inline_stack.empty()); 446 DCHECK(inline_stack.empty());
449 } 447 }
450 } 448 }
451 } 449 }
452 450
451 void CpuProfiler::RecordDeoptInlinedFrames(CodeEntry* entry,
452 AbstractCode* abstract_code) {
453 if (abstract_code->kind() != AbstractCode::OPTIMIZED_FUNCTION) return;
454 Code* code = abstract_code->GetCode();
455 DeoptimizationInputData* deopt_input_data =
456 DeoptimizationInputData::cast(code->deoptimization_data());
457 int const mask = RelocInfo::ModeMask(RelocInfo::DEOPT_ID);
458 for (RelocIterator rit(code, mask); !rit.done(); rit.next()) {
459 RelocInfo* reloc_info = rit.rinfo();
460 DCHECK(RelocInfo::IsDeoptId(reloc_info->rmode()));
461 int deopt_id = static_cast<int>(reloc_info->data());
462 int translation_index =
463 deopt_input_data->TranslationIndex(deopt_id)->value();
464 TranslationIterator it(deopt_input_data->TranslationByteArray(),
465 translation_index);
466 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next());
467 DCHECK_EQ(Translation::BEGIN, opcode);
468 it.Skip(Translation::NumberOfOperandsFor(opcode));
469 std::vector<CodeEntry::DeoptInlinedFrame> inlined_frames;
470 while (it.HasNext() &&
471 Translation::BEGIN !=
472 (opcode = static_cast<Translation::Opcode>(it.Next()))) {
473 if (opcode != Translation::JS_FRAME &&
474 opcode != Translation::INTERPRETED_FRAME) {
475 it.Skip(Translation::NumberOfOperandsFor(opcode));
476 continue;
477 }
478 BailoutId ast_id = BailoutId(it.Next());
479 int shared_info_id = it.Next();
480 it.Next(); // Skip height
481 SharedFunctionInfo* shared = SharedFunctionInfo::cast(
482 deopt_input_data->LiteralArray()->get(shared_info_id));
483 int source_position = Deoptimizer::ComputeSourcePosition(shared, ast_id);
484 int script_id = v8::UnboundScript::kNoScriptId;
485 if (shared->script()->IsScript()) {
486 Script* script = Script::cast(shared->script());
487 script_id = script->id();
488 }
489 CodeEntry::DeoptInlinedFrame frame = {source_position, script_id};
490 inlined_frames.push_back(frame);
491 }
492 if (!inlined_frames.empty() && !entry->HasDeoptInlinedFramesFor(deopt_id)) {
493 entry->AddDeoptInlinedFrames(deopt_id, inlined_frames);
494 DCHECK(inlined_frames.empty());
495 }
496 }
497 }
498
453 CpuProfiler::CpuProfiler(Isolate* isolate) 499 CpuProfiler::CpuProfiler(Isolate* isolate)
454 : isolate_(isolate), 500 : isolate_(isolate),
455 sampling_interval_(base::TimeDelta::FromMicroseconds( 501 sampling_interval_(base::TimeDelta::FromMicroseconds(
456 FLAG_cpu_profiler_sampling_interval)), 502 FLAG_cpu_profiler_sampling_interval)),
457 profiles_(new CpuProfilesCollection(isolate->heap())), 503 profiles_(new CpuProfilesCollection(isolate->heap())),
458 generator_(NULL), 504 generator_(NULL),
459 processor_(NULL), 505 processor_(NULL),
460 is_profiling_(false) { 506 is_profiling_(false) {
461 } 507 }
462 508
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 Builtins::Name id = static_cast<Builtins::Name>(i); 635 Builtins::Name id = static_cast<Builtins::Name>(i);
590 rec->start = builtins->builtin(id)->address(); 636 rec->start = builtins->builtin(id)->address();
591 rec->builtin_id = id; 637 rec->builtin_id = id;
592 processor_->Enqueue(evt_rec); 638 processor_->Enqueue(evt_rec);
593 } 639 }
594 } 640 }
595 641
596 642
597 } // namespace internal 643 } // namespace internal
598 } // namespace v8 644 } // namespace v8
OLDNEW
« no previous file with comments | « src/profiler/cpu-profiler.h ('k') | src/profiler/cpu-profiler-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698