| 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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 439 |
| 440 intptr_t count() const { return count_; } | 440 intptr_t count() const { return count_; } |
| 441 | 441 |
| 442 private: | 442 private: |
| 443 WriteStream* stream_; | 443 WriteStream* stream_; |
| 444 WritePointerVisitor ptr_writer_; | 444 WritePointerVisitor ptr_writer_; |
| 445 intptr_t count_; | 445 intptr_t count_; |
| 446 }; | 446 }; |
| 447 | 447 |
| 448 | 448 |
| 449 void ObjectGraph::Serialize(WriteStream* stream) { | 449 intptr_t ObjectGraph::Serialize(WriteStream* stream) { |
| 450 // Current encoding assumes objects do not move, so promote everything to old. | 450 // Current encoding assumes objects do not move, so promote everything to old. |
| 451 isolate()->heap()->new_space()->Evacuate(); | 451 isolate()->heap()->new_space()->Evacuate(); |
| 452 WriteGraphVisitor visitor(isolate(), stream); | 452 WriteGraphVisitor visitor(isolate(), stream); |
| 453 stream->WriteUnsigned(kObjectAlignment); |
| 453 stream->WriteUnsigned(0); | 454 stream->WriteUnsigned(0); |
| 454 stream->WriteUnsigned(0); | 455 stream->WriteUnsigned(0); |
| 455 stream->WriteUnsigned(0); | 456 stream->WriteUnsigned(0); |
| 456 { | 457 { |
| 457 WritePointerVisitor ptr_writer(isolate(), stream); | 458 WritePointerVisitor ptr_writer(isolate(), stream); |
| 458 isolate()->VisitObjectPointers(&ptr_writer, false, false); | 459 isolate()->VisitObjectPointers(&ptr_writer, false, false); |
| 459 } | 460 } |
| 460 stream->WriteUnsigned(0); | 461 stream->WriteUnsigned(0); |
| 461 IterateObjects(&visitor); | 462 IterateObjects(&visitor); |
| 463 return visitor.count() + 1; // + root |
| 462 } | 464 } |
| 463 | 465 |
| 464 } // namespace dart | 466 } // namespace dart |
| OLD | NEW |