| 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 365 |
| 366 intptr_t ObjectGraph::InboundReferences(Object* obj, const Array& references) { | 366 intptr_t ObjectGraph::InboundReferences(Object* obj, const Array& references) { |
| 367 Object& scratch = Object::Handle(); | 367 Object& scratch = Object::Handle(); |
| 368 NoGCScope no_gc_scope_; | 368 NoGCScope no_gc_scope_; |
| 369 InboundReferencesVisitor visitor(isolate(), obj->raw(), references, &scratch); | 369 InboundReferencesVisitor visitor(isolate(), obj->raw(), references, &scratch); |
| 370 isolate()->heap()->IterateObjects(&visitor); | 370 isolate()->heap()->IterateObjects(&visitor); |
| 371 return visitor.length(); | 371 return visitor.length(); |
| 372 } | 372 } |
| 373 | 373 |
| 374 | 374 |
| 375 void WritePtr(RawObject* raw, WriteStream* stream) { | 375 static void WritePtr(RawObject* raw, WriteStream* stream) { |
| 376 ASSERT(raw->IsHeapObject()); | 376 ASSERT(raw->IsHeapObject()); |
| 377 ASSERT(raw->IsOldObject()); | 377 ASSERT(raw->IsOldObject()); |
| 378 uword addr = RawObject::ToAddr(raw); | 378 uword addr = RawObject::ToAddr(raw); |
| 379 ASSERT(Utils::IsAligned(addr, kObjectAlignment)); | 379 ASSERT(Utils::IsAligned(addr, kObjectAlignment)); |
| 380 // Using units of kObjectAlignment makes the ids fit into Smis when parsed | 380 // Using units of kObjectAlignment makes the ids fit into Smis when parsed |
| 381 // in the Dart code of the Observatory. | 381 // in the Dart code of the Observatory. |
| 382 // TODO(koda): Use delta-encoding/back-references to further compress this. | 382 // TODO(koda): Use delta-encoding/back-references to further compress this. |
| 383 stream->WriteUnsigned(addr / kObjectAlignment); | 383 stream->WriteUnsigned(addr / kObjectAlignment); |
| 384 } | 384 } |
| 385 | 385 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 402 } | 402 } |
| 403 | 403 |
| 404 intptr_t count() const { return count_; } | 404 intptr_t count() const { return count_; } |
| 405 | 405 |
| 406 private: | 406 private: |
| 407 WriteStream* stream_; | 407 WriteStream* stream_; |
| 408 intptr_t count_; | 408 intptr_t count_; |
| 409 }; | 409 }; |
| 410 | 410 |
| 411 | 411 |
| 412 void WriteHeader(RawObject* raw, intptr_t size, intptr_t cid, | 412 static void WriteHeader(RawObject* raw, intptr_t size, intptr_t cid, |
| 413 WriteStream* stream) { | 413 WriteStream* stream) { |
| 414 WritePtr(raw, stream); | 414 WritePtr(raw, stream); |
| 415 ASSERT(Utils::IsAligned(size, kObjectAlignment)); | 415 ASSERT(Utils::IsAligned(size, kObjectAlignment)); |
| 416 stream->WriteUnsigned(size); | 416 stream->WriteUnsigned(size); |
| 417 stream->WriteUnsigned(cid); | 417 stream->WriteUnsigned(cid); |
| 418 } | 418 } |
| 419 | 419 |
| 420 | 420 |
| 421 class WriteGraphVisitor : public ObjectGraph::Visitor { | 421 class WriteGraphVisitor : public ObjectGraph::Visitor { |
| 422 public: | 422 public: |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 stream->WriteUnsigned(0); | 455 stream->WriteUnsigned(0); |
| 456 { | 456 { |
| 457 WritePointerVisitor ptr_writer(isolate(), stream); | 457 WritePointerVisitor ptr_writer(isolate(), stream); |
| 458 isolate()->VisitObjectPointers(&ptr_writer, false, false); | 458 isolate()->VisitObjectPointers(&ptr_writer, false, false); |
| 459 } | 459 } |
| 460 stream->WriteUnsigned(0); | 460 stream->WriteUnsigned(0); |
| 461 IterateObjects(&visitor); | 461 IterateObjects(&visitor); |
| 462 } | 462 } |
| 463 | 463 |
| 464 } // namespace dart | 464 } // namespace dart |
| OLD | NEW |