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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 ASSERT(Isolate::Current()->no_gc_scope_depth() != 0); | 216 ASSERT(Isolate::Current()->no_gc_scope_depth() != 0); |
217 } | 217 } |
218 | 218 |
219 intptr_t length() const { return length_; } | 219 intptr_t length() const { return length_; } |
220 | 220 |
221 virtual Direction VisitObject(ObjectGraph::StackIterator* it) { | 221 virtual Direction VisitObject(ObjectGraph::StackIterator* it) { |
222 if (it->Get() != obj_) { | 222 if (it->Get() != obj_) { |
223 return kProceed; | 223 return kProceed; |
224 } else { | 224 } else { |
225 HANDLESCOPE(Isolate::Current()); | 225 HANDLESCOPE(Isolate::Current()); |
226 Object& parent = Object::Handle(); | 226 Object& current = Object::Handle(); |
227 for (length_ = 0; it->MoveToParent(); ++length_) { | 227 do { |
228 if (!path_.IsNull() && length_ < path_.Length()) { | 228 if (!path_.IsNull() && length_ < path_.Length()) { |
229 parent = it->Get(); | 229 current = it->Get(); |
230 path_.SetAt(length_, parent); | 230 path_.SetAt(length_, current); |
231 } | 231 } |
232 } | 232 ++length_; |
| 233 } while (it->MoveToParent()); |
233 return kAbort; | 234 return kAbort; |
234 } | 235 } |
235 } | 236 } |
236 | 237 |
237 private: | 238 private: |
238 RawObject* obj_; | 239 RawObject* obj_; |
239 const Array& path_; | 240 const Array& path_; |
240 intptr_t length_; | 241 intptr_t length_; |
241 }; | 242 }; |
242 | 243 |
243 | 244 |
244 intptr_t ObjectGraph::RetainingPath(Object* obj, const Array& path) { | 245 intptr_t ObjectGraph::RetainingPath(Object* obj, const Array& path) { |
245 NoGCScope no_gc_scope_; | 246 NoGCScope no_gc_scope_; |
246 // To break the trivial path, the handle 'obj' is temporarily cleared during | 247 // To break the trivial path, the handle 'obj' is temporarily cleared during |
247 // the search, but restored before returning. | 248 // the search, but restored before returning. |
248 RawObject* raw = obj->raw(); | 249 RawObject* raw = obj->raw(); |
249 *obj = Object::null(); | 250 *obj = Object::null(); |
250 RetainingPathVisitor visitor(raw, path); | 251 RetainingPathVisitor visitor(raw, path); |
251 IterateObjects(&visitor); | 252 IterateObjects(&visitor); |
252 *obj = raw; | 253 *obj = raw; |
253 return visitor.length(); | 254 return visitor.length(); |
254 } | 255 } |
255 | 256 |
256 } // namespace dart | 257 } // namespace dart |
OLD | NEW |