| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #ifndef VM_SNAPSHOT_H_ | 5 #ifndef VM_SNAPSHOT_H_ |
| 6 #define VM_SNAPSHOT_H_ | 6 #define VM_SNAPSHOT_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
| 10 #include "vm/bitfield.h" | 10 #include "vm/bitfield.h" |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 DISALLOW_IMPLICIT_CONSTRUCTORS(BaseWriter); | 472 DISALLOW_IMPLICIT_CONSTRUCTORS(BaseWriter); |
| 473 }; | 473 }; |
| 474 | 474 |
| 475 | 475 |
| 476 class SnapshotWriter : public BaseWriter { | 476 class SnapshotWriter : public BaseWriter { |
| 477 public: | 477 public: |
| 478 SnapshotWriter(Snapshot::Kind kind, uint8_t** buffer, ReAlloc alloc) | 478 SnapshotWriter(Snapshot::Kind kind, uint8_t** buffer, ReAlloc alloc) |
| 479 : BaseWriter(buffer, alloc), | 479 : BaseWriter(buffer, alloc), |
| 480 kind_(kind), | 480 kind_(kind), |
| 481 object_store_(Isolate::Current()->object_store()), | 481 object_store_(Isolate::Current()->object_store()), |
| 482 class_table_(Isolate::Current()->class_table()), |
| 482 forward_list_() { | 483 forward_list_() { |
| 483 } | 484 } |
| 484 ~SnapshotWriter() { } | 485 ~SnapshotWriter() { } |
| 485 | 486 |
| 486 // Snapshot kind. | 487 // Snapshot kind. |
| 487 Snapshot::Kind kind() const { return kind_; } | 488 Snapshot::Kind kind() const { return kind_; } |
| 488 | 489 |
| 489 // Finalize the serialized buffer by filling in the header information | 490 // Finalize the serialized buffer by filling in the header information |
| 490 // which comprises of a flag(full/partial snaphot) and the length of | 491 // which comprises of a flag(full/partial snaphot) and the length of |
| 491 // serialzed bytes. | 492 // serialzed bytes. |
| 492 void FinalizeBuffer() { | 493 void FinalizeBuffer() { |
| 493 BaseWriter::FinalizeBuffer(kind_); | 494 BaseWriter::FinalizeBuffer(kind_); |
| 494 UnmarkAll(); | 495 UnmarkAll(); |
| 495 } | 496 } |
| 496 | 497 |
| 497 // Serialize an object into the buffer. | 498 // Serialize an object into the buffer. |
| 498 void WriteObject(RawObject* raw); | 499 void WriteObject(RawObject* raw); |
| 499 | 500 |
| 500 void WriteClassId(RawClass* cls); | 501 void WriteClassId(RawClass* cls); |
| 501 | 502 |
| 502 // Unmark all objects that were marked as forwarded for serializing. | 503 // Unmark all objects that were marked as forwarded for serializing. |
| 503 void UnmarkAll(); | 504 void UnmarkAll(); |
| 504 | 505 |
| 505 // Writes a full snapshot of the Isolate. | 506 // Writes a full snapshot of the Isolate. |
| 506 void WriteFullSnapshot(); | 507 void WriteFullSnapshot(); |
| 507 | 508 |
| 509 uword GetObjectTags(RawObject* raw); |
| 510 |
| 508 private: | 511 private: |
| 509 class ForwardObjectNode : public ZoneAllocated { | 512 class ForwardObjectNode : public ZoneAllocated { |
| 510 public: | 513 public: |
| 511 ForwardObjectNode(RawObject* raw, RawClass* cls) : raw_(raw), cls_(cls) {} | 514 ForwardObjectNode(RawObject* raw, uword tags) : raw_(raw), tags_(tags) {} |
| 512 RawObject* raw() const { return raw_; } | 515 RawObject* raw() const { return raw_; } |
| 513 RawClass* cls() const { return cls_; } | 516 uword tags() const { return tags_; } |
| 514 | 517 |
| 515 private: | 518 private: |
| 516 RawObject* raw_; | 519 RawObject* raw_; |
| 517 RawClass* cls_; | 520 uword tags_; |
| 518 | 521 |
| 519 DISALLOW_COPY_AND_ASSIGN(ForwardObjectNode); | 522 DISALLOW_COPY_AND_ASSIGN(ForwardObjectNode); |
| 520 }; | 523 }; |
| 521 | 524 |
| 522 intptr_t MarkObject(RawObject* raw, RawClass* cls); | 525 intptr_t MarkObject(RawObject* raw, RawClass* cls); |
| 523 | 526 |
| 524 void WriteInlinedObject(RawObject* raw); | 527 void WriteInlinedObject(RawObject* raw); |
| 525 | 528 |
| 526 ObjectStore* object_store() const { return object_store_; } | 529 ObjectStore* object_store() const { return object_store_; } |
| 527 | 530 |
| 528 Snapshot::Kind kind_; | 531 Snapshot::Kind kind_; |
| 529 ObjectStore* object_store_; // Object store for common classes. | 532 ObjectStore* object_store_; // Object store for common classes. |
| 533 ClassTable* class_table_; // Class table for the class index to class lookup. |
| 530 GrowableArray<ForwardObjectNode*> forward_list_; | 534 GrowableArray<ForwardObjectNode*> forward_list_; |
| 531 | 535 |
| 532 DISALLOW_COPY_AND_ASSIGN(SnapshotWriter); | 536 DISALLOW_COPY_AND_ASSIGN(SnapshotWriter); |
| 533 }; | 537 }; |
| 534 | 538 |
| 535 | 539 |
| 536 class ScriptSnapshotWriter : public SnapshotWriter { | 540 class ScriptSnapshotWriter : public SnapshotWriter { |
| 537 public: | 541 public: |
| 538 ScriptSnapshotWriter(uint8_t** buffer, ReAlloc alloc) | 542 ScriptSnapshotWriter(uint8_t** buffer, ReAlloc alloc) |
| 539 : SnapshotWriter(Snapshot::kScript, buffer, alloc) { | 543 : SnapshotWriter(Snapshot::kScript, buffer, alloc) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 560 | 564 |
| 561 private: | 565 private: |
| 562 SnapshotWriter* writer_; | 566 SnapshotWriter* writer_; |
| 563 | 567 |
| 564 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); | 568 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); |
| 565 }; | 569 }; |
| 566 | 570 |
| 567 } // namespace dart | 571 } // namespace dart |
| 568 | 572 |
| 569 #endif // VM_SNAPSHOT_H_ | 573 #endif // VM_SNAPSHOT_H_ |
| OLD | NEW |