| 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 #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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 static void UnmarkAll(Isolate* isolate) { | 106 static void UnmarkAll(Isolate* isolate) { |
| 107 Unmarker unmarker(isolate); | 107 Unmarker unmarker(isolate); |
| 108 isolate->heap()->IterateObjects(&unmarker); | 108 isolate->heap()->IterateObjects(&unmarker); |
| 109 } | 109 } |
| 110 | 110 |
| 111 private: | 111 private: |
| 112 DISALLOW_COPY_AND_ASSIGN(Unmarker); | 112 DISALLOW_COPY_AND_ASSIGN(Unmarker); |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 | 115 |
| 116 ObjectGraph::ObjectGraph(Isolate* isolate) : isolate_(isolate) { | 116 ObjectGraph::ObjectGraph(Isolate* isolate) |
| 117 : StackResource(isolate), isolate_(isolate) { |
| 117 // The VM isolate has all its objects pre-marked, so iterating over it | 118 // The VM isolate has all its objects pre-marked, so iterating over it |
| 118 // would be a no-op. | 119 // would be a no-op. |
| 119 ASSERT(isolate_ != Dart::vm_isolate()); | 120 ASSERT(isolate_ != Dart::vm_isolate()); |
| 120 isolate_->heap()->WriteProtectCode(false); | 121 isolate_->heap()->WriteProtectCode(false); |
| 121 } | 122 } |
| 122 | 123 |
| 123 | 124 |
| 124 ObjectGraph::~ObjectGraph() { | 125 ObjectGraph::~ObjectGraph() { |
| 125 isolate_->heap()->WriteProtectCode(true); | 126 isolate_->heap()->WriteProtectCode(true); |
| 126 } | 127 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 140 NoGCScope no_gc_scope_; | 141 NoGCScope no_gc_scope_; |
| 141 Stack stack(isolate_); | 142 Stack stack(isolate_); |
| 142 RawObject* root_raw = root.raw(); | 143 RawObject* root_raw = root.raw(); |
| 143 stack.VisitPointer(&root_raw); | 144 stack.VisitPointer(&root_raw); |
| 144 stack.TraverseGraph(visitor); | 145 stack.TraverseGraph(visitor); |
| 145 // TODO(koda): Optimize if we only visited a small subgraph. | 146 // TODO(koda): Optimize if we only visited a small subgraph. |
| 146 Unmarker::UnmarkAll(isolate_); | 147 Unmarker::UnmarkAll(isolate_); |
| 147 } | 148 } |
| 148 | 149 |
| 149 } // namespace dart | 150 } // namespace dart |
| OLD | NEW |