Chromium Code Reviews| Index: runtime/vm/snapshot.h |
| diff --git a/runtime/vm/snapshot.h b/runtime/vm/snapshot.h |
| index 42bff45915c1c5c240608e9edeb42795bcc824ad..01669489c1cb50bc2988f5bfd32cce6c2288cf85 100644 |
| --- a/runtime/vm/snapshot.h |
| +++ b/runtime/vm/snapshot.h |
| @@ -37,6 +37,7 @@ class RawMint; |
| class RawObject; |
| class RawOneByteString; |
| class RawScript; |
| +class RawSmi; |
| class RawTokenStream; |
| class RawType; |
| class RawTypeParameter; |
| @@ -193,6 +194,7 @@ class ReadStream : public ValueObject { |
| // SnapshotReader needs access to the private Raw classes. |
| friend class SnapshotReader; |
| + friend class MessageReader; |
| DISALLOW_COPY_AND_ASSIGN(ReadStream); |
| }; |
| @@ -298,12 +300,9 @@ class WriteStream : public ValueObject { |
| }; |
| -// Reads a snapshot into objects. |
| -class SnapshotReader { |
| +class BaseReader { |
| public: |
| - SnapshotReader(const Snapshot* snapshot, Isolate* isolate); |
| - ~SnapshotReader() { } |
| - |
| + BaseReader(const uint8_t* buffer, intptr_t size) : stream_(buffer, size) {} |
| // Reads raw data (for basic types). |
| // sizeof(T) must be in {1,2,4,8}. |
| template <typename T> |
| @@ -318,6 +317,20 @@ class SnapshotReader { |
| return value; |
| } |
| + RawSmi* ReadAsSmi(); |
| + intptr_t ReadSmiValue(); |
| + |
| + private: |
| + ReadStream stream_; // input stream. |
| +}; |
| + |
| + |
| +// Reads a snapshot into objects. |
| +class SnapshotReader : public BaseReader { |
| + public: |
| + SnapshotReader(const Snapshot* snapshot, Isolate* isolate); |
| + ~SnapshotReader() { } |
| + |
| Isolate* isolate() const { return isolate_; } |
| Heap* heap() const { return isolate_->heap(); } |
| ObjectStore* object_store() const { return isolate_->object_store(); } |
| @@ -377,7 +390,6 @@ class SnapshotReader { |
| // Based on header field check to see if it is an internal VM class. |
| RawClass* LookupInternalClass(intptr_t class_header); |
| - ReadStream stream_; // input stream. |
| Snapshot::Kind kind_; // Indicates type of snapshot(full, script, message). |
| Isolate* isolate_; // Current isolate. |
| Class& cls_; // Temporary Class handle. |
| @@ -392,6 +404,39 @@ class SnapshotReader { |
| }; |
| +// Reads a snapshot into C structure. |
| +class MessageReader : public BaseReader { |
|
turnidge
2012/01/26 19:48:30
Maybe name this CMessageReader?
Søren Gjesse
2012/01/27 14:40:03
Done.
|
| + public: |
| + MessageReader(const uint8_t* buffer, intptr_t length); |
| + ~MessageReader() { } |
| + |
| + Dart_Value* ReadObject(); |
| + |
| + private: |
| + // Allocate a Dart_Value object on the C heap. |
|
turnidge
2012/01/26 19:48:30
s/Allocate/Allocates/
Søren Gjesse
2012/01/27 14:40:03
Done.
|
| + Dart_Value* AllocateDartValue(); |
| + // Allocate a Dart_Value object with the specified type on the C heap. |
| + Dart_Value* AllocateDartValue(Dart_Value::Type type); |
| + // Allocate a Dart_Value object for the null object on the C heap. |
| + Dart_Value* AllocateDartValueNull(); |
| + // Allocate a Dart_Value object for a boolean object on the C heap. |
| + Dart_Value* AllocateDartValueBool(bool value); |
| + // Allocate a Dart_Value object for for a 32-bit integer on the C heap. |
| + Dart_Value* AllocateDartValueInt32(int32_t value); |
| + // Allocate a Dart_Value object for a double on the C heap. |
| + Dart_Value* AllocateDartValueDouble(double value); |
| + // Allocate a Dart_Value object for string data on the C heap. |
| + Dart_Value* AllocateDartValueString(intptr_t length); |
| + // Allocate a C array of Dart_Value objects on the C heap. |
| + Dart_Value* AllocateDartValueArray(intptr_t length); |
| + |
| + intptr_t LookupInternalClass(intptr_t class_header); |
| + Dart_Value* ReadInlinedObject(intptr_t object_id); |
| + Dart_Value* ReadObjectImpl(intptr_t header); |
| + Dart_Value* ReadIndexedObject(intptr_t object_id); |
| +}; |
| + |
| + |
| class BaseWriter { |
| public: |
| // Size of the snapshot. |