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

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

Issue 2595003002: Use std::deque for storing edges and children in heap snapshot. (Closed)
Patch Set: fix ce Created 3 years, 11 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
« no previous file with comments | « src/api.cc ('k') | src/profiler/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_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_ 5 #ifndef V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_
6 #define V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_ 6 #define V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_
7 7
8 #include <deque>
8 #include <unordered_map> 9 #include <unordered_map>
9 10
10 #include "include/v8-profiler.h" 11 #include "include/v8-profiler.h"
11 #include "src/base/platform/time.h" 12 #include "src/base/platform/time.h"
12 #include "src/objects.h" 13 #include "src/objects.h"
13 #include "src/profiler/strings-storage.h" 14 #include "src/profiler/strings-storage.h"
14 15
15 namespace v8 { 16 namespace v8 {
16 namespace internal { 17 namespace internal {
17 18
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 Type type() { return static_cast<Type>(type_); } 109 Type type() { return static_cast<Type>(type_); }
109 const char* name() { return name_; } 110 const char* name() { return name_; }
110 void set_name(const char* name) { name_ = name; } 111 void set_name(const char* name) { name_ = name; }
111 SnapshotObjectId id() { return id_; } 112 SnapshotObjectId id() { return id_; }
112 size_t self_size() { return self_size_; } 113 size_t self_size() { return self_size_; }
113 unsigned trace_node_id() const { return trace_node_id_; } 114 unsigned trace_node_id() const { return trace_node_id_; }
114 INLINE(int index() const); 115 INLINE(int index() const);
115 int children_count() const { return children_count_; } 116 int children_count() const { return children_count_; }
116 INLINE(int set_children_index(int index)); 117 INLINE(int set_children_index(int index));
117 void add_child(HeapGraphEdge* edge) { 118 void add_child(HeapGraphEdge* edge) {
118 children_arr()[children_count_++] = edge; 119 *(children_begin() + children_count_++) = edge;
119 } 120 }
120 Vector<HeapGraphEdge*> children() { 121 HeapGraphEdge* child(int i) { return *(children_begin() + i); }
121 return Vector<HeapGraphEdge*>(children_arr(), children_count_); }
122 INLINE(Isolate* isolate() const); 122 INLINE(Isolate* isolate() const);
123 123
124 void SetIndexedReference( 124 void SetIndexedReference(
125 HeapGraphEdge::Type type, int index, HeapEntry* entry); 125 HeapGraphEdge::Type type, int index, HeapEntry* entry);
126 void SetNamedReference( 126 void SetNamedReference(
127 HeapGraphEdge::Type type, const char* name, HeapEntry* entry); 127 HeapGraphEdge::Type type, const char* name, HeapEntry* entry);
128 128
129 void Print( 129 void Print(
130 const char* prefix, const char* edge_name, int max_depth, int indent); 130 const char* prefix, const char* edge_name, int max_depth, int indent);
131 131
132 private: 132 private:
133 INLINE(HeapGraphEdge** children_arr()); 133 INLINE(std::deque<HeapGraphEdge*>::iterator children_begin());
134 INLINE(std::deque<HeapGraphEdge*>::iterator children_end());
134 const char* TypeAsString(); 135 const char* TypeAsString();
135 136
136 unsigned type_: 4; 137 unsigned type_: 4;
137 int children_count_: 28; 138 int children_count_: 28;
138 int children_index_; 139 int children_index_;
139 size_t self_size_; 140 size_t self_size_;
140 HeapSnapshot* snapshot_; 141 HeapSnapshot* snapshot_;
141 const char* name_; 142 const char* name_;
142 SnapshotObjectId id_; 143 SnapshotObjectId id_;
143 // id of allocation stack trace top node 144 // id of allocation stack trace top node
(...skipping 12 matching lines...) Expand all
156 void Delete(); 157 void Delete();
157 158
158 HeapProfiler* profiler() { return profiler_; } 159 HeapProfiler* profiler() { return profiler_; }
159 size_t RawSnapshotSize() const; 160 size_t RawSnapshotSize() const;
160 HeapEntry* root() { return &entries_[root_index_]; } 161 HeapEntry* root() { return &entries_[root_index_]; }
161 HeapEntry* gc_roots() { return &entries_[gc_roots_index_]; } 162 HeapEntry* gc_roots() { return &entries_[gc_roots_index_]; }
162 HeapEntry* gc_subroot(int index) { 163 HeapEntry* gc_subroot(int index) {
163 return &entries_[gc_subroot_indexes_[index]]; 164 return &entries_[gc_subroot_indexes_[index]];
164 } 165 }
165 List<HeapEntry>& entries() { return entries_; } 166 List<HeapEntry>& entries() { return entries_; }
166 List<HeapGraphEdge>& edges() { return edges_; } 167 std::deque<HeapGraphEdge>& edges() { return edges_; }
167 List<HeapGraphEdge*>& children() { return children_; } 168 std::deque<HeapGraphEdge*>& children() { return children_; }
168 void RememberLastJSObjectId(); 169 void RememberLastJSObjectId();
169 SnapshotObjectId max_snapshot_js_object_id() const { 170 SnapshotObjectId max_snapshot_js_object_id() const {
170 return max_snapshot_js_object_id_; 171 return max_snapshot_js_object_id_;
171 } 172 }
172 173
173 HeapEntry* AddEntry(HeapEntry::Type type, 174 HeapEntry* AddEntry(HeapEntry::Type type,
174 const char* name, 175 const char* name,
175 SnapshotObjectId id, 176 SnapshotObjectId id,
176 size_t size, 177 size_t size,
177 unsigned trace_node_id); 178 unsigned trace_node_id);
178 void AddSyntheticRootEntries(); 179 void AddSyntheticRootEntries();
179 HeapEntry* GetEntryById(SnapshotObjectId id); 180 HeapEntry* GetEntryById(SnapshotObjectId id);
180 List<HeapEntry*>* GetSortedEntriesList(); 181 List<HeapEntry*>* GetSortedEntriesList();
181 void FillChildren(); 182 void FillChildren();
182 183
183 void Print(int max_depth); 184 void Print(int max_depth);
184 185
185 private: 186 private:
186 HeapEntry* AddRootEntry(); 187 HeapEntry* AddRootEntry();
187 HeapEntry* AddGcRootsEntry(); 188 HeapEntry* AddGcRootsEntry();
188 HeapEntry* AddGcSubrootEntry(int tag, SnapshotObjectId id); 189 HeapEntry* AddGcSubrootEntry(int tag, SnapshotObjectId id);
189 190
190 HeapProfiler* profiler_; 191 HeapProfiler* profiler_;
191 int root_index_; 192 int root_index_;
192 int gc_roots_index_; 193 int gc_roots_index_;
193 int gc_subroot_indexes_[VisitorSynchronization::kNumberOfSyncTags]; 194 int gc_subroot_indexes_[VisitorSynchronization::kNumberOfSyncTags];
194 List<HeapEntry> entries_; 195 List<HeapEntry> entries_;
195 List<HeapGraphEdge> edges_; 196 std::deque<HeapGraphEdge> edges_;
196 List<HeapGraphEdge*> children_; 197 std::deque<HeapGraphEdge*> children_;
197 List<HeapEntry*> sorted_entries_; 198 List<HeapEntry*> sorted_entries_;
198 SnapshotObjectId max_snapshot_js_object_id_; 199 SnapshotObjectId max_snapshot_js_object_id_;
199 200
200 friend class HeapSnapshotTester; 201 friend class HeapSnapshotTester;
201 202
202 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot); 203 DISALLOW_COPY_AND_ASSIGN(HeapSnapshot);
203 }; 204 };
204 205
205 206
206 class HeapObjectsMap { 207 class HeapObjectsMap {
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 friend class HeapSnapshotJSONSerializerIterator; 623 friend class HeapSnapshotJSONSerializerIterator;
623 624
624 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); 625 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer);
625 }; 626 };
626 627
627 628
628 } // namespace internal 629 } // namespace internal
629 } // namespace v8 630 } // namespace v8
630 631
631 #endif // V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_ 632 #endif // V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_H_
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/profiler/heap-snapshot-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698