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

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

Issue 5862002: Version 3.0.2. (Closed)
Patch Set: Created 10 years 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
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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 Type type, 519 Type type,
520 const char* name, 520 const char* name,
521 uint64_t id, 521 uint64_t id,
522 int self_size, 522 int self_size,
523 int children_count, 523 int children_count,
524 int retainers_count); 524 int retainers_count);
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 inline uint64_t id(); 529 uint64_t id();
530 int self_size() { return self_size_; } 530 int self_size() { return self_size_; }
531 int retained_size() { return retained_size_; } 531 int retained_size() { return retained_size_; }
532 void add_retained_size(int size) { retained_size_ += size; } 532 void add_retained_size(int size) { retained_size_ += size; }
533 void set_retained_size(int value) { retained_size_ = value; } 533 void set_retained_size(int value) { retained_size_ = value; }
534 int ordered_index() { return ordered_index_; } 534 int ordered_index() { return ordered_index_; }
535 void set_ordered_index(int value) { ordered_index_ = value; } 535 void set_ordered_index(int value) { ordered_index_ = value; }
536 536
537 Vector<HeapGraphEdge> children() { 537 Vector<HeapGraphEdge> children() {
538 return Vector<HeapGraphEdge>(children_arr(), children_count_); } 538 return Vector<HeapGraphEdge>(children_arr(), children_count_); }
539 Vector<HeapGraphEdge*> retainers() { 539 Vector<HeapGraphEdge*> retainers() {
(...skipping 11 matching lines...) Expand all
551 bool not_painted_reachable_from_others() { 551 bool not_painted_reachable_from_others() {
552 return painted_ != kPaintedReachableFromOthers; 552 return painted_ != kPaintedReachableFromOthers;
553 } 553 }
554 void paint_reachable_from_others() { 554 void paint_reachable_from_others() {
555 painted_ = kPaintedReachableFromOthers; 555 painted_ = kPaintedReachableFromOthers;
556 } 556 }
557 template<class Visitor> 557 template<class Visitor>
558 void ApplyAndPaintAllReachable(Visitor* visitor); 558 void ApplyAndPaintAllReachable(Visitor* visitor);
559 void PaintAllReachable(); 559 void PaintAllReachable();
560 560
561 bool is_leaf() { return painted_ == kLeaf; }
562 void set_leaf() { painted_ = kLeaf; }
563 bool is_non_leaf() { return painted_ == kNonLeaf; }
564 void set_non_leaf() { painted_ = kNonLeaf; }
565 bool is_processed() { return painted_ == kProcessed; }
566 void set_processed() { painted_ = kProcessed; }
567
561 void SetIndexedReference(HeapGraphEdge::Type type, 568 void SetIndexedReference(HeapGraphEdge::Type type,
562 int child_index, 569 int child_index,
563 int index, 570 int index,
564 HeapEntry* entry, 571 HeapEntry* entry,
565 int retainer_index); 572 int retainer_index);
566 void SetNamedReference(HeapGraphEdge::Type type, 573 void SetNamedReference(HeapGraphEdge::Type type,
567 int child_index, 574 int child_index,
568 const char* name, 575 const char* name,
569 HeapEntry* entry, 576 HeapEntry* entry,
570 int retainer_index); 577 int retainer_index);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 struct Id { 618 struct Id {
612 uint32_t id1_; 619 uint32_t id1_;
613 uint32_t id2_; 620 uint32_t id2_;
614 } id_; // This is to avoid extra padding of 64-bit value. 621 } id_; // This is to avoid extra padding of 64-bit value.
615 const char* name_; 622 const char* name_;
616 623
617 // Paints used for exact retained sizes calculation. 624 // Paints used for exact retained sizes calculation.
618 static const unsigned kUnpainted = 0; 625 static const unsigned kUnpainted = 0;
619 static const unsigned kPainted = 1; 626 static const unsigned kPainted = 1;
620 static const unsigned kPaintedReachableFromOthers = 2; 627 static const unsigned kPaintedReachableFromOthers = 2;
628 // Paints used for approximate retained sizes calculation.
629 static const unsigned kLeaf = 0;
630 static const unsigned kNonLeaf = 1;
631 static const unsigned kProcessed = 2;
621 632
622 static const int kExactRetainedSizeTag = 1; 633 static const int kExactRetainedSizeTag = 1;
623 634
624 DISALLOW_COPY_AND_ASSIGN(HeapEntry); 635 DISALLOW_COPY_AND_ASSIGN(HeapEntry);
625 }; 636 };
626 637
627 638
628 class HeapGraphPath { 639 class HeapGraphPath {
629 public: 640 public:
630 HeapGraphPath() 641 HeapGraphPath()
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 const char* title, 675 const char* title,
665 unsigned uid); 676 unsigned uid);
666 ~HeapSnapshot(); 677 ~HeapSnapshot();
667 678
668 HeapSnapshotsCollection* collection() { return collection_; } 679 HeapSnapshotsCollection* collection() { return collection_; }
669 Type type() { return type_; } 680 Type type() { return type_; }
670 const char* title() { return title_; } 681 const char* title() { return title_; }
671 unsigned uid() { return uid_; } 682 unsigned uid() { return uid_; }
672 HeapEntry* root() { return root_entry_; } 683 HeapEntry* root() { return root_entry_; }
673 HeapEntry* gc_roots() { return gc_roots_entry_; } 684 HeapEntry* gc_roots() { return gc_roots_entry_; }
674 List<HeapEntry*>* entries() { return &entries_; }
675 685
676 void AllocateEntries( 686 void AllocateEntries(
677 int entries_count, int children_count, int retainers_count); 687 int entries_count, int children_count, int retainers_count);
678 HeapEntry* AddEntry( 688 HeapEntry* AddEntry(
679 HeapObject* object, int children_count, int retainers_count); 689 HeapObject* object, int children_count, int retainers_count);
680 HeapEntry* AddEntry(HeapEntry::Type type, 690 HeapEntry* AddEntry(HeapEntry::Type type,
681 const char* name, 691 const char* name,
682 uint64_t id, 692 uint64_t id,
683 int size, 693 int size,
684 int children_count, 694 int children_count,
685 int retainers_count); 695 int retainers_count);
696 void ApproximateRetainedSizes();
686 void ClearPaint(); 697 void ClearPaint();
687 HeapSnapshotsDiff* CompareWith(HeapSnapshot* snapshot); 698 HeapSnapshotsDiff* CompareWith(HeapSnapshot* snapshot);
688 HeapEntry* GetEntryById(uint64_t id); 699 HeapEntry* GetEntryById(uint64_t id);
689 List<HeapGraphPath*>* GetRetainingPaths(HeapEntry* entry); 700 List<HeapGraphPath*>* GetRetainingPaths(HeapEntry* entry);
690 List<HeapEntry*>* GetSortedEntriesList(); 701 List<HeapEntry*>* GetSortedEntriesList();
691 template<class Visitor> 702 template<class Visitor>
692 void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); } 703 void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); }
693 void SetDominatorsToSelf(); 704 void SetDominatorsToSelf();
694 705
695 void Print(int max_depth); 706 void Print(int max_depth);
696 void PrintEntriesSize(); 707 void PrintEntriesSize();
697 708
698 static HeapObject* const kInternalRootObject; 709 static HeapObject* const kInternalRootObject;
699 static HeapObject* const kGcRootsObject; 710 static HeapObject* const kGcRootsObject;
700 711
701 private: 712 private:
702 HeapEntry* AddEntry(HeapObject* object, 713 HeapEntry* AddEntry(HeapObject* object,
703 HeapEntry::Type type, 714 HeapEntry::Type type,
704 const char* name, 715 const char* name,
705 int children_count, 716 int children_count,
706 int retainers_count); 717 int retainers_count);
707 HeapEntry* GetNextEntryToInit(); 718 HeapEntry* GetNextEntryToInit();
719 void BuildDominatorTree(const Vector<HeapEntry*>& entries,
720 Vector<HeapEntry*>* dominators);
721 void FillReversePostorderIndexes(Vector<HeapEntry*>* entries);
722 void SetEntriesDominators();
708 723
709 HeapSnapshotsCollection* collection_; 724 HeapSnapshotsCollection* collection_;
710 Type type_; 725 Type type_;
711 const char* title_; 726 const char* title_;
712 unsigned uid_; 727 unsigned uid_;
713 HeapEntry* root_entry_; 728 HeapEntry* root_entry_;
714 HeapEntry* gc_roots_entry_; 729 HeapEntry* gc_roots_entry_;
715 char* raw_entries_; 730 char* raw_entries_;
716 List<HeapEntry*> entries_; 731 List<HeapEntry*> entries_;
717 bool entries_sorted_; 732 bool entries_sorted_;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 838
824 class HeapSnapshotsCollection { 839 class HeapSnapshotsCollection {
825 public: 840 public:
826 HeapSnapshotsCollection(); 841 HeapSnapshotsCollection();
827 ~HeapSnapshotsCollection(); 842 ~HeapSnapshotsCollection();
828 843
829 bool is_tracking_objects() { return is_tracking_objects_; } 844 bool is_tracking_objects() { return is_tracking_objects_; }
830 845
831 HeapSnapshot* NewSnapshot( 846 HeapSnapshot* NewSnapshot(
832 HeapSnapshot::Type type, const char* name, unsigned uid); 847 HeapSnapshot::Type type, const char* name, unsigned uid);
833 void SnapshotGenerationFinished(HeapSnapshot* snapshot); 848 void SnapshotGenerationFinished() { ids_.SnapshotGenerationFinished(); }
834 List<HeapSnapshot*>* snapshots() { return &snapshots_; } 849 List<HeapSnapshot*>* snapshots() { return &snapshots_; }
835 HeapSnapshot* GetSnapshot(unsigned uid); 850 HeapSnapshot* GetSnapshot(unsigned uid);
836 851
837 const char* GetName(String* name) { return names_.GetName(name); } 852 const char* GetName(String* name) { return names_.GetName(name); }
838 const char* GetName(int index) { return names_.GetName(index); } 853 const char* GetName(int index) { return names_.GetName(index); }
839 const char* GetFunctionName(String* name) { 854 const char* GetFunctionName(String* name) {
840 return names_.GetFunctionName(name); 855 return names_.GetFunctionName(name);
841 } 856 }
842 857
843 TokenEnumerator* token_enumerator() { return token_enumerator_; } 858 TokenEnumerator* token_enumerator() { return token_enumerator_; }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 const char* reference_name, 961 const char* reference_name,
947 Object* child_obj, 962 Object* child_obj,
948 HeapEntry* child_entry) = 0; 963 HeapEntry* child_entry) = 0;
949 virtual void SetRootGcRootsReference() = 0; 964 virtual void SetRootGcRootsReference() = 0;
950 virtual void SetRootShortcutReference(Object* child_obj, 965 virtual void SetRootShortcutReference(Object* child_obj,
951 HeapEntry* child_entry) = 0; 966 HeapEntry* child_entry) = 0;
952 virtual void SetStrongRootReference(Object* child_obj, 967 virtual void SetStrongRootReference(Object* child_obj,
953 HeapEntry* child_entry) = 0; 968 HeapEntry* child_entry) = 0;
954 }; 969 };
955 970
956 HeapSnapshotGenerator(HeapSnapshot* snapshot, 971 explicit HeapSnapshotGenerator(HeapSnapshot* snapshot);
957 v8::ActivityControl* control); 972 void GenerateSnapshot();
958 bool GenerateSnapshot();
959 973
960 private: 974 private:
961 bool ApproximateRetainedSizes();
962 bool BuildDominatorTree(const Vector<HeapEntry*>& entries,
963 Vector<HeapEntry*>* dominators);
964 bool CountEntriesAndReferences();
965 HeapEntry* GetEntry(Object* obj); 975 HeapEntry* GetEntry(Object* obj);
966 void IncProgressCounter() { ++progress_counter_; }
967 void ExtractReferences(HeapObject* obj); 976 void ExtractReferences(HeapObject* obj);
968 void ExtractClosureReferences(JSObject* js_obj, HeapEntry* entry); 977 void ExtractClosureReferences(JSObject* js_obj, HeapEntry* entry);
969 void ExtractPropertyReferences(JSObject* js_obj, HeapEntry* entry); 978 void ExtractPropertyReferences(JSObject* js_obj, HeapEntry* entry);
970 void ExtractElementReferences(JSObject* js_obj, HeapEntry* entry); 979 void ExtractElementReferences(JSObject* js_obj, HeapEntry* entry);
971 void ExtractInternalReferences(JSObject* js_obj, HeapEntry* entry); 980 void ExtractInternalReferences(JSObject* js_obj, HeapEntry* entry);
972 bool FillReferences();
973 void FillReversePostorderIndexes(Vector<HeapEntry*>* entries);
974 bool IterateAndExtractReferences();
975 inline bool ReportProgress(bool force = false);
976 bool SetEntriesDominators();
977 void SetClosureReference(HeapObject* parent_obj, 981 void SetClosureReference(HeapObject* parent_obj,
978 HeapEntry* parent, 982 HeapEntry* parent,
979 String* reference_name, 983 String* reference_name,
980 Object* child); 984 Object* child);
981 void SetElementReference(HeapObject* parent_obj, 985 void SetElementReference(HeapObject* parent_obj,
982 HeapEntry* parent, 986 HeapEntry* parent,
983 int index, 987 int index,
984 Object* child); 988 Object* child);
985 void SetInternalReference(HeapObject* parent_obj, 989 void SetInternalReference(HeapObject* parent_obj,
986 HeapEntry* parent, 990 HeapEntry* parent,
(...skipping 11 matching lines...) Expand all
998 HeapEntry* parent, 1002 HeapEntry* parent,
999 String* reference_name, 1003 String* reference_name,
1000 Object* child); 1004 Object* child);
1001 void SetPropertyShortcutReference(HeapObject* parent_obj, 1005 void SetPropertyShortcutReference(HeapObject* parent_obj,
1002 HeapEntry* parent, 1006 HeapEntry* parent,
1003 String* reference_name, 1007 String* reference_name,
1004 Object* child); 1008 Object* child);
1005 void SetRootShortcutReference(Object* child); 1009 void SetRootShortcutReference(Object* child);
1006 void SetRootGcRootsReference(); 1010 void SetRootGcRootsReference();
1007 void SetGcRootsReference(Object* child); 1011 void SetGcRootsReference(Object* child);
1008 void SetProgressTotal(int iterations_count);
1009 1012
1010 HeapSnapshot* snapshot_; 1013 HeapSnapshot* snapshot_;
1011 v8::ActivityControl* control_;
1012 HeapSnapshotsCollection* collection_; 1014 HeapSnapshotsCollection* collection_;
1013 // Mapping from HeapObject* pointers to HeapEntry* pointers. 1015 // Mapping from HeapObject* pointers to HeapEntry* pointers.
1014 HeapEntriesMap entries_; 1016 HeapEntriesMap entries_;
1015 SnapshotFillerInterface* filler_; 1017 SnapshotFillerInterface* filler_;
1016 // Used during references extraction to mark heap objects that 1018 // Used during references extraction to mark heap objects that
1017 // are references via non-hidden properties. 1019 // are references via non-hidden properties.
1018 HeapObjectsSet known_references_; 1020 HeapObjectsSet known_references_;
1019 // Used during snapshot generation.
1020 int progress_counter_;
1021 int progress_total_;
1022 1021
1023 friend class IndexedReferencesExtractor; 1022 friend class IndexedReferencesExtractor;
1024 friend class RootsReferencesExtractor; 1023 friend class RootsReferencesExtractor;
1025 1024
1026 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotGenerator); 1025 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotGenerator);
1027 }; 1026 };
1028 1027
1029 class OutputStreamWriter; 1028 class OutputStreamWriter;
1030 1029
1031 class HeapSnapshotJSONSerializer { 1030 class HeapSnapshotJSONSerializer {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 }; 1075 };
1077 1076
1078 1077
1079 String* GetConstructorNameForHeapProfile(JSObject* object); 1078 String* GetConstructorNameForHeapProfile(JSObject* object);
1080 1079
1081 } } // namespace v8::internal 1080 } } // namespace v8::internal
1082 1081
1083 #endif // ENABLE_LOGGING_AND_PROFILING 1082 #endif // ENABLE_LOGGING_AND_PROFILING
1084 1083
1085 #endif // V8_PROFILE_GENERATOR_H_ 1084 #endif // V8_PROFILE_GENERATOR_H_
OLDNEW
« ChangeLog ('K') | « src/preparser-api.cc ('k') | src/profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698