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

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

Issue 1295223002: Drop support for recording Dart objects in a timeline trace (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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 | « no previous file | 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
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return recorder_; 189 return recorder_;
190 } 190 }
191 191
192 // TODO(johnmccutchan): Disallow setting recorder after Init? 192 // TODO(johnmccutchan): Disallow setting recorder after Init?
193 void set_recorder(TimelineEventRecorder* recorder) { 193 void set_recorder(TimelineEventRecorder* recorder) {
194 recorder_ = recorder; 194 recorder_ = recorder;
195 } 195 }
196 196
197 // Records an event. Will return |NULL| if not enabled. The returned 197 // Records an event. Will return |NULL| if not enabled. The returned
198 // |TimelineEvent| is in an undefined state and must be initialized. 198 // |TimelineEvent| is in an undefined state and must be initialized.
199 // |obj| is associated with the returned |TimelineEvent|.
200 TimelineEvent* StartEvent(const Object& obj);
201
202 // Records an event. Will return |NULL| if not enabled. The returned
203 // |TimelineEvent| is in an undefined state and must be initialized.
204 TimelineEvent* StartEvent(); 199 TimelineEvent* StartEvent();
205 200
206 void CompleteEvent(TimelineEvent* event); 201 void CompleteEvent(TimelineEvent* event);
207 202
208 int64_t GetNextSeq(); 203 int64_t GetNextSeq();
209 204
210 private: 205 private:
211 TimelineEventRecorder* recorder_; 206 TimelineEventRecorder* recorder_;
212 const char* name_; 207 const char* name_;
213 bool enabled_; 208 bool enabled_;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 378
384 // Interface method(s) which must be implemented. 379 // Interface method(s) which must be implemented.
385 virtual void PrintJSON(JSONStream* js) = 0; 380 virtual void PrintJSON(JSONStream* js) = 0;
386 virtual TimelineEventBlock* GetNewBlock() = 0; 381 virtual TimelineEventBlock* GetNewBlock() = 0;
387 virtual TimelineEventBlock* GetHeadBlock() = 0; 382 virtual TimelineEventBlock* GetHeadBlock() = 0;
388 383
389 void WriteTo(const char* directory); 384 void WriteTo(const char* directory);
390 385
391 protected: 386 protected:
392 // Interface method(s) which must be implemented. 387 // Interface method(s) which must be implemented.
393 virtual void VisitObjectPointers(ObjectPointerVisitor* visitor) = 0;
394 virtual TimelineEvent* StartEvent(const Object& object) = 0;
395 virtual TimelineEvent* StartEvent() = 0; 388 virtual TimelineEvent* StartEvent() = 0;
396 virtual void CompleteEvent(TimelineEvent* event) = 0; 389 virtual void CompleteEvent(TimelineEvent* event) = 0;
397 390
398 // Utility method(s). 391 // Utility method(s).
399 void PrintJSONMeta(JSONArray* array) const; 392 void PrintJSONMeta(JSONArray* array) const;
400 TimelineEvent* ThreadBlockStartEvent(); 393 TimelineEvent* ThreadBlockStartEvent();
401 394
402 Mutex lock_; 395 Mutex lock_;
403 396
404 friend class TimelineEventBlockIterator; 397 friend class TimelineEventBlockIterator;
405 friend class TimelineStream; 398 friend class TimelineStream;
406 friend class TimelineTestHelper; 399 friend class TimelineTestHelper;
407 friend class Isolate; 400 friend class Isolate;
408 401
409 private: 402 private:
410 DISALLOW_COPY_AND_ASSIGN(TimelineEventRecorder); 403 DISALLOW_COPY_AND_ASSIGN(TimelineEventRecorder);
411 }; 404 };
412 405
413 406
414 // A recorder that stores events in a ring buffer of fixed capacity. 407 // A recorder that stores events in a ring buffer of fixed capacity.
415 // This recorder does track Dart objects.
416 class TimelineEventRingRecorder : public TimelineEventRecorder { 408 class TimelineEventRingRecorder : public TimelineEventRecorder {
417 public: 409 public:
418 static const intptr_t kDefaultCapacity = 8192; 410 static const intptr_t kDefaultCapacity = 8192;
419 411
420 explicit TimelineEventRingRecorder(intptr_t capacity = kDefaultCapacity); 412 explicit TimelineEventRingRecorder(intptr_t capacity = kDefaultCapacity);
421 ~TimelineEventRingRecorder(); 413 ~TimelineEventRingRecorder();
422 414
423 void PrintJSON(JSONStream* js); 415 void PrintJSON(JSONStream* js);
424 TimelineEventBlock* GetNewBlock(); 416 TimelineEventBlock* GetNewBlock();
425 TimelineEventBlock* GetHeadBlock(); 417 TimelineEventBlock* GetHeadBlock();
426 418
427 protected: 419 protected:
428 void VisitObjectPointers(ObjectPointerVisitor* visitor);
429 TimelineEvent* StartEvent(const Object& object);
430 TimelineEvent* StartEvent(); 420 TimelineEvent* StartEvent();
431 void CompleteEvent(TimelineEvent* event); 421 void CompleteEvent(TimelineEvent* event);
432 422
433 intptr_t FindOldestBlockIndex() const; 423 intptr_t FindOldestBlockIndex() const;
434 TimelineEventBlock* GetNewBlockLocked(); 424 TimelineEventBlock* GetNewBlockLocked();
435 425
436 void PrintJSONEvents(JSONArray* array) const; 426 void PrintJSONEvents(JSONArray* array) const;
437 427
438 TimelineEventBlock** blocks_; 428 TimelineEventBlock** blocks_;
439 RawArray* event_objects_; 429 RawArray* event_objects_;
440 intptr_t capacity_; 430 intptr_t capacity_;
441 intptr_t num_blocks_; 431 intptr_t num_blocks_;
442 intptr_t block_cursor_; 432 intptr_t block_cursor_;
443 }; 433 };
444 434
445 435
446 // An abstract recorder that calls |StreamEvent| whenever an event is complete. 436 // An abstract recorder that calls |StreamEvent| whenever an event is complete.
447 // This recorder does not track Dart objects.
448 class TimelineEventStreamingRecorder : public TimelineEventRecorder { 437 class TimelineEventStreamingRecorder : public TimelineEventRecorder {
449 public: 438 public:
450 TimelineEventStreamingRecorder(); 439 TimelineEventStreamingRecorder();
451 ~TimelineEventStreamingRecorder(); 440 ~TimelineEventStreamingRecorder();
452 441
453 void PrintJSON(JSONStream* js); 442 void PrintJSON(JSONStream* js);
454 TimelineEventBlock* GetNewBlock() { 443 TimelineEventBlock* GetNewBlock() {
455 return NULL; 444 return NULL;
456 } 445 }
457 TimelineEventBlock* GetHeadBlock() { 446 TimelineEventBlock* GetHeadBlock() {
458 return NULL; 447 return NULL;
459 } 448 }
460 449
461 // Called when |event| is ready to be streamed. It is unsafe to keep a 450 // Called when |event| is ready to be streamed. It is unsafe to keep a
462 // reference to |event| as it may be freed as soon as this function returns. 451 // reference to |event| as it may be freed as soon as this function returns.
463 virtual void StreamEvent(TimelineEvent* event) = 0; 452 virtual void StreamEvent(TimelineEvent* event) = 0;
464 453
465 protected: 454 protected:
466 void VisitObjectPointers(ObjectPointerVisitor* visitor);
467 TimelineEvent* StartEvent(const Object& object);
468 TimelineEvent* StartEvent(); 455 TimelineEvent* StartEvent();
469 void CompleteEvent(TimelineEvent* event); 456 void CompleteEvent(TimelineEvent* event);
470 }; 457 };
471 458
472 459
473 // A recorder that stores events in chains of blocks of events. 460 // A recorder that stores events in chains of blocks of events.
474 // This recorder does not track Dart objects.
475 // NOTE: This recorder will continue to allocate blocks until it exhausts 461 // NOTE: This recorder will continue to allocate blocks until it exhausts
476 // memory. 462 // memory.
477 class TimelineEventEndlessRecorder : public TimelineEventRecorder { 463 class TimelineEventEndlessRecorder : public TimelineEventRecorder {
478 public: 464 public:
479 TimelineEventEndlessRecorder(); 465 TimelineEventEndlessRecorder();
480 466
481 // Acquire a new block of events. 467 // Acquire a new block of events.
482 // Takes a lock. 468 // Takes a lock.
483 // Recorder owns the block and it should be filled by only one thread. 469 // Recorder owns the block and it should be filled by only one thread.
484 TimelineEventBlock* GetNewBlock(); 470 TimelineEventBlock* GetNewBlock();
485 471
486 TimelineEventBlock* GetHeadBlock(); 472 TimelineEventBlock* GetHeadBlock();
487 473
488 // It is expected that this function is only called when an isolate is 474 // It is expected that this function is only called when an isolate is
489 // shutting itself down. 475 // shutting itself down.
490 // NOTE: Calling this while threads are filling in their blocks is not safe 476 // NOTE: Calling this while threads are filling in their blocks is not safe
491 // and there are no checks in place to ensure that doesn't happen. 477 // and there are no checks in place to ensure that doesn't happen.
492 // TODO(koda): Add isolate count to |ThreadRegistry| and verify that it is 1. 478 // TODO(koda): Add isolate count to |ThreadRegistry| and verify that it is 1.
493 void PrintJSON(JSONStream* js); 479 void PrintJSON(JSONStream* js);
494 480
495 protected: 481 protected:
496 void VisitObjectPointers(ObjectPointerVisitor* visitor);
497 TimelineEvent* StartEvent(const Object& object);
498 TimelineEvent* StartEvent(); 482 TimelineEvent* StartEvent();
499 void CompleteEvent(TimelineEvent* event); 483 void CompleteEvent(TimelineEvent* event);
500 484
501 TimelineEventBlock* GetNewBlockLocked(); 485 TimelineEventBlock* GetNewBlockLocked();
502 void PrintJSONEvents(JSONArray* array) const; 486 void PrintJSONEvents(JSONArray* array) const;
503 487
504 // Useful only for testing. Only works for one thread. 488 // Useful only for testing. Only works for one thread.
505 void Clear(); 489 void Clear();
506 490
507 TimelineEventBlock* head_; 491 TimelineEventBlock* head_;
(...skipping 18 matching lines...) Expand all
526 TimelineEventBlock* Next(); 510 TimelineEventBlock* Next();
527 511
528 private: 512 private:
529 TimelineEventBlock* current_; 513 TimelineEventBlock* current_;
530 TimelineEventRecorder* recorder_; 514 TimelineEventRecorder* recorder_;
531 }; 515 };
532 516
533 } // namespace dart 517 } // namespace dart
534 518
535 #endif // VM_TIMELINE_H_ 519 #endif // VM_TIMELINE_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/timeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698