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

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

Issue 3197010: Version 2.3.10... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 10 years, 4 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/objects-visiting.h ('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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 61
62 // Provides a storage of strings allocated in C++ heap, to hold them 62 // Provides a storage of strings allocated in C++ heap, to hold them
63 // forever, even if they disappear from JS heap or external storage. 63 // forever, even if they disappear from JS heap or external storage.
64 class StringsStorage { 64 class StringsStorage {
65 public: 65 public:
66 StringsStorage(); 66 StringsStorage();
67 ~StringsStorage(); 67 ~StringsStorage();
68 68
69 const char* GetName(String* name); 69 const char* GetName(String* name);
70 inline const char* GetFunctionName(String* name);
71 inline const char* GetFunctionName(const char* name);
70 72
71 private: 73 private:
72 INLINE(static bool StringsMatch(void* key1, void* key2)) { 74 INLINE(static bool StringsMatch(void* key1, void* key2)) {
73 return strcmp(reinterpret_cast<char*>(key1), 75 return strcmp(reinterpret_cast<char*>(key1),
74 reinterpret_cast<char*>(key2)) == 0; 76 reinterpret_cast<char*>(key2)) == 0;
75 } 77 }
76 78
77 // Mapping of strings by String::Hash to const char* strings. 79 // Mapping of strings by String::Hash to const char* strings.
78 HashMap names_; 80 HashMap names_;
79 81
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name); 293 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name);
292 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, 294 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag,
293 const char* name_prefix, String* name); 295 const char* name_prefix, String* name);
294 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, int args_count); 296 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, int args_count);
295 CodeEntry* NewCodeEntry(int security_token_id); 297 CodeEntry* NewCodeEntry(int security_token_id);
296 298
297 // Called from profile generator thread. 299 // Called from profile generator thread.
298 void AddPathToCurrentProfiles(const Vector<CodeEntry*>& path); 300 void AddPathToCurrentProfiles(const Vector<CodeEntry*>& path);
299 301
300 private: 302 private:
301 INLINE(const char* GetFunctionName(String* name));
302 INLINE(const char* GetFunctionName(const char* name));
303 const char* GetName(int args_count); 303 const char* GetName(int args_count);
304 const char* GetFunctionName(String* name) {
305 return function_and_resource_names_.GetFunctionName(name);
306 }
307 const char* GetFunctionName(const char* name) {
308 return function_and_resource_names_.GetFunctionName(name);
309 }
304 List<CpuProfile*>* GetProfilesList(int security_token_id); 310 List<CpuProfile*>* GetProfilesList(int security_token_id);
305 int TokenToIndex(int security_token_id); 311 int TokenToIndex(int security_token_id);
306 312
307 INLINE(static bool UidsMatch(void* key1, void* key2)) { 313 INLINE(static bool UidsMatch(void* key1, void* key2)) {
308 return key1 == key2; 314 return key1 == key2;
309 } 315 }
310 316
311 StringsStorage function_and_resource_names_; 317 StringsStorage function_and_resource_names_;
312 // Mapping from args_count (int) to char* strings. 318 // Mapping from args_count (int) to char* strings.
313 List<char*> args_count_names_; 319 List<char*> args_count_names_;
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 enum Type { 497 enum Type {
492 kInternal = v8::HeapGraphNode::kInternal, 498 kInternal = v8::HeapGraphNode::kInternal,
493 kArray = v8::HeapGraphNode::kArray, 499 kArray = v8::HeapGraphNode::kArray,
494 kString = v8::HeapGraphNode::kString, 500 kString = v8::HeapGraphNode::kString,
495 kObject = v8::HeapGraphNode::kObject, 501 kObject = v8::HeapGraphNode::kObject,
496 kCode = v8::HeapGraphNode::kCode, 502 kCode = v8::HeapGraphNode::kCode,
497 kClosure = v8::HeapGraphNode::kClosure 503 kClosure = v8::HeapGraphNode::kClosure
498 }; 504 };
499 505
500 HeapEntry() { } 506 HeapEntry() { }
501 void Init(HeapSnapshot* snapshot, int children_count, int retainers_count);
502 void Init(HeapSnapshot* snapshot, 507 void Init(HeapSnapshot* snapshot,
503 Type type, 508 Type type,
504 const char* name, 509 const char* name,
505 uint64_t id, 510 uint64_t id,
506 int self_size, 511 int self_size,
507 int children_count, 512 int children_count,
508 int retainers_count); 513 int retainers_count);
509 514
510 HeapSnapshot* snapshot() { return snapshot_; } 515 HeapSnapshot* snapshot() { return snapshot_; }
511 Type type() { return static_cast<Type>(type_); } 516 Type type() { return static_cast<Type>(type_); }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 class HeapSnapshotsCollection; 638 class HeapSnapshotsCollection;
634 class HeapSnapshotsDiff; 639 class HeapSnapshotsDiff;
635 640
636 // HeapSnapshot represents a single heap snapshot. It is stored in 641 // HeapSnapshot represents a single heap snapshot. It is stored in
637 // HeapSnapshotsCollection, which is also a factory for 642 // HeapSnapshotsCollection, which is also a factory for
638 // HeapSnapshots. All HeapSnapshots share strings copied from JS heap 643 // HeapSnapshots. All HeapSnapshots share strings copied from JS heap
639 // to be able to return them even if they were collected. 644 // to be able to return them even if they were collected.
640 // HeapSnapshotGenerator fills in a HeapSnapshot. 645 // HeapSnapshotGenerator fills in a HeapSnapshot.
641 class HeapSnapshot { 646 class HeapSnapshot {
642 public: 647 public:
648 enum Type {
649 kFull = v8::HeapSnapshot::kFull,
650 kAggregated = v8::HeapSnapshot::kAggregated
651 };
652
643 HeapSnapshot(HeapSnapshotsCollection* collection, 653 HeapSnapshot(HeapSnapshotsCollection* collection,
654 Type type,
644 const char* title, 655 const char* title,
645 unsigned uid); 656 unsigned uid);
646 ~HeapSnapshot(); 657 ~HeapSnapshot();
647 658
648 HeapSnapshotsCollection* collection() { return collection_; } 659 HeapSnapshotsCollection* collection() { return collection_; }
660 Type type() { return type_; }
649 const char* title() { return title_; } 661 const char* title() { return title_; }
650 unsigned uid() { return uid_; } 662 unsigned uid() { return uid_; }
651 HeapEntry* root() { return entries_[root_entry_index_]; } 663 HeapEntry* root() { return entries_[root_entry_index_]; }
652 664
653 void AllocateEntries( 665 void AllocateEntries(
654 int entries_count, int children_count, int retainers_count); 666 int entries_count, int children_count, int retainers_count);
655 HeapEntry* AddEntry( 667 HeapEntry* AddEntry(
656 HeapObject* object, int children_count, int retainers_count); 668 HeapObject* object, int children_count, int retainers_count);
657 bool WillAddEntry(HeapObject* object); 669 bool WillAddEntry(HeapObject* object);
670 HeapEntry* AddEntry(HeapEntry::Type type,
671 const char* name,
672 uint64_t id,
673 int size,
674 int children_count,
675 int retainers_count);
658 int AddCalculatedData(); 676 int AddCalculatedData();
659 HeapEntryCalculatedData& GetCalculatedData(int index) { 677 HeapEntryCalculatedData& GetCalculatedData(int index) {
660 return calculated_data_[index]; 678 return calculated_data_[index];
661 } 679 }
662 void ClearPaint(); 680 void ClearPaint();
663 HeapSnapshotsDiff* CompareWith(HeapSnapshot* snapshot); 681 HeapSnapshotsDiff* CompareWith(HeapSnapshot* snapshot);
664 List<HeapEntry*>* GetSortedEntriesList(); 682 List<HeapEntry*>* GetSortedEntriesList();
665 template<class Visitor> 683 template<class Visitor>
666 void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); } 684 void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); }
667 685
668 void Print(int max_depth); 686 void Print(int max_depth);
669 void PrintEntriesSize(); 687 void PrintEntriesSize();
670 688
671 static HeapObject *const kInternalRootObject; 689 static HeapObject *const kInternalRootObject;
672 690
673 private: 691 private:
674 HeapEntry* AddEntry(HeapObject* object, 692 HeapEntry* AddEntry(HeapObject* object,
675 HeapEntry::Type type, 693 HeapEntry::Type type,
676 const char* name, 694 const char* name,
677 int children_count, 695 int children_count,
678 int retainers_count); 696 int retainers_count);
679 HeapEntry* GetNextEntryToInit(); 697 HeapEntry* GetNextEntryToInit();
680 static int GetObjectSize(HeapObject* obj); 698 static int GetObjectSize(HeapObject* obj);
681 static int CalculateNetworkSize(JSObject* obj); 699 static int CalculateNetworkSize(JSObject* obj);
682 700
683 HeapSnapshotsCollection* collection_; 701 HeapSnapshotsCollection* collection_;
702 Type type_;
684 const char* title_; 703 const char* title_;
685 unsigned uid_; 704 unsigned uid_;
686 int root_entry_index_; 705 int root_entry_index_;
687 char* raw_entries_; 706 char* raw_entries_;
688 List<HeapEntry*> entries_; 707 List<HeapEntry*> entries_;
689 bool entries_sorted_; 708 bool entries_sorted_;
690 List<HeapEntryCalculatedData> calculated_data_; 709 List<HeapEntryCalculatedData> calculated_data_;
710 #ifdef DEBUG
711 int raw_entries_size_;
712 #endif
691 713
692 friend class HeapSnapshotTester; 714 friend class HeapSnapshotTester;
693 715
694 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); 716 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot);
695 }; 717 };
696 718
697 719
698 class HeapObjectsMap { 720 class HeapObjectsMap {
699 public: 721 public:
700 HeapObjectsMap(); 722 HeapObjectsMap();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 }; 807 };
786 808
787 809
788 class HeapSnapshotsCollection { 810 class HeapSnapshotsCollection {
789 public: 811 public:
790 HeapSnapshotsCollection(); 812 HeapSnapshotsCollection();
791 ~HeapSnapshotsCollection(); 813 ~HeapSnapshotsCollection();
792 814
793 bool is_tracking_objects() { return is_tracking_objects_; } 815 bool is_tracking_objects() { return is_tracking_objects_; }
794 816
795 HeapSnapshot* NewSnapshot(const char* name, unsigned uid); 817 HeapSnapshot* NewSnapshot(
818 HeapSnapshot::Type type, const char* name, unsigned uid);
796 void SnapshotGenerationFinished() { ids_.SnapshotGenerationFinished(); } 819 void SnapshotGenerationFinished() { ids_.SnapshotGenerationFinished(); }
797 List<HeapSnapshot*>* snapshots() { return &snapshots_; } 820 List<HeapSnapshot*>* snapshots() { return &snapshots_; }
798 HeapSnapshot* GetSnapshot(unsigned uid); 821 HeapSnapshot* GetSnapshot(unsigned uid);
799 822
800 const char* GetName(String* name) { return names_.GetName(name); } 823 const char* GetName(String* name) { return names_.GetName(name); }
824 const char* GetFunctionName(String* name) {
825 return names_.GetFunctionName(name);
826 }
801 827
802 TokenEnumerator* token_enumerator() { return token_enumerator_; } 828 TokenEnumerator* token_enumerator() { return token_enumerator_; }
803 829
804 uint64_t GetObjectId(Address addr) { return ids_.FindObject(addr); } 830 uint64_t GetObjectId(Address addr) { return ids_.FindObject(addr); }
805 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); } 831 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); }
806 832
807 HeapSnapshotsDiff* CompareSnapshots(HeapSnapshot* snapshot1, 833 HeapSnapshotsDiff* CompareSnapshots(HeapSnapshot* snapshot1,
808 HeapSnapshot* snapshot2); 834 HeapSnapshot* snapshot2);
809 835
810 private: 836 private:
(...skipping 30 matching lines...) Expand all
841 void CountReference(HeapObject* from, HeapObject* to, 867 void CountReference(HeapObject* from, HeapObject* to,
842 int* prev_children_count = NULL, 868 int* prev_children_count = NULL,
843 int* prev_retainers_count = NULL); 869 int* prev_retainers_count = NULL);
844 template<class Visitor> 870 template<class Visitor>
845 void UpdateEntries(Visitor* visitor); 871 void UpdateEntries(Visitor* visitor);
846 872
847 int entries_count() { return entries_count_; } 873 int entries_count() { return entries_count_; }
848 int total_children_count() { return total_children_count_; } 874 int total_children_count() { return total_children_count_; }
849 int total_retainers_count() { return total_retainers_count_; } 875 int total_retainers_count() { return total_retainers_count_; }
850 876
877 static HeapEntry *const kHeapEntryPlaceholder;
878
851 private: 879 private:
852 struct EntryInfo { 880 struct EntryInfo {
853 explicit EntryInfo(HeapEntry* entry) 881 explicit EntryInfo(HeapEntry* entry)
854 : entry(entry), children_count(0), retainers_count(0) { } 882 : entry(entry), children_count(0), retainers_count(0) { }
855 HeapEntry* entry; 883 HeapEntry* entry;
856 int children_count; 884 int children_count;
857 int retainers_count; 885 int retainers_count;
858 }; 886 };
859 887
860 uint32_t Hash(HeapObject* object) { 888 uint32_t Hash(HeapObject* object) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 Object* child_obj, 924 Object* child_obj,
897 HeapEntry* child_entry) = 0; 925 HeapEntry* child_entry) = 0;
898 virtual void SetNamedReference(HeapGraphEdge::Type type, 926 virtual void SetNamedReference(HeapGraphEdge::Type type,
899 HeapObject* parent_obj, 927 HeapObject* parent_obj,
900 HeapEntry* parent_entry, 928 HeapEntry* parent_entry,
901 const char* reference_name, 929 const char* reference_name,
902 Object* child_obj, 930 Object* child_obj,
903 HeapEntry* child_entry) = 0; 931 HeapEntry* child_entry) = 0;
904 virtual void SetRootReference(Object* child_obj, 932 virtual void SetRootReference(Object* child_obj,
905 HeapEntry* child_entry) = 0; 933 HeapEntry* child_entry) = 0;
906
907 static HeapEntry *const kHeapEntryPlaceholder;
908 }; 934 };
909 935
910 explicit HeapSnapshotGenerator(HeapSnapshot* snapshot); 936 explicit HeapSnapshotGenerator(HeapSnapshot* snapshot);
911 void GenerateSnapshot(); 937 void GenerateSnapshot();
912 938
913 private: 939 private:
914 HeapEntry* GetEntry(Object* obj); 940 HeapEntry* GetEntry(Object* obj);
915 int GetGlobalSecurityToken(); 941 int GetGlobalSecurityToken();
916 int GetObjectSecurityToken(HeapObject* obj); 942 int GetObjectSecurityToken(HeapObject* obj);
917 void ExtractReferences(HeapObject* obj); 943 void ExtractReferences(HeapObject* obj);
(...skipping 27 matching lines...) Expand all
945 friend class IndexedReferencesExtractor; 971 friend class IndexedReferencesExtractor;
946 972
947 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotGenerator); 973 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotGenerator);
948 }; 974 };
949 975
950 } } // namespace v8::internal 976 } } // namespace v8::internal
951 977
952 #endif // ENABLE_LOGGING_AND_PROFILING 978 #endif // ENABLE_LOGGING_AND_PROFILING
953 979
954 #endif // V8_PROFILE_GENERATOR_H_ 980 #endif // V8_PROFILE_GENERATOR_H_
OLDNEW
« no previous file with comments | « src/objects-visiting.h ('k') | src/profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698