Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Unified Diff: runtime/vm/snapshot.h

Issue 9235063: Implementation of message reader for converting a message snapshot into a C structure (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed first round of review comments from asive@ and turnidge@ Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/snapshot.h
diff --git a/runtime/vm/snapshot.h b/runtime/vm/snapshot.h
index 42bff45915c1c5c240608e9edeb42795bcc824ad..fee634782352cdd141c95599dafd6e135b22200b 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 CMessageReader;
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,41 @@ class SnapshotReader {
};
+// Reads a message snapshot into C structure.
+class CMessageReader : public BaseReader {
+ public:
+ CMessageReader(const uint8_t* buffer, intptr_t length, ReAlloc alloc);
+ ~CMessageReader() { }
+
+ Dart_CObject* ReadObject();
+
+ private:
+ // Allocates a Dart_CObject object on the C heap.
+ Dart_CObject* AllocateDartValue();
+ // Allocates a Dart_CObject object with the specified type on the C heap.
+ Dart_CObject* AllocateDartValue(Dart_CObject::Type type);
+ // Allocates a Dart_CObject object for the null object on the C heap.
+ Dart_CObject* AllocateDartValueNull();
+ // Allocates a Dart_CObject object for a boolean object on the C heap.
+ Dart_CObject* AllocateDartValueBool(bool value);
+ // Allocates a Dart_CObject object for for a 32-bit integer on the C heap.
+ Dart_CObject* AllocateDartValueInt32(int32_t value);
+ // Allocates a Dart_CObject object for a double on the C heap.
+ Dart_CObject* AllocateDartValueDouble(double value);
+ // Allocates a Dart_CObject object for string data on the C heap.
+ Dart_CObject* AllocateDartValueString(intptr_t length);
+ // Allocates a C array of Dart_CObject objects on the C heap.
+ Dart_CObject* AllocateDartValueArray(intptr_t length);
+
+ intptr_t LookupInternalClass(intptr_t class_header);
+ Dart_CObject* ReadInlinedObject(intptr_t object_id);
+ Dart_CObject* ReadObjectImpl(intptr_t header);
+ Dart_CObject* ReadIndexedObject(intptr_t object_id);
+
+ ReAlloc alloc_;
+};
+
+
class BaseWriter {
public:
// Size of the snapshot.

Powered by Google App Engine
This is Rietveld 408576698