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

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: removed CodeDeoptEvent::position 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
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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 inline_locations_.insert(std::make_pair(pc_offset, std::vector<CodeEntry*>())) 148 inline_locations_.insert(std::make_pair(pc_offset, std::vector<CodeEntry*>()))
149 .first->second.swap(inline_stack); 149 .first->second.swap(inline_stack);
150 } 150 }
151 151
152 const std::vector<CodeEntry*>* CodeEntry::GetInlineStack(int pc_offset) const { 152 const std::vector<CodeEntry*>* CodeEntry::GetInlineStack(int pc_offset) const {
153 auto it = inline_locations_.find(pc_offset); 153 auto it = inline_locations_.find(pc_offset);
154 return it != inline_locations_.end() ? &it->second : NULL; 154 return it != inline_locations_.end() ? &it->second : NULL;
155 } 155 }
156 156
157 void CodeEntry::AddDeoptInlinedFrames( 157 void CodeEntry::AddDeoptInlinedFrames(
158 int deopt_id, std::vector<DeoptInlinedFrame>& inlined_frames) { 158 int deopt_id, std::vector<CpuProfileDeoptFrame>& inlined_frames) {
159 // It's better to use std::move to place the vector into the map, 159 // It's better to use std::move to place the vector into the map,
160 // but it's not supported by the current stdlibc++ on MacOS. 160 // but it's not supported by the current stdlibc++ on MacOS.
161 deopt_inlined_frames_ 161 deopt_inlined_frames_
162 .insert(std::make_pair(deopt_id, std::vector<DeoptInlinedFrame>())) 162 .insert(std::make_pair(deopt_id, std::vector<CpuProfileDeoptFrame>()))
alph 2016/11/17 00:09:43 I believe it's now ok to use std::move Could you p
163 .first->second.swap(inlined_frames); 163 .first->second.swap(inlined_frames);
164 } 164 }
165 165
166 bool CodeEntry::HasDeoptInlinedFramesFor(int deopt_id) const { 166 bool CodeEntry::HasDeoptInlinedFramesFor(int deopt_id) const {
167 return deopt_inlined_frames_.find(deopt_id) != deopt_inlined_frames_.end(); 167 return deopt_inlined_frames_.find(deopt_id) != deopt_inlined_frames_.end();
168 } 168 }
169 169
170 void CodeEntry::FillFunctionInfo(SharedFunctionInfo* shared) { 170 void CodeEntry::FillFunctionInfo(SharedFunctionInfo* shared) {
171 if (!shared->script()->IsScript()) return; 171 if (!shared->script()->IsScript()) return;
172 Script* script = Script::cast(shared->script()); 172 Script* script = Script::cast(shared->script());
173 set_script_id(script->id()); 173 set_script_id(script->id());
174 set_position(shared->start_position()); 174 set_position(shared->start_position());
175 set_bailout_reason(GetBailoutReason(shared->disable_optimization_reason())); 175 set_bailout_reason(GetBailoutReason(shared->disable_optimization_reason()));
176 } 176 }
177 177
178 CpuProfileDeoptInfo CodeEntry::GetDeoptInfo() { 178 CpuProfileDeoptInfo CodeEntry::GetDeoptInfo() {
179 DCHECK(has_deopt_info()); 179 DCHECK(has_deopt_info());
180 180
181 CpuProfileDeoptInfo info; 181 CpuProfileDeoptInfo info;
182 info.deopt_reason = deopt_reason_; 182 info.deopt_reason = deopt_reason_;
183 DCHECK_NE(kNoDeoptimizationId, deopt_id_); 183 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()) { 184 if (deopt_inlined_frames_.find(deopt_id_) == deopt_inlined_frames_.end()) {
186 info.stack.push_back(CpuProfileDeoptFrame({script_id_, position})); 185 info.stack.push_back(CpuProfileDeoptFrame({script_id_, position()}));
187 } else { 186 } else {
188 // Copy stack of inlined frames where the deopt happened. 187 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 } 188 }
198 return info; 189 return info;
199 } 190 }
200 191
201 192
202 void ProfileNode::CollectDeoptInfo(CodeEntry* entry) { 193 void ProfileNode::CollectDeoptInfo(CodeEntry* entry) {
203 deopt_infos_.push_back(entry->GetDeoptInfo()); 194 deopt_infos_.push_back(entry->GetDeoptInfo());
204 entry->clear_deopt_info(); 195 entry->clear_deopt_info();
205 } 196 }
206 197
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 case EXTERNAL: 776 case EXTERNAL:
786 return CodeEntry::program_entry(); 777 return CodeEntry::program_entry();
787 case IDLE: 778 case IDLE:
788 return CodeEntry::idle_entry(); 779 return CodeEntry::idle_entry();
789 default: return NULL; 780 default: return NULL;
790 } 781 }
791 } 782 }
792 783
793 } // namespace internal 784 } // namespace internal
794 } // namespace v8 785 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698