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

Side by Side Diff: src/cpu-profiler.cc

Issue 682143003: Reland of Extend CPU profiler with mapping ticks to source lines (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 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 | Annotate | Revision Log
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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/cpu-profiler-inl.h" 7 #include "src/cpu-profiler-inl.h"
8 8
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/frames-inl.h" 10 #include "src/frames-inl.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 192 }
193 193
194 194
195 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, 195 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
196 Code* code, 196 Code* code,
197 const char* name) { 197 const char* name) {
198 if (FilterOutCodeCreateEvent(tag)) return; 198 if (FilterOutCodeCreateEvent(tag)) return;
199 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 199 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
200 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 200 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
201 rec->start = code->address(); 201 rec->start = code->address();
202 rec->entry = profiles_->NewCodeEntry(tag, profiles_->GetFunctionName(name)); 202 rec->entry = profiles_->NewCodeEntry(
203 tag, profiles_->GetFunctionName(name), CodeEntry::kEmptyNamePrefix,
204 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo,
205 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start());
203 rec->size = code->ExecutableSize(); 206 rec->size = code->ExecutableSize();
204 rec->shared = NULL; 207 rec->shared = NULL;
205 processor_->Enqueue(evt_rec); 208 processor_->Enqueue(evt_rec);
206 } 209 }
207 210
208 211
209 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, 212 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
210 Code* code, 213 Code* code,
211 Name* name) { 214 Name* name) {
212 if (FilterOutCodeCreateEvent(tag)) return; 215 if (FilterOutCodeCreateEvent(tag)) return;
213 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 216 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
214 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 217 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
215 rec->start = code->address(); 218 rec->start = code->address();
216 rec->entry = profiles_->NewCodeEntry(tag, profiles_->GetFunctionName(name)); 219 rec->entry = profiles_->NewCodeEntry(
220 tag, profiles_->GetFunctionName(name), CodeEntry::kEmptyNamePrefix,
221 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo,
222 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start());
217 rec->size = code->ExecutableSize(); 223 rec->size = code->ExecutableSize();
218 rec->shared = NULL; 224 rec->shared = NULL;
219 processor_->Enqueue(evt_rec); 225 processor_->Enqueue(evt_rec);
220 } 226 }
221 227
222 228
223 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code, 229 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code,
224 SharedFunctionInfo* shared, 230 SharedFunctionInfo* shared,
225 CompilationInfo* info, Name* script_name) { 231 CompilationInfo* info, Name* script_name) {
226 if (FilterOutCodeCreateEvent(tag)) return; 232 if (FilterOutCodeCreateEvent(tag)) return;
227 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 233 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
228 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 234 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
229 rec->start = code->address(); 235 rec->start = code->address();
230 rec->entry = profiles_->NewCodeEntry( 236 rec->entry = profiles_->NewCodeEntry(
231 tag, profiles_->GetFunctionName(shared->DebugName()), 237 tag, profiles_->GetFunctionName(shared->DebugName()),
232 CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name)); 238 CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name),
239 CpuProfileNode::kNoLineNumberInfo, CpuProfileNode::kNoColumnNumberInfo,
240 NULL, code->instruction_start());
233 if (info) { 241 if (info) {
234 rec->entry->set_no_frame_ranges(info->ReleaseNoFrameRanges()); 242 rec->entry->set_no_frame_ranges(info->ReleaseNoFrameRanges());
235 } 243 }
236 if (shared->script()->IsScript()) { 244 if (shared->script()->IsScript()) {
237 DCHECK(Script::cast(shared->script())); 245 DCHECK(Script::cast(shared->script()));
238 Script* script = Script::cast(shared->script()); 246 Script* script = Script::cast(shared->script());
239 rec->entry->set_script_id(script->id()->value()); 247 rec->entry->set_script_id(script->id()->value());
240 rec->entry->set_bailout_reason( 248 rec->entry->set_bailout_reason(
241 GetBailoutReason(shared->DisableOptimizationReason())); 249 GetBailoutReason(shared->DisableOptimizationReason()));
242 } 250 }
243 rec->size = code->ExecutableSize(); 251 rec->size = code->ExecutableSize();
244 rec->shared = shared->address(); 252 rec->shared = shared->address();
245 processor_->Enqueue(evt_rec); 253 processor_->Enqueue(evt_rec);
246 } 254 }
247 255
248 256
249 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code, 257 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code,
250 SharedFunctionInfo* shared, 258 SharedFunctionInfo* shared,
251 CompilationInfo* info, Name* script_name, 259 CompilationInfo* info, Name* script_name,
252 int line, int column) { 260 int line, int column) {
253 if (FilterOutCodeCreateEvent(tag)) return; 261 if (FilterOutCodeCreateEvent(tag)) return;
254 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 262 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
255 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 263 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
256 rec->start = code->address(); 264 rec->start = code->address();
265 Script* script = Script::cast(shared->script());
266 JITLineInfoTable* line_table = NULL;
267 if (script) {
268 line_table = new JITLineInfoTable();
269 for (RelocIterator it(code); !it.done(); it.next()) {
270 RelocInfo::Mode mode = it.rinfo()->rmode();
271 if (RelocInfo::IsPosition(mode)) {
272 int position = static_cast<int>(it.rinfo()->data());
273 if (position >= 0) {
274 int pc_offset = static_cast<int>(it.rinfo()->pc() - code->address());
275 int line_number = script->GetLineNumber(position) + 1;
276 line_table->SetPosition(pc_offset, line_number);
277 }
278 }
279 }
280 }
257 rec->entry = profiles_->NewCodeEntry( 281 rec->entry = profiles_->NewCodeEntry(
258 tag, profiles_->GetFunctionName(shared->DebugName()), 282 tag, profiles_->GetFunctionName(shared->DebugName()),
259 CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name), line, 283 CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name), line,
260 column); 284 column, line_table, code->instruction_start());
261 if (info) { 285 if (info) {
262 rec->entry->set_no_frame_ranges(info->ReleaseNoFrameRanges()); 286 rec->entry->set_no_frame_ranges(info->ReleaseNoFrameRanges());
263 } 287 }
264 DCHECK(Script::cast(shared->script()));
265 Script* script = Script::cast(shared->script());
266 rec->entry->set_script_id(script->id()->value()); 288 rec->entry->set_script_id(script->id()->value());
267 rec->size = code->ExecutableSize(); 289 rec->size = code->ExecutableSize();
268 rec->shared = shared->address(); 290 rec->shared = shared->address();
269 rec->entry->set_bailout_reason( 291 rec->entry->set_bailout_reason(
270 GetBailoutReason(shared->DisableOptimizationReason())); 292 GetBailoutReason(shared->DisableOptimizationReason()));
271 processor_->Enqueue(evt_rec); 293 processor_->Enqueue(evt_rec);
272 } 294 }
273 295
274 296
275 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, 297 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
276 Code* code, 298 Code* code,
277 int args_count) { 299 int args_count) {
278 if (FilterOutCodeCreateEvent(tag)) return; 300 if (FilterOutCodeCreateEvent(tag)) return;
279 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 301 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
280 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 302 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
281 rec->start = code->address(); 303 rec->start = code->address();
282 rec->entry = profiles_->NewCodeEntry( 304 rec->entry = profiles_->NewCodeEntry(
283 tag, 305 tag, profiles_->GetName(args_count), "args_count: ",
284 profiles_->GetName(args_count), 306 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo,
285 "args_count: "); 307 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start());
286 rec->size = code->ExecutableSize(); 308 rec->size = code->ExecutableSize();
287 rec->shared = NULL; 309 rec->shared = NULL;
288 processor_->Enqueue(evt_rec); 310 processor_->Enqueue(evt_rec);
289 } 311 }
290 312
291 313
292 void CpuProfiler::CodeMoveEvent(Address from, Address to) { 314 void CpuProfiler::CodeMoveEvent(Address from, Address to) {
293 CodeEventsContainer evt_rec(CodeEventRecord::CODE_MOVE); 315 CodeEventsContainer evt_rec(CodeEventRecord::CODE_MOVE);
294 CodeMoveEventRecord* rec = &evt_rec.CodeMoveEventRecord_; 316 CodeMoveEventRecord* rec = &evt_rec.CodeMoveEventRecord_;
295 rec->from = from; 317 rec->from = from;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 processor_->Enqueue(evt_rec); 357 processor_->Enqueue(evt_rec);
336 } 358 }
337 359
338 360
339 void CpuProfiler::RegExpCodeCreateEvent(Code* code, String* source) { 361 void CpuProfiler::RegExpCodeCreateEvent(Code* code, String* source) {
340 if (FilterOutCodeCreateEvent(Logger::REG_EXP_TAG)) return; 362 if (FilterOutCodeCreateEvent(Logger::REG_EXP_TAG)) return;
341 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 363 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
342 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 364 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
343 rec->start = code->address(); 365 rec->start = code->address();
344 rec->entry = profiles_->NewCodeEntry( 366 rec->entry = profiles_->NewCodeEntry(
345 Logger::REG_EXP_TAG, 367 Logger::REG_EXP_TAG, profiles_->GetName(source), "RegExp: ",
346 profiles_->GetName(source), 368 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo,
347 "RegExp: "); 369 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start());
348 rec->size = code->ExecutableSize(); 370 rec->size = code->ExecutableSize();
349 processor_->Enqueue(evt_rec); 371 processor_->Enqueue(evt_rec);
350 } 372 }
351 373
352 374
353 void CpuProfiler::SetterCallbackEvent(Name* name, Address entry_point) { 375 void CpuProfiler::SetterCallbackEvent(Name* name, Address entry_point) {
354 if (FilterOutCodeCreateEvent(Logger::CALLBACK_TAG)) return; 376 if (FilterOutCodeCreateEvent(Logger::CALLBACK_TAG)) return;
355 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 377 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
356 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 378 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
357 rec->start = entry_point; 379 rec->start = entry_point;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; 519 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_;
498 Builtins::Name id = static_cast<Builtins::Name>(i); 520 Builtins::Name id = static_cast<Builtins::Name>(i);
499 rec->start = builtins->builtin(id)->address(); 521 rec->start = builtins->builtin(id)->address();
500 rec->builtin_id = id; 522 rec->builtin_id = id;
501 processor_->Enqueue(evt_rec); 523 processor_->Enqueue(evt_rec);
502 } 524 }
503 } 525 }
504 526
505 527
506 } } // namespace v8::internal 528 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/profile-generator.h » ('j') | test/cctest/test-cpu-profiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698