Commit 7fef610d authored by loislo's avatar loislo Committed by Commit bot

CpuProfiler: log pc offset for deopts.

This is the fifth part of https://codereview.chromium.org/1012633002
In this part we collect the offsets of deopt calls and save it into
an inlined function info.

On the Next:
Later when deopt happens we will get the offset of deopt call and
search it among inlined infos.

BUG=chromium:452067
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#27258}
parent 46d6ffed
...@@ -352,6 +352,8 @@ bool LCodeGen::GenerateJumpTable() { ...@@ -352,6 +352,8 @@ bool LCodeGen::GenerateJumpTable() {
} else { } else {
__ bl(&call_deopt_entry); __ bl(&call_deopt_entry);
} }
info()->LogDeoptCallPosition(masm()->pc_offset(),
table_entry->deopt_info.inlining_id);
masm()->CheckConstPool(false, false); masm()->CheckConstPool(false, false);
} }
...@@ -887,6 +889,7 @@ void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr, ...@@ -887,6 +889,7 @@ void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr,
!info()->saves_caller_doubles()) { !info()->saves_caller_doubles()) {
DeoptComment(deopt_info); DeoptComment(deopt_info);
__ Call(entry, RelocInfo::RUNTIME_ENTRY); __ Call(entry, RelocInfo::RUNTIME_ENTRY);
info()->LogDeoptCallPosition(masm()->pc_offset(), deopt_info.inlining_id);
} else { } else {
Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type, Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type,
!frame_is_built_); !frame_is_built_);
......
...@@ -876,6 +876,8 @@ bool LCodeGen::GenerateJumpTable() { ...@@ -876,6 +876,8 @@ bool LCodeGen::GenerateJumpTable() {
// table. // table.
__ Bl(&call_deopt_entry); __ Bl(&call_deopt_entry);
} }
info()->LogDeoptCallPosition(masm()->pc_offset(),
table_entry->deopt_info.inlining_id);
masm()->CheckConstPool(false, false); masm()->CheckConstPool(false, false);
} }
...@@ -1061,6 +1063,7 @@ void LCodeGen::DeoptimizeBranch( ...@@ -1061,6 +1063,7 @@ void LCodeGen::DeoptimizeBranch(
frame_is_built_ && !info()->saves_caller_doubles()) { frame_is_built_ && !info()->saves_caller_doubles()) {
DeoptComment(deopt_info); DeoptComment(deopt_info);
__ Call(entry, RelocInfo::RUNTIME_ENTRY); __ Call(entry, RelocInfo::RUNTIME_ENTRY);
info()->LogDeoptCallPosition(masm()->pc_offset(), deopt_info.inlining_id);
} else { } else {
Deoptimizer::JumpTableEntry* table_entry = Deoptimizer::JumpTableEntry* table_entry =
new (zone()) Deoptimizer::JumpTableEntry( new (zone()) Deoptimizer::JumpTableEntry(
......
...@@ -322,6 +322,14 @@ int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, ...@@ -322,6 +322,14 @@ int CompilationInfo::TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
} }
void CompilationInfo::LogDeoptCallPosition(int pc_offset, int inlining_id) {
if (!track_positions_ || IsStub()) return;
DCHECK_LT(static_cast<size_t>(inlining_id), inlined_function_infos_->size());
inlined_function_infos_->at(inlining_id)
.deopt_pc_offsets.push_back(pc_offset);
}
class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder { class HOptimizedGraphBuilderWithPositions: public HOptimizedGraphBuilder {
public: public:
explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info) explicit HOptimizedGraphBuilderWithPositions(CompilationInfo* info)
......
...@@ -97,6 +97,7 @@ struct InlinedFunctionInfo { ...@@ -97,6 +97,7 @@ struct InlinedFunctionInfo {
SourcePosition inline_position; SourcePosition inline_position;
int script_id; int script_id;
int start_position; int start_position;
std::vector<int> deopt_pc_offsets;
static const int kNoParentId = -1; static const int kNoParentId = -1;
}; };
...@@ -342,6 +343,13 @@ class CompilationInfo { ...@@ -342,6 +343,13 @@ class CompilationInfo {
std::vector<InlinedFunctionInfo>* inlined_function_infos() { std::vector<InlinedFunctionInfo>* inlined_function_infos() {
return inlined_function_infos_; return inlined_function_infos_;
} }
std::vector<InlinedFunctionInfo>* ReleaseInlinedFunctionInfos() {
std::vector<InlinedFunctionInfo>* tmp = inlined_function_infos_;
inlined_function_infos_ = NULL;
return tmp;
}
void LogDeoptCallPosition(int pc_offset, int inlining_id);
int TraceInlinedFunction(Handle<SharedFunctionInfo> shared, int TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
SourcePosition position, int pareint_id); SourcePosition position, int pareint_id);
......
...@@ -395,6 +395,8 @@ bool LCodeGen::GenerateJumpTable() { ...@@ -395,6 +395,8 @@ bool LCodeGen::GenerateJumpTable() {
if (info()->saves_caller_doubles()) RestoreCallerDoubles(); if (info()->saves_caller_doubles()) RestoreCallerDoubles();
__ call(entry, RelocInfo::RUNTIME_ENTRY); __ call(entry, RelocInfo::RUNTIME_ENTRY);
} }
info()->LogDeoptCallPosition(masm()->pc_offset(),
table_entry->deopt_info.inlining_id);
} }
if (needs_frame.is_linked()) { if (needs_frame.is_linked()) {
__ bind(&needs_frame); __ bind(&needs_frame);
...@@ -888,6 +890,7 @@ void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, ...@@ -888,6 +890,7 @@ void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr,
if (cc == no_condition && frame_is_built_) { if (cc == no_condition && frame_is_built_) {
DeoptComment(deopt_info); DeoptComment(deopt_info);
__ call(entry, RelocInfo::RUNTIME_ENTRY); __ call(entry, RelocInfo::RUNTIME_ENTRY);
info()->LogDeoptCallPosition(masm()->pc_offset(), deopt_info.inlining_id);
} else { } else {
Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type, Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type,
!frame_is_built_); !frame_is_built_);
......
...@@ -353,6 +353,8 @@ bool LCodeGen::GenerateJumpTable() { ...@@ -353,6 +353,8 @@ bool LCodeGen::GenerateJumpTable() {
} else { } else {
__ Call(&call_deopt_entry); __ Call(&call_deopt_entry);
} }
info()->LogDeoptCallPosition(masm()->pc_offset(),
table_entry->deopt_info.inlining_id);
} }
if (needs_frame.is_linked()) { if (needs_frame.is_linked()) {
...@@ -853,6 +855,7 @@ void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr, ...@@ -853,6 +855,7 @@ void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr,
!info()->saves_caller_doubles()) { !info()->saves_caller_doubles()) {
DeoptComment(deopt_info); DeoptComment(deopt_info);
__ Call(entry, RelocInfo::RUNTIME_ENTRY, condition, src1, src2); __ Call(entry, RelocInfo::RUNTIME_ENTRY, condition, src1, src2);
info()->LogDeoptCallPosition(masm()->pc_offset(), deopt_info.inlining_id);
} else { } else {
Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type, Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type,
!frame_is_built_); !frame_is_built_);
......
...@@ -320,6 +320,8 @@ bool LCodeGen::GenerateJumpTable() { ...@@ -320,6 +320,8 @@ bool LCodeGen::GenerateJumpTable() {
} else { } else {
__ Call(&call_deopt_entry); __ Call(&call_deopt_entry);
} }
info()->LogDeoptCallPosition(masm()->pc_offset(),
table_entry->deopt_info.inlining_id);
} }
if (needs_frame.is_linked()) { if (needs_frame.is_linked()) {
__ bind(&needs_frame); __ bind(&needs_frame);
...@@ -820,6 +822,7 @@ void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr, ...@@ -820,6 +822,7 @@ void LCodeGen::DeoptimizeIf(Condition condition, LInstruction* instr,
!info()->saves_caller_doubles()) { !info()->saves_caller_doubles()) {
DeoptComment(deopt_info); DeoptComment(deopt_info);
__ Call(entry, RelocInfo::RUNTIME_ENTRY, condition, src1, src2); __ Call(entry, RelocInfo::RUNTIME_ENTRY, condition, src1, src2);
info()->LogDeoptCallPosition(masm()->pc_offset(), deopt_info.inlining_id);
} else { } else {
Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type, Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type,
!frame_is_built_); !frame_is_built_);
......
...@@ -343,6 +343,8 @@ bool LCodeGen::GenerateJumpTable() { ...@@ -343,6 +343,8 @@ bool LCodeGen::GenerateJumpTable() {
} else { } else {
__ b(&call_deopt_entry, SetLK); __ b(&call_deopt_entry, SetLK);
} }
info()->LogDeoptCallPosition(masm()->pc_offset(),
table_entry->deopt_info.inlining_id);
} }
if (needs_frame.is_linked()) { if (needs_frame.is_linked()) {
...@@ -809,6 +811,7 @@ void LCodeGen::DeoptimizeIf(Condition cond, LInstruction* instr, ...@@ -809,6 +811,7 @@ void LCodeGen::DeoptimizeIf(Condition cond, LInstruction* instr,
if (cond == al && frame_is_built_ && !info()->saves_caller_doubles()) { if (cond == al && frame_is_built_ && !info()->saves_caller_doubles()) {
DeoptComment(deopt_info); DeoptComment(deopt_info);
__ Call(entry, RelocInfo::RUNTIME_ENTRY); __ Call(entry, RelocInfo::RUNTIME_ENTRY);
info()->LogDeoptCallPosition(masm()->pc_offset(), deopt_info.inlining_id);
} else { } else {
Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type, Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type,
!frame_is_built_); !frame_is_built_);
......
...@@ -317,6 +317,8 @@ bool LCodeGen::GenerateJumpTable() { ...@@ -317,6 +317,8 @@ bool LCodeGen::GenerateJumpTable() {
} }
__ call(entry, RelocInfo::RUNTIME_ENTRY); __ call(entry, RelocInfo::RUNTIME_ENTRY);
} }
info()->LogDeoptCallPosition(masm()->pc_offset(),
table_entry->deopt_info.inlining_id);
} }
if (needs_frame.is_linked()) { if (needs_frame.is_linked()) {
...@@ -358,7 +360,7 @@ bool LCodeGen::GenerateJumpTable() { ...@@ -358,7 +360,7 @@ bool LCodeGen::GenerateJumpTable() {
__ Move(MemOperand(rsp, 2 * kPointerSize), Smi::FromInt(StackFrame::STUB)); __ Move(MemOperand(rsp, 2 * kPointerSize), Smi::FromInt(StackFrame::STUB));
/* stack layout /* stack layout
4: old ebp 4: old rbp
3: context pointer 3: context pointer
2: stub marker 2: stub marker
1: return address 1: return address
...@@ -811,6 +813,7 @@ void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, ...@@ -811,6 +813,7 @@ void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr,
!info()->saves_caller_doubles()) { !info()->saves_caller_doubles()) {
DeoptComment(deopt_info); DeoptComment(deopt_info);
__ call(entry, RelocInfo::RUNTIME_ENTRY); __ call(entry, RelocInfo::RUNTIME_ENTRY);
info()->LogDeoptCallPosition(masm()->pc_offset(), deopt_info.inlining_id);
} else { } else {
Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type, Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type,
!frame_is_built_); !frame_is_built_);
......
...@@ -391,6 +391,8 @@ bool LCodeGen::GenerateJumpTable() { ...@@ -391,6 +391,8 @@ bool LCodeGen::GenerateJumpTable() {
} else { } else {
__ call(entry, RelocInfo::RUNTIME_ENTRY); __ call(entry, RelocInfo::RUNTIME_ENTRY);
} }
info()->LogDeoptCallPosition(masm()->pc_offset(),
table_entry->deopt_info.inlining_id);
} }
if (needs_frame.is_linked()) { if (needs_frame.is_linked()) {
__ bind(&needs_frame); __ bind(&needs_frame);
...@@ -1173,6 +1175,7 @@ void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr, ...@@ -1173,6 +1175,7 @@ void LCodeGen::DeoptimizeIf(Condition cc, LInstruction* instr,
if (cc == no_condition && frame_is_built_) { if (cc == no_condition && frame_is_built_) {
DeoptComment(deopt_info); DeoptComment(deopt_info);
__ call(entry, RelocInfo::RUNTIME_ENTRY); __ call(entry, RelocInfo::RUNTIME_ENTRY);
info()->LogDeoptCallPosition(masm()->pc_offset(), deopt_info.inlining_id);
} else { } else {
Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type, Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type,
!frame_is_built_); !frame_is_built_);
......
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