Chromium Code Reviews| Index: src/profile-generator.h |
| diff --git a/src/profile-generator.h b/src/profile-generator.h |
| index 4762eb6342b711baff7691bcf352a4026e48581a..7c0a33fc4c94d37ac367020ea03513763a8ac059 100644 |
| --- a/src/profile-generator.h |
| +++ b/src/profile-generator.h |
| @@ -66,6 +66,8 @@ class StringsStorage { |
| StringsStorage(); |
| ~StringsStorage(); |
| + const char* PrintF(const char* format, ...); |
|
Vitaly Repeshko
2011/03/09 14:15:49
"PrintF" is a bad name. We don't actually print an
mnaganov (inactive)
2011/03/09 15:26:32
Renamed to GetFormatted and GetVFormatted, as it d
|
| + const char* VPrintF(const char* format, va_list args); |
| const char* GetName(String* name); |
| const char* GetName(int index); |
| inline const char* GetFunctionName(String* name); |
| @@ -76,11 +78,10 @@ class StringsStorage { |
| return strcmp(reinterpret_cast<char*>(key1), |
| reinterpret_cast<char*>(key2)) == 0; |
| } |
| + const char* AddOrDisposeString(char* str, uint32_t hash); |
| // Mapping of strings by String::Hash to const char* strings. |
| HashMap names_; |
| - // Mapping from ints to char* strings. |
| - List<char*> index_names_; |
| DISALLOW_COPY_AND_ASSIGN(StringsStorage); |
| }; |
| @@ -517,7 +518,8 @@ class HeapEntry BASE_EMBEDDED { |
| kCode = v8::HeapGraphNode::kCode, |
| kClosure = v8::HeapGraphNode::kClosure, |
| kRegExp = v8::HeapGraphNode::kRegExp, |
| - kHeapNumber = v8::HeapGraphNode::kHeapNumber |
| + kHeapNumber = v8::HeapGraphNode::kHeapNumber, |
| + kNative = v8::HeapGraphNode::kNative |
| }; |
| HeapEntry() { } |
| @@ -604,8 +606,8 @@ class HeapEntry BASE_EMBEDDED { |
| const char* TypeAsString(); |
| unsigned painted_: 2; |
| - unsigned type_: 3; |
| - int children_count_: 27; |
| + unsigned type_: 4; |
| + int children_count_: 26; |
| int retainers_count_; |
| int self_size_; |
| union { |
| @@ -677,6 +679,7 @@ class HeapSnapshot { |
| unsigned uid() { return uid_; } |
| HeapEntry* root() { return root_entry_; } |
| HeapEntry* gc_roots() { return gc_roots_entry_; } |
| + HeapEntry* dom_subtrees_root() { return dom_subtrees_root_entry_; } |
| List<HeapEntry*>* entries() { return &entries_; } |
| void AllocateEntries( |
| @@ -689,6 +692,7 @@ class HeapSnapshot { |
| int retainers_count); |
| HeapEntry* AddRootEntry(int children_count); |
| HeapEntry* AddGcRootsEntry(int children_count, int retainers_count); |
| + HeapEntry* AddNativesRootEntry(int children_count, int retainers_count); |
| void ClearPaint(); |
| HeapSnapshotsDiff* CompareWith(HeapSnapshot* snapshot); |
| HeapEntry* GetEntryById(uint64_t id); |
| @@ -710,6 +714,7 @@ class HeapSnapshot { |
| unsigned uid_; |
| HeapEntry* root_entry_; |
| HeapEntry* gc_roots_entry_; |
| + HeapEntry* dom_subtrees_root_entry_; |
| char* raw_entries_; |
| List<HeapEntry*> entries_; |
| bool entries_sorted_; |
| @@ -733,8 +738,11 @@ class HeapObjectsMap { |
| uint64_t FindObject(Address addr); |
| void MoveObject(Address from, Address to); |
| + static uint64_t GenerateId(v8::RetainedObjectInfo* info); |
| + |
| static const uint64_t kInternalRootObjectId; |
| static const uint64_t kGcRootsObjectId; |
| + static const uint64_t kNativesRootObjectId; |
| static const uint64_t kFirstAvailableObjectId; |
| private: |
| @@ -837,6 +845,7 @@ class HeapSnapshotsCollection { |
| const char* GetFunctionName(String* name) { |
| return names_.GetFunctionName(name); |
| } |
| + const char* PrintF(const char* format, ...); |
| TokenEnumerator* token_enumerator() { return token_enumerator_; } |
| @@ -950,8 +959,11 @@ class HeapObjectsSet { |
| class SnapshotFillerInterface { |
| public: |
| virtual ~SnapshotFillerInterface() { } |
| - virtual HeapEntry* AddEntry(HeapThing ptr) = 0; |
| - virtual HeapEntry* FindOrAddEntry(HeapThing ptr) = 0; |
| + virtual HeapEntry* AddEntry(HeapThing ptr, |
| + HeapEntriesAllocator* allocator) = 0; |
| + virtual HeapEntry* FindEntry(HeapThing ptr) = 0; |
| + virtual HeapEntry* FindOrAddEntry(HeapThing ptr, |
| + HeapEntriesAllocator* allocator) = 0; |
| virtual void SetIndexedReference(HeapGraphEdge::Type type, |
| HeapThing parent_ptr, |
| HeapEntry* parent_entry, |
| @@ -997,6 +1009,8 @@ class V8HeapExplorer : public HeapEntriesAllocator { |
| int EstimateObjectsCount(); |
| bool IterateAndExtractReferences(SnapshotFillerInterface* filler); |
| + static HeapObject* const kInternalRootObject; |
| + |
| private: |
| HeapEntry* AddEntry( |
| HeapObject* object, int children_count, int retainers_count); |
| @@ -1052,7 +1066,6 @@ class V8HeapExplorer : public HeapEntriesAllocator { |
| HeapObjectsSet known_references_; |
| SnapshotFillerInterface* filler_; |
| - static HeapObject* const kInternalRootObject; |
| static HeapObject* const kGcRootsObject; |
| friend class IndexedReferencesExtractor; |
| @@ -1062,6 +1075,54 @@ class V8HeapExplorer : public HeapEntriesAllocator { |
| }; |
| +// An implementation of retained native objects extractor. |
| +class NativeObjectsExplorer : public HeapEntriesAllocator { |
| + public: |
| + NativeObjectsExplorer(HeapSnapshot* snapshot, |
| + SnapshottingProgressReportingInterface* progress); |
| + ~NativeObjectsExplorer(); |
|
Vitaly Repeshko
2011/03/09 14:15:49
Please make the implicit "virtual" explicit.
mnaganov (inactive)
2011/03/09 15:26:32
Done.
|
| + virtual HeapEntry* AllocateEntry( |
| + HeapThing ptr, int children_count, int retainers_count); |
| + void AddRootEntries(SnapshotFillerInterface* filler); |
| + int EstimateObjectsCount(); |
| + bool IterateAndExtractReferences(SnapshotFillerInterface* filler); |
| + |
| + private: |
| + void FillRetainedObjects(); |
| + List<HeapObject*>* GetListMaybeDisposeInfo(v8::RetainedObjectInfo* info); |
| + void SetNativeRootReference(v8::RetainedObjectInfo* info); |
| + void SetRootNativesRootReference(); |
| + void SetWrapperNativeReferences(HeapObject* wrapper, |
| + v8::RetainedObjectInfo* info); |
| + void VisitSubtreeWrapper(Object** p, uint16_t class_id); |
| + |
| + static uint32_t InfoHash(v8::RetainedObjectInfo* info) { |
| + return ComputeIntegerHash(static_cast<uint32_t>(info->GetHash())); |
| + } |
| + static bool RetainedInfosMatch(void* key1, void* key2) { |
| + return key1 == key2 || |
| + (reinterpret_cast<v8::RetainedObjectInfo*>(key1))->IsEquivalent( |
| + reinterpret_cast<v8::RetainedObjectInfo*>(key2)); |
| + } |
| + |
| + HeapSnapshot* snapshot_; |
| + HeapSnapshotsCollection* collection_; |
| + SnapshottingProgressReportingInterface* progress_; |
| + bool embedder_queried_; |
| + HeapObjectsSet in_groups_; |
| + // RetainedObjectInfo* -> List<HeapObject*>* |
| + HashMap objects_by_info_; |
| + // Used during references extraction. |
| + SnapshotFillerInterface* filler_; |
| + |
| + static HeapThing const kNativesRootObject; |
| + |
| + friend class GlobalHandlesExtractor; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(NativeObjectsExplorer); |
| +}; |
| + |
| + |
| class HeapSnapshotGenerator : public SnapshottingProgressReportingInterface { |
| public: |
| HeapSnapshotGenerator(HeapSnapshot* snapshot, |
| @@ -1083,6 +1144,7 @@ class HeapSnapshotGenerator : public SnapshottingProgressReportingInterface { |
| HeapSnapshot* snapshot_; |
| v8::ActivityControl* control_; |
| V8HeapExplorer v8_heap_explorer_; |
| + NativeObjectsExplorer dom_explorer_; |
| // Mapping from HeapThing pointers to HeapEntry* pointers. |
| HeapEntriesMap entries_; |
| // Used during snapshot generation. |