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

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

Issue 183113005: Fix usage of heap_ (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 // Notes on stack frame walking: 867 // Notes on stack frame walking:
868 // 868 //
869 // The sampling profiler will collect up to Sample::kNumStackFrames stack frames 869 // The sampling profiler will collect up to Sample::kNumStackFrames stack frames
870 // The stack frame walking code uses the frame pointer to traverse the stack. 870 // The stack frame walking code uses the frame pointer to traverse the stack.
871 // If the VM is compiled without frame pointers (which is the default on 871 // If the VM is compiled without frame pointers (which is the default on
872 // recent GCC versions with optimizing enabled) the stack walking code may 872 // recent GCC versions with optimizing enabled) the stack walking code may
873 // fail (sometimes leading to a crash). 873 // fail (sometimes leading to a crash).
874 // 874 //
875 class ProfilerSampleStackWalker : public ValueObject { 875 class ProfilerSampleStackWalker : public ValueObject {
876 public: 876 public:
877 ProfilerSampleStackWalker(Heap* heap, 877 ProfilerSampleStackWalker(Sample* sample,
878 Sample* sample,
879 uword stack_lower, 878 uword stack_lower,
880 uword stack_upper, 879 uword stack_upper,
881 uword pc, 880 uword pc,
882 uword fp, 881 uword fp,
883 uword sp) 882 uword sp)
884 : heap_(heap), 883 : sample_(sample),
885 sample_(sample),
886 stack_upper_(stack_upper), 884 stack_upper_(stack_upper),
887 original_pc_(pc), 885 original_pc_(pc),
888 original_fp_(fp), 886 original_fp_(fp),
889 original_sp_(sp), 887 original_sp_(sp),
890 lower_bound_(stack_lower) { 888 lower_bound_(stack_lower) {
891 ASSERT(sample_ != NULL); 889 ASSERT(sample_ != NULL);
892 } 890 }
893 891
892 #if defined(DEBUG_STACK_WALK)
siva 2014/02/27 18:30:48 I missed this in the last round, normally we don't
893 void set_heap(Heap* heap) {
894 heap_ = heap;
895 }
896 #endif
897
894 int walk() { 898 int walk() {
895 const intptr_t kMaxStep = 0x1000; // 4K. 899 const intptr_t kMaxStep = 0x1000; // 4K.
896 const bool kWalkStack = true; // Walk the stack. 900 const bool kWalkStack = true; // Walk the stack.
897 // Always store the exclusive PC. 901 // Always store the exclusive PC.
898 sample_->SetAt(0, original_pc_); 902 sample_->SetAt(0, original_pc_);
899 if (!kWalkStack) { 903 if (!kWalkStack) {
900 // Not walking the stack, only took exclusive sample. 904 // Not walking the stack, only took exclusive sample.
901 return 1; 905 return 1;
902 } 906 }
903 uword* pc = reinterpret_cast<uword*>(original_pc_); 907 uword* pc = reinterpret_cast<uword*>(original_pc_);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 bool ValidFramePointer(uword* fp) const { 977 bool ValidFramePointer(uword* fp) const {
974 if (fp == NULL) { 978 if (fp == NULL) {
975 return false; 979 return false;
976 } 980 }
977 uword cursor = reinterpret_cast<uword>(fp); 981 uword cursor = reinterpret_cast<uword>(fp);
978 cursor += sizeof(fp); 982 cursor += sizeof(fp);
979 bool r = cursor >= lower_bound_ && cursor < stack_upper_; 983 bool r = cursor >= lower_bound_ && cursor < stack_upper_;
980 return r; 984 return r;
981 } 985 }
982 986
987 #if defined(DEBUG_STACK_WALK)
983 Heap* heap_; 988 Heap* heap_;
989 #endif
984 Sample* sample_; 990 Sample* sample_;
985 const uword stack_upper_; 991 const uword stack_upper_;
986 const uword original_pc_; 992 const uword original_pc_;
987 const uword original_fp_; 993 const uword original_fp_;
988 const uword original_sp_; 994 const uword original_sp_;
989 uword lower_bound_; 995 uword lower_bound_;
990 }; 996 };
991 997
992 void Profiler::RecordSampleInterruptCallback( 998 void Profiler::RecordSampleInterruptCallback(
993 const InterruptedThreadState& state, 999 const InterruptedThreadState& state,
(...skipping 12 matching lines...) Expand all
1006 } 1012 }
1007 Sample* sample = sample_buffer->ReserveSample(); 1013 Sample* sample = sample_buffer->ReserveSample();
1008 sample->Init(isolate, OS::GetCurrentTimeMicros(), state.tid); 1014 sample->Init(isolate, OS::GetCurrentTimeMicros(), state.tid);
1009 uword stack_lower = 0; 1015 uword stack_lower = 0;
1010 uword stack_upper = 0; 1016 uword stack_upper = 0;
1011 isolate->GetStackBounds(&stack_lower, &stack_upper); 1017 isolate->GetStackBounds(&stack_lower, &stack_upper);
1012 if ((stack_lower == 0) || (stack_upper == 0)) { 1018 if ((stack_lower == 0) || (stack_upper == 0)) {
1013 stack_lower = 0; 1019 stack_lower = 0;
1014 stack_upper = 0; 1020 stack_upper = 0;
1015 } 1021 }
1016 ProfilerSampleStackWalker stackWalker(isolate->heap(), sample, stack_lower, 1022 ProfilerSampleStackWalker stackWalker(sample, stack_lower, stack_upper,
1017 stack_upper, state.pc, state.fp, 1023 state.pc, state.fp, state.sp);
1018 state.sp); 1024 #if defined(DEBUG_STACK_WALK)
1025 stackWalker.set_heap(isolate->heap());
1026 #endif
1019 stackWalker.walk(); 1027 stackWalker.walk();
1020 } 1028 }
1021 1029
1022 1030
1023 } // namespace dart 1031 } // 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