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

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

Issue 1363033003: Make TimelineEventBlocks reclaimable (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
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_TIMELINE_H_ 5 #ifndef VM_TIMELINE_H_
6 #define VM_TIMELINE_H_ 6 #define VM_TIMELINE_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/bitfield.h" 9 #include "vm/bitfield.h"
10 10
(...skipping 27 matching lines...) Expand all
38 // Shutdown timeline system. Not thread safe. 38 // Shutdown timeline system. Not thread safe.
39 static void Shutdown(); 39 static void Shutdown();
40 40
41 // Access the global recorder. Not thread safe. 41 // Access the global recorder. Not thread safe.
42 static TimelineEventRecorder* recorder(); 42 static TimelineEventRecorder* recorder();
43 43
44 static bool EnableStreamByDefault(const char* stream_name); 44 static bool EnableStreamByDefault(const char* stream_name);
45 45
46 static TimelineStream* GetVMStream(); 46 static TimelineStream* GetVMStream();
47 47
48 // Reclaim all |TimelineEventBlock|s that are owned by the current isolate.
49 static void ReclaimIsolateBlocks();
50
51 // Reclaim all |TimelineEventBlocks|s that are owned by all isolates and
52 // the global block owned by the VM.
53 static void ReclaimAllBlocks();
54
48 #define ISOLATE_TIMELINE_STREAM_FLAGS(name, not_used) \ 55 #define ISOLATE_TIMELINE_STREAM_FLAGS(name, not_used) \
49 static const bool* Stream##name##EnabledFlag() { \ 56 static const bool* Stream##name##EnabledFlag() { \
50 return &stream_##name##_enabled_; \ 57 return &stream_##name##_enabled_; \
51 } \ 58 } \
52 static void SetStream##name##Enabled(bool enabled) { \ 59 static void SetStream##name##Enabled(bool enabled) { \
53 stream_##name##_enabled_ = enabled; \ 60 stream_##name##_enabled_ = enabled; \
54 } 61 }
55 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_FLAGS) 62 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_FLAGS)
56 #undef ISOLATE_TIMELINE_STREAM_FLAGS 63 #undef ISOLATE_TIMELINE_STREAM_FLAGS
57 64
58 private: 65 private:
66 static void ReclaimBlocksForIsolate(Isolate* isolate);
67
59 static TimelineEventRecorder* recorder_; 68 static TimelineEventRecorder* recorder_;
60 static TimelineStream* vm_stream_; 69 static TimelineStream* vm_stream_;
61 70
62 #define ISOLATE_TIMELINE_STREAM_DECLARE_FLAG(name, not_used) \ 71 #define ISOLATE_TIMELINE_STREAM_DECLARE_FLAG(name, not_used) \
63 static bool stream_##name##_enabled_; 72 static bool stream_##name##_enabled_;
64 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_DECLARE_FLAG) 73 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_DECLARE_FLAG)
65 #undef ISOLATE_TIMELINE_STREAM_DECLARE_FLAG 74 #undef ISOLATE_TIMELINE_STREAM_DECLARE_FLAG
66 75
67 friend class TimelineRecorderOverride; 76 friend class TimelineRecorderOverride;
77 friend class ReclaimBlocksIsolateVisitor;
68 }; 78 };
69 79
70 80
71 // You should get a |TimelineEvent| from a |TimelineStream|. 81 // You should get a |TimelineEvent| from a |TimelineStream|.
72 class TimelineEvent { 82 class TimelineEvent {
73 public: 83 public:
74 // Keep in sync with StateBits below. 84 // Keep in sync with StateBits below.
75 enum EventType { 85 enum EventType {
76 kNone, 86 kNone,
77 kDuration, 87 kDuration,
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 464
455 class IsolateTimelineEventFilter : public TimelineEventFilter { 465 class IsolateTimelineEventFilter : public TimelineEventFilter {
456 public: 466 public:
457 explicit IsolateTimelineEventFilter(Isolate* isolate); 467 explicit IsolateTimelineEventFilter(Isolate* isolate);
458 468
459 bool IncludeBlock(TimelineEventBlock* block) { 469 bool IncludeBlock(TimelineEventBlock* block) {
460 if (block == NULL) { 470 if (block == NULL) {
461 return false; 471 return false;
462 } 472 }
463 // Not empty, not open, and isolate match. 473 // Not empty, not open, and isolate match.
464 return !block->IsEmpty() && 474 return !block->IsEmpty() && !block->open() &&
turnidge 2015/09/24 17:05:52 Consider in_use instead of open?
Cutch 2015/09/24 18:14:16 Done.
465 (block->isolate() == isolate_); 475 (block->isolate() == isolate_);
466 } 476 }
467 477
468 private: 478 private:
469 Isolate* isolate_; 479 Isolate* isolate_;
470 }; 480 };
471 481
472 482
473 // Recorder of |TimelineEvent|s. 483 // Recorder of |TimelineEvent|s.
474 class TimelineEventRecorder { 484 class TimelineEventRecorder {
(...skipping 18 matching lines...) Expand all
493 virtual TimelineEventBlock* GetNewBlockLocked(Isolate* isolate) = 0; 503 virtual TimelineEventBlock* GetNewBlockLocked(Isolate* isolate) = 0;
494 504
495 // Utility method(s). 505 // Utility method(s).
496 void PrintJSONMeta(JSONArray* array) const; 506 void PrintJSONMeta(JSONArray* array) const;
497 TimelineEvent* ThreadBlockStartEvent(); 507 TimelineEvent* ThreadBlockStartEvent();
498 TimelineEvent* GlobalBlockStartEvent(); 508 TimelineEvent* GlobalBlockStartEvent();
499 509
500 Mutex lock_; 510 Mutex lock_;
501 // Only accessed under |lock_|. 511 // Only accessed under |lock_|.
502 TimelineEventBlock* global_block_; 512 TimelineEventBlock* global_block_;
503 void FinishGlobalBlock(); 513 void ReclaimGlobalBlock();
504 514
505 uintptr_t async_id_; 515 uintptr_t async_id_;
506 516
507 friend class ThreadRegistry; 517 friend class ThreadRegistry;
508 friend class TimelineEvent; 518 friend class TimelineEvent;
509 friend class TimelineEventBlockIterator; 519 friend class TimelineEventBlockIterator;
510 friend class TimelineStream; 520 friend class TimelineStream;
511 friend class TimelineTestHelper; 521 friend class TimelineTestHelper;
512 friend class Timeline; 522 friend class Timeline;
513 friend class Isolate; 523 friend class Isolate;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 TimelineEventBlock* Next(); 622 TimelineEventBlock* Next();
613 623
614 private: 624 private:
615 TimelineEventBlock* current_; 625 TimelineEventBlock* current_;
616 TimelineEventRecorder* recorder_; 626 TimelineEventRecorder* recorder_;
617 }; 627 };
618 628
619 } // namespace dart 629 } // namespace dart
620 630
621 #endif // VM_TIMELINE_H_ 631 #endif // VM_TIMELINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698