| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/assert.h" | 9 #include "vm/assert.h" |
| 10 #include "vm/bitfield.h" | 10 #include "vm/bitfield.h" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 void WriteMessage(intptr_t field_count, intptr_t *data); | 342 void WriteMessage(intptr_t field_count, intptr_t *data); |
| 343 | 343 |
| 344 private: | 344 private: |
| 345 // Writes raw data to the stream (basic type). | 345 // Writes raw data to the stream (basic type). |
| 346 // sizeof(T) must be in {1,2,4,8}. | 346 // sizeof(T) must be in {1,2,4,8}. |
| 347 template <typename T> | 347 template <typename T> |
| 348 void Write(T value) { | 348 void Write(T value) { |
| 349 WriteStream::Raw<sizeof(T), T>::Write(&stream_, value); | 349 WriteStream::Raw<sizeof(T), T>::Write(&stream_, value); |
| 350 } | 350 } |
| 351 | 351 |
| 352 // Setup header information for an object. | 352 // Write an object that is serialized as an Id (singleton, object store, |
| 353 void WriteObjectHeader(SerializedHeaderType type, intptr_t id) { | 353 // or an object that was already serialized before). |
| 354 void WriteIndexedObject(intptr_t object_id) { |
| 355 WriteSerializationMarker(kObjectId, object_id); |
| 356 } |
| 357 |
| 358 // Write out object header value. |
| 359 void WriteObjectHeader(intptr_t class_id, intptr_t tags) { |
| 360 // Write out the class information. |
| 361 WriteIndexedObject(class_id); |
| 362 // Write out the tags information. |
| 363 Write<intptr_t>(tags); |
| 364 } |
| 365 |
| 366 // Write serialization header information for an object. |
| 367 void WriteSerializationMarker(SerializedHeaderType type, intptr_t id) { |
| 354 uword value = 0; | 368 uword value = 0; |
| 355 value = SerializedHeaderTag::update(type, value); | 369 value = SerializedHeaderTag::update(type, value); |
| 356 value = SerializedHeaderData::update(id, value); | 370 value = SerializedHeaderData::update(id, value); |
| 357 Write<uword>(value); | 371 Write<uword>(value); |
| 358 } | 372 } |
| 359 | 373 |
| 360 // Finalize the serialized buffer by filling in the header information | 374 // Finalize the serialized buffer by filling in the header information |
| 361 // which comprises of a flag(full/partial snaphot) and the length of | 375 // which comprises of a flag(full/partial snaphot) and the length of |
| 362 // serialzed bytes. | 376 // serialzed bytes. |
| 363 void FinalizeBuffer() { | 377 void FinalizeBuffer() { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 template <typename T> | 416 template <typename T> |
| 403 void Write(T value) { | 417 void Write(T value) { |
| 404 WriteStream::Raw<sizeof(T), T>::Write(&stream_, value); | 418 WriteStream::Raw<sizeof(T), T>::Write(&stream_, value); |
| 405 } | 419 } |
| 406 | 420 |
| 407 // Serialize an object into the buffer. | 421 // Serialize an object into the buffer. |
| 408 void WriteObject(RawObject* raw); | 422 void WriteObject(RawObject* raw); |
| 409 | 423 |
| 410 void WriteClassId(RawClass* cls); | 424 void WriteClassId(RawClass* cls); |
| 411 | 425 |
| 412 // Setup header information for an object. | 426 // Write an object that is serialized as an Id (singleton, object store, |
| 413 void WriteObjectHeader(SerializedHeaderType type, intptr_t value); | 427 // or an object that was already serialized before). |
| 428 void WriteIndexedObject(intptr_t object_id) { |
| 429 WriteSerializationMarker(kObjectId, object_id); |
| 430 } |
| 431 |
| 432 // Write out object header value. |
| 433 void WriteObjectHeader(intptr_t class_id, intptr_t tags) { |
| 434 // Write out the class information. |
| 435 WriteIndexedObject(class_id); |
| 436 // Write out the tags information. |
| 437 Write<intptr_t>(tags); |
| 438 } |
| 439 |
| 440 // Write serialization header information for an object. |
| 441 void WriteSerializationMarker(SerializedHeaderType type, intptr_t id) { |
| 442 uword value = 0; |
| 443 value = SerializedHeaderTag::update(type, value); |
| 444 value = SerializedHeaderData::update(id, value); |
| 445 Write<uword>(value); |
| 446 } |
| 414 | 447 |
| 415 // Unmark all objects that were marked as forwarded for serializing. | 448 // Unmark all objects that were marked as forwarded for serializing. |
| 416 void UnmarkAll(); | 449 void UnmarkAll(); |
| 417 | 450 |
| 418 // Writes a full snapshot of the Isolate. | 451 // Writes a full snapshot of the Isolate. |
| 419 void WriteFullSnapshot(); | 452 void WriteFullSnapshot(); |
| 420 | 453 |
| 421 private: | 454 private: |
| 422 class ForwardObjectNode : public ZoneAllocated { | 455 class ForwardObjectNode : public ZoneAllocated { |
| 423 public: | 456 public: |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 | 507 |
| 475 private: | 508 private: |
| 476 SnapshotWriter* writer_; | 509 SnapshotWriter* writer_; |
| 477 | 510 |
| 478 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); | 511 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); |
| 479 }; | 512 }; |
| 480 | 513 |
| 481 } // namespace dart | 514 } // namespace dart |
| 482 | 515 |
| 483 #endif // VM_SNAPSHOT_H_ | 516 #endif // VM_SNAPSHOT_H_ |
| OLD | NEW |