OLD | NEW |
---|---|
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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_SERVICE_H_ | 5 #ifndef VM_PROFILER_SERVICE_H_ |
6 #define VM_PROFILER_SERVICE_H_ | 6 #define VM_PROFILER_SERVICE_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 10 matching lines...) Expand all Loading... | |
21 // Forward declarations. | 21 // Forward declarations. |
22 class Code; | 22 class Code; |
23 class Function; | 23 class Function; |
24 class JSONArray; | 24 class JSONArray; |
25 class JSONStream; | 25 class JSONStream; |
26 class ProfileFunctionTable; | 26 class ProfileFunctionTable; |
27 class ProfileCodeTable; | 27 class ProfileCodeTable; |
28 class RawCode; | 28 class RawCode; |
29 class RawFunction; | 29 class RawFunction; |
30 class SampleFilter; | 30 class SampleFilter; |
31 class ProcessedSampleBuffer; | |
31 | 32 |
32 // Profile data related to a |Function|. | 33 // Profile data related to a |Function|. |
33 class ProfileFunction : public ZoneAllocated { | 34 class ProfileFunction : public ZoneAllocated { |
34 public: | 35 public: |
35 enum Kind { | 36 enum Kind { |
36 kDartFunction, // Dart function. | 37 kDartFunction, // Dart function. |
37 kNativeFunction, // Synthetic function for Native (C/C++). | 38 kNativeFunction, // Synthetic function for Native (C/C++). |
38 kTagFunction, // Synthetic function for a VM or User tag. | 39 kTagFunction, // Synthetic function for a VM or User tag. |
39 kStubFunction, // Synthetic function for stub code. | 40 kStubFunction, // Synthetic function for stub code. |
40 kUnknownFunction, // A singleton function for unknown objects. | 41 kUnknownFunction, // A singleton function for unknown objects. |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 intptr_t NumChildren() const { | 244 intptr_t NumChildren() const { |
244 return children_.length(); | 245 return children_.length(); |
245 } | 246 } |
246 | 247 |
247 ProfileTrieNode* At(intptr_t i) { | 248 ProfileTrieNode* At(intptr_t i) { |
248 return children_.At(i); | 249 return children_.At(i); |
249 } | 250 } |
250 | 251 |
251 intptr_t IndexOf(ProfileTrieNode* node); | 252 intptr_t IndexOf(ProfileTrieNode* node); |
252 | 253 |
254 intptr_t frame_id() const { return frame_id_; } | |
255 void set_frame_id(intptr_t id) { frame_id_ = id; } | |
Cutch
2015/12/15 21:54:59
Rewrite to be:
ASSERT(frame_id_ == -1);
frame_id_
rmacnak
2015/12/16 00:14:21
Done.
| |
256 | |
253 protected: | 257 protected: |
254 void SortChildren(); | 258 void SortChildren(); |
255 | 259 |
256 static int ProfileTrieNodeCompare(ProfileTrieNode* const* a, | 260 static int ProfileTrieNodeCompare(ProfileTrieNode* const* a, |
257 ProfileTrieNode* const* b) { | 261 ProfileTrieNode* const* b) { |
258 ASSERT(a != NULL); | 262 ASSERT(a != NULL); |
259 ASSERT(b != NULL); | 263 ASSERT(b != NULL); |
260 return (*b)->count() - (*a)->count(); | 264 return (*b)->count() - (*a)->count(); |
261 } | 265 } |
262 | 266 |
263 | 267 |
264 intptr_t table_index_; | 268 intptr_t table_index_; |
265 intptr_t count_; | 269 intptr_t count_; |
266 ZoneGrowableArray<ProfileTrieNode*> children_; | 270 ZoneGrowableArray<ProfileTrieNode*> children_; |
271 intptr_t frame_id_; | |
267 | 272 |
268 friend class ProfileBuilder; | 273 friend class ProfileBuilder; |
269 }; | 274 }; |
270 | 275 |
271 | 276 |
272 // The model for a profile. Most of the model is zone allocated, therefore | 277 // The model for a profile. Most of the model is zone allocated, therefore |
273 // a zone must be created that lives longer than this object. | 278 // a zone must be created that lives longer than this object. |
274 class Profile : public ValueObject { | 279 class Profile : public ValueObject { |
275 public: | 280 public: |
276 enum TagOrder { | 281 enum TagOrder { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 int64_t max_time() const { return max_time_; } | 313 int64_t max_time() const { return max_time_; } |
309 int64_t GetTimeSpan() const { | 314 int64_t GetTimeSpan() const { |
310 return max_time() - min_time(); | 315 return max_time() - min_time(); |
311 } | 316 } |
312 intptr_t sample_count() const { return sample_count_; } | 317 intptr_t sample_count() const { return sample_count_; } |
313 | 318 |
314 ProfileFunction* GetFunction(intptr_t index); | 319 ProfileFunction* GetFunction(intptr_t index); |
315 ProfileCode* GetCode(intptr_t index); | 320 ProfileCode* GetCode(intptr_t index); |
316 ProfileTrieNode* GetTrieRoot(TrieKind trie_kind); | 321 ProfileTrieNode* GetTrieRoot(TrieKind trie_kind); |
317 | 322 |
318 void PrintJSON(JSONStream* stream); | 323 void PrintProfileJSON(JSONStream* stream); |
324 void PrintTimelineJSON(JSONStream* stream); | |
319 | 325 |
320 private: | 326 private: |
327 void PrintTimelineFrameJSON(JSONObject* frames, | |
328 ProfileTrieNode* current, | |
329 ProfileTrieNode* parent, | |
330 intptr_t* next_id); | |
331 | |
321 Isolate* isolate_; | 332 Isolate* isolate_; |
333 Zone* zone_; | |
334 ProcessedSampleBuffer* samples_; | |
322 ProfileCodeTable* live_code_; | 335 ProfileCodeTable* live_code_; |
323 ProfileCodeTable* dead_code_; | 336 ProfileCodeTable* dead_code_; |
324 ProfileCodeTable* tag_code_; | 337 ProfileCodeTable* tag_code_; |
325 ProfileFunctionTable* functions_; | 338 ProfileFunctionTable* functions_; |
326 intptr_t dead_code_index_offset_; | 339 intptr_t dead_code_index_offset_; |
327 intptr_t tag_code_index_offset_; | 340 intptr_t tag_code_index_offset_; |
328 | 341 |
329 ProfileTrieNode* roots_[kNumTrieKinds]; | 342 ProfileTrieNode* roots_[kNumTrieKinds]; |
330 | 343 |
331 int64_t min_time_; | 344 int64_t min_time_; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 }; | 391 }; |
379 | 392 |
380 static void PrintJSON(JSONStream* stream, | 393 static void PrintJSON(JSONStream* stream, |
381 Profile::TagOrder tag_order, | 394 Profile::TagOrder tag_order, |
382 intptr_t extra_tags); | 395 intptr_t extra_tags); |
383 | 396 |
384 static void PrintAllocationJSON(JSONStream* stream, | 397 static void PrintAllocationJSON(JSONStream* stream, |
385 Profile::TagOrder tag_order, | 398 Profile::TagOrder tag_order, |
386 const Class& cls); | 399 const Class& cls); |
387 | 400 |
401 static void PrintTimelineJSON(JSONStream* stream, | |
402 Profile::TagOrder tag_order); | |
403 | |
388 static void ClearSamples(); | 404 static void ClearSamples(); |
389 | 405 |
390 private: | 406 private: |
391 static void PrintJSONImpl(Thread* thread, | 407 static void PrintJSONImpl(Thread* thread, |
392 JSONStream* stream, | 408 JSONStream* stream, |
393 Profile::TagOrder tag_order, | 409 Profile::TagOrder tag_order, |
394 intptr_t extra_tags, | 410 intptr_t extra_tags, |
395 SampleFilter* filter); | 411 SampleFilter* filter, |
412 bool as_timline); | |
396 }; | 413 }; |
397 | 414 |
398 } // namespace dart | 415 } // namespace dart |
399 | 416 |
400 #endif // VM_PROFILER_SERVICE_H_ | 417 #endif // VM_PROFILER_SERVICE_H_ |
OLD | NEW |