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

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

Issue 350403005: Include parent field/list index in retaining path. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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 | « runtime/bin/vmservice/client/tests/ui/retainingPath.dart ('k') | runtime/vm/object_graph.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 (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 #ifndef VM_OBJECT_GRAPH_H_ 5 #ifndef VM_OBJECT_GRAPH_H_
6 #define VM_OBJECT_GRAPH_H_ 6 #define VM_OBJECT_GRAPH_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 class Isolate; 13 class Isolate;
14 14
15 // Utility to traverse the object graph in an ordered fashion. 15 // Utility to traverse the object graph in an ordered fashion.
16 // Example uses: 16 // Example uses:
17 // - find a retaining path from the isolate roots to a particular object, or 17 // - find a retaining path from the isolate roots to a particular object, or
18 // - determine how much memory is retained by some particular object(s). 18 // - determine how much memory is retained by some particular object(s).
19 class ObjectGraph : public StackResource { 19 class ObjectGraph : public StackResource {
20 public: 20 public:
21 class Stack; 21 class Stack;
22 22
23 // Allows climbing the search tree all the way to the root. 23 // Allows climbing the search tree all the way to the root.
24 class StackIterator { 24 class StackIterator {
25 public: 25 public:
26 // The object this iterator currently points to. 26 // The object this iterator currently points to.
27 RawObject* Get() const; 27 RawObject* Get() const;
28 // Returns false if there is no parent. 28 // Returns false if there is no parent.
29 bool MoveToParent(); 29 bool MoveToParent();
30 // Offset into parent for the pointer to current object. -1 if no parent.
31 intptr_t OffsetFromParentInWords() const;
30 private: 32 private:
31 StackIterator(const Stack* stack, intptr_t index) 33 StackIterator(const Stack* stack, intptr_t index)
32 : stack_(stack), index_(index) { } 34 : stack_(stack), index_(index) { }
33 const Stack* stack_; 35 const Stack* stack_;
34 intptr_t index_; 36 intptr_t index_;
35 friend class ObjectGraph::Stack; 37 friend class ObjectGraph::Stack;
36 DISALLOW_IMPLICIT_CONSTRUCTORS(StackIterator); 38 DISALLOW_IMPLICIT_CONSTRUCTORS(StackIterator);
37 }; 39 };
38 40
39 class Visitor { 41 class Visitor {
(...skipping 22 matching lines...) Expand all
62 // (including 'root' itself). 64 // (including 'root' itself).
63 void IterateObjectsFrom(const Object& root, Visitor* visitor); 65 void IterateObjectsFrom(const Object& root, Visitor* visitor);
64 66
65 // The number of bytes retained by 'obj'. 67 // The number of bytes retained by 'obj'.
66 intptr_t SizeRetainedByInstance(const Object& obj); 68 intptr_t SizeRetainedByInstance(const Object& obj);
67 69
68 // The number of bytes retained by the set of all objects of the given class. 70 // The number of bytes retained by the set of all objects of the given class.
69 intptr_t SizeRetainedByClass(intptr_t class_id); 71 intptr_t SizeRetainedByClass(intptr_t class_id);
70 72
71 // Finds some retaining path from the isolate roots to 'obj'. Populates the 73 // Finds some retaining path from the isolate roots to 'obj'. Populates the
72 // provided array, starting 'obj' itself, up to the smaller of the length of 74 // provided array with pairs of (object, offset from parent in words),
73 // the array and the length of the path. Returns the length of the path. A 75 // starting with 'obj' itself, as far as there is room. Returns the number
74 // null input array behaves like a zero-length input array. 76 // of objects on the full path. A null input array behaves like a zero-length
77 // input array. The 'offset' of a root is -1.
75 // 78 //
76 // To break the trivial path, the handle 'obj' is temporarily cleared during 79 // To break the trivial path, the handle 'obj' is temporarily cleared during
77 // the search, but restored before returning. If no path is found (i.e., the 80 // the search, but restored before returning. If no path is found (i.e., the
78 // provided handle was the only way to reach the object), zero is returned. 81 // provided handle was the only way to reach the object), zero is returned.
79 intptr_t RetainingPath(Object* obj, const Array& path); 82 intptr_t RetainingPath(Object* obj, const Array& path);
80 83
81 private: 84 private:
82 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectGraph); 85 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectGraph);
83 }; 86 };
84 87
85 } // namespace dart 88 } // namespace dart
86 89
87 #endif // VM_OBJECT_GRAPH_H_ 90 #endif // VM_OBJECT_GRAPH_H_
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/client/tests/ui/retainingPath.dart ('k') | runtime/vm/object_graph.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698