Index: src/profile-generator.h |
diff --git a/src/profile-generator.h b/src/profile-generator.h |
index 4762eb6342b711baff7691bcf352a4026e48581a..553d7f233d010792d7e4d34ac80288abc0744588 100644 |
--- a/src/profile-generator.h |
+++ b/src/profile-generator.h |
@@ -66,6 +66,9 @@ class StringsStorage { |
StringsStorage(); |
~StringsStorage(); |
+ const char* GetCopy(const char* src); |
+ const char* GetFormatted(const char* format, ...); |
+ const char* GetVFormatted(const char* format, va_list args); |
const char* GetName(String* name); |
const char* GetName(int index); |
inline const char* GetFunctionName(String* name); |
@@ -76,11 +79,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 +519,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 +607,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 +680,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_; } |
Vitaly Repeshko
2011/03/09 19:10:08
"dom" -> "native"?
mnaganov (inactive)
2011/03/10 12:23:35
Done.
|
List<HeapEntry*>* entries() { return &entries_; } |
void AllocateEntries( |
@@ -689,6 +693,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 +715,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 +739,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: |
@@ -832,12 +841,7 @@ class HeapSnapshotsCollection { |
List<HeapSnapshot*>* snapshots() { return &snapshots_; } |
HeapSnapshot* GetSnapshot(unsigned uid); |
- const char* GetName(String* name) { return names_.GetName(name); } |
- const char* GetName(int index) { return names_.GetName(index); } |
- const char* GetFunctionName(String* name) { |
- return names_.GetFunctionName(name); |
- } |
- |
+ StringsStorage* names() { return &names_; } |
TokenEnumerator* token_enumerator() { return token_enumerator_; } |
uint64_t GetObjectId(Address addr) { return ids_.FindObject(addr); } |
@@ -950,8 +954,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, |
@@ -990,13 +997,15 @@ class V8HeapExplorer : public HeapEntriesAllocator { |
public: |
V8HeapExplorer(HeapSnapshot* snapshot, |
SnapshottingProgressReportingInterface* progress); |
- ~V8HeapExplorer(); |
+ virtual ~V8HeapExplorer(); |
virtual HeapEntry* AllocateEntry( |
HeapThing ptr, int children_count, int retainers_count); |
void AddRootEntries(SnapshotFillerInterface* filler); |
int EstimateObjectsCount(); |
bool IterateAndExtractReferences(SnapshotFillerInterface* filler); |
+ static HeapObject* const kInternalRootObject; |
+ |
private: |
HeapEntry* AddEntry( |
HeapObject* object, int children_count, int retainers_count); |
@@ -1052,7 +1061,6 @@ class V8HeapExplorer : public HeapEntriesAllocator { |
HeapObjectsSet known_references_; |
SnapshotFillerInterface* filler_; |
- static HeapObject* const kInternalRootObject; |
static HeapObject* const kGcRootsObject; |
friend class IndexedReferencesExtractor; |
@@ -1062,6 +1070,54 @@ class V8HeapExplorer : public HeapEntriesAllocator { |
}; |
+// An implementation of retained native objects extractor. |
+class NativeObjectsExplorer : public HeapEntriesAllocator { |
+ public: |
+ NativeObjectsExplorer(HeapSnapshot* snapshot, |
+ SnapshottingProgressReportingInterface* progress); |
+ virtual ~NativeObjectsExplorer(); |
+ 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 +1139,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. |