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

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

Issue 2561773002: Revert of Merged: [cpu-profiler] use new source position information for deoptimization in cpu profiler (Closed)
Patch Set: Created 4 years 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 inline_locations_.insert(std::make_pair(pc_offset, std::move(inline_stack))); 146 // It's better to use std::move to place the vector into the map,
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);
147 } 150 }
148 151
149 const std::vector<CodeEntry*>* CodeEntry::GetInlineStack(int pc_offset) const { 152 const std::vector<CodeEntry*>* CodeEntry::GetInlineStack(int pc_offset) const {
150 auto it = inline_locations_.find(pc_offset); 153 auto it = inline_locations_.find(pc_offset);
151 return it != inline_locations_.end() ? &it->second : NULL; 154 return it != inline_locations_.end() ? &it->second : NULL;
152 } 155 }
153 156
154 void CodeEntry::AddDeoptInlinedFrames( 157 void CodeEntry::AddDeoptInlinedFrames(
155 int deopt_id, std::vector<CpuProfileDeoptFrame> inlined_frames) { 158 int deopt_id, std::vector<DeoptInlinedFrame>& inlined_frames) {
156 deopt_inlined_frames_.insert( 159 // It's better to use std::move to place the vector into the map,
157 std::make_pair(deopt_id, std::move(inlined_frames))); 160 // but it's not supported by the current stdlibc++ on MacOS.
161 deopt_inlined_frames_
162 .insert(std::make_pair(deopt_id, std::vector<DeoptInlinedFrame>()))
163 .first->second.swap(inlined_frames);
158 } 164 }
159 165
160 bool CodeEntry::HasDeoptInlinedFramesFor(int deopt_id) const { 166 bool CodeEntry::HasDeoptInlinedFramesFor(int deopt_id) const {
161 return deopt_inlined_frames_.find(deopt_id) != deopt_inlined_frames_.end(); 167 return deopt_inlined_frames_.find(deopt_id) != deopt_inlined_frames_.end();
162 } 168 }
163 169
164 void CodeEntry::FillFunctionInfo(SharedFunctionInfo* shared) { 170 void CodeEntry::FillFunctionInfo(SharedFunctionInfo* shared) {
165 if (!shared->script()->IsScript()) return; 171 if (!shared->script()->IsScript()) return;
166 Script* script = Script::cast(shared->script()); 172 Script* script = Script::cast(shared->script());
167 set_script_id(script->id()); 173 set_script_id(script->id());
168 set_position(shared->start_position()); 174 set_position(shared->start_position());
169 set_bailout_reason(GetBailoutReason(shared->disable_optimization_reason())); 175 set_bailout_reason(GetBailoutReason(shared->disable_optimization_reason()));
170 } 176 }
171 177
172 CpuProfileDeoptInfo CodeEntry::GetDeoptInfo() { 178 CpuProfileDeoptInfo CodeEntry::GetDeoptInfo() {
173 DCHECK(has_deopt_info()); 179 DCHECK(has_deopt_info());
174 180
175 CpuProfileDeoptInfo info; 181 CpuProfileDeoptInfo info;
176 info.deopt_reason = deopt_reason_; 182 info.deopt_reason = deopt_reason_;
177 DCHECK_NE(kNoDeoptimizationId, deopt_id_); 183 DCHECK_NE(kNoDeoptimizationId, deopt_id_);
184 size_t position = static_cast<size_t>(deopt_position_.ScriptOffset());
178 if (deopt_inlined_frames_.find(deopt_id_) == deopt_inlined_frames_.end()) { 185 if (deopt_inlined_frames_.find(deopt_id_) == deopt_inlined_frames_.end()) {
179 info.stack.push_back(CpuProfileDeoptFrame( 186 info.stack.push_back(CpuProfileDeoptFrame({script_id_, position}));
180 {script_id_, static_cast<size_t>(std::max(0, position()))}));
181 } else { 187 } else {
182 info.stack = deopt_inlined_frames_[deopt_id_]; 188 // Copy stack of inlined frames where the deopt happened.
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 }
183 } 197 }
184 return info; 198 return info;
185 } 199 }
186 200
187 201
188 void ProfileNode::CollectDeoptInfo(CodeEntry* entry) { 202 void ProfileNode::CollectDeoptInfo(CodeEntry* entry) {
189 deopt_infos_.push_back(entry->GetDeoptInfo()); 203 deopt_infos_.push_back(entry->GetDeoptInfo());
190 entry->clear_deopt_info(); 204 entry->clear_deopt_info();
191 } 205 }
192 206
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 case EXTERNAL: 785 case EXTERNAL:
772 return CodeEntry::program_entry(); 786 return CodeEntry::program_entry();
773 case IDLE: 787 case IDLE:
774 return CodeEntry::idle_entry(); 788 return CodeEntry::idle_entry();
775 default: return NULL; 789 default: return NULL;
776 } 790 }
777 } 791 }
778 792
779 } // namespace internal 793 } // namespace internal
780 } // namespace v8 794 } // 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