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

Side by Side Diff: include/libplatform/v8-tracing.h

Issue 2372983003: Turn libplatform into a component (Closed)
Patch Set: updates Created 4 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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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_LIBPLATFORM_V8_TRACING_H_ 5 #ifndef V8_LIBPLATFORM_V8_TRACING_H_
6 #define V8_LIBPLATFORM_V8_TRACING_H_ 6 #define V8_LIBPLATFORM_V8_TRACING_H_
7 7
8 #include <fstream> 8 #include <fstream>
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
11 11
12 #include "libplatform/libplatform-export.h"
13
12 namespace v8 { 14 namespace v8 {
13 namespace platform { 15 namespace platform {
14 namespace tracing { 16 namespace tracing {
15 17
16 const int kTraceMaxNumArgs = 2; 18 const int kTraceMaxNumArgs = 2;
17 19
18 class TraceObject { 20 class V8_PLATFORM_EXPORT TraceObject {
19 public: 21 public:
20 union ArgValue { 22 union ArgValue {
21 bool as_bool; 23 bool as_bool;
22 uint64_t as_uint; 24 uint64_t as_uint;
23 int64_t as_int; 25 int64_t as_int;
24 double as_double; 26 double as_double;
25 const void* as_pointer; 27 const void* as_pointer;
26 const char* as_string; 28 const char* as_string;
27 }; 29 };
28 30
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 int64_t ts_; 82 int64_t ts_;
81 int64_t tts_; 83 int64_t tts_;
82 uint64_t duration_; 84 uint64_t duration_;
83 uint64_t cpu_duration_; 85 uint64_t cpu_duration_;
84 86
85 // Disallow copy and assign 87 // Disallow copy and assign
86 TraceObject(const TraceObject&) = delete; 88 TraceObject(const TraceObject&) = delete;
87 void operator=(const TraceObject&) = delete; 89 void operator=(const TraceObject&) = delete;
88 }; 90 };
89 91
90 class TraceWriter { 92 class V8_PLATFORM_EXPORT TraceWriter {
91 public: 93 public:
92 TraceWriter() {} 94 TraceWriter() {}
93 virtual ~TraceWriter() {} 95 virtual ~TraceWriter() {}
94 virtual void AppendTraceEvent(TraceObject* trace_event) = 0; 96 virtual void AppendTraceEvent(TraceObject* trace_event) = 0;
95 virtual void Flush() = 0; 97 virtual void Flush() = 0;
96 98
97 static TraceWriter* CreateJSONTraceWriter(std::ostream& stream); 99 static TraceWriter* CreateJSONTraceWriter(std::ostream& stream);
98 100
99 private: 101 private:
100 // Disallow copy and assign 102 // Disallow copy and assign
101 TraceWriter(const TraceWriter&) = delete; 103 TraceWriter(const TraceWriter&) = delete;
102 void operator=(const TraceWriter&) = delete; 104 void operator=(const TraceWriter&) = delete;
103 }; 105 };
104 106
105 class TraceBufferChunk { 107 class V8_PLATFORM_EXPORT TraceBufferChunk {
106 public: 108 public:
107 explicit TraceBufferChunk(uint32_t seq); 109 explicit TraceBufferChunk(uint32_t seq);
108 110
109 void Reset(uint32_t new_seq); 111 void Reset(uint32_t new_seq);
110 bool IsFull() const { return next_free_ == kChunkSize; } 112 bool IsFull() const { return next_free_ == kChunkSize; }
111 TraceObject* AddTraceEvent(size_t* event_index); 113 TraceObject* AddTraceEvent(size_t* event_index);
112 TraceObject* GetEventAt(size_t index) { return &chunk_[index]; } 114 TraceObject* GetEventAt(size_t index) { return &chunk_[index]; }
113 115
114 uint32_t seq() const { return seq_; } 116 uint32_t seq() const { return seq_; }
115 size_t size() const { return next_free_; } 117 size_t size() const { return next_free_; }
116 118
117 static const size_t kChunkSize = 64; 119 static const size_t kChunkSize = 64;
118 120
119 private: 121 private:
120 size_t next_free_ = 0; 122 size_t next_free_ = 0;
121 TraceObject chunk_[kChunkSize]; 123 TraceObject chunk_[kChunkSize];
122 uint32_t seq_; 124 uint32_t seq_;
123 125
124 // Disallow copy and assign 126 // Disallow copy and assign
125 TraceBufferChunk(const TraceBufferChunk&) = delete; 127 TraceBufferChunk(const TraceBufferChunk&) = delete;
126 void operator=(const TraceBufferChunk&) = delete; 128 void operator=(const TraceBufferChunk&) = delete;
127 }; 129 };
128 130
129 class TraceBuffer { 131 class V8_PLATFORM_EXPORT TraceBuffer {
130 public: 132 public:
131 TraceBuffer() {} 133 TraceBuffer() {}
132 virtual ~TraceBuffer() {} 134 virtual ~TraceBuffer() {}
133 135
134 virtual TraceObject* AddTraceEvent(uint64_t* handle) = 0; 136 virtual TraceObject* AddTraceEvent(uint64_t* handle) = 0;
135 virtual TraceObject* GetEventByHandle(uint64_t handle) = 0; 137 virtual TraceObject* GetEventByHandle(uint64_t handle) = 0;
136 virtual bool Flush() = 0; 138 virtual bool Flush() = 0;
137 139
138 static const size_t kRingBufferChunks = 1024; 140 static const size_t kRingBufferChunks = 1024;
139 141
(...skipping 15 matching lines...) Expand all
155 // and we use it as a ring buffer during recording. 157 // and we use it as a ring buffer during recording.
156 RECORD_CONTINUOUSLY, 158 RECORD_CONTINUOUSLY,
157 159
158 // Record until the trace buffer is full, but with a huge buffer size. 160 // Record until the trace buffer is full, but with a huge buffer size.
159 RECORD_AS_MUCH_AS_POSSIBLE, 161 RECORD_AS_MUCH_AS_POSSIBLE,
160 162
161 // Echo to console. Events are discarded. 163 // Echo to console. Events are discarded.
162 ECHO_TO_CONSOLE, 164 ECHO_TO_CONSOLE,
163 }; 165 };
164 166
165 class TraceConfig { 167 class V8_PLATFORM_EXPORT TraceConfig {
166 public: 168 public:
167 typedef std::vector<std::string> StringList; 169 typedef std::vector<std::string> StringList;
168 170
169 static TraceConfig* CreateDefaultTraceConfig(); 171 static TraceConfig* CreateDefaultTraceConfig();
170 172
171 TraceConfig() 173 TraceConfig()
172 : enable_sampling_(false), 174 : enable_sampling_(false),
173 enable_systrace_(false), 175 enable_systrace_(false),
174 enable_argument_filter_(false) {} 176 enable_argument_filter_(false) {}
175 TraceRecordMode GetTraceRecordMode() const { return record_mode_; } 177 TraceRecordMode GetTraceRecordMode() const { return record_mode_; }
(...skipping 17 matching lines...) Expand all
193 bool enable_systrace_ : 1; 195 bool enable_systrace_ : 1;
194 bool enable_argument_filter_ : 1; 196 bool enable_argument_filter_ : 1;
195 StringList included_categories_; 197 StringList included_categories_;
196 StringList excluded_categories_; 198 StringList excluded_categories_;
197 199
198 // Disallow copy and assign 200 // Disallow copy and assign
199 TraceConfig(const TraceConfig&) = delete; 201 TraceConfig(const TraceConfig&) = delete;
200 void operator=(const TraceConfig&) = delete; 202 void operator=(const TraceConfig&) = delete;
201 }; 203 };
202 204
203 class TracingController { 205 class V8_PLATFORM_EXPORT TracingController {
204 public: 206 public:
205 enum Mode { DISABLED = 0, RECORDING_MODE }; 207 enum Mode { DISABLED = 0, RECORDING_MODE };
206 208
207 // The pointer returned from GetCategoryGroupEnabledInternal() points to a 209 // The pointer returned from GetCategoryGroupEnabledInternal() points to a
208 // value with zero or more of the following bits. Used in this class only. 210 // value with zero or more of the following bits. Used in this class only.
209 // The TRACE_EVENT macros should only use the value as a bool. 211 // The TRACE_EVENT macros should only use the value as a bool.
210 // These values must be in sync with macro values in TraceEvent.h in Blink. 212 // These values must be in sync with macro values in TraceEvent.h in Blink.
211 enum CategoryGroupEnabledFlags { 213 enum CategoryGroupEnabledFlags {
212 // Category group enabled for the recording mode. 214 // Category group enabled for the recording mode.
213 ENABLED_FOR_RECORDING = 1 << 0, 215 ENABLED_FOR_RECORDING = 1 << 0,
(...skipping 30 matching lines...) Expand all
244 // Disallow copy and assign 246 // Disallow copy and assign
245 TracingController(const TracingController&) = delete; 247 TracingController(const TracingController&) = delete;
246 void operator=(const TracingController&) = delete; 248 void operator=(const TracingController&) = delete;
247 }; 249 };
248 250
249 } // namespace tracing 251 } // namespace tracing
250 } // namespace platform 252 } // namespace platform
251 } // namespace v8 253 } // namespace v8
252 254
253 #endif // V8_LIBPLATFORM_V8_TRACING_H_ 255 #endif // V8_LIBPLATFORM_V8_TRACING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698