Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef VM_PROFILER_H_ | 5 #ifndef VM_PROFILER_H_ |
| 6 #define VM_PROFILER_H_ | 6 #define VM_PROFILER_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/code_observers.h" | 9 #include "vm/code_observers.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 static void EndExecution(Isolate* isolate); | 34 static void EndExecution(Isolate* isolate); |
| 35 | 35 |
| 36 static void PrintToJSONStream(Isolate* isolate, JSONStream* stream, | 36 static void PrintToJSONStream(Isolate* isolate, JSONStream* stream, |
| 37 bool full); | 37 bool full); |
| 38 static void WriteProfile(Isolate* isolate); | 38 static void WriteProfile(Isolate* isolate); |
| 39 | 39 |
| 40 static SampleBuffer* sample_buffer() { | 40 static SampleBuffer* sample_buffer() { |
| 41 return sample_buffer_; | 41 return sample_buffer_; |
| 42 } | 42 } |
| 43 | 43 |
| 44 | |
|
siva
2014/02/12 00:58:52
We usually have only one blank line before 'privat
| |
| 44 private: | 45 private: |
| 45 static bool initialized_; | 46 static bool initialized_; |
| 46 static Monitor* monitor_; | 47 static Monitor* monitor_; |
| 47 | 48 |
| 48 static intptr_t ProcessSamples(Isolate* isolate, | |
| 49 ProfilerCodeRegionTable* code_region_table, | |
| 50 SampleBuffer* sample_buffer); | |
| 51 | |
| 52 static intptr_t ProcessSample(Isolate* isolate, | |
| 53 ProfilerCodeRegionTable* code_region_table, | |
| 54 Sample* sample); | |
| 55 | |
| 56 static void RecordTickInterruptCallback(const InterruptedThreadState& state, | |
| 57 void* data); | |
| 58 | |
| 59 static void RecordSampleInterruptCallback(const InterruptedThreadState& state, | 49 static void RecordSampleInterruptCallback(const InterruptedThreadState& state, |
| 60 void* data); | 50 void* data); |
| 61 | 51 |
| 62 static SampleBuffer* sample_buffer_; | 52 static SampleBuffer* sample_buffer_; |
| 63 }; | 53 }; |
| 64 | 54 |
| 65 | 55 |
| 66 class IsolateProfilerData { | 56 class IsolateProfilerData { |
| 67 public: | 57 public: |
| 68 IsolateProfilerData(SampleBuffer* sample_buffer, bool own_sample_buffer); | 58 IsolateProfilerData(SampleBuffer* sample_buffer, bool own_sample_buffer); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 Isolate* isolate_; | 109 Isolate* isolate_; |
| 120 SampleType type_; | 110 SampleType type_; |
| 121 // Note: This class has a size determined at run-time. The pcs_ array | 111 // Note: This class has a size determined at run-time. The pcs_ array |
| 122 // must be the final field. | 112 // must be the final field. |
| 123 uintptr_t pcs_[0]; | 113 uintptr_t pcs_[0]; |
| 124 | 114 |
| 125 DISALLOW_COPY_AND_ASSIGN(Sample); | 115 DISALLOW_COPY_AND_ASSIGN(Sample); |
| 126 }; | 116 }; |
| 127 | 117 |
| 128 | 118 |
| 119 class SampleVisitor { | |
| 120 public: | |
| 121 explicit SampleVisitor(Isolate* isolate); | |
| 122 virtual ~SampleVisitor() {} | |
| 123 | |
| 124 virtual void VisitSample(Sample* sample) = 0; | |
| 125 | |
| 126 intptr_t visited() const { | |
| 127 return visited_; | |
| 128 } | |
| 129 | |
| 130 void IncrementVisited() { | |
| 131 visited_++; | |
| 132 } | |
| 133 | |
| 134 Isolate* isolate() const { | |
| 135 return isolate_; | |
| 136 } | |
| 137 | |
| 138 private: | |
| 139 Isolate* isolate_; | |
| 140 intptr_t visited_; | |
| 141 | |
| 142 DISALLOW_IMPLICIT_CONSTRUCTORS(SampleVisitor); | |
| 143 }; | |
| 144 | |
| 145 | |
| 129 // Ring buffer of samples. | 146 // Ring buffer of samples. |
| 130 class SampleBuffer { | 147 class SampleBuffer { |
| 131 public: | 148 public: |
| 132 static const intptr_t kDefaultBufferCapacity = 120000; // 2 minutes @ 1000hz. | 149 static const intptr_t kDefaultBufferCapacity = 120000; // 2 minutes @ 1000hz. |
| 133 | 150 |
| 134 explicit SampleBuffer(intptr_t capacity = kDefaultBufferCapacity); | 151 explicit SampleBuffer(intptr_t capacity = kDefaultBufferCapacity); |
| 135 ~SampleBuffer(); | 152 ~SampleBuffer(); |
| 136 | 153 |
| 137 intptr_t capacity() const { return capacity_; } | 154 intptr_t capacity() const { return capacity_; } |
| 138 Sample* ReserveSample(); | 155 Sample* ReserveSample(); |
| 139 void CopySample(intptr_t i, Sample* sample) const; | 156 void CopySample(intptr_t i, Sample* sample) const; |
| 140 Sample* At(intptr_t idx) const; | 157 Sample* At(intptr_t idx) const; |
| 141 | 158 |
| 159 void VisitSamples(SampleVisitor* visitor); | |
| 160 | |
| 142 private: | 161 private: |
| 143 Sample* samples_; | 162 Sample* samples_; |
| 144 intptr_t capacity_; | 163 intptr_t capacity_; |
| 145 uintptr_t cursor_; | 164 uintptr_t cursor_; |
| 146 | 165 |
| 147 DISALLOW_COPY_AND_ASSIGN(SampleBuffer); | 166 DISALLOW_COPY_AND_ASSIGN(SampleBuffer); |
| 148 }; | 167 }; |
| 149 | 168 |
| 150 | 169 |
| 151 class ProfilerSampleStackWalker : public ValueObject { | |
| 152 public: | |
| 153 ProfilerSampleStackWalker(Sample* sample, | |
| 154 uintptr_t stack_lower, | |
| 155 uintptr_t stack_upper, | |
| 156 uintptr_t pc, | |
| 157 uintptr_t fp, | |
| 158 uintptr_t sp); | |
| 159 | |
| 160 int walk(); | |
| 161 | |
| 162 private: | |
| 163 uword* CallerPC(uword* fp); | |
| 164 uword* CallerFP(uword* fp); | |
| 165 | |
| 166 bool ValidInstructionPointer(uword* pc); | |
| 167 | |
| 168 bool ValidFramePointer(uword* fp); | |
| 169 | |
| 170 Sample* sample_; | |
| 171 const uintptr_t stack_lower_; | |
| 172 const uintptr_t stack_upper_; | |
| 173 const uintptr_t original_pc_; | |
| 174 const uintptr_t original_fp_; | |
| 175 const uintptr_t original_sp_; | |
| 176 uintptr_t lower_bound_; | |
| 177 }; | |
| 178 | |
| 179 | |
| 180 } // namespace dart | 170 } // namespace dart |
| 181 | 171 |
| 182 #endif // VM_PROFILER_H_ | 172 #endif // VM_PROFILER_H_ |
| OLD | NEW |