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

Side by Side Diff: src/profile-generator.h

Issue 10416035: Eliminate dominator and retained_size fields. They are calculating on front-end side. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: comments addressed Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « src/api.cc ('k') | src/profile-generator.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 const char* name, 522 const char* name,
523 SnapshotObjectId id, 523 SnapshotObjectId id,
524 int self_size); 524 int self_size);
525 525
526 HeapSnapshot* snapshot() { return snapshot_; } 526 HeapSnapshot* snapshot() { return snapshot_; }
527 Type type() { return static_cast<Type>(type_); } 527 Type type() { return static_cast<Type>(type_); }
528 const char* name() { return name_; } 528 const char* name() { return name_; }
529 void set_name(const char* name) { name_ = name; } 529 void set_name(const char* name) { name_ = name; }
530 inline SnapshotObjectId id() { return id_; } 530 inline SnapshotObjectId id() { return id_; }
531 int self_size() { return self_size_; } 531 int self_size() { return self_size_; }
532 int retained_size() { return retained_size_; }
533 void add_retained_size(int size) { retained_size_ += size; }
534 void set_retained_size(int size) { retained_size_ = size; }
535 INLINE(int index() const); 532 INLINE(int index() const);
536 int postorder_index() { return postorder_index_; }
537 void set_postorder_index(int value) { postorder_index_ = value; }
538 int children_count() const { return children_count_; } 533 int children_count() const { return children_count_; }
539 INLINE(int set_children_index(int index)); 534 INLINE(int set_children_index(int index));
540 INLINE(int set_retainers_index(int index));
541 void add_child(HeapGraphEdge* edge) { 535 void add_child(HeapGraphEdge* edge) {
542 children_arr()[children_count_++] = edge; 536 children_arr()[children_count_++] = edge;
543 } 537 }
544 void add_retainer(HeapGraphEdge* edge) {
545 retainers_arr()[retainers_count_++] = edge;
546 }
547 Vector<HeapGraphEdge*> children() { 538 Vector<HeapGraphEdge*> children() {
548 return Vector<HeapGraphEdge*>(children_arr(), children_count_); } 539 return Vector<HeapGraphEdge*>(children_arr(), children_count_); }
549 Vector<HeapGraphEdge*> retainers() {
550 return Vector<HeapGraphEdge*>(retainers_arr(), retainers_count_); }
551 INLINE(HeapEntry* dominator() const);
552 void set_dominator(HeapEntry* entry) {
553 ASSERT(entry != NULL);
554 dominator_ = entry->index();
555 }
556 void clear_paint() { painted_ = false; }
557 bool painted() { return painted_; }
558 void paint() { painted_ = true; }
559 bool user_reachable() { return user_reachable_; }
560 void set_user_reachable() { user_reachable_ = true; }
561 540
562 void SetIndexedReference( 541 void SetIndexedReference(
563 HeapGraphEdge::Type type, int index, HeapEntry* entry); 542 HeapGraphEdge::Type type, int index, HeapEntry* entry);
564 void SetNamedReference( 543 void SetNamedReference(
565 HeapGraphEdge::Type type, const char* name, HeapEntry* entry); 544 HeapGraphEdge::Type type, const char* name, HeapEntry* entry);
566 545
567 void Print( 546 void Print(
568 const char* prefix, const char* edge_name, int max_depth, int indent); 547 const char* prefix, const char* edge_name, int max_depth, int indent);
569 548
570 Handle<HeapObject> GetHeapObject(); 549 Handle<HeapObject> GetHeapObject();
571 550
572 private: 551 private:
573 INLINE(HeapGraphEdge** children_arr()); 552 INLINE(HeapGraphEdge** children_arr());
574 INLINE(HeapGraphEdge** retainers_arr());
575 const char* TypeAsString(); 553 const char* TypeAsString();
576 554
577 unsigned painted_: 1;
578 unsigned user_reachable_: 1;
579 int dominator_: 30;
580 unsigned type_: 4; 555 unsigned type_: 4;
581 int retainers_count_: 28; 556 int children_count_: 28;
582 int retainers_index_;
583 int children_count_;
584 int children_index_; 557 int children_index_;
585 int self_size_; 558 int self_size_;
586 union {
587 int postorder_index_; // Used during dominator tree building.
588 int retained_size_; // At that moment, there is no retained size yet.
589 };
590 SnapshotObjectId id_; 559 SnapshotObjectId id_;
591 HeapSnapshot* snapshot_; 560 HeapSnapshot* snapshot_;
592 const char* name_; 561 const char* name_;
593 }; 562 };
594 563
595 564
596 class HeapSnapshotsCollection; 565 class HeapSnapshotsCollection;
597 566
598 // HeapSnapshot represents a single heap snapshot. It is stored in 567 // HeapSnapshot represents a single heap snapshot. It is stored in
599 // HeapSnapshotsCollection, which is also a factory for 568 // HeapSnapshotsCollection, which is also a factory for
(...skipping 19 matching lines...) Expand all
619 size_t RawSnapshotSize() const; 588 size_t RawSnapshotSize() const;
620 HeapEntry* root() { return &entries_[root_index_]; } 589 HeapEntry* root() { return &entries_[root_index_]; }
621 HeapEntry* gc_roots() { return &entries_[gc_roots_index_]; } 590 HeapEntry* gc_roots() { return &entries_[gc_roots_index_]; }
622 HeapEntry* natives_root() { return &entries_[natives_root_index_]; } 591 HeapEntry* natives_root() { return &entries_[natives_root_index_]; }
623 HeapEntry* gc_subroot(int index) { 592 HeapEntry* gc_subroot(int index) {
624 return &entries_[gc_subroot_indexes_[index]]; 593 return &entries_[gc_subroot_indexes_[index]];
625 } 594 }
626 List<HeapEntry>& entries() { return entries_; } 595 List<HeapEntry>& entries() { return entries_; }
627 List<HeapGraphEdge>& edges() { return edges_; } 596 List<HeapGraphEdge>& edges() { return edges_; }
628 List<HeapGraphEdge*>& children() { return children_; } 597 List<HeapGraphEdge*>& children() { return children_; }
629 List<HeapGraphEdge*>& retainers() { return retainers_; }
630 void RememberLastJSObjectId(); 598 void RememberLastJSObjectId();
631 SnapshotObjectId max_snapshot_js_object_id() const { 599 SnapshotObjectId max_snapshot_js_object_id() const {
632 return max_snapshot_js_object_id_; 600 return max_snapshot_js_object_id_;
633 } 601 }
634 602
635 HeapEntry* AddEntry(HeapEntry::Type type, 603 HeapEntry* AddEntry(HeapEntry::Type type,
636 const char* name, 604 const char* name,
637 SnapshotObjectId id, 605 SnapshotObjectId id,
638 int size); 606 int size);
639 HeapEntry* AddRootEntry(); 607 HeapEntry* AddRootEntry();
640 HeapEntry* AddGcRootsEntry(); 608 HeapEntry* AddGcRootsEntry();
641 HeapEntry* AddGcSubrootEntry(int tag); 609 HeapEntry* AddGcSubrootEntry(int tag);
642 HeapEntry* AddNativesRootEntry(); 610 HeapEntry* AddNativesRootEntry();
643 void ClearPaint();
644 HeapEntry* GetEntryById(SnapshotObjectId id); 611 HeapEntry* GetEntryById(SnapshotObjectId id);
645 List<HeapEntry*>* GetSortedEntriesList(); 612 List<HeapEntry*>* GetSortedEntriesList();
646 void SetDominatorsToSelf(); 613 void FillChildren();
647 void FillChildrenAndRetainers();
648 614
649 void Print(int max_depth); 615 void Print(int max_depth);
650 void PrintEntriesSize(); 616 void PrintEntriesSize();
651 617
652 private: 618 private:
653 HeapSnapshotsCollection* collection_; 619 HeapSnapshotsCollection* collection_;
654 Type type_; 620 Type type_;
655 const char* title_; 621 const char* title_;
656 unsigned uid_; 622 unsigned uid_;
657 int root_index_; 623 int root_index_;
658 int gc_roots_index_; 624 int gc_roots_index_;
659 int natives_root_index_; 625 int natives_root_index_;
660 int gc_subroot_indexes_[VisitorSynchronization::kNumberOfSyncTags]; 626 int gc_subroot_indexes_[VisitorSynchronization::kNumberOfSyncTags];
661 List<HeapEntry> entries_; 627 List<HeapEntry> entries_;
662 List<HeapGraphEdge> edges_; 628 List<HeapGraphEdge> edges_;
663 List<HeapGraphEdge*> children_; 629 List<HeapGraphEdge*> children_;
664 List<HeapGraphEdge*> retainers_;
665 List<HeapEntry*> sorted_entries_; 630 List<HeapEntry*> sorted_entries_;
666 SnapshotObjectId max_snapshot_js_object_id_; 631 SnapshotObjectId max_snapshot_js_object_id_;
667 632
668 friend class HeapSnapshotTester; 633 friend class HeapSnapshotTester;
669 634
670 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); 635 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot);
671 }; 636 };
672 637
673 638
674 class HeapObjectsMap { 639 class HeapObjectsMap {
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 }; 1019 };
1055 1020
1056 1021
1057 class HeapSnapshotGenerator : public SnapshottingProgressReportingInterface { 1022 class HeapSnapshotGenerator : public SnapshottingProgressReportingInterface {
1058 public: 1023 public:
1059 HeapSnapshotGenerator(HeapSnapshot* snapshot, 1024 HeapSnapshotGenerator(HeapSnapshot* snapshot,
1060 v8::ActivityControl* control); 1025 v8::ActivityControl* control);
1061 bool GenerateSnapshot(); 1026 bool GenerateSnapshot();
1062 1027
1063 private: 1028 private:
1064 bool BuildDominatorTree(const Vector<HeapEntry*>& entries,
1065 Vector<int>* dominators);
1066 bool CalculateRetainedSizes();
1067 bool FillReferences(); 1029 bool FillReferences();
1068 void FillPostorderIndexes(Vector<HeapEntry*>* entries);
1069 bool IsUserGlobalReference(const HeapGraphEdge* edge);
1070 void MarkUserReachableObjects();
1071 void ProgressStep(); 1030 void ProgressStep();
1072 bool ProgressReport(bool force = false); 1031 bool ProgressReport(bool force = false);
1073 bool SetEntriesDominators();
1074 void SetProgressTotal(int iterations_count); 1032 void SetProgressTotal(int iterations_count);
1075 1033
1076 HeapSnapshot* snapshot_; 1034 HeapSnapshot* snapshot_;
1077 v8::ActivityControl* control_; 1035 v8::ActivityControl* control_;
1078 V8HeapExplorer v8_heap_explorer_; 1036 V8HeapExplorer v8_heap_explorer_;
1079 NativeObjectsExplorer dom_explorer_; 1037 NativeObjectsExplorer dom_explorer_;
1080 // Mapping from HeapThing pointers to HeapEntry* pointers. 1038 // Mapping from HeapThing pointers to HeapEntry* pointers.
1081 HeapEntriesMap entries_; 1039 HeapEntriesMap entries_;
1082 // Used during snapshot generation. 1040 // Used during snapshot generation.
1083 int progress_counter_; 1041 int progress_counter_;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 1092
1135 friend class HeapSnapshotJSONSerializerEnumerator; 1093 friend class HeapSnapshotJSONSerializerEnumerator;
1136 friend class HeapSnapshotJSONSerializerIterator; 1094 friend class HeapSnapshotJSONSerializerIterator;
1137 1095
1138 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); 1096 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer);
1139 }; 1097 };
1140 1098
1141 } } // namespace v8::internal 1099 } } // namespace v8::internal
1142 1100
1143 #endif // V8_PROFILE_GENERATOR_H_ 1101 #endif // V8_PROFILE_GENERATOR_H_
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698