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

Side by Side Diff: src/heap-snapshot-generator.h

Issue 590833002: Simplify synthetic roots creation in heap snapshot (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed compilation failire in dbg mode Created 6 years, 3 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/heap-snapshot-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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_HEAP_SNAPSHOT_GENERATOR_H_ 5 #ifndef V8_HEAP_SNAPSHOT_GENERATOR_H_
6 #define V8_HEAP_SNAPSHOT_GENERATOR_H_ 6 #define V8_HEAP_SNAPSHOT_GENERATOR_H_
7 7
8 #include "src/profile-generator-inl.h" 8 #include "src/profile-generator-inl.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 Type type, 93 Type type,
94 const char* name, 94 const char* name,
95 SnapshotObjectId id, 95 SnapshotObjectId id,
96 size_t self_size, 96 size_t self_size,
97 unsigned trace_node_id); 97 unsigned trace_node_id);
98 98
99 HeapSnapshot* snapshot() { return snapshot_; } 99 HeapSnapshot* snapshot() { return snapshot_; }
100 Type type() { return static_cast<Type>(type_); } 100 Type type() { return static_cast<Type>(type_); }
101 const char* name() { return name_; } 101 const char* name() { return name_; }
102 void set_name(const char* name) { name_ = name; } 102 void set_name(const char* name) { name_ = name; }
103 inline SnapshotObjectId id() { return id_; } 103 SnapshotObjectId id() { return id_; }
104 size_t self_size() { return self_size_; } 104 size_t self_size() { return self_size_; }
105 unsigned trace_node_id() const { return trace_node_id_; } 105 unsigned trace_node_id() const { return trace_node_id_; }
106 INLINE(int index() const); 106 INLINE(int index() const);
107 int children_count() const { return children_count_; } 107 int children_count() const { return children_count_; }
108 INLINE(int set_children_index(int index)); 108 INLINE(int set_children_index(int index));
109 void add_child(HeapGraphEdge* edge) { 109 void add_child(HeapGraphEdge* edge) {
110 children_arr()[children_count_++] = edge; 110 children_arr()[children_count_++] = edge;
111 } 111 }
112 Vector<HeapGraphEdge*> children() { 112 Vector<HeapGraphEdge*> children() {
113 return Vector<HeapGraphEdge*>(children_arr(), children_count_); } 113 return Vector<HeapGraphEdge*>(children_arr(), children_count_); }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 const char* title, 147 const char* title,
148 unsigned uid); 148 unsigned uid);
149 void Delete(); 149 void Delete();
150 150
151 HeapProfiler* profiler() { return profiler_; } 151 HeapProfiler* profiler() { return profiler_; }
152 const char* title() { return title_; } 152 const char* title() { return title_; }
153 unsigned uid() { return uid_; } 153 unsigned uid() { return uid_; }
154 size_t RawSnapshotSize() const; 154 size_t RawSnapshotSize() const;
155 HeapEntry* root() { return &entries_[root_index_]; } 155 HeapEntry* root() { return &entries_[root_index_]; }
156 HeapEntry* gc_roots() { return &entries_[gc_roots_index_]; } 156 HeapEntry* gc_roots() { return &entries_[gc_roots_index_]; }
157 HeapEntry* natives_root() { return &entries_[natives_root_index_]; }
158 HeapEntry* gc_subroot(int index) { 157 HeapEntry* gc_subroot(int index) {
159 return &entries_[gc_subroot_indexes_[index]]; 158 return &entries_[gc_subroot_indexes_[index]];
160 } 159 }
161 List<HeapEntry>& entries() { return entries_; } 160 List<HeapEntry>& entries() { return entries_; }
162 List<HeapGraphEdge>& edges() { return edges_; } 161 List<HeapGraphEdge>& edges() { return edges_; }
163 List<HeapGraphEdge*>& children() { return children_; } 162 List<HeapGraphEdge*>& children() { return children_; }
164 void RememberLastJSObjectId(); 163 void RememberLastJSObjectId();
165 SnapshotObjectId max_snapshot_js_object_id() const { 164 SnapshotObjectId max_snapshot_js_object_id() const {
166 return max_snapshot_js_object_id_; 165 return max_snapshot_js_object_id_;
167 } 166 }
168 167
169 HeapEntry* AddEntry(HeapEntry::Type type, 168 HeapEntry* AddEntry(HeapEntry::Type type,
170 const char* name, 169 const char* name,
171 SnapshotObjectId id, 170 SnapshotObjectId id,
172 size_t size, 171 size_t size,
173 unsigned trace_node_id); 172 unsigned trace_node_id);
174 HeapEntry* AddRootEntry(); 173 void AddSyntheticRootEntries();
175 HeapEntry* AddGcRootsEntry();
176 HeapEntry* AddGcSubrootEntry(int tag);
177 HeapEntry* AddNativesRootEntry();
178 HeapEntry* GetEntryById(SnapshotObjectId id); 174 HeapEntry* GetEntryById(SnapshotObjectId id);
179 List<HeapEntry*>* GetSortedEntriesList(); 175 List<HeapEntry*>* GetSortedEntriesList();
180 void FillChildren(); 176 void FillChildren();
181 177
182 void Print(int max_depth); 178 void Print(int max_depth);
183 void PrintEntriesSize(); 179 void PrintEntriesSize();
184 180
185 private: 181 private:
182 HeapEntry* AddRootEntry();
183 HeapEntry* AddGcRootsEntry();
184 HeapEntry* AddGcSubrootEntry(int tag, SnapshotObjectId id);
185
186 HeapProfiler* profiler_; 186 HeapProfiler* profiler_;
187 const char* title_; 187 const char* title_;
188 unsigned uid_; 188 unsigned uid_;
189 int root_index_; 189 int root_index_;
190 int gc_roots_index_; 190 int gc_roots_index_;
191 int natives_root_index_;
192 int gc_subroot_indexes_[VisitorSynchronization::kNumberOfSyncTags]; 191 int gc_subroot_indexes_[VisitorSynchronization::kNumberOfSyncTags];
193 List<HeapEntry> entries_; 192 List<HeapEntry> entries_;
194 List<HeapGraphEdge> edges_; 193 List<HeapGraphEdge> edges_;
195 List<HeapGraphEdge*> children_; 194 List<HeapGraphEdge*> children_;
196 List<HeapEntry*> sorted_entries_; 195 List<HeapEntry*> sorted_entries_;
197 SnapshotObjectId max_snapshot_js_object_id_; 196 SnapshotObjectId max_snapshot_js_object_id_;
198 197
199 friend class HeapSnapshotTester; 198 friend class HeapSnapshotTester;
200 199
201 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); 200 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot);
(...skipping 14 matching lines...) Expand all
216 void UpdateObjectSize(Address addr, int size); 215 void UpdateObjectSize(Address addr, int size);
217 SnapshotObjectId last_assigned_id() const { 216 SnapshotObjectId last_assigned_id() const {
218 return next_id_ - kObjectIdStep; 217 return next_id_ - kObjectIdStep;
219 } 218 }
220 219
221 void StopHeapObjectsTracking(); 220 void StopHeapObjectsTracking();
222 SnapshotObjectId PushHeapObjectsStats(OutputStream* stream); 221 SnapshotObjectId PushHeapObjectsStats(OutputStream* stream);
223 size_t GetUsedMemorySize() const; 222 size_t GetUsedMemorySize() const;
224 223
225 SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info); 224 SnapshotObjectId GenerateId(v8::RetainedObjectInfo* info);
226 static inline SnapshotObjectId GetNthGcSubrootId(int delta);
227 225
228 static const int kObjectIdStep = 2; 226 static const int kObjectIdStep = 2;
229 static const SnapshotObjectId kInternalRootObjectId; 227 static const SnapshotObjectId kInternalRootObjectId;
230 static const SnapshotObjectId kGcRootsObjectId; 228 static const SnapshotObjectId kGcRootsObjectId;
231 static const SnapshotObjectId kNativesRootObjectId;
232 static const SnapshotObjectId kGcRootsFirstSubrootId; 229 static const SnapshotObjectId kGcRootsFirstSubrootId;
233 static const SnapshotObjectId kFirstAvailableObjectId; 230 static const SnapshotObjectId kFirstAvailableObjectId;
234 231
235 int FindUntrackedObjects(); 232 int FindUntrackedObjects();
236 233
237 void UpdateHeapObjectsMap(); 234 void UpdateHeapObjectsMap();
238 void RemoveDeadEntries(); 235 void RemoveDeadEntries();
239 236
240 private: 237 private:
241 struct EntryInfo { 238 struct EntryInfo {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 void TagGlobalObjects(); 338 void TagGlobalObjects();
342 void TagCodeObject(Code* code); 339 void TagCodeObject(Code* code);
343 void TagBuiltinCodeObject(Code* code, const char* name); 340 void TagBuiltinCodeObject(Code* code, const char* name);
344 HeapEntry* AddEntry(Address address, 341 HeapEntry* AddEntry(Address address,
345 HeapEntry::Type type, 342 HeapEntry::Type type,
346 const char* name, 343 const char* name,
347 size_t size); 344 size_t size);
348 345
349 static String* GetConstructorName(JSObject* object); 346 static String* GetConstructorName(JSObject* object);
350 347
351 static HeapObject* const kInternalRootObject;
352
353 private: 348 private:
354 typedef bool (V8HeapExplorer::*ExtractReferencesMethod)(int entry, 349 typedef bool (V8HeapExplorer::*ExtractReferencesMethod)(int entry,
355 HeapObject* object); 350 HeapObject* object);
356 351
357 HeapEntry* AddEntry(HeapObject* object); 352 HeapEntry* AddEntry(HeapObject* object);
358 HeapEntry* AddEntry(HeapObject* object, 353 HeapEntry* AddEntry(HeapObject* object,
359 HeapEntry::Type type, 354 HeapEntry::Type type,
360 const char* name); 355 const char* name);
361 356
362 const char* GetSystemEntryName(HeapObject* object); 357 const char* GetSystemEntryName(HeapObject* object);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 void SetRootGcRootsReference(); 438 void SetRootGcRootsReference();
444 void SetGcRootsReference(VisitorSynchronization::SyncTag tag); 439 void SetGcRootsReference(VisitorSynchronization::SyncTag tag);
445 void SetGcSubrootReference( 440 void SetGcSubrootReference(
446 VisitorSynchronization::SyncTag tag, bool is_weak, Object* child); 441 VisitorSynchronization::SyncTag tag, bool is_weak, Object* child);
447 const char* GetStrongGcSubrootName(Object* object); 442 const char* GetStrongGcSubrootName(Object* object);
448 void TagObject(Object* obj, const char* tag); 443 void TagObject(Object* obj, const char* tag);
449 void MarkAsWeakContainer(Object* object); 444 void MarkAsWeakContainer(Object* object);
450 445
451 HeapEntry* GetEntry(Object* obj); 446 HeapEntry* GetEntry(Object* obj);
452 447
453 static inline HeapObject* GetNthGcSubrootObject(int delta);
454 static inline int GetGcSubrootOrder(HeapObject* subroot);
455
456 Heap* heap_; 448 Heap* heap_;
457 HeapSnapshot* snapshot_; 449 HeapSnapshot* snapshot_;
458 StringsStorage* names_; 450 StringsStorage* names_;
459 HeapObjectsMap* heap_object_map_; 451 HeapObjectsMap* heap_object_map_;
460 SnapshottingProgressReportingInterface* progress_; 452 SnapshottingProgressReportingInterface* progress_;
461 SnapshotFiller* filler_; 453 SnapshotFiller* filler_;
462 HeapObjectsSet objects_tags_; 454 HeapObjectsSet objects_tags_;
463 HeapObjectsSet strong_gc_subroot_names_; 455 HeapObjectsSet strong_gc_subroot_names_;
464 HeapObjectsSet user_roots_; 456 HeapObjectsSet user_roots_;
465 HeapObjectsSet weak_containers_; 457 HeapObjectsSet weak_containers_;
466 v8::HeapProfiler::ObjectNameResolver* global_object_name_resolver_; 458 v8::HeapProfiler::ObjectNameResolver* global_object_name_resolver_;
467 459
468 static HeapObject* const kGcRootsObject;
469 static HeapObject* const kFirstGcSubrootObject;
470 static HeapObject* const kLastGcSubrootObject;
471
472 friend class IndexedReferencesExtractor; 460 friend class IndexedReferencesExtractor;
473 friend class GcSubrootsEnumerator;
474 friend class RootsReferencesExtractor; 461 friend class RootsReferencesExtractor;
475 462
476 DISALLOW_COPY_AND_ASSIGN(V8HeapExplorer); 463 DISALLOW_COPY_AND_ASSIGN(V8HeapExplorer);
477 }; 464 };
478 465
479 466
480 class NativeGroupRetainedObjectInfo; 467 class NativeGroupRetainedObjectInfo;
481 468
482 469
483 // An implementation of retained native objects extractor. 470 // An implementation of retained native objects extractor.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 friend class HeapSnapshotJSONSerializerEnumerator; 605 friend class HeapSnapshotJSONSerializerEnumerator;
619 friend class HeapSnapshotJSONSerializerIterator; 606 friend class HeapSnapshotJSONSerializerIterator;
620 607
621 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); 608 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer);
622 }; 609 };
623 610
624 611
625 } } // namespace v8::internal 612 } } // namespace v8::internal
626 613
627 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_ 614 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_
OLDNEW
« no previous file with comments | « no previous file | src/heap-snapshot-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698