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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 }; | 417 }; |
418 }; | 418 }; |
419 | 419 |
420 | 420 |
421 // Reads a message snapshot into C structure. | 421 // Reads a message snapshot into C structure. |
422 class CMessageReader : public BaseReader { | 422 class CMessageReader : public BaseReader { |
423 public: | 423 public: |
424 CMessageReader(const uint8_t* buffer, intptr_t length, ReAlloc alloc); | 424 CMessageReader(const uint8_t* buffer, intptr_t length, ReAlloc alloc); |
425 ~CMessageReader() { } | 425 ~CMessageReader() { } |
426 | 426 |
427 Dart_CObject* ReadObject(); | 427 Dart_CMessage* ReadMessage(); |
428 | 428 |
429 private: | 429 private: |
430 // Allocates a Dart_CObject object on the C heap. | 430 // Allocates a Dart_CObject object on the C heap. |
431 Dart_CObject* AllocateDartCObject(); | 431 Dart_CObject* AllocateDartCObject(); |
432 // Allocates a Dart_CObject object with the specified type on the C heap. | 432 // Allocates a Dart_CObject object with the specified type on the C heap. |
433 Dart_CObject* AllocateDartCObject(Dart_CObject::Type type); | 433 Dart_CObject* AllocateDartCObject(Dart_CObject::Type type); |
434 // Allocates a Dart_CObject object for the null object on the C heap. | 434 // Allocates a Dart_CObject object for the null object on the C heap. |
435 Dart_CObject* AllocateDartCObjectNull(); | 435 Dart_CObject* AllocateDartCObjectNull(); |
436 // Allocates a Dart_CObject object for a boolean object on the C heap. | 436 // Allocates a Dart_CObject object for a boolean object on the C heap. |
437 Dart_CObject* AllocateDartCObjectBool(bool value); | 437 Dart_CObject* AllocateDartCObjectBool(bool value); |
438 // Allocates a Dart_CObject object for for a 32-bit integer on the C heap. | 438 // Allocates a Dart_CObject object for for a 32-bit integer on the C heap. |
439 Dart_CObject* AllocateDartCObjectInt32(int32_t value); | 439 Dart_CObject* AllocateDartCObjectInt32(int32_t value); |
440 // Allocates a Dart_CObject object for a double on the C heap. | 440 // Allocates a Dart_CObject object for a double on the C heap. |
441 Dart_CObject* AllocateDartCObjectDouble(double value); | 441 Dart_CObject* AllocateDartCObjectDouble(double value); |
442 // Allocates a Dart_CObject object for string data on the C heap. | 442 // Allocates a Dart_CObject object for string data on the C heap. |
443 Dart_CObject* AllocateDartCObjectString(intptr_t length); | 443 Dart_CObject* AllocateDartCObjectString(intptr_t length); |
444 // Allocates a C array of Dart_CObject objects on the C heap. | 444 // Allocates a C array of Dart_CObject objects on the C heap. |
445 Dart_CObject* AllocateDartCObjectArray(intptr_t length); | 445 Dart_CObject* AllocateDartCObjectArray(intptr_t length); |
446 | 446 |
447 intptr_t LookupInternalClass(intptr_t class_header); | 447 intptr_t LookupInternalClass(intptr_t class_header); |
448 Dart_CObject* ReadInlinedObject(intptr_t object_id); | 448 Dart_CObject* ReadInlinedObject(intptr_t object_id); |
449 Dart_CObject* ReadObjectImpl(intptr_t header); | 449 Dart_CObject* ReadObjectImpl(intptr_t header); |
450 Dart_CObject* ReadIndexedObject(intptr_t object_id); | 450 Dart_CObject* ReadIndexedObject(intptr_t object_id); |
| 451 Dart_CObject* ReadObject(); |
451 | 452 |
452 // Add object to backward references. | 453 // Add object to backward references. |
453 void AddBackwardReference(intptr_t id, Dart_CObject* obj); | 454 void AddBackwardReference(intptr_t id, Dart_CObject* obj); |
454 | 455 |
455 Dart_CObject_Internal* AsInternal(Dart_CObject* object) { | 456 Dart_CObject_Internal* AsInternal(Dart_CObject* object) { |
456 ASSERT(object->type >= Dart_CObject::kNumberOfTypes); | 457 ASSERT(object->type >= Dart_CObject::kNumberOfTypes); |
457 return reinterpret_cast<Dart_CObject_Internal*>(object); | 458 return reinterpret_cast<Dart_CObject_Internal*>(object); |
458 } | 459 } |
459 | 460 |
460 ReAlloc alloc_; | 461 ReAlloc alloc_; |
461 GrowableArray<Dart_CObject*> backward_references_; | 462 GrowableArray<Dart_CObject*> backward_references_; |
| 463 GrowableArray<Dart_CObject*> allocated_; |
462 | 464 |
463 Dart_CObject type_arguments_marker; | 465 Dart_CObject type_arguments_marker; |
464 Dart_CObject dynamic_type_marker; | 466 Dart_CObject dynamic_type_marker; |
| 467 |
| 468 const uint8_t* original_message_; |
| 469 intptr_t original_message_length_; |
465 }; | 470 }; |
466 | 471 |
467 | 472 |
468 class BaseWriter { | 473 class BaseWriter { |
469 public: | 474 public: |
470 // Size of the snapshot. | 475 // Size of the snapshot. |
471 intptr_t BytesWritten() const { return stream_.bytes_written(); } | 476 intptr_t BytesWritten() const { return stream_.bytes_written(); } |
472 | 477 |
473 // Writes raw data to the stream (basic type). | 478 // Writes raw data to the stream (basic type). |
474 // sizeof(T) must be in {1,2,4,8}. | 479 // sizeof(T) must be in {1,2,4,8}. |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 | 638 |
634 private: | 639 private: |
635 SnapshotWriter* writer_; | 640 SnapshotWriter* writer_; |
636 | 641 |
637 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); | 642 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); |
638 }; | 643 }; |
639 | 644 |
640 } // namespace dart | 645 } // namespace dart |
641 | 646 |
642 #endif // VM_SNAPSHOT_H_ | 647 #endif // VM_SNAPSHOT_H_ |
OLD | NEW |