OLD | NEW |
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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 | 551 |
552 Vector<HeapGraphEdge> children() { | 552 Vector<HeapGraphEdge> children() { |
553 return Vector<HeapGraphEdge>(children_arr(), children_count_); } | 553 return Vector<HeapGraphEdge>(children_arr(), children_count_); } |
554 Vector<HeapGraphEdge*> retainers() { | 554 Vector<HeapGraphEdge*> retainers() { |
555 return Vector<HeapGraphEdge*>(retainers_arr(), retainers_count_); } | 555 return Vector<HeapGraphEdge*>(retainers_arr(), retainers_count_); } |
556 HeapEntry* dominator() { return dominator_; } | 556 HeapEntry* dominator() { return dominator_; } |
557 void set_dominator(HeapEntry* entry) { | 557 void set_dominator(HeapEntry* entry) { |
558 ASSERT(entry != NULL); | 558 ASSERT(entry != NULL); |
559 dominator_ = entry; | 559 dominator_ = entry; |
560 } | 560 } |
561 | 561 void clear_paint() { painted_ = false; } |
562 void clear_paint() { painted_ = kUnpainted; } | 562 bool painted() { return painted_; } |
563 bool painted_reachable() { return painted_ == kPainted; } | 563 void paint() { painted_ = true; } |
564 void paint_reachable() { | |
565 ASSERT(painted_ == kUnpainted); | |
566 painted_ = kPainted; | |
567 } | |
568 bool not_painted_reachable_from_others() { | |
569 return painted_ != kPaintedReachableFromOthers; | |
570 } | |
571 void paint_reachable_from_others() { | |
572 painted_ = kPaintedReachableFromOthers; | |
573 } | |
574 template<class Visitor> | |
575 void ApplyAndPaintAllReachable(Visitor* visitor); | |
576 void PaintAllReachable(); | |
577 | 564 |
578 void SetIndexedReference(HeapGraphEdge::Type type, | 565 void SetIndexedReference(HeapGraphEdge::Type type, |
579 int child_index, | 566 int child_index, |
580 int index, | 567 int index, |
581 HeapEntry* entry, | 568 HeapEntry* entry, |
582 int retainer_index); | 569 int retainer_index); |
583 void SetNamedReference(HeapGraphEdge::Type type, | 570 void SetNamedReference(HeapGraphEdge::Type type, |
584 int child_index, | 571 int child_index, |
585 const char* name, | 572 const char* name, |
586 HeapEntry* entry, | 573 HeapEntry* entry, |
587 int retainer_index); | 574 int retainer_index); |
588 void SetUnidirElementReference(int child_index, int index, HeapEntry* entry); | 575 void SetUnidirElementReference(int child_index, int index, HeapEntry* entry); |
589 | 576 |
590 int EntrySize() { return EntriesSize(1, children_count_, retainers_count_); } | 577 int EntrySize() { return EntriesSize(1, children_count_, retainers_count_); } |
591 int RetainedSize(bool exact); | |
592 | 578 |
593 void Print( | 579 void Print( |
594 const char* prefix, const char* edge_name, int max_depth, int indent); | 580 const char* prefix, const char* edge_name, int max_depth, int indent); |
595 | 581 |
596 Handle<HeapObject> GetHeapObject(); | 582 Handle<HeapObject> GetHeapObject(); |
597 | 583 |
598 static int EntriesSize(int entries_count, | 584 static int EntriesSize(int entries_count, |
599 int children_count, | 585 int children_count, |
600 int retainers_count); | 586 int retainers_count); |
601 | 587 |
602 private: | 588 private: |
603 HeapGraphEdge* children_arr() { | 589 HeapGraphEdge* children_arr() { |
604 return reinterpret_cast<HeapGraphEdge*>(this + 1); | 590 return reinterpret_cast<HeapGraphEdge*>(this + 1); |
605 } | 591 } |
606 HeapGraphEdge** retainers_arr() { | 592 HeapGraphEdge** retainers_arr() { |
607 return reinterpret_cast<HeapGraphEdge**>(children_arr() + children_count_); | 593 return reinterpret_cast<HeapGraphEdge**>(children_arr() + children_count_); |
608 } | 594 } |
609 void CalculateExactRetainedSize(); | |
610 const char* TypeAsString(); | 595 const char* TypeAsString(); |
611 | 596 |
612 unsigned painted_: 2; | 597 unsigned painted_: 1; |
613 unsigned type_: 4; | 598 unsigned type_: 4; |
614 int children_count_: 26; | 599 int children_count_: 27; |
615 int retainers_count_; | 600 int retainers_count_; |
616 int self_size_; | 601 int self_size_; |
617 union { | 602 union { |
618 int ordered_index_; // Used during dominator tree building. | 603 int ordered_index_; // Used during dominator tree building. |
619 int retained_size_; // At that moment, there is no retained size yet. | 604 int retained_size_; // At that moment, there is no retained size yet. |
620 }; | 605 }; |
621 HeapEntry* dominator_; | 606 HeapEntry* dominator_; |
622 HeapSnapshot* snapshot_; | 607 HeapSnapshot* snapshot_; |
623 struct Id { | 608 struct Id { |
624 uint32_t id1_; | 609 uint32_t id1_; |
625 uint32_t id2_; | 610 uint32_t id2_; |
626 } id_; // This is to avoid extra padding of 64-bit value. | 611 } id_; // This is to avoid extra padding of 64-bit value. |
627 const char* name_; | 612 const char* name_; |
628 | 613 |
629 // Paints used for exact retained sizes calculation. | |
630 static const unsigned kUnpainted = 0; | |
631 static const unsigned kPainted = 1; | |
632 static const unsigned kPaintedReachableFromOthers = 2; | |
633 | |
634 static const int kExactRetainedSizeTag = 1; | |
635 | |
636 DISALLOW_COPY_AND_ASSIGN(HeapEntry); | 614 DISALLOW_COPY_AND_ASSIGN(HeapEntry); |
637 }; | 615 }; |
638 | 616 |
639 | 617 |
640 class HeapSnapshotsCollection; | 618 class HeapSnapshotsCollection; |
641 | 619 |
642 // HeapSnapshot represents a single heap snapshot. It is stored in | 620 // HeapSnapshot represents a single heap snapshot. It is stored in |
643 // HeapSnapshotsCollection, which is also a factory for | 621 // HeapSnapshotsCollection, which is also a factory for |
644 // HeapSnapshots. All HeapSnapshots share strings copied from JS heap | 622 // HeapSnapshots. All HeapSnapshots share strings copied from JS heap |
645 // to be able to return them even if they were collected. | 623 // to be able to return them even if they were collected. |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 }; | 1070 }; |
1093 | 1071 |
1094 | 1072 |
1095 class HeapSnapshotGenerator : public SnapshottingProgressReportingInterface { | 1073 class HeapSnapshotGenerator : public SnapshottingProgressReportingInterface { |
1096 public: | 1074 public: |
1097 HeapSnapshotGenerator(HeapSnapshot* snapshot, | 1075 HeapSnapshotGenerator(HeapSnapshot* snapshot, |
1098 v8::ActivityControl* control); | 1076 v8::ActivityControl* control); |
1099 bool GenerateSnapshot(); | 1077 bool GenerateSnapshot(); |
1100 | 1078 |
1101 private: | 1079 private: |
1102 bool ApproximateRetainedSizes(); | |
1103 bool BuildDominatorTree(const Vector<HeapEntry*>& entries, | 1080 bool BuildDominatorTree(const Vector<HeapEntry*>& entries, |
1104 Vector<int>* dominators); | 1081 Vector<int>* dominators); |
| 1082 bool CalculateRetainedSizes(); |
1105 bool CountEntriesAndReferences(); | 1083 bool CountEntriesAndReferences(); |
1106 bool FillReferences(); | 1084 bool FillReferences(); |
1107 void FillReversePostorderIndexes(Vector<HeapEntry*>* entries); | 1085 void FillReversePostorderIndexes(Vector<HeapEntry*>* entries); |
1108 void ProgressStep(); | 1086 void ProgressStep(); |
1109 bool ProgressReport(bool force = false); | 1087 bool ProgressReport(bool force = false); |
1110 bool SetEntriesDominators(); | 1088 bool SetEntriesDominators(); |
1111 void SetProgressTotal(int iterations_count); | 1089 void SetProgressTotal(int iterations_count); |
1112 | 1090 |
1113 HeapSnapshot* snapshot_; | 1091 HeapSnapshot* snapshot_; |
1114 v8::ActivityControl* control_; | 1092 v8::ActivityControl* control_; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 | 1150 |
1173 friend class HeapSnapshotJSONSerializerEnumerator; | 1151 friend class HeapSnapshotJSONSerializerEnumerator; |
1174 friend class HeapSnapshotJSONSerializerIterator; | 1152 friend class HeapSnapshotJSONSerializerIterator; |
1175 | 1153 |
1176 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 1154 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
1177 }; | 1155 }; |
1178 | 1156 |
1179 } } // namespace v8::internal | 1157 } } // namespace v8::internal |
1180 | 1158 |
1181 #endif // V8_PROFILE_GENERATOR_H_ | 1159 #endif // V8_PROFILE_GENERATOR_H_ |
OLD | NEW |