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

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

Issue 6759025: Version 3.2.6 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 9 years, 8 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/preparser-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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 union { 483 union {
484 int index_; 484 int index_;
485 const char* name_; 485 const char* name_;
486 }; 486 };
487 HeapEntry* to_; 487 HeapEntry* to_;
488 488
489 DISALLOW_COPY_AND_ASSIGN(HeapGraphEdge); 489 DISALLOW_COPY_AND_ASSIGN(HeapGraphEdge);
490 }; 490 };
491 491
492 492
493 class CachedHeapGraphPath;
494 class HeapGraphPath;
495 class HeapSnapshot; 493 class HeapSnapshot;
496 494
497 // HeapEntry instances represent an entity from the heap (or a special 495 // HeapEntry instances represent an entity from the heap (or a special
498 // virtual node, e.g. root). To make heap snapshots more compact, 496 // virtual node, e.g. root). To make heap snapshots more compact,
499 // HeapEntries has a special memory layout (no Vectors or Lists used): 497 // HeapEntries has a special memory layout (no Vectors or Lists used):
500 // 498 //
501 // +-----------------+ 499 // +-----------------+
502 // HeapEntry 500 // HeapEntry
503 // +-----------------+ 501 // +-----------------+
504 // HeapGraphEdge | 502 // HeapGraphEdge |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 int retained_size() { return retained_size_; } 542 int retained_size() { return retained_size_; }
545 void add_retained_size(int size) { retained_size_ += size; } 543 void add_retained_size(int size) { retained_size_ += size; }
546 void set_retained_size(int value) { retained_size_ = value; } 544 void set_retained_size(int value) { retained_size_ = value; }
547 int ordered_index() { return ordered_index_; } 545 int ordered_index() { return ordered_index_; }
548 void set_ordered_index(int value) { ordered_index_ = value; } 546 void set_ordered_index(int value) { ordered_index_ = value; }
549 547
550 Vector<HeapGraphEdge> children() { 548 Vector<HeapGraphEdge> children() {
551 return Vector<HeapGraphEdge>(children_arr(), children_count_); } 549 return Vector<HeapGraphEdge>(children_arr(), children_count_); }
552 Vector<HeapGraphEdge*> retainers() { 550 Vector<HeapGraphEdge*> retainers() {
553 return Vector<HeapGraphEdge*>(retainers_arr(), retainers_count_); } 551 return Vector<HeapGraphEdge*>(retainers_arr(), retainers_count_); }
554 List<HeapGraphPath*>* GetRetainingPaths();
555 HeapEntry* dominator() { return dominator_; } 552 HeapEntry* dominator() { return dominator_; }
556 void set_dominator(HeapEntry* entry) { dominator_ = entry; } 553 void set_dominator(HeapEntry* entry) { dominator_ = entry; }
557 554
558 void clear_paint() { painted_ = kUnpainted; } 555 void clear_paint() { painted_ = kUnpainted; }
559 bool painted_reachable() { return painted_ == kPainted; } 556 bool painted_reachable() { return painted_ == kPainted; }
560 void paint_reachable() { 557 void paint_reachable() {
561 ASSERT(painted_ == kUnpainted); 558 ASSERT(painted_ == kUnpainted);
562 painted_ = kPainted; 559 painted_ = kPainted;
563 } 560 }
564 bool not_painted_reachable_from_others() { 561 bool not_painted_reachable_from_others() {
(...skipping 13 matching lines...) Expand all
578 int retainer_index); 575 int retainer_index);
579 void SetNamedReference(HeapGraphEdge::Type type, 576 void SetNamedReference(HeapGraphEdge::Type type,
580 int child_index, 577 int child_index,
581 const char* name, 578 const char* name,
582 HeapEntry* entry, 579 HeapEntry* entry,
583 int retainer_index); 580 int retainer_index);
584 void SetUnidirElementReference(int child_index, int index, HeapEntry* entry); 581 void SetUnidirElementReference(int child_index, int index, HeapEntry* entry);
585 582
586 int EntrySize() { return EntriesSize(1, children_count_, retainers_count_); } 583 int EntrySize() { return EntriesSize(1, children_count_, retainers_count_); }
587 int RetainedSize(bool exact); 584 int RetainedSize(bool exact);
588 List<HeapGraphPath*>* CalculateRetainingPaths();
589 585
590 void Print(int max_depth, int indent); 586 void Print(int max_depth, int indent);
591 587
592 static int EntriesSize(int entries_count, 588 static int EntriesSize(int entries_count,
593 int children_count, 589 int children_count,
594 int retainers_count); 590 int retainers_count);
595 static uint32_t Hash(HeapEntry* entry) {
596 return ComputeIntegerHash(
597 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(entry)));
598 }
599 static bool Match(void* entry1, void* entry2) { return entry1 == entry2; }
600 591
601 private: 592 private:
602 HeapGraphEdge* children_arr() { 593 HeapGraphEdge* children_arr() {
603 return reinterpret_cast<HeapGraphEdge*>(this + 1); 594 return reinterpret_cast<HeapGraphEdge*>(this + 1);
604 } 595 }
605 HeapGraphEdge** retainers_arr() { 596 HeapGraphEdge** retainers_arr() {
606 return reinterpret_cast<HeapGraphEdge**>(children_arr() + children_count_); 597 return reinterpret_cast<HeapGraphEdge**>(children_arr() + children_count_);
607 } 598 }
608 void CalculateExactRetainedSize(); 599 void CalculateExactRetainedSize();
609 void FindRetainingPaths(CachedHeapGraphPath* prev_path,
610 List<HeapGraphPath*>* retaining_paths);
611 const char* TypeAsString(); 600 const char* TypeAsString();
612 601
613 unsigned painted_: 2; 602 unsigned painted_: 2;
614 unsigned type_: 4; 603 unsigned type_: 4;
615 int children_count_: 26; 604 int children_count_: 26;
616 int retainers_count_; 605 int retainers_count_;
617 int self_size_; 606 int self_size_;
618 union { 607 union {
619 int ordered_index_; // Used during dominator tree building. 608 int ordered_index_; // Used during dominator tree building.
620 int retained_size_; // At that moment, there is no retained size yet. 609 int retained_size_; // At that moment, there is no retained size yet.
(...skipping 10 matching lines...) Expand all
631 static const unsigned kUnpainted = 0; 620 static const unsigned kUnpainted = 0;
632 static const unsigned kPainted = 1; 621 static const unsigned kPainted = 1;
633 static const unsigned kPaintedReachableFromOthers = 2; 622 static const unsigned kPaintedReachableFromOthers = 2;
634 623
635 static const int kExactRetainedSizeTag = 1; 624 static const int kExactRetainedSizeTag = 1;
636 625
637 DISALLOW_COPY_AND_ASSIGN(HeapEntry); 626 DISALLOW_COPY_AND_ASSIGN(HeapEntry);
638 }; 627 };
639 628
640 629
641 class HeapGraphPath {
642 public:
643 HeapGraphPath()
644 : path_(8) { }
645 explicit HeapGraphPath(const List<HeapGraphEdge*>& path);
646
647 void Add(HeapGraphEdge* edge) { path_.Add(edge); }
648 void Set(int index, HeapGraphEdge* edge) { path_[index] = edge; }
649 const List<HeapGraphEdge*>* path() { return &path_; }
650
651 void Print();
652
653 private:
654 List<HeapGraphEdge*> path_;
655
656 DISALLOW_COPY_AND_ASSIGN(HeapGraphPath);
657 };
658
659
660 class HeapSnapshotsCollection; 630 class HeapSnapshotsCollection;
661 class HeapSnapshotsDiff;
662 631
663 // HeapSnapshot represents a single heap snapshot. It is stored in 632 // HeapSnapshot represents a single heap snapshot. It is stored in
664 // HeapSnapshotsCollection, which is also a factory for 633 // HeapSnapshotsCollection, which is also a factory for
665 // HeapSnapshots. All HeapSnapshots share strings copied from JS heap 634 // HeapSnapshots. All HeapSnapshots share strings copied from JS heap
666 // to be able to return them even if they were collected. 635 // to be able to return them even if they were collected.
667 // HeapSnapshotGenerator fills in a HeapSnapshot. 636 // HeapSnapshotGenerator fills in a HeapSnapshot.
668 class HeapSnapshot { 637 class HeapSnapshot {
669 public: 638 public:
670 enum Type { 639 enum Type {
671 kFull = v8::HeapSnapshot::kFull, 640 kFull = v8::HeapSnapshot::kFull,
(...skipping 21 matching lines...) Expand all
693 HeapEntry* AddEntry(HeapEntry::Type type, 662 HeapEntry* AddEntry(HeapEntry::Type type,
694 const char* name, 663 const char* name,
695 uint64_t id, 664 uint64_t id,
696 int size, 665 int size,
697 int children_count, 666 int children_count,
698 int retainers_count); 667 int retainers_count);
699 HeapEntry* AddRootEntry(int children_count); 668 HeapEntry* AddRootEntry(int children_count);
700 HeapEntry* AddGcRootsEntry(int children_count, int retainers_count); 669 HeapEntry* AddGcRootsEntry(int children_count, int retainers_count);
701 HeapEntry* AddNativesRootEntry(int children_count, int retainers_count); 670 HeapEntry* AddNativesRootEntry(int children_count, int retainers_count);
702 void ClearPaint(); 671 void ClearPaint();
703 HeapSnapshotsDiff* CompareWith(HeapSnapshot* snapshot);
704 HeapEntry* GetEntryById(uint64_t id); 672 HeapEntry* GetEntryById(uint64_t id);
705 List<HeapGraphPath*>* GetRetainingPaths(HeapEntry* entry);
706 List<HeapEntry*>* GetSortedEntriesList(); 673 List<HeapEntry*>* GetSortedEntriesList();
707 template<class Visitor> 674 template<class Visitor>
708 void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); } 675 void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); }
709 void SetDominatorsToSelf(); 676 void SetDominatorsToSelf();
710 677
711 void Print(int max_depth); 678 void Print(int max_depth);
712 void PrintEntriesSize(); 679 void PrintEntriesSize();
713 680
714 private: 681 private:
715 HeapEntry* GetNextEntryToInit(); 682 HeapEntry* GetNextEntryToInit();
716 683
717 HeapSnapshotsCollection* collection_; 684 HeapSnapshotsCollection* collection_;
718 Type type_; 685 Type type_;
719 const char* title_; 686 const char* title_;
720 unsigned uid_; 687 unsigned uid_;
721 HeapEntry* root_entry_; 688 HeapEntry* root_entry_;
722 HeapEntry* gc_roots_entry_; 689 HeapEntry* gc_roots_entry_;
723 HeapEntry* natives_root_entry_; 690 HeapEntry* natives_root_entry_;
724 char* raw_entries_; 691 char* raw_entries_;
725 List<HeapEntry*> entries_; 692 List<HeapEntry*> entries_;
726 bool entries_sorted_; 693 bool entries_sorted_;
727 HashMap retaining_paths_;
728 #ifdef DEBUG 694 #ifdef DEBUG
729 int raw_entries_size_; 695 int raw_entries_size_;
730 #endif 696 #endif
731 697
732 friend class HeapSnapshotTester; 698 friend class HeapSnapshotTester;
733 699
734 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); 700 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot);
735 }; 701 };
736 702
737 703
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 740
775 bool initial_fill_mode_; 741 bool initial_fill_mode_;
776 uint64_t next_id_; 742 uint64_t next_id_;
777 HashMap entries_map_; 743 HashMap entries_map_;
778 List<EntryInfo>* entries_; 744 List<EntryInfo>* entries_;
779 745
780 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap); 746 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap);
781 }; 747 };
782 748
783 749
784 class HeapSnapshotsDiff {
785 public:
786 HeapSnapshotsDiff(HeapSnapshot* snapshot1, HeapSnapshot* snapshot2)
787 : snapshot1_(snapshot1),
788 snapshot2_(snapshot2),
789 raw_additions_root_(NULL),
790 raw_deletions_root_(NULL) { }
791
792 ~HeapSnapshotsDiff() {
793 DeleteArray(raw_deletions_root_);
794 DeleteArray(raw_additions_root_);
795 }
796
797 void AddAddedEntry(int child_index, int index, HeapEntry* entry) {
798 additions_root()->SetUnidirElementReference(child_index, index, entry);
799 }
800
801 void AddDeletedEntry(int child_index, int index, HeapEntry* entry) {
802 deletions_root()->SetUnidirElementReference(child_index, index, entry);
803 }
804
805 void CreateRoots(int additions_count, int deletions_count);
806
807 HeapEntry* additions_root() {
808 return reinterpret_cast<HeapEntry*>(raw_additions_root_);
809 }
810 HeapEntry* deletions_root() {
811 return reinterpret_cast<HeapEntry*>(raw_deletions_root_);
812 }
813
814 private:
815 HeapSnapshot* snapshot1_;
816 HeapSnapshot* snapshot2_;
817 char* raw_additions_root_;
818 char* raw_deletions_root_;
819
820 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotsDiff);
821 };
822
823
824 class HeapSnapshotsComparator {
825 public:
826 HeapSnapshotsComparator() { }
827 ~HeapSnapshotsComparator();
828 HeapSnapshotsDiff* Compare(HeapSnapshot* snapshot1, HeapSnapshot* snapshot2);
829 private:
830 List<HeapSnapshotsDiff*> diffs_;
831
832 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotsComparator);
833 };
834
835
836 class HeapSnapshotsCollection { 750 class HeapSnapshotsCollection {
837 public: 751 public:
838 HeapSnapshotsCollection(); 752 HeapSnapshotsCollection();
839 ~HeapSnapshotsCollection(); 753 ~HeapSnapshotsCollection();
840 754
841 bool is_tracking_objects() { return is_tracking_objects_; } 755 bool is_tracking_objects() { return is_tracking_objects_; }
842 756
843 HeapSnapshot* NewSnapshot( 757 HeapSnapshot* NewSnapshot(
844 HeapSnapshot::Type type, const char* name, unsigned uid); 758 HeapSnapshot::Type type, const char* name, unsigned uid);
845 void SnapshotGenerationFinished(HeapSnapshot* snapshot); 759 void SnapshotGenerationFinished(HeapSnapshot* snapshot);
846 List<HeapSnapshot*>* snapshots() { return &snapshots_; } 760 List<HeapSnapshot*>* snapshots() { return &snapshots_; }
847 HeapSnapshot* GetSnapshot(unsigned uid); 761 HeapSnapshot* GetSnapshot(unsigned uid);
848 void RemoveSnapshot(HeapSnapshot* snapshot); 762 void RemoveSnapshot(HeapSnapshot* snapshot);
849 763
850 StringsStorage* names() { return &names_; } 764 StringsStorage* names() { return &names_; }
851 TokenEnumerator* token_enumerator() { return token_enumerator_; } 765 TokenEnumerator* token_enumerator() { return token_enumerator_; }
852 766
853 uint64_t GetObjectId(Address addr) { return ids_.FindObject(addr); } 767 uint64_t GetObjectId(Address addr) { return ids_.FindObject(addr); }
854 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); } 768 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); }
855 769
856 HeapSnapshotsDiff* CompareSnapshots(HeapSnapshot* snapshot1,
857 HeapSnapshot* snapshot2);
858
859 private: 770 private:
860 INLINE(static bool HeapSnapshotsMatch(void* key1, void* key2)) { 771 INLINE(static bool HeapSnapshotsMatch(void* key1, void* key2)) {
861 return key1 == key2; 772 return key1 == key2;
862 } 773 }
863 774
864 bool is_tracking_objects_; // Whether tracking object moves is needed. 775 bool is_tracking_objects_; // Whether tracking object moves is needed.
865 List<HeapSnapshot*> snapshots_; 776 List<HeapSnapshot*> snapshots_;
866 // Mapping from snapshots' uids to HeapSnapshot* pointers. 777 // Mapping from snapshots' uids to HeapSnapshot* pointers.
867 HashMap snapshots_uids_; 778 HashMap snapshots_uids_;
868 StringsStorage names_; 779 StringsStorage names_;
869 TokenEnumerator* token_enumerator_; 780 TokenEnumerator* token_enumerator_;
870 // Mapping from HeapObject addresses to objects' uids. 781 // Mapping from HeapObject addresses to objects' uids.
871 HeapObjectsMap ids_; 782 HeapObjectsMap ids_;
872 HeapSnapshotsComparator comparator_;
873 783
874 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotsCollection); 784 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotsCollection);
875 }; 785 };
876 786
877 787
878 // A typedef for referencing anything that can be snapshotted living 788 // A typedef for referencing anything that can be snapshotted living
879 // in any kind of heap memory. 789 // in any kind of heap memory.
880 typedef void* HeapThing; 790 typedef void* HeapThing;
881 791
882 792
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 }; 1115 };
1206 1116
1207 1117
1208 String* GetConstructorNameForHeapProfile(JSObject* object); 1118 String* GetConstructorNameForHeapProfile(JSObject* object);
1209 1119
1210 } } // namespace v8::internal 1120 } } // namespace v8::internal
1211 1121
1212 #endif // ENABLE_LOGGING_AND_PROFILING 1122 #endif // ENABLE_LOGGING_AND_PROFILING
1213 1123
1214 #endif // V8_PROFILE_GENERATOR_H_ 1124 #endif // V8_PROFILE_GENERATOR_H_
OLDNEW
« no previous file with comments | « src/preparser-api.cc ('k') | src/profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698