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

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

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

Powered by Google App Engine
This is Rietveld 408576698