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

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

Issue 9617006: Replace uint64_t type with ObjectId and use uint32_t as the base for ObjectId type. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Alexey's comment addressed. I've landed a patch for GetHash functuion. http://trac.webkit.org/chang… Created 8 years, 9 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 | « no previous file | src/profile-generator.cc » ('j') | src/profile-generator.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
28 #ifndef V8_PROFILE_GENERATOR_H_ 28 #ifndef V8_PROFILE_GENERATOR_H_
29 #define V8_PROFILE_GENERATOR_H_ 29 #define V8_PROFILE_GENERATOR_H_
30 30
31 #include "allocation.h" 31 #include "allocation.h"
32 #include "hashmap.h" 32 #include "hashmap.h"
33 #include "../include/v8-profiler.h" 33 #include "../include/v8-profiler.h"
34 34
35 namespace v8 { 35 namespace v8 {
36 namespace internal { 36 namespace internal {
37 37
38 typedef uint32_t SnapshotObjectId;
39
38 class TokenEnumerator { 40 class TokenEnumerator {
39 public: 41 public:
40 TokenEnumerator(); 42 TokenEnumerator();
41 ~TokenEnumerator(); 43 ~TokenEnumerator();
42 int GetTokenId(Object* token); 44 int GetTokenId(Object* token);
43 45
44 static const int kNoSecurityToken = -1; 46 static const int kNoSecurityToken = -1;
45 static const int kInheritsSecurityToken = -2; 47 static const int kInheritsSecurityToken = -2;
46 48
47 private: 49 private:
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 kRegExp = v8::HeapGraphNode::kRegExp, 528 kRegExp = v8::HeapGraphNode::kRegExp,
527 kHeapNumber = v8::HeapGraphNode::kHeapNumber, 529 kHeapNumber = v8::HeapGraphNode::kHeapNumber,
528 kNative = v8::HeapGraphNode::kNative, 530 kNative = v8::HeapGraphNode::kNative,
529 kSynthetic = v8::HeapGraphNode::kSynthetic 531 kSynthetic = v8::HeapGraphNode::kSynthetic
530 }; 532 };
531 533
532 HeapEntry() { } 534 HeapEntry() { }
533 void Init(HeapSnapshot* snapshot, 535 void Init(HeapSnapshot* snapshot,
534 Type type, 536 Type type,
535 const char* name, 537 const char* name,
536 uint64_t id, 538 SnapshotObjectId id,
537 int self_size, 539 int self_size,
538 int children_count, 540 int children_count,
539 int retainers_count); 541 int retainers_count);
540 542
541 HeapSnapshot* snapshot() { return snapshot_; } 543 HeapSnapshot* snapshot() { return snapshot_; }
542 Type type() { return static_cast<Type>(type_); } 544 Type type() { return static_cast<Type>(type_); }
543 const char* name() { return name_; } 545 const char* name() { return name_; }
544 void set_name(const char* name) { name_ = name; } 546 void set_name(const char* name) { name_ = name; }
545 inline uint64_t id(); 547 inline SnapshotObjectId id();
546 int self_size() { return self_size_; } 548 int self_size() { return self_size_; }
547 int retained_size() { return retained_size_; } 549 int retained_size() { return retained_size_; }
548 void add_retained_size(int size) { retained_size_ += size; } 550 void add_retained_size(int size) { retained_size_ += size; }
549 void set_retained_size(int value) { retained_size_ = value; } 551 void set_retained_size(int value) { retained_size_ = value; }
550 int ordered_index() { return ordered_index_; } 552 int ordered_index() { return ordered_index_; }
551 void set_ordered_index(int value) { ordered_index_ = value; } 553 void set_ordered_index(int value) { ordered_index_ = value; }
552 554
553 Vector<HeapGraphEdge> children() { 555 Vector<HeapGraphEdge> children() {
554 return Vector<HeapGraphEdge>(children_arr(), children_count_); } 556 return Vector<HeapGraphEdge>(children_arr(), children_count_); }
555 Vector<HeapGraphEdge*> retainers() { 557 Vector<HeapGraphEdge*> retainers() {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 HeapEntry* gc_roots() { return gc_roots_entry_; } 646 HeapEntry* gc_roots() { return gc_roots_entry_; }
645 HeapEntry* natives_root() { return natives_root_entry_; } 647 HeapEntry* natives_root() { return natives_root_entry_; }
646 HeapEntry* gc_subroot(int index) { return gc_subroot_entries_[index]; } 648 HeapEntry* gc_subroot(int index) { return gc_subroot_entries_[index]; }
647 List<HeapEntry*>* entries() { return &entries_; } 649 List<HeapEntry*>* entries() { return &entries_; }
648 int raw_entries_size() { return raw_entries_size_; } 650 int raw_entries_size() { return raw_entries_size_; }
649 651
650 void AllocateEntries( 652 void AllocateEntries(
651 int entries_count, int children_count, int retainers_count); 653 int entries_count, int children_count, int retainers_count);
652 HeapEntry* AddEntry(HeapEntry::Type type, 654 HeapEntry* AddEntry(HeapEntry::Type type,
653 const char* name, 655 const char* name,
654 uint64_t id, 656 SnapshotObjectId id,
655 int size, 657 int size,
656 int children_count, 658 int children_count,
657 int retainers_count); 659 int retainers_count);
658 HeapEntry* AddRootEntry(int children_count); 660 HeapEntry* AddRootEntry(int children_count);
659 HeapEntry* AddGcRootsEntry(int children_count, int retainers_count); 661 HeapEntry* AddGcRootsEntry(int children_count, int retainers_count);
660 HeapEntry* AddGcSubrootEntry(int tag, 662 HeapEntry* AddGcSubrootEntry(int tag,
661 int children_count, 663 int children_count,
662 int retainers_count); 664 int retainers_count);
663 HeapEntry* AddNativesRootEntry(int children_count, int retainers_count); 665 HeapEntry* AddNativesRootEntry(int children_count, int retainers_count);
664 void ClearPaint(); 666 void ClearPaint();
665 HeapEntry* GetEntryById(uint64_t id); 667 HeapEntry* GetEntryById(SnapshotObjectId id);
666 List<HeapEntry*>* GetSortedEntriesList(); 668 List<HeapEntry*>* GetSortedEntriesList();
667 template<class Visitor> 669 template<class Visitor>
668 void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); } 670 void IterateEntries(Visitor* visitor) { entries_.Iterate(visitor); }
669 void SetDominatorsToSelf(); 671 void SetDominatorsToSelf();
670 672
671 void Print(int max_depth); 673 void Print(int max_depth);
672 void PrintEntriesSize(); 674 void PrintEntriesSize();
673 675
674 private: 676 private:
675 HeapEntry* GetNextEntryToInit(); 677 HeapEntry* GetNextEntryToInit();
(...skipping 16 matching lines...) Expand all
692 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); 694 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot);
693 }; 695 };
694 696
695 697
696 class HeapObjectsMap { 698 class HeapObjectsMap {
697 public: 699 public:
698 HeapObjectsMap(); 700 HeapObjectsMap();
699 ~HeapObjectsMap(); 701 ~HeapObjectsMap();
700 702
701 void SnapshotGenerationFinished(); 703 void SnapshotGenerationFinished();
702 uint64_t FindObject(Address addr); 704 SnapshotObjectId FindObject(Address addr);
703 void MoveObject(Address from, Address to); 705 void MoveObject(Address from, Address to);
704 706
705 static uint64_t GenerateId(v8::RetainedObjectInfo* info); 707 static SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info);
706 static inline uint64_t GetNthGcSubrootId(int delta); 708 static inline SnapshotObjectId GetNthGcSubrootId(int delta);
707 709
708 static const int kObjectIdStep = 2; 710 static const int kObjectIdStep = 2;
709 static const uint64_t kInternalRootObjectId; 711 static const SnapshotObjectId kInternalRootObjectId;
710 static const uint64_t kGcRootsObjectId; 712 static const SnapshotObjectId kGcRootsObjectId;
711 static const uint64_t kNativesRootObjectId; 713 static const SnapshotObjectId kNativesRootObjectId;
712 static const uint64_t kGcRootsFirstSubrootId; 714 static const SnapshotObjectId kGcRootsFirstSubrootId;
713 static const uint64_t kFirstAvailableObjectId; 715 static const SnapshotObjectId kFirstAvailableObjectId;
714 716
715 private: 717 private:
716 struct EntryInfo { 718 struct EntryInfo {
717 explicit EntryInfo(uint64_t id) : id(id), accessed(true) { } 719 explicit EntryInfo(SnapshotObjectId id) : id(id), accessed(true) { }
718 EntryInfo(uint64_t id, bool accessed) : id(id), accessed(accessed) { } 720 EntryInfo(SnapshotObjectId id, bool accessed) : id(id), accessed(accessed) { }
719 uint64_t id; 721 SnapshotObjectId id;
720 bool accessed; 722 bool accessed;
721 }; 723 };
722 724
723 void AddEntry(Address addr, uint64_t id); 725 void AddEntry(Address addr, SnapshotObjectId id);
724 uint64_t FindEntry(Address addr); 726 SnapshotObjectId FindEntry(Address addr);
725 void RemoveDeadEntries(); 727 void RemoveDeadEntries();
726 728
727 static bool AddressesMatch(void* key1, void* key2) { 729 static bool AddressesMatch(void* key1, void* key2) {
728 return key1 == key2; 730 return key1 == key2;
729 } 731 }
730 732
731 static uint32_t AddressHash(Address addr) { 733 static uint32_t AddressHash(Address addr) {
732 return ComputeIntegerHash( 734 return ComputeIntegerHash(
733 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)), 735 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(addr)),
734 v8::internal::kZeroHashSeed); 736 v8::internal::kZeroHashSeed);
735 } 737 }
736 738
737 bool initial_fill_mode_; 739 bool initial_fill_mode_;
738 uint64_t next_id_; 740 SnapshotObjectId next_id_;
739 HashMap entries_map_; 741 HashMap entries_map_;
740 List<EntryInfo>* entries_; 742 List<EntryInfo>* entries_;
741 743
742 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap); 744 DISALLOW_COPY_AND_ASSIGN(HeapObjectsMap);
743 }; 745 };
744 746
745 747
746 class HeapSnapshotsCollection { 748 class HeapSnapshotsCollection {
747 public: 749 public:
748 HeapSnapshotsCollection(); 750 HeapSnapshotsCollection();
749 ~HeapSnapshotsCollection(); 751 ~HeapSnapshotsCollection();
750 752
751 bool is_tracking_objects() { return is_tracking_objects_; } 753 bool is_tracking_objects() { return is_tracking_objects_; }
752 754
753 HeapSnapshot* NewSnapshot( 755 HeapSnapshot* NewSnapshot(
754 HeapSnapshot::Type type, const char* name, unsigned uid); 756 HeapSnapshot::Type type, const char* name, unsigned uid);
755 void SnapshotGenerationFinished(HeapSnapshot* snapshot); 757 void SnapshotGenerationFinished(HeapSnapshot* snapshot);
756 List<HeapSnapshot*>* snapshots() { return &snapshots_; } 758 List<HeapSnapshot*>* snapshots() { return &snapshots_; }
757 HeapSnapshot* GetSnapshot(unsigned uid); 759 HeapSnapshot* GetSnapshot(unsigned uid);
758 void RemoveSnapshot(HeapSnapshot* snapshot); 760 void RemoveSnapshot(HeapSnapshot* snapshot);
759 761
760 StringsStorage* names() { return &names_; } 762 StringsStorage* names() { return &names_; }
761 TokenEnumerator* token_enumerator() { return token_enumerator_; } 763 TokenEnumerator* token_enumerator() { return token_enumerator_; }
762 764
763 uint64_t GetObjectId(Address addr) { return ids_.FindObject(addr); } 765 SnapshotObjectId GetObjectId(Address addr) { return ids_.FindObject(addr); }
764 Handle<HeapObject> FindHeapObjectById(uint64_t id); 766 Handle<HeapObject> FindHeapObjectById(SnapshotObjectId id);
765 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); } 767 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); }
766 768
767 private: 769 private:
768 INLINE(static bool HeapSnapshotsMatch(void* key1, void* key2)) { 770 INLINE(static bool HeapSnapshotsMatch(void* key1, void* key2)) {
769 return key1 == key2; 771 return key1 == key2;
770 } 772 }
771 773
772 bool is_tracking_objects_; // Whether tracking object moves is needed. 774 bool is_tracking_objects_; // Whether tracking object moves is needed.
773 List<HeapSnapshot*> snapshots_; 775 List<HeapSnapshot*> snapshots_;
774 // Mapping from snapshots' uids to HeapSnapshot* pointers. 776 // Mapping from snapshots' uids to HeapSnapshot* pointers.
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 1155
1154 friend class HeapSnapshotJSONSerializerEnumerator; 1156 friend class HeapSnapshotJSONSerializerEnumerator;
1155 friend class HeapSnapshotJSONSerializerIterator; 1157 friend class HeapSnapshotJSONSerializerIterator;
1156 1158
1157 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); 1159 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer);
1158 }; 1160 };
1159 1161
1160 } } // namespace v8::internal 1162 } } // namespace v8::internal
1161 1163
1162 #endif // V8_PROFILE_GENERATOR_H_ 1164 #endif // V8_PROFILE_GENERATOR_H_
OLDNEW
« no previous file with comments | « no previous file | src/profile-generator.cc » ('j') | src/profile-generator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698