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

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

Issue 1554623003: Don't conflate Timeline serialized json with event type (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
« runtime/lib/timeline.cc ('K') | « runtime/vm/timeline.h ('k') | no next file » | 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 #include <cstdlib> 5 #include <cstdlib>
6 6
7 #include "vm/atomic.h" 7 #include "vm/atomic.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/json_stream.h" 9 #include "vm/json_stream.h"
10 #include "vm/lockers.h" 10 #include "vm/lockers.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 void TimelineEvent::Reset() { 193 void TimelineEvent::Reset() {
194 set_event_type(kNone); 194 set_event_type(kNone);
195 thread_ = OSThread::kInvalidThreadId; 195 thread_ = OSThread::kInvalidThreadId;
196 isolate_id_ = ILLEGAL_PORT; 196 isolate_id_ = ILLEGAL_PORT;
197 category_ = ""; 197 category_ = "";
198 label_ = NULL; 198 label_ = NULL;
199 FreeArguments(); 199 FreeArguments();
200 } 200 }
201 201
202 202
203 void TimelineEvent::AsyncBegin(const char* label, int64_t async_id) { 203 void TimelineEvent::AsyncBegin(const char* label,
204 int64_t async_id,
205 int64_t micros) {
204 Init(kAsyncBegin, label); 206 Init(kAsyncBegin, label);
205 set_timestamp0(OS::GetCurrentMonotonicMicros()); 207 set_timestamp0(micros);
206 // Overload timestamp1_ with the async_id. 208 // Overload timestamp1_ with the async_id.
207 set_timestamp1(async_id); 209 set_timestamp1(async_id);
208 } 210 }
209 211
210 212
211 void TimelineEvent::AsyncInstant(const char* label, 213 void TimelineEvent::AsyncInstant(const char* label,
212 int64_t async_id) { 214 int64_t async_id,
215 int64_t micros) {
213 Init(kAsyncInstant, label); 216 Init(kAsyncInstant, label);
214 set_timestamp0(OS::GetCurrentMonotonicMicros()); 217 set_timestamp0(micros);
215 // Overload timestamp1_ with the async_id. 218 // Overload timestamp1_ with the async_id.
216 set_timestamp1(async_id); 219 set_timestamp1(async_id);
217 } 220 }
218 221
219 222
220 void TimelineEvent::AsyncEnd(const char* label, 223 void TimelineEvent::AsyncEnd(const char* label,
221 int64_t async_id) { 224 int64_t async_id,
225 int64_t micros) {
222 Init(kAsyncEnd, label); 226 Init(kAsyncEnd, label);
223 set_timestamp0(OS::GetCurrentMonotonicMicros()); 227 set_timestamp0(micros);
224 // Overload timestamp1_ with the async_id. 228 // Overload timestamp1_ with the async_id.
225 set_timestamp1(async_id); 229 set_timestamp1(async_id);
226 } 230 }
227 231
228 232
229 void TimelineEvent::DurationBegin(const char* label) { 233 void TimelineEvent::DurationBegin(const char* label,
234 int64_t micros) {
230 Init(kDuration, label); 235 Init(kDuration, label);
231 set_timestamp0(OS::GetCurrentMonotonicMicros()); 236 set_timestamp0(micros);
232 } 237 }
233 238
234 239
235 void TimelineEvent::DurationEnd() { 240 void TimelineEvent::DurationEnd(int64_t micros) {
236 ASSERT(timestamp1_ == 0); 241 ASSERT(timestamp1_ == 0);
237 set_timestamp1(OS::GetCurrentMonotonicMicros()); 242 set_timestamp1(micros);
238 } 243 }
239 244
240 245
241 void TimelineEvent::Instant(const char* label) { 246 void TimelineEvent::Instant(const char* label,
247 int64_t micros) {
242 Init(kInstant, label); 248 Init(kInstant, label);
243 set_timestamp0(OS::GetCurrentMonotonicMicros()); 249 set_timestamp0(micros);
244 } 250 }
245 251
246 252
247 void TimelineEvent::Duration(const char* label, 253 void TimelineEvent::Duration(const char* label,
248 int64_t start_micros, 254 int64_t start_micros,
249 int64_t end_micros) { 255 int64_t end_micros) {
250 Init(kDuration, label); 256 Init(kDuration, label);
251 set_timestamp0(start_micros); 257 set_timestamp0(start_micros);
252 set_timestamp1(end_micros); 258 set_timestamp1(end_micros);
253 } 259 }
254 260
255 261
256 void TimelineEvent::Begin(const char* label, 262 void TimelineEvent::Begin(const char* label,
257 int64_t micros) { 263 int64_t micros) {
258 Init(kBegin, label); 264 Init(kBegin, label);
259 set_timestamp0(micros); 265 set_timestamp0(micros);
260 } 266 }
261 267
262 268
263 void TimelineEvent::End(const char* label, 269 void TimelineEvent::End(const char* label,
264 int64_t micros) { 270 int64_t micros) {
265 Init(kEnd, label); 271 Init(kEnd, label);
266 set_timestamp0(micros); 272 set_timestamp0(micros);
267 } 273 }
268 274
269 275
270 void TimelineEvent::SerializedJSON(const char* json, 276 void TimelineEvent::CompleteWithPreSerializedJSON(const char* json) {
271 int64_t timestamp0, 277 set_pre_serialized_json(true);
272 int64_t timestamp1) {
273 Init(kSerializedJSON, "Dart");
274 set_timestamp0(timestamp0);
275 set_timestamp1(timestamp1);
276 SetNumArguments(1); 278 SetNumArguments(1);
277 CopyArgument(0, "Dart", json); 279 CopyArgument(0, "Dart", json);
280 Complete();
278 } 281 }
279 282
280 283
281 void TimelineEvent::SetNumArguments(intptr_t length) { 284 void TimelineEvent::SetNumArguments(intptr_t length) {
282 // Cannot call this twice. 285 // Cannot call this twice.
283 ASSERT(arguments_ == NULL); 286 ASSERT(arguments_ == NULL);
284 ASSERT(arguments_length_ == 0); 287 ASSERT(arguments_length_ == 0);
285 if (length == 0) { 288 if (length == 0) {
286 return; 289 return;
287 } 290 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 int64_t r_t1 = time_origin_micros + time_extent_micros; 402 int64_t r_t1 = time_origin_micros + time_extent_micros;
400 ASSERT(r_t0 <= r_t1); 403 ASSERT(r_t0 <= r_t1);
401 return !((r_t1 < e_t0) || (e_t1 < r_t0)); 404 return !((r_t1 < e_t0) || (e_t1 < r_t0));
402 } 405 }
403 int64_t delta = TimeOrigin() - time_origin_micros; 406 int64_t delta = TimeOrigin() - time_origin_micros;
404 return (delta >= 0) && (delta <= time_extent_micros); 407 return (delta >= 0) && (delta <= time_extent_micros);
405 } 408 }
406 409
407 410
408 const char* TimelineEvent::GetSerializedJSON() const { 411 const char* TimelineEvent::GetSerializedJSON() const {
409 ASSERT(event_type() == kSerializedJSON); 412 ASSERT(pre_serialized_json());
410 ASSERT(arguments_length_ == 1); 413 ASSERT(arguments_length_ == 1);
411 ASSERT(arguments_ != NULL); 414 ASSERT(arguments_ != NULL);
412 return arguments_[0].value; 415 return arguments_[0].value;
413 } 416 }
414 417
415 418
416 void TimelineEvent::PrintJSON(JSONStream* stream) const { 419 void TimelineEvent::PrintJSON(JSONStream* stream) const {
417 if (event_type() == kSerializedJSON) { 420 if (pre_serialized_json()) {
418 // Event has already been serialized into JSON- just append the 421 // Event has already been serialized into JSON- just append the
419 // raw data. 422 // raw data.
420 stream->AppendSerializedObject(GetSerializedJSON()); 423 stream->AppendSerializedObject(GetSerializedJSON());
421 return; 424 return;
422 } 425 }
423 JSONObject obj(stream); 426 JSONObject obj(stream);
424 int64_t pid = OS::ProcessId(); 427 int64_t pid = OS::ProcessId();
425 int64_t tid = OSThread::ThreadIdToIntPtr(thread_); 428 int64_t tid = OSThread::ThreadIdToIntPtr(thread_);
426 obj.AddProperty("name", label_); 429 obj.AddProperty("name", label_);
427 obj.AddProperty("cat", category_); 430 obj.AddProperty("cat", category_);
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 1319
1317 1320
1318 TimelineEventBlock* TimelineEventBlockIterator::Next() { 1321 TimelineEventBlock* TimelineEventBlockIterator::Next() {
1319 ASSERT(current_ != NULL); 1322 ASSERT(current_ != NULL);
1320 TimelineEventBlock* r = current_; 1323 TimelineEventBlock* r = current_;
1321 current_ = current_->next(); 1324 current_ = current_->next();
1322 return r; 1325 return r;
1323 } 1326 }
1324 1327
1325 } // namespace dart 1328 } // namespace dart
OLDNEW
« runtime/lib/timeline.cc ('K') | « runtime/vm/timeline.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698