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

Side by Side Diff: src/profiler/profile-generator.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/profile-generator.h ('k') | src/s390/assembler-s390.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/profile-generator.h" 5 #include "src/profiler/profile-generator.h"
6 6
7 #include "src/ast/scopeinfo.h" 7 #include "src/ast/scopeinfo.h"
8 #include "src/base/adapters.h"
8 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
9 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
10 #include "src/global-handles.h" 11 #include "src/global-handles.h"
11 #include "src/profiler/profile-generator-inl.h" 12 #include "src/profiler/profile-generator-inl.h"
12 #include "src/profiler/sampler.h" 13 #include "src/profiler/sampler.h"
13 #include "src/splay-tree-inl.h" 14 #include "src/splay-tree-inl.h"
14 #include "src/unicode.h" 15 #include "src/unicode.h"
15 16
16 namespace v8 { 17 namespace v8 {
17 namespace internal { 18 namespace internal {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // but it's not supported by the current stdlibc++ on MacOS. 112 // but it's not supported by the current stdlibc++ on MacOS.
112 inline_locations_.insert(std::make_pair(pc_offset, std::vector<CodeEntry*>())) 113 inline_locations_.insert(std::make_pair(pc_offset, std::vector<CodeEntry*>()))
113 .first->second.swap(inline_stack); 114 .first->second.swap(inline_stack);
114 } 115 }
115 116
116 const std::vector<CodeEntry*>* CodeEntry::GetInlineStack(int pc_offset) const { 117 const std::vector<CodeEntry*>* CodeEntry::GetInlineStack(int pc_offset) const {
117 auto it = inline_locations_.find(pc_offset); 118 auto it = inline_locations_.find(pc_offset);
118 return it != inline_locations_.end() ? &it->second : NULL; 119 return it != inline_locations_.end() ? &it->second : NULL;
119 } 120 }
120 121
122 void CodeEntry::AddDeoptInlinedFrames(
123 int deopt_id, std::vector<DeoptInlinedFrame>& inlined_frames) {
124 // It's better to use std::move to place the vector into the map,
125 // but it's not supported by the current stdlibc++ on MacOS.
126 deopt_inlined_frames_
127 .insert(std::make_pair(deopt_id, std::vector<DeoptInlinedFrame>()))
128 .first->second.swap(inlined_frames);
129 }
130
131 bool CodeEntry::HasDeoptInlinedFramesFor(int deopt_id) const {
132 return deopt_inlined_frames_.find(deopt_id) != deopt_inlined_frames_.end();
133 }
134
121 void CodeEntry::FillFunctionInfo(SharedFunctionInfo* shared) { 135 void CodeEntry::FillFunctionInfo(SharedFunctionInfo* shared) {
122 if (!shared->script()->IsScript()) return; 136 if (!shared->script()->IsScript()) return;
123 Script* script = Script::cast(shared->script()); 137 Script* script = Script::cast(shared->script());
124 set_script_id(script->id()); 138 set_script_id(script->id());
125 set_position(shared->start_position()); 139 set_position(shared->start_position());
126 set_bailout_reason(GetBailoutReason(shared->disable_optimization_reason())); 140 set_bailout_reason(GetBailoutReason(shared->disable_optimization_reason()));
127 } 141 }
128 142
129 CpuProfileDeoptInfo CodeEntry::GetDeoptInfo() { 143 CpuProfileDeoptInfo CodeEntry::GetDeoptInfo() {
130 DCHECK(has_deopt_info()); 144 DCHECK(has_deopt_info());
131 145
132 CpuProfileDeoptInfo info; 146 CpuProfileDeoptInfo info;
133 info.deopt_reason = deopt_reason_; 147 info.deopt_reason = deopt_reason_;
134 if (inlined_function_infos_.empty()) { 148 DCHECK_NE(Deoptimizer::DeoptInfo::kNoDeoptId, deopt_id_);
149 if (deopt_inlined_frames_.find(deopt_id_) == deopt_inlined_frames_.end()) {
135 info.stack.push_back(CpuProfileDeoptFrame( 150 info.stack.push_back(CpuProfileDeoptFrame(
136 {script_id_, position_ + deopt_position_.position()})); 151 {script_id_, position_ + deopt_position_.position()}));
137 return info; 152 } else {
138 } 153 size_t deopt_position = deopt_position_.raw();
139 // Copy the only branch from the inlining tree where the deopt happened. 154 // Copy stack of inlined frames where the deopt happened.
140 SourcePosition position = deopt_position_; 155 std::vector<DeoptInlinedFrame>& frames = deopt_inlined_frames_[deopt_id_];
141 int inlining_id = deopt_inlining_id_; 156 for (DeoptInlinedFrame& inlined_frame : base::Reversed(frames)) {
142 while (inlining_id != InlinedFunctionInfo::kNoParentId) { 157 info.stack.push_back(CpuProfileDeoptFrame(
143 InlinedFunctionInfo& inlined_info = inlined_function_infos_.at(inlining_id); 158 {inlined_frame.script_id, deopt_position + inlined_frame.position}));
144 info.stack.push_back( 159 deopt_position = 0; // Done with innermost frame.
145 CpuProfileDeoptFrame({inlined_info.script_id, 160 }
146 inlined_info.start_position + position.raw()}));
147 position = inlined_info.inline_position;
148 inlining_id = inlined_info.parent_id;
149 } 161 }
150 return info; 162 return info;
151 } 163 }
152 164
153 165
154 void ProfileNode::CollectDeoptInfo(CodeEntry* entry) { 166 void ProfileNode::CollectDeoptInfo(CodeEntry* entry) {
155 deopt_infos_.push_back(entry->GetDeoptInfo()); 167 deopt_infos_.push_back(entry->GetDeoptInfo());
156 entry->clear_deopt_info(); 168 entry->clear_deopt_info();
157 } 169 }
158 170
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 case EXTERNAL: 714 case EXTERNAL:
703 return program_entry_; 715 return program_entry_;
704 case IDLE: 716 case IDLE:
705 return idle_entry_; 717 return idle_entry_;
706 default: return NULL; 718 default: return NULL;
707 } 719 }
708 } 720 }
709 721
710 } // namespace internal 722 } // namespace internal
711 } // namespace v8 723 } // namespace v8
OLDNEW
« no previous file with comments | « src/profiler/profile-generator.h ('k') | src/s390/assembler-s390.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698