Chromium Code Reviews| Index: src/profiler/cpu-profiler.cc |
| diff --git a/src/profiler/cpu-profiler.cc b/src/profiler/cpu-profiler.cc |
| index 05a1bad445cb7b27e06cd71c5ca26406cbd306ee..b679502b40812aa3357d7f83e9db32a80482e3d0 100644 |
| --- a/src/profiler/cpu-profiler.cc |
| +++ b/src/profiler/cpu-profiler.cc |
| @@ -307,9 +307,7 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 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()); |
| - } |
| + RecordDeoptInlinedFrames(rec->entry, abstract_code); |
| rec->entry->FillFunctionInfo(shared); |
| rec->size = abstract_code->ExecutableSize(); |
| processor_->Enqueue(evt_rec); |
| @@ -353,7 +351,7 @@ void CpuProfiler::CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta) { |
| rec->start = code->address(); |
| rec->deopt_reason = Deoptimizer::GetDeoptReason(info.deopt_reason); |
| rec->position = info.position; |
| - rec->inlining_id = info.inlining_id; |
| + rec->deopt_id = info.deopt_id; |
| processor_->Enqueue(evt_rec); |
| processor_->AddDeoptStack(isolate_, pc, fp_to_sp_delta); |
| } |
| @@ -450,6 +448,54 @@ void CpuProfiler::RecordInliningInfo(CodeEntry* entry, |
| } |
| } |
| +void CpuProfiler::RecordDeoptInlinedFrames(CodeEntry* entry, |
| + AbstractCode* abstract_code) { |
| + if (!abstract_code->IsCode()) return; |
| + Code* code = abstract_code->GetCode(); |
| + if (code->kind() != Code::OPTIMIZED_FUNCTION) return; |
|
Yang
2016/05/13 06:53:22
You could just check for abstract_code->kind(), an
Michael Starzinger
2016/05/13 08:08:18
Done.
|
| + DeoptimizationInputData* deopt_input_data = |
| + DeoptimizationInputData::cast(code->deoptimization_data()); |
| + for (RelocIterator rit(code); !rit.done(); rit.next()) { |
|
Yang
2016/05/13 06:53:22
You could pass (1 << DEOPT_ID) as reloc info mask
Michael Starzinger
2016/05/13 08:08:18
Done.
|
| + RelocInfo* reloc_info = rit.rinfo(); |
| + if (!RelocInfo::IsDeoptId(reloc_info->rmode())) continue; |
| + int deopt_id = static_cast<int>(reloc_info->data()); |
| + int translation_index = |
| + deopt_input_data->TranslationIndex(deopt_id)->value(); |
| + TranslationIterator it(deopt_input_data->TranslationByteArray(), |
| + translation_index); |
| + Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); |
| + DCHECK_EQ(Translation::BEGIN, opcode); |
| + it.Skip(Translation::NumberOfOperandsFor(opcode)); |
| + std::vector<CodeEntry::DeoptInlinedFrame> inlined_frames; |
| + while (it.HasNext() && |
| + Translation::BEGIN != |
| + (opcode = static_cast<Translation::Opcode>(it.Next()))) { |
| + if (opcode != Translation::JS_FRAME && |
| + opcode != Translation::INTERPRETED_FRAME) { |
| + it.Skip(Translation::NumberOfOperandsFor(opcode)); |
| + continue; |
| + } |
| + BailoutId ast_id = BailoutId(it.Next()); |
| + int shared_info_id = it.Next(); |
| + it.Next(); // Skip height |
| + SharedFunctionInfo* shared = SharedFunctionInfo::cast( |
| + deopt_input_data->LiteralArray()->get(shared_info_id)); |
| + int source_position = Deoptimizer::ComputeSourcePosition(shared, ast_id); |
| + int script_id = v8::UnboundScript::kNoScriptId; |
| + if (shared->script()->IsScript()) { |
| + Script* script = Script::cast(shared->script()); |
| + script_id = script->id(); |
| + } |
| + CodeEntry::DeoptInlinedFrame frame = {source_position, script_id}; |
| + inlined_frames.push_back(frame); |
| + } |
| + if (!inlined_frames.empty() && !entry->HasDeoptInlinedFramesFor(deopt_id)) { |
| + entry->AddDeoptInlinedFrames(deopt_id, inlined_frames); |
| + DCHECK(inlined_frames.empty()); |
| + } |
| + } |
| +} |
| + |
| CpuProfiler::CpuProfiler(Isolate* isolate) |
| : isolate_(isolate), |
| sampling_interval_(base::TimeDelta::FromMicroseconds( |