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

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

Issue 1402383003: Simplify timeline backend (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 #include "vm/os.h" 10 #include "vm/os.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // Shutdown timeline system. Not thread safe. 42 // Shutdown timeline system. Not thread safe.
43 static void Shutdown(); 43 static void Shutdown();
44 44
45 // Access the global recorder. Not thread safe. 45 // Access the global recorder. Not thread safe.
46 static TimelineEventRecorder* recorder(); 46 static TimelineEventRecorder* recorder();
47 47
48 static bool EnableStreamByDefault(const char* stream_name); 48 static bool EnableStreamByDefault(const char* stream_name);
49 49
50 static TimelineStream* GetVMStream(); 50 static TimelineStream* GetVMStream();
51 51
52 // Reclaim all |TimelineEventBlock|s that are owned by the current isolate. 52 // Reclaim all |TimelineEventBlocks|s that are cached by threads.
53 static void ReclaimIsolateBlocks(); 53 static void ReclaimCachedBlocksFromThreads();
54
55 // Reclaim all |TimelineEventBlocks|s that are owned by all isolates and
56 // the global block owned by the VM.
57 static void ReclaimAllBlocks();
58 54
59 #define ISOLATE_TIMELINE_STREAM_FLAGS(name, not_used) \ 55 #define ISOLATE_TIMELINE_STREAM_FLAGS(name, not_used) \
60 static const bool* Stream##name##EnabledFlag() { \ 56 static const bool* Stream##name##EnabledFlag() { \
61 return &stream_##name##_enabled_; \ 57 return &stream_##name##_enabled_; \
62 } \ 58 } \
63 static void SetStream##name##Enabled(bool enabled) { \ 59 static void SetStream##name##Enabled(bool enabled) { \
64 stream_##name##_enabled_ = enabled; \ 60 stream_##name##_enabled_ = enabled; \
65 } 61 }
66 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_FLAGS) 62 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_FLAGS)
67 #undef ISOLATE_TIMELINE_STREAM_FLAGS 63 #undef ISOLATE_TIMELINE_STREAM_FLAGS
68 64
69 private: 65 private:
70 static void ReclaimBlocksForIsolate(Isolate* isolate);
71
72 static TimelineEventRecorder* recorder_; 66 static TimelineEventRecorder* recorder_;
73 static TimelineStream* vm_stream_; 67 static TimelineStream* vm_stream_;
74 68
75 #define ISOLATE_TIMELINE_STREAM_DECLARE_FLAG(name, not_used) \ 69 #define ISOLATE_TIMELINE_STREAM_DECLARE_FLAG(name, not_used) \
76 static bool stream_##name##_enabled_; 70 static bool stream_##name##_enabled_;
77 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_DECLARE_FLAG) 71 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_DECLARE_FLAG)
78 #undef ISOLATE_TIMELINE_STREAM_DECLARE_FLAG 72 #undef ISOLATE_TIMELINE_STREAM_DECLARE_FLAG
79 73
80 friend class TimelineRecorderOverride; 74 friend class TimelineRecorderOverride;
81 friend class ReclaimBlocksIsolateVisitor; 75 friend class ReclaimBlocksIsolateVisitor;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 238
245 void StreamInit(TimelineStream* stream); 239 void StreamInit(TimelineStream* stream);
246 void Init(EventType event_type, const char* label); 240 void Init(EventType event_type, const char* label);
247 241
248 void set_event_type(EventType event_type) { 242 void set_event_type(EventType event_type) {
249 // We only reserve 4 bits to hold the event type. 243 // We only reserve 4 bits to hold the event type.
250 COMPILE_ASSERT(kNumEventTypes < 16); 244 COMPILE_ASSERT(kNumEventTypes < 16);
251 state_ = EventTypeField::update(event_type, state_); 245 state_ = EventTypeField::update(event_type, state_);
252 } 246 }
253 247
254 void set_global_block(bool global_block) {
255 state_ = GlobalBlockField::update(global_block, state_);
256 }
257
258 bool global_block() const {
259 return GlobalBlockField::decode(state_);
260 }
261
262 enum StateBits { 248 enum StateBits {
263 kEventTypeBit = 0, // reserve 4 bits for type. 249 kEventTypeBit = 0, // reserve 4 bits for type.
264 // Was this event allocated from the global block? 250 kNextBit = 4,
265 kGlobalBlockBit = 4,
266 kNextBit = 5,
267 }; 251 };
268 252
269 class EventTypeField : public BitField<EventType, kEventTypeBit, 4> {}; 253 class EventTypeField : public BitField<EventType, kEventTypeBit, 4> {};
270 class GlobalBlockField : public BitField<bool, kGlobalBlockBit, 1> {};
271 254
272 friend class TimelineEventRecorder; 255 friend class TimelineEventRecorder;
273 friend class TimelineEventEndlessRecorder; 256 friend class TimelineEventEndlessRecorder;
274 friend class TimelineEventRingRecorder; 257 friend class TimelineEventRingRecorder;
275 friend class TimelineStream; 258 friend class TimelineStream;
276 friend class TimelineTestHelper; 259 friend class TimelineTestHelper;
277 DISALLOW_COPY_AND_ASSIGN(TimelineEvent); 260 DISALLOW_COPY_AND_ASSIGN(TimelineEvent);
278 }; 261 };
279 262
280 263
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 virtual TimelineEvent* StartEvent() = 0; 547 virtual TimelineEvent* StartEvent() = 0;
565 virtual void CompleteEvent(TimelineEvent* event) = 0; 548 virtual void CompleteEvent(TimelineEvent* event) = 0;
566 virtual TimelineEventBlock* GetHeadBlockLocked() = 0; 549 virtual TimelineEventBlock* GetHeadBlockLocked() = 0;
567 virtual TimelineEventBlock* GetNewBlockLocked(Isolate* isolate) = 0; 550 virtual TimelineEventBlock* GetNewBlockLocked(Isolate* isolate) = 0;
568 virtual intptr_t NumDartEventsLocked() = 0; 551 virtual intptr_t NumDartEventsLocked() = 0;
569 virtual DartTimelineEvent* DartEventAtLocked(intptr_t i) = 0; 552 virtual DartTimelineEvent* DartEventAtLocked(intptr_t i) = 0;
570 553
571 // Utility method(s). 554 // Utility method(s).
572 void PrintJSONMeta(JSONArray* array) const; 555 void PrintJSONMeta(JSONArray* array) const;
573 TimelineEvent* ThreadBlockStartEvent(); 556 TimelineEvent* ThreadBlockStartEvent();
574 TimelineEvent* GlobalBlockStartEvent();
575 void ThreadBlockCompleteEvent(TimelineEvent* event); 557 void ThreadBlockCompleteEvent(TimelineEvent* event);
576 void GlobalBlockCompleteEvent(TimelineEvent* event);
577 558
578 Mutex lock_; 559 Mutex lock_;
579 // Only accessed under |lock_|.
580 TimelineEventBlock* global_block_;
581 void ReclaimGlobalBlock();
582
583 uintptr_t async_id_; 560 uintptr_t async_id_;
584 561
585 friend class DartTimelineEventIterator; 562 friend class DartTimelineEventIterator;
586 friend class TimelineEvent; 563 friend class TimelineEvent;
587 friend class TimelineEventBlockIterator; 564 friend class TimelineEventBlockIterator;
588 friend class TimelineStream; 565 friend class TimelineStream;
589 friend class TimelineTestHelper; 566 friend class TimelineTestHelper;
590 friend class Timeline; 567 friend class Timeline;
591 568
592 private: 569 private:
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 714
738 private: 715 private:
739 intptr_t cursor_; 716 intptr_t cursor_;
740 intptr_t num_events_; 717 intptr_t num_events_;
741 TimelineEventRecorder* recorder_; 718 TimelineEventRecorder* recorder_;
742 }; 719 };
743 720
744 } // namespace dart 721 } // namespace dart
745 722
746 #endif // VM_TIMELINE_H_ 723 #endif // VM_TIMELINE_H_
OLDNEW
« no previous file with comments | « runtime/vm/thread_registry.cc ('k') | runtime/vm/timeline.cc » ('j') | runtime/vm/timeline.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698