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

Side by Side Diff: runtime/vm/object_graph.cc

Issue 286203015: ObjectGraph::RetainingPath (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object_graph.h" 5 #include "vm/object_graph.h"
6 6
7 #include "vm/dart.h" 7 #include "vm/dart.h"
8 #include "vm/growable_array.h" 8 #include "vm/growable_array.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 intptr_t ObjectGraph::SizeRetainedByClass(intptr_t class_id) { 200 intptr_t ObjectGraph::SizeRetainedByClass(intptr_t class_id) {
201 SizeVisitor total; 201 SizeVisitor total;
202 IterateObjects(&total); 202 IterateObjects(&total);
203 intptr_t size_total = total.size(); 203 intptr_t size_total = total.size();
204 SizeExcludingClassVisitor excluding_class(class_id); 204 SizeExcludingClassVisitor excluding_class(class_id);
205 IterateObjects(&excluding_class); 205 IterateObjects(&excluding_class);
206 intptr_t size_excluding_class = excluding_class.size(); 206 intptr_t size_excluding_class = excluding_class.size();
207 return size_total - size_excluding_class; 207 return size_total - size_excluding_class;
208 } 208 }
209 209
210
211 class RetainingPathVisitor : public ObjectGraph::Visitor {
212 public:
213 RetainingPathVisitor(RawObject* obj, const Array& path)
214 : obj_(obj), path_(path), length_(0) {
215 ASSERT(Isolate::Current()->no_gc_scope_depth() != 0);
turnidge 2014/05/20 18:00:38 We could consider clearing path_ here. Are we una
koda 2014/05/20 20:37:49 Yes, we need to avoid GC during the search.
216 }
217 intptr_t length() const { return length_; }
turnidge 2014/05/20 18:00:38 blank line here would help me.
koda 2014/05/20 20:37:49 Done.
218 virtual Direction VisitObject(ObjectGraph::StackIterator* it) {
219 if (it->Get() != obj_) {
220 return kProceed;
221 }
222 Object& parent = Object::Handle();
223 for (length_ = 0; it->MoveToParent(); ++length_) {
224 if (length_ < path_.Length()) {
Cutch 2014/05/20 17:39:12 Could we allow path to be Array::null() and call l
koda 2014/05/20 20:37:49 Done. Although I expect the common use will be to
225 parent = it->Get();
226 path_.SetAt(length_, parent);
227 }
228 }
229 return kAbort;
230 }
231 private:
232 RawObject* obj_;
233 const Array& path_;
234 intptr_t length_;
235 };
236
237
238 intptr_t ObjectGraph::RetainingPath(Object* obj, const Array& path) {
239 NoGCScope no_gc_scope_;
turnidge 2014/05/20 18:00:38 Maybe comment on what you are doing here with obj
koda 2014/05/20 20:37:49 Done.
240 RawObject* raw = obj->raw();
241 *obj = Object::null();
242 RetainingPathVisitor visitor(raw, path);
243 IterateObjects(&visitor);
244 *obj = raw;
245 return visitor.length();
246 }
247
210 } // namespace dart 248 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698