| OLD | NEW |
| 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/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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 : title_(title), | 353 : title_(title), |
| 354 record_samples_(record_samples), | 354 record_samples_(record_samples), |
| 355 start_time_(base::TimeTicks::HighResolutionNow()), | 355 start_time_(base::TimeTicks::HighResolutionNow()), |
| 356 top_down_(isolate) {} | 356 top_down_(isolate) {} |
| 357 | 357 |
| 358 void CpuProfile::AddPath(base::TimeTicks timestamp, | 358 void CpuProfile::AddPath(base::TimeTicks timestamp, |
| 359 const Vector<CodeEntry*>& path, int src_line, | 359 const Vector<CodeEntry*>& path, int src_line, |
| 360 bool update_stats) { | 360 bool update_stats) { |
| 361 ProfileNode* top_frame_node = | 361 ProfileNode* top_frame_node = |
| 362 top_down_.AddPathFromEnd(path, src_line, update_stats); | 362 top_down_.AddPathFromEnd(path, src_line, update_stats); |
| 363 if (record_samples_) { | 363 if (record_samples_ && !timestamp.IsNull()) { |
| 364 timestamps_.Add(timestamp); | 364 timestamps_.Add(timestamp); |
| 365 samples_.Add(top_frame_node); | 365 samples_.Add(top_frame_node); |
| 366 } | 366 } |
| 367 } | 367 } |
| 368 | 368 |
| 369 | 369 |
| 370 void CpuProfile::CalculateTotalTicksAndSamplingRate() { | 370 void CpuProfile::CalculateTotalTicksAndSamplingRate() { |
| 371 end_time_ = base::TimeTicks::HighResolutionNow(); | 371 end_time_ = base::TimeTicks::HighResolutionNow(); |
| 372 } | 372 } |
| 373 | 373 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 // In the latter case we know the caller for sure but in the | 629 // In the latter case we know the caller for sure but in the |
| 630 // former case we don't so we simply replace the frame with | 630 // former case we don't so we simply replace the frame with |
| 631 // 'unresolved' entry. | 631 // 'unresolved' entry. |
| 632 if (sample.top_frame_type == StackFrame::JAVA_SCRIPT) { | 632 if (sample.top_frame_type == StackFrame::JAVA_SCRIPT) { |
| 633 *entry++ = unresolved_entry_; | 633 *entry++ = unresolved_entry_; |
| 634 } | 634 } |
| 635 } | 635 } |
| 636 } | 636 } |
| 637 } | 637 } |
| 638 | 638 |
| 639 for (const Address* stack_pos = sample.stack, | 639 for (const Address *stack_pos = sample.stack, |
| 640 *stack_end = stack_pos + sample.frames_count; | 640 *stack_end = stack_pos + sample.frames_count; |
| 641 stack_pos != stack_end; | 641 stack_pos != stack_end; ++stack_pos) { |
| 642 ++stack_pos) { | |
| 643 *entry = code_map_.FindEntry(*stack_pos); | 642 *entry = code_map_.FindEntry(*stack_pos); |
| 644 | 643 |
| 645 // Skip unresolved frames (e.g. internal frame) and get source line of | 644 // Skip unresolved frames (e.g. internal frame) and get source line of |
| 646 // the first JS caller. | 645 // the first JS caller. |
| 647 if (src_line_not_found && *entry) { | 646 if (src_line_not_found && *entry) { |
| 648 int pc_offset = | 647 int pc_offset = |
| 649 static_cast<int>(*stack_pos - (*entry)->instruction_start()); | 648 static_cast<int>(*stack_pos - (*entry)->instruction_start()); |
| 650 src_line = (*entry)->GetSourceLine(pc_offset); | 649 src_line = (*entry)->GetSourceLine(pc_offset); |
| 651 if (src_line == v8::CpuProfileNode::kNoLineNumberInfo) { | 650 if (src_line == v8::CpuProfileNode::kNoLineNumberInfo) { |
| 652 src_line = (*entry)->line_number(); | 651 src_line = (*entry)->line_number(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 case EXTERNAL: | 689 case EXTERNAL: |
| 691 return program_entry_; | 690 return program_entry_; |
| 692 case IDLE: | 691 case IDLE: |
| 693 return idle_entry_; | 692 return idle_entry_; |
| 694 default: return NULL; | 693 default: return NULL; |
| 695 } | 694 } |
| 696 } | 695 } |
| 697 | 696 |
| 698 } // namespace internal | 697 } // namespace internal |
| 699 } // namespace v8 | 698 } // namespace v8 |
| OLD | NEW |