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 1362503002: Add global timeline stream overrides (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/timeline.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 namespace dart { 11 namespace dart {
12 12
13 class JSONArray; 13 class JSONArray;
14 class JSONObject; 14 class JSONObject;
15 class JSONStream; 15 class JSONStream;
16 class Object; 16 class Object;
17 class ObjectPointerVisitor; 17 class ObjectPointerVisitor;
18 class RawArray; 18 class RawArray;
19 class Thread; 19 class Thread;
20 class TimelineEvent; 20 class TimelineEvent;
21 class TimelineEventBlock; 21 class TimelineEventBlock;
22 class TimelineEventRecorder; 22 class TimelineEventRecorder;
23 class TimelineStream; 23 class TimelineStream;
24 24
25 // (name, enabled by default for isolate).
26 #define ISOLATE_TIMELINE_STREAM_LIST(V) \
27 V(API, false) \
28 V(Compiler, false) \
29 V(Embedder, false) \
30 V(GC, false) \
31 V(Isolate, false) \
25 32
26 class Timeline : public AllStatic { 33 class Timeline : public AllStatic {
27 public: 34 public:
28 // Initialize timeline system. Not thread safe. 35 // Initialize timeline system. Not thread safe.
29 static void InitOnce(); 36 static void InitOnce();
30 37
31 // Shutdown timeline system. Not thread safe. 38 // Shutdown timeline system. Not thread safe.
32 static void Shutdown(); 39 static void Shutdown();
33 40
34 // Access the global recorder. Not thread safe. 41 // Access the global recorder. Not thread safe.
35 static TimelineEventRecorder* recorder(); 42 static TimelineEventRecorder* recorder();
36 43
37 static bool EnableStreamByDefault(const char* stream_name); 44 static bool EnableStreamByDefault(const char* stream_name);
38 45
39 static TimelineStream* GetVMStream(); 46 static TimelineStream* GetVMStream();
40 47
48 #define ISOLATE_TIMELINE_STREAM_FLAGS(name, not_used) \
49 static const bool* Stream##name##EnabledFlag() { \
50 return &stream_##name##_enabled_; \
51 } \
52 static void SetStream##name##Enabled(bool enabled) { \
53 stream_##name##_enabled_ = enabled; \
54 }
55 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_FLAGS)
56 #undef ISOLATE_TIMELINE_STREAM_FLAGS
57
41 private: 58 private:
42 static TimelineEventRecorder* recorder_; 59 static TimelineEventRecorder* recorder_;
43 static TimelineStream* vm_stream_; 60 static TimelineStream* vm_stream_;
44 61
62 #define ISOLATE_TIMELINE_STREAM_DECLARE_FLAG(name, not_used) \
63 static bool stream_##name##_enabled_;
64 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_DECLARE_FLAG)
65 #undef ISOLATE_TIMELINE_STREAM_DECLARE_FLAG
66
45 friend class TimelineRecorderOverride; 67 friend class TimelineRecorderOverride;
46 }; 68 };
47 69
48 70
49 // You should get a |TimelineEvent| from a |TimelineStream|. 71 // You should get a |TimelineEvent| from a |TimelineStream|.
50 class TimelineEvent { 72 class TimelineEvent {
51 public: 73 public:
52 // Keep in sync with StateBits below. 74 // Keep in sync with StateBits below.
53 enum EventType { 75 enum EventType {
54 kNone, 76 kNone,
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 205
184 class EventTypeField : public BitField<EventType, kEventTypeBit, 4> {}; 206 class EventTypeField : public BitField<EventType, kEventTypeBit, 4> {};
185 207
186 friend class TimelineTestHelper; 208 friend class TimelineTestHelper;
187 friend class TimelineStream; 209 friend class TimelineStream;
188 DISALLOW_COPY_AND_ASSIGN(TimelineEvent); 210 DISALLOW_COPY_AND_ASSIGN(TimelineEvent);
189 }; 211 };
190 212
191 213
192 // A stream of timeline events. A stream has a name and can be enabled or 214 // A stream of timeline events. A stream has a name and can be enabled or
193 // disabled. 215 // disabled (globally and per isolate).
194 class TimelineStream { 216 class TimelineStream {
195 public: 217 public:
196 TimelineStream(); 218 TimelineStream();
197 219
198 void Init(const char* name, bool enabled); 220 void Init(const char* name,
221 bool enabled,
222 const bool* globally_enabled = NULL);
199 223
200 const char* name() const { 224 const char* name() const {
201 return name_; 225 return name_;
202 } 226 }
203 227
228 bool Enabled() const {
229 return ((globally_enabled_ != NULL) && *globally_enabled_) ||
230 enabled();
231 }
232
204 bool enabled() const { 233 bool enabled() const {
205 return enabled_; 234 return enabled_;
206 } 235 }
207 236
208 void set_enabled(bool enabled) { 237 void set_enabled(bool enabled) {
209 enabled_ = enabled; 238 enabled_ = enabled;
210 } 239 }
211 240
212 // Records an event. Will return |NULL| if not enabled. The returned 241 // Records an event. Will return |NULL| if not enabled. The returned
213 // |TimelineEvent| is in an undefined state and must be initialized. 242 // |TimelineEvent| is in an undefined state and must be initialized.
214 TimelineEvent* StartEvent(); 243 TimelineEvent* StartEvent();
215 244
216 private: 245 private:
217 const char* name_; 246 const char* name_;
218 bool enabled_; 247 bool enabled_;
248 const bool* globally_enabled_;
219 }; 249 };
220 250
221
222 // (name, enabled by default).
223 #define ISOLATE_TIMELINE_STREAM_LIST(V) \
224 V(API, false) \
225 V(Compiler, false) \
226 V(Embedder, false) \
227 V(GC, false) \
228 V(Isolate, false) \
229
230
231 #define TIMELINE_FUNCTION_COMPILATION_DURATION(thread, suffix, function) \ 251 #define TIMELINE_FUNCTION_COMPILATION_DURATION(thread, suffix, function) \
232 TimelineDurationScope tds(thread, \ 252 TimelineDurationScope tds(thread, \
233 thread->isolate()->GetCompilerStream(), \ 253 thread->isolate()->GetCompilerStream(), \
234 "Compile" suffix); \ 254 "Compile" suffix); \
235 if (tds.enabled()) { \ 255 if (tds.enabled()) { \
236 tds.SetNumArguments(1); \ 256 tds.SetNumArguments(1); \
237 tds.CopyArgument( \ 257 tds.CopyArgument( \
238 0, \ 258 0, \
239 "function", \ 259 "function", \
240 const_cast<char*>(function.ToLibNamePrefixedQualifiedCString())); \ 260 const_cast<char*>(function.ToLibNamePrefixedQualifiedCString())); \
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 TimelineEventBlock* Next(); 612 TimelineEventBlock* Next();
593 613
594 private: 614 private:
595 TimelineEventBlock* current_; 615 TimelineEventBlock* current_;
596 TimelineEventRecorder* recorder_; 616 TimelineEventRecorder* recorder_;
597 }; 617 };
598 618
599 } // namespace dart 619 } // namespace dart
600 620
601 #endif // VM_TIMELINE_H_ 621 #endif // VM_TIMELINE_H_
OLDNEW
« no previous file with comments | « runtime/vm/isolate.cc ('k') | runtime/vm/timeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698