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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 | 167 |
168 ObjectGraph::~ObjectGraph() { | 168 ObjectGraph::~ObjectGraph() { |
169 isolate()->heap()->WriteProtectCode(true); | 169 isolate()->heap()->WriteProtectCode(true); |
170 } | 170 } |
171 | 171 |
172 | 172 |
173 void ObjectGraph::IterateObjects(ObjectGraph::Visitor* visitor) { | 173 void ObjectGraph::IterateObjects(ObjectGraph::Visitor* visitor) { |
174 NoSafepointScope no_safepoint_scope_; | 174 NoSafepointScope no_safepoint_scope_; |
175 Stack stack(isolate()); | 175 Stack stack(isolate()); |
176 isolate()->IterateObjectPointers(&stack, false, false); | 176 isolate()->IterateObjectPointers(&stack, false); |
177 stack.TraverseGraph(visitor); | 177 stack.TraverseGraph(visitor); |
178 Unmarker::UnmarkAll(isolate()); | 178 Unmarker::UnmarkAll(isolate()); |
179 } | 179 } |
180 | 180 |
181 | 181 |
182 void ObjectGraph::IterateObjectsFrom(const Object& root, | 182 void ObjectGraph::IterateObjectsFrom(const Object& root, |
183 ObjectGraph::Visitor* visitor) { | 183 ObjectGraph::Visitor* visitor) { |
184 NoSafepointScope no_safepoint_scope_; | 184 NoSafepointScope no_safepoint_scope_; |
185 Stack stack(isolate()); | 185 Stack stack(isolate()); |
186 RawObject* root_raw = root.raw(); | 186 RawObject* root_raw = root.raw(); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 intptr_t ObjectGraph::Serialize(WriteStream* stream) { | 466 intptr_t ObjectGraph::Serialize(WriteStream* stream) { |
467 // Current encoding assumes objects do not move, so promote everything to old. | 467 // Current encoding assumes objects do not move, so promote everything to old. |
468 isolate()->heap()->new_space()->Evacuate(); | 468 isolate()->heap()->new_space()->Evacuate(); |
469 WriteGraphVisitor visitor(isolate(), stream); | 469 WriteGraphVisitor visitor(isolate(), stream); |
470 stream->WriteUnsigned(kObjectAlignment); | 470 stream->WriteUnsigned(kObjectAlignment); |
471 stream->WriteUnsigned(0); | 471 stream->WriteUnsigned(0); |
472 stream->WriteUnsigned(0); | 472 stream->WriteUnsigned(0); |
473 stream->WriteUnsigned(0); | 473 stream->WriteUnsigned(0); |
474 { | 474 { |
475 WritePointerVisitor ptr_writer(isolate(), stream); | 475 WritePointerVisitor ptr_writer(isolate(), stream); |
476 isolate()->IterateObjectPointers(&ptr_writer, false, false); | 476 isolate()->IterateObjectPointers(&ptr_writer, false); |
477 } | 477 } |
478 stream->WriteUnsigned(0); | 478 stream->WriteUnsigned(0); |
479 IterateObjects(&visitor); | 479 IterateObjects(&visitor); |
480 return visitor.count() + 1; // + root | 480 return visitor.count() + 1; // + root |
481 } | 481 } |
482 | 482 |
483 } // namespace dart | 483 } // namespace dart |
OLD | NEW |