| OLD | NEW |
| 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 RUNTIME_VM_OBJECT_GRAPH_H_ | 5 #ifndef RUNTIME_VM_OBJECT_GRAPH_H_ |
| 6 #define RUNTIME_VM_OBJECT_GRAPH_H_ | 6 #define RUNTIME_VM_OBJECT_GRAPH_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/object.h" | |
| 10 | 9 |
| 11 namespace dart { | 10 namespace dart { |
| 12 | 11 |
| 12 class Array; |
| 13 class Isolate; | 13 class Isolate; |
| 14 class Object; |
| 15 class RawObject; |
| 16 class WriteStream; |
| 14 | 17 |
| 15 // Utility to traverse the object graph in an ordered fashion. | 18 // Utility to traverse the object graph in an ordered fashion. |
| 16 // Example uses: | 19 // Example uses: |
| 17 // - find a retaining path from the isolate roots to a particular object, or | 20 // - 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). | 21 // - determine how much memory is retained by some particular object(s). |
| 19 class ObjectGraph : public StackResource { | 22 class ObjectGraph : public StackResource { |
| 20 public: | 23 public: |
| 21 class Stack; | 24 class Stack; |
| 22 | 25 |
| 23 // Allows climbing the search tree all the way to the root. | 26 // Allows climbing the search tree all the way to the root. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 intptr_t RetainingPath(Object* obj, const Array& path); | 89 intptr_t RetainingPath(Object* obj, const Array& path); |
| 87 | 90 |
| 88 // Find the objects that reference 'obj'. Populates the provided array with | 91 // Find the objects that reference 'obj'. Populates the provided array with |
| 89 // pairs of (object pointing to 'obj', offset of pointer in words), as far as | 92 // pairs of (object pointing to 'obj', offset of pointer in words), as far as |
| 90 // there is room. Returns the number of objects found. | 93 // there is room. Returns the number of objects found. |
| 91 // | 94 // |
| 92 // An object for which this function answers no inbound references might still | 95 // An object for which this function answers no inbound references might still |
| 93 // be live due to references from the stack or embedder handles. | 96 // be live due to references from the stack or embedder handles. |
| 94 intptr_t InboundReferences(Object* obj, const Array& references); | 97 intptr_t InboundReferences(Object* obj, const Array& references); |
| 95 | 98 |
| 99 enum SnapshotRoots { kVM, kUser }; |
| 100 |
| 96 // Write the isolate's object graph to 'stream'. Smis and nulls are omitted. | 101 // Write the isolate's object graph to 'stream'. Smis and nulls are omitted. |
| 97 // Returns the number of nodes in the stream, including the root. | 102 // Returns the number of nodes in the stream, including the root. |
| 98 // If collect_garabage is false, the graph will include weakly-reachable | 103 // If collect_garabage is false, the graph will include weakly-reachable |
| 99 // objects. | 104 // objects. |
| 100 // TODO(koda): Document format; support streaming/chunking. | 105 // TODO(koda): Document format; support streaming/chunking. |
| 101 intptr_t Serialize(WriteStream* stream, bool collect_garbage); | 106 intptr_t Serialize(WriteStream* stream, |
| 107 SnapshotRoots roots, |
| 108 bool collect_garbage); |
| 102 | 109 |
| 103 private: | 110 private: |
| 104 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectGraph); | 111 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectGraph); |
| 105 }; | 112 }; |
| 106 | 113 |
| 107 } // namespace dart | 114 } // namespace dart |
| 108 | 115 |
| 109 #endif // RUNTIME_VM_OBJECT_GRAPH_H_ | 116 #endif // RUNTIME_VM_OBJECT_GRAPH_H_ |
| OLD | NEW |