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

Side by Side Diff: src/profiler/profile-generator.cc

Issue 2503393002: [cpu-profiler] use new source position information for deoptimization in cpu profiler (Closed)
Patch Set: addressed comment Created 4 years, 1 month 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/profiler/profile-generator-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/profile-generator.h" 5 #include "src/profiler/profile-generator.h"
6 6
7 #include "src/base/adapters.h" 7 #include "src/base/adapters.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/global-handles.h" 10 #include "src/global-handles.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 136
137 int CodeEntry::GetSourceLine(int pc_offset) const { 137 int CodeEntry::GetSourceLine(int pc_offset) const {
138 if (line_info_ && !line_info_->empty()) { 138 if (line_info_ && !line_info_->empty()) {
139 return line_info_->GetSourceLineNumber(pc_offset); 139 return line_info_->GetSourceLineNumber(pc_offset);
140 } 140 }
141 return v8::CpuProfileNode::kNoLineNumberInfo; 141 return v8::CpuProfileNode::kNoLineNumberInfo;
142 } 142 }
143 143
144 void CodeEntry::AddInlineStack(int pc_offset, 144 void CodeEntry::AddInlineStack(int pc_offset,
145 std::vector<CodeEntry*>& inline_stack) { 145 std::vector<CodeEntry*> inline_stack) {
146 // It's better to use std::move to place the vector into the map, 146 inline_locations_.insert(std::make_pair(pc_offset, std::move(inline_stack)));
147 // but it's not supported by the current stdlibc++ on MacOS.
148 inline_locations_.insert(std::make_pair(pc_offset, std::vector<CodeEntry*>()))
149 .first->second.swap(inline_stack);
150 } 147 }
151 148
152 const std::vector<CodeEntry*>* CodeEntry::GetInlineStack(int pc_offset) const { 149 const std::vector<CodeEntry*>* CodeEntry::GetInlineStack(int pc_offset) const {
153 auto it = inline_locations_.find(pc_offset); 150 auto it = inline_locations_.find(pc_offset);
154 return it != inline_locations_.end() ? &it->second : NULL; 151 return it != inline_locations_.end() ? &it->second : NULL;
155 } 152 }
156 153
157 void CodeEntry::AddDeoptInlinedFrames( 154 void CodeEntry::AddDeoptInlinedFrames(
158 int deopt_id, std::vector<DeoptInlinedFrame>& inlined_frames) { 155 int deopt_id, std::vector<CpuProfileDeoptFrame> inlined_frames) {
159 // It's better to use std::move to place the vector into the map, 156 deopt_inlined_frames_.insert(
160 // but it's not supported by the current stdlibc++ on MacOS. 157 std::make_pair(deopt_id, std::move(inlined_frames)));
161 deopt_inlined_frames_
162 .insert(std::make_pair(deopt_id, std::vector<DeoptInlinedFrame>()))
163 .first->second.swap(inlined_frames);
164 } 158 }
165 159
166 bool CodeEntry::HasDeoptInlinedFramesFor(int deopt_id) const { 160 bool CodeEntry::HasDeoptInlinedFramesFor(int deopt_id) const {
167 return deopt_inlined_frames_.find(deopt_id) != deopt_inlined_frames_.end(); 161 return deopt_inlined_frames_.find(deopt_id) != deopt_inlined_frames_.end();
168 } 162 }
169 163
170 void CodeEntry::FillFunctionInfo(SharedFunctionInfo* shared) { 164 void CodeEntry::FillFunctionInfo(SharedFunctionInfo* shared) {
171 if (!shared->script()->IsScript()) return; 165 if (!shared->script()->IsScript()) return;
172 Script* script = Script::cast(shared->script()); 166 Script* script = Script::cast(shared->script());
173 set_script_id(script->id()); 167 set_script_id(script->id());
174 set_position(shared->start_position()); 168 set_position(shared->start_position());
175 set_bailout_reason(GetBailoutReason(shared->disable_optimization_reason())); 169 set_bailout_reason(GetBailoutReason(shared->disable_optimization_reason()));
176 } 170 }
177 171
178 CpuProfileDeoptInfo CodeEntry::GetDeoptInfo() { 172 CpuProfileDeoptInfo CodeEntry::GetDeoptInfo() {
179 DCHECK(has_deopt_info()); 173 DCHECK(has_deopt_info());
180 174
181 CpuProfileDeoptInfo info; 175 CpuProfileDeoptInfo info;
182 info.deopt_reason = deopt_reason_; 176 info.deopt_reason = deopt_reason_;
183 DCHECK_NE(kNoDeoptimizationId, deopt_id_); 177 DCHECK_NE(kNoDeoptimizationId, deopt_id_);
184 size_t position = static_cast<size_t>(deopt_position_.ScriptOffset());
185 if (deopt_inlined_frames_.find(deopt_id_) == deopt_inlined_frames_.end()) { 178 if (deopt_inlined_frames_.find(deopt_id_) == deopt_inlined_frames_.end()) {
186 info.stack.push_back(CpuProfileDeoptFrame({script_id_, position})); 179 info.stack.push_back(CpuProfileDeoptFrame(
180 {script_id_, static_cast<size_t>(std::max(0, position()))}));
187 } else { 181 } else {
188 // Copy stack of inlined frames where the deopt happened. 182 info.stack = deopt_inlined_frames_[deopt_id_];
189 std::vector<DeoptInlinedFrame>& frames = deopt_inlined_frames_[deopt_id_];
190 bool first = true;
191 for (DeoptInlinedFrame& inlined_frame : base::Reversed(frames)) {
192 info.stack.push_back(
193 CpuProfileDeoptFrame({inlined_frame.script_id,
194 first ? position : inlined_frame.position}));
195 first = false; // Done with innermost frame.
196 }
197 } 183 }
198 return info; 184 return info;
199 } 185 }
200 186
201 187
202 void ProfileNode::CollectDeoptInfo(CodeEntry* entry) { 188 void ProfileNode::CollectDeoptInfo(CodeEntry* entry) {
203 deopt_infos_.push_back(entry->GetDeoptInfo()); 189 deopt_infos_.push_back(entry->GetDeoptInfo());
204 entry->clear_deopt_info(); 190 entry->clear_deopt_info();
205 } 191 }
206 192
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 case EXTERNAL: 772 case EXTERNAL:
787 return CodeEntry::program_entry(); 773 return CodeEntry::program_entry();
788 case IDLE: 774 case IDLE:
789 return CodeEntry::idle_entry(); 775 return CodeEntry::idle_entry();
790 default: return NULL; 776 default: return NULL;
791 } 777 }
792 } 778 }
793 779
794 } // namespace internal 780 } // namespace internal
795 } // namespace v8 781 } // namespace v8
OLDNEW
« no previous file with comments | « src/profiler/profile-generator.h ('k') | src/profiler/profile-generator-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698