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

Side by Side Diff: runtime/vm/profiler.cc

Issue 101223011: Fix sample reuse in profiler ring buffer (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/utils.h" 5 #include "platform/utils.h"
6 6
7 #include "vm/allocation.h" 7 #include "vm/allocation.h"
8 #include "vm/atomic.h" 8 #include "vm/atomic.h"
9 #include "vm/code_patcher.h" 9 #include "vm/code_patcher.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 uintptr_t fp, 709 uintptr_t fp,
710 uintptr_t sp) : 710 uintptr_t sp) :
711 sample_(sample), 711 sample_(sample),
712 stack_lower_(stack_lower), 712 stack_lower_(stack_lower),
713 stack_upper_(stack_upper), 713 stack_upper_(stack_upper),
714 original_pc_(pc), 714 original_pc_(pc),
715 original_fp_(fp), 715 original_fp_(fp),
716 original_sp_(sp), 716 original_sp_(sp),
717 lower_bound_(stack_lower) { 717 lower_bound_(stack_lower) {
718 ASSERT(sample_ != NULL); 718 ASSERT(sample_ != NULL);
719 // Zero out the PCs before (re)using the sample.
720 for (int i = 0; i < Sample::kNumStackFrames; i++) {
721 sample_->pcs[i] = 0;
722 }
719 } 723 }
720 724
721 725
722 int ProfilerSampleStackWalker::walk() { 726 int ProfilerSampleStackWalker::walk() {
723 const intptr_t kMaxStep = 0x1000; // 4K. 727 const intptr_t kMaxStep = 0x1000; // 4K.
724 uword* pc = reinterpret_cast<uword*>(original_pc_); 728 uword* pc = reinterpret_cast<uword*>(original_pc_);
729 // Always store the exclusive PC.
730 sample_->pcs[0] = original_pc_;
725 #define WALK_STACK 731 #define WALK_STACK
726 #if defined(WALK_STACK) 732 #if defined(WALK_STACK)
727 uword* fp = reinterpret_cast<uword*>(original_fp_); 733 uword* fp = reinterpret_cast<uword*>(original_fp_);
728 uword* previous_fp = fp; 734 uword* previous_fp = fp;
729 if (original_sp_ > original_fp_) { 735 if (original_sp_ > original_fp_) {
730 // Stack pointer should not be above frame pointer. 736 // Stack pointer should not be above frame pointer.
731 return 0; 737 return 1;
732 } 738 }
733 intptr_t gap = original_fp_ - original_sp_; 739 intptr_t gap = original_fp_ - original_sp_;
734 if (gap >= kMaxStep) { 740 if (gap >= kMaxStep) {
735 // Gap between frame pointer and stack pointer is 741 // Gap between frame pointer and stack pointer is
736 // too large. 742 // too large.
737 return 0; 743 return 1;
738 } 744 }
739 if (original_sp_ < lower_bound_) { 745 if (original_sp_ < lower_bound_) {
740 // The stack pointer gives us a better lower bound than 746 // The stack pointer gives us a better lower bound than
741 // the isolates stack limit. 747 // the isolates stack limit.
742 lower_bound_ = original_sp_; 748 lower_bound_ = original_sp_;
743 } 749 }
744 int i = 0; 750 int i = 0;
745 for (; i < Sample::kNumStackFrames; i++) { 751 for (; i < Sample::kNumStackFrames; i++) {
746 sample_->pcs[i] = reinterpret_cast<uintptr_t>(pc); 752 sample_->pcs[i] = reinterpret_cast<uintptr_t>(pc);
747 if (!ValidFramePointer(fp)) { 753 if (!ValidFramePointer(fp)) {
748 break; 754 return i + 1;
749 } 755 }
750 pc = CallerPC(fp); 756 pc = CallerPC(fp);
751 previous_fp = fp; 757 previous_fp = fp;
752 fp = CallerFP(fp); 758 fp = CallerFP(fp);
753 intptr_t step = fp - previous_fp; 759 intptr_t step = fp - previous_fp;
754 if ((step >= kMaxStep) || (fp <= previous_fp) || !ValidFramePointer(fp)) { 760 if ((step >= kMaxStep) || (fp <= previous_fp) || !ValidFramePointer(fp)) {
755 // Frame pointer step is too large. 761 // Frame pointer step is too large.
756 // Frame pointer did not move to a higher address. 762 // Frame pointer did not move to a higher address.
757 // Frame pointer is outside of isolate stack bounds. 763 // Frame pointer is outside of isolate stack bounds.
758 break; 764 return i + 1;
759 } 765 }
760 // Move the lower bound up. 766 // Move the lower bound up.
761 lower_bound_ = reinterpret_cast<uintptr_t>(fp); 767 lower_bound_ = reinterpret_cast<uintptr_t>(fp);
762 } 768 }
763 return i; 769 return i;
764 #else 770 #else
765 sample_->pcs[0] = reinterpret_cast<uintptr_t>(pc); 771 sample_->pcs[0] = reinterpret_cast<uintptr_t>(pc);
766 return 0; 772 return 0;
767 #endif 773 #endif
768 } 774 }
(...skipping 16 matching lines...) Expand all
785 return false; 791 return false;
786 } 792 }
787 uintptr_t cursor = reinterpret_cast<uintptr_t>(fp); 793 uintptr_t cursor = reinterpret_cast<uintptr_t>(fp);
788 cursor += sizeof(fp); 794 cursor += sizeof(fp);
789 bool r = cursor >= lower_bound_ && cursor < stack_upper_; 795 bool r = cursor >= lower_bound_ && cursor < stack_upper_;
790 return r; 796 return r;
791 } 797 }
792 798
793 799
794 } // namespace dart 800 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698