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

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

Issue 151143003: Improve CodeRegionTable build time by 30x (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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
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 #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
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/19 18:09:54 extra blank line?
Cutch 2014/02/19 18:20:31 Done.
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 14 matching lines...) Expand all
83 73
84 // Profile sample. 74 // Profile sample.
85 class Sample { 75 class Sample {
86 public: 76 public:
87 enum SampleType { 77 enum SampleType {
88 kIsolateSample, 78 kIsolateSample,
89 }; 79 };
90 80
91 static void InitOnce(); 81 static void InitOnce();
92 82
93 uintptr_t At(intptr_t i) const; 83 uword At(intptr_t i) const;
94 void SetAt(intptr_t i, uintptr_t pc); 84 void SetAt(intptr_t i, uword pc);
95 void Init(SampleType type, Isolate* isolate, int64_t timestamp, ThreadId tid); 85 void Init(SampleType type, Isolate* isolate, int64_t timestamp, ThreadId tid);
96 void CopyInto(Sample* dst) const; 86 void CopyInto(Sample* dst) const;
97 87
98 static Sample* Allocate(); 88 static Sample* Allocate();
99 static intptr_t instance_size() { 89 static intptr_t instance_size() {
100 return instance_size_; 90 return instance_size_;
101 } 91 }
102 92
103 SampleType type() const { 93 SampleType type() const {
104 return type_; 94 return type_;
105 } 95 }
106 96
107 Isolate* isolate() const { 97 Isolate* isolate() const {
108 return isolate_; 98 return isolate_;
109 } 99 }
110 100
111 int64_t timestamp() const { 101 int64_t timestamp() const {
112 return timestamp_; 102 return timestamp_;
113 } 103 }
114 104
115 private: 105 private:
116 static intptr_t instance_size_; 106 static intptr_t instance_size_;
117 int64_t timestamp_; 107 int64_t timestamp_;
118 ThreadId tid_; 108 ThreadId tid_;
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 uword 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) : isolate_(isolate), visited_(0) { }
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698