OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 #ifndef V8_PROFILE_GENERATOR_H_ | 5 #ifndef V8_PROFILE_GENERATOR_H_ |
6 #define V8_PROFILE_GENERATOR_H_ | 6 #define V8_PROFILE_GENERATOR_H_ |
7 | 7 |
8 #include "include/v8-profiler.h" | 8 #include "include/v8-profiler.h" |
9 #include "src/allocation.h" | 9 #include "src/allocation.h" |
10 #include "src/hashmap.h" | 10 #include "src/hashmap.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 DISALLOW_COPY_AND_ASSIGN(ProfileTree); | 170 DISALLOW_COPY_AND_ASSIGN(ProfileTree); |
171 }; | 171 }; |
172 | 172 |
173 | 173 |
174 class CpuProfile { | 174 class CpuProfile { |
175 public: | 175 public: |
176 CpuProfile(const char* title, bool record_samples); | 176 CpuProfile(const char* title, bool record_samples); |
177 | 177 |
178 // Add pc -> ... -> main() call path to the profile. | 178 // Add pc -> ... -> main() call path to the profile. |
179 void AddPath(TimeTicks timestamp, const Vector<CodeEntry*>& path); | 179 void AddPath(base::TimeTicks timestamp, const Vector<CodeEntry*>& path); |
180 void CalculateTotalTicksAndSamplingRate(); | 180 void CalculateTotalTicksAndSamplingRate(); |
181 | 181 |
182 const char* title() const { return title_; } | 182 const char* title() const { return title_; } |
183 const ProfileTree* top_down() const { return &top_down_; } | 183 const ProfileTree* top_down() const { return &top_down_; } |
184 | 184 |
185 int samples_count() const { return samples_.length(); } | 185 int samples_count() const { return samples_.length(); } |
186 ProfileNode* sample(int index) const { return samples_.at(index); } | 186 ProfileNode* sample(int index) const { return samples_.at(index); } |
187 TimeTicks sample_timestamp(int index) const { return timestamps_.at(index); } | 187 base::TimeTicks sample_timestamp(int index) const { |
| 188 return timestamps_.at(index); |
| 189 } |
188 | 190 |
189 TimeTicks start_time() const { return start_time_; } | 191 base::TimeTicks start_time() const { return start_time_; } |
190 TimeTicks end_time() const { return end_time_; } | 192 base::TimeTicks end_time() const { return end_time_; } |
191 | 193 |
192 void UpdateTicksScale(); | 194 void UpdateTicksScale(); |
193 | 195 |
194 void Print(); | 196 void Print(); |
195 | 197 |
196 private: | 198 private: |
197 const char* title_; | 199 const char* title_; |
198 bool record_samples_; | 200 bool record_samples_; |
199 TimeTicks start_time_; | 201 base::TimeTicks start_time_; |
200 TimeTicks end_time_; | 202 base::TimeTicks end_time_; |
201 List<ProfileNode*> samples_; | 203 List<ProfileNode*> samples_; |
202 List<TimeTicks> timestamps_; | 204 List<base::TimeTicks> timestamps_; |
203 ProfileTree top_down_; | 205 ProfileTree top_down_; |
204 | 206 |
205 DISALLOW_COPY_AND_ASSIGN(CpuProfile); | 207 DISALLOW_COPY_AND_ASSIGN(CpuProfile); |
206 }; | 208 }; |
207 | 209 |
208 | 210 |
209 class CodeMap { | 211 class CodeMap { |
210 public: | 212 public: |
211 CodeMap() : next_shared_id_(1) { } | 213 CodeMap() : next_shared_id_(1) { } |
212 void AddCode(Address addr, CodeEntry* entry, unsigned size); | 214 void AddCode(Address addr, CodeEntry* entry, unsigned size); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 CodeEntry* NewCodeEntry( | 280 CodeEntry* NewCodeEntry( |
279 Logger::LogEventsAndTags tag, | 281 Logger::LogEventsAndTags tag, |
280 const char* name, | 282 const char* name, |
281 const char* name_prefix = CodeEntry::kEmptyNamePrefix, | 283 const char* name_prefix = CodeEntry::kEmptyNamePrefix, |
282 const char* resource_name = CodeEntry::kEmptyResourceName, | 284 const char* resource_name = CodeEntry::kEmptyResourceName, |
283 int line_number = v8::CpuProfileNode::kNoLineNumberInfo, | 285 int line_number = v8::CpuProfileNode::kNoLineNumberInfo, |
284 int column_number = v8::CpuProfileNode::kNoColumnNumberInfo); | 286 int column_number = v8::CpuProfileNode::kNoColumnNumberInfo); |
285 | 287 |
286 // Called from profile generator thread. | 288 // Called from profile generator thread. |
287 void AddPathToCurrentProfiles( | 289 void AddPathToCurrentProfiles( |
288 TimeTicks timestamp, const Vector<CodeEntry*>& path); | 290 base::TimeTicks timestamp, const Vector<CodeEntry*>& path); |
289 | 291 |
290 // Limits the number of profiles that can be simultaneously collected. | 292 // Limits the number of profiles that can be simultaneously collected. |
291 static const int kMaxSimultaneousProfiles = 100; | 293 static const int kMaxSimultaneousProfiles = 100; |
292 | 294 |
293 private: | 295 private: |
294 StringsStorage function_and_resource_names_; | 296 StringsStorage function_and_resource_names_; |
295 List<CodeEntry*> code_entries_; | 297 List<CodeEntry*> code_entries_; |
296 List<CpuProfile*> finished_profiles_; | 298 List<CpuProfile*> finished_profiles_; |
297 | 299 |
298 // Accessed by VM thread and profile generator thread. | 300 // Accessed by VM thread and profile generator thread. |
299 List<CpuProfile*> current_profiles_; | 301 List<CpuProfile*> current_profiles_; |
300 Semaphore current_profiles_semaphore_; | 302 base::Semaphore current_profiles_semaphore_; |
301 | 303 |
302 DISALLOW_COPY_AND_ASSIGN(CpuProfilesCollection); | 304 DISALLOW_COPY_AND_ASSIGN(CpuProfilesCollection); |
303 }; | 305 }; |
304 | 306 |
305 | 307 |
306 class ProfileGenerator { | 308 class ProfileGenerator { |
307 public: | 309 public: |
308 explicit ProfileGenerator(CpuProfilesCollection* profiles); | 310 explicit ProfileGenerator(CpuProfilesCollection* profiles); |
309 | 311 |
310 void RecordTickSample(const TickSample& sample); | 312 void RecordTickSample(const TickSample& sample); |
(...skipping 18 matching lines...) Expand all Loading... |
329 CodeEntry* gc_entry_; | 331 CodeEntry* gc_entry_; |
330 CodeEntry* unresolved_entry_; | 332 CodeEntry* unresolved_entry_; |
331 | 333 |
332 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); | 334 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); |
333 }; | 335 }; |
334 | 336 |
335 | 337 |
336 } } // namespace v8::internal | 338 } } // namespace v8::internal |
337 | 339 |
338 #endif // V8_PROFILE_GENERATOR_H_ | 340 #endif // V8_PROFILE_GENERATOR_H_ |
OLD | NEW |