| 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" | 9 #include "vm/object.h" |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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. | 30 // Offset into parent for the pointer to current object. -1 if no parent. |
| 31 intptr_t OffsetFromParentInWords() const; | 31 intptr_t OffsetFromParentInWords() const; |
| 32 |
| 32 private: | 33 private: |
| 33 StackIterator(const Stack* stack, intptr_t index) | 34 StackIterator(const Stack* stack, intptr_t index) |
| 34 : stack_(stack), index_(index) { } | 35 : stack_(stack), index_(index) {} |
| 35 const Stack* stack_; | 36 const Stack* stack_; |
| 36 intptr_t index_; | 37 intptr_t index_; |
| 37 friend class ObjectGraph::Stack; | 38 friend class ObjectGraph::Stack; |
| 38 DISALLOW_IMPLICIT_CONSTRUCTORS(StackIterator); | 39 DISALLOW_IMPLICIT_CONSTRUCTORS(StackIterator); |
| 39 }; | 40 }; |
| 40 | 41 |
| 41 class Visitor { | 42 class Visitor { |
| 42 public: | 43 public: |
| 43 // Directs how the search should continue after visiting an object. | 44 // Directs how the search should continue after visiting an object. |
| 44 enum Direction { | 45 enum Direction { |
| 45 kProceed, // Recurse on this object's pointers. | 46 kProceed, // Recurse on this object's pointers. |
| 46 kBacktrack, // Ignore this object's pointers. | 47 kBacktrack, // Ignore this object's pointers. |
| 47 kAbort, // Terminate the entire search immediately. | 48 kAbort, // Terminate the entire search immediately. |
| 48 }; | 49 }; |
| 49 virtual ~Visitor() { } | 50 virtual ~Visitor() {} |
| 50 // Visits the object pointed to by *it. The iterator is only valid | 51 // Visits the object pointed to by *it. The iterator is only valid |
| 51 // during this call. This method must not allocate from the heap or | 52 // during this call. This method must not allocate from the heap or |
| 52 // trigger GC in any way. | 53 // trigger GC in any way. |
| 53 virtual Direction VisitObject(StackIterator* it) = 0; | 54 virtual Direction VisitObject(StackIterator* it) = 0; |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 explicit ObjectGraph(Thread* thread); | 57 explicit ObjectGraph(Thread* thread); |
| 57 ~ObjectGraph(); | 58 ~ObjectGraph(); |
| 58 | 59 |
| 59 // Visits all strongly reachable objects in the isolate's heap, in a | 60 // Visits all strongly reachable objects in the isolate's heap, in a |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // TODO(koda): Document format; support streaming/chunking. | 100 // TODO(koda): Document format; support streaming/chunking. |
| 100 intptr_t Serialize(WriteStream* stream, bool collect_garbage); | 101 intptr_t Serialize(WriteStream* stream, bool collect_garbage); |
| 101 | 102 |
| 102 private: | 103 private: |
| 103 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectGraph); | 104 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectGraph); |
| 104 }; | 105 }; |
| 105 | 106 |
| 106 } // namespace dart | 107 } // namespace dart |
| 107 | 108 |
| 108 #endif // RUNTIME_VM_OBJECT_GRAPH_H_ | 109 #endif // RUNTIME_VM_OBJECT_GRAPH_H_ |
| OLD | NEW |