Index: runtime/vm/raw_object_snapshot.cc |
=================================================================== |
--- runtime/vm/raw_object_snapshot.cc (revision 11192) |
+++ runtime/vm/raw_object_snapshot.cc (working copy) |
@@ -232,7 +232,7 @@ |
writer->Write<int8_t>(ptr()->type_state_); |
// Write out all the object pointer fields. |
- SnapshotWriterVisitor visitor(writer, false); |
+ SnapshotWriterVisitor visitor(writer); |
siva
2012/08/22 23:55:05
We should probably leave it as , false here becaus
regis
2012/08/23 00:24:25
I fixed it the other way around, by reading refs.
|
visitor.VisitPointers(from(), to()); |
} |
@@ -287,7 +287,7 @@ |
writer->Write<int8_t>(ptr()->type_state_); |
// Write out all the object pointer fields. |
- SnapshotWriterVisitor visitor(writer, false); |
+ SnapshotWriterVisitor visitor(writer); |
siva
2012/08/22 23:55:05
Ditto.
regis
2012/08/23 00:24:25
Ditto
|
visitor.VisitPointers(from(), to()); |
} |
@@ -407,7 +407,7 @@ |
writer->WriteIntptrValue(writer->GetObjectTags(this)); |
// Write out all the object pointer fields. |
- SnapshotWriterVisitor visitor(writer, false); |
+ SnapshotWriterVisitor visitor(writer); |
siva
2012/08/22 23:55:05
Ditto.
regis
2012/08/23 00:24:25
Ditto
|
visitor.VisitPointers(from(), to()); |
} |
@@ -417,7 +417,8 @@ |
intptr_t tags, |
Snapshot::Kind kind) { |
ASSERT(reader != NULL); |
- ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); |
+ ASSERT((kind != Snapshot::kMessage) && |
turnidge
2012/08/22 23:49:17
Why the extra parens?
regis
2012/08/23 00:24:25
Not that I like them that much, but our style guid
|
+ !RawObject::IsCreatedFromSnapshot(tags)); |
// Allocate function object. |
PatchClass& cls = PatchClass::ZoneHandle(reader->isolate(), |
@@ -443,7 +444,7 @@ |
intptr_t object_id, |
Snapshot::Kind kind) { |
ASSERT(writer != NULL); |
- ASSERT(kind != Snapshot::kMessage && |
+ ASSERT((kind != Snapshot::kMessage) && |
!RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
// Write out the serialization header value for this object. |
@@ -463,7 +464,8 @@ |
intptr_t tags, |
Snapshot::Kind kind) { |
ASSERT(reader != NULL); |
- ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); |
+ ASSERT((kind != Snapshot::kMessage) && |
+ !RawObject::IsCreatedFromSnapshot(tags)); |
// Allocate function object. |
Function& func = Function::ZoneHandle( |
@@ -498,7 +500,7 @@ |
intptr_t object_id, |
Snapshot::Kind kind) { |
ASSERT(writer != NULL); |
- ASSERT(kind != Snapshot::kMessage && |
+ ASSERT((kind != Snapshot::kMessage) && |
!RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
// Write out the serialization header value for this object. |
@@ -528,7 +530,8 @@ |
intptr_t tags, |
Snapshot::Kind kind) { |
ASSERT(reader != NULL); |
- ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); |
+ ASSERT((kind != Snapshot::kMessage) && |
+ !RawObject::IsCreatedFromSnapshot(tags)); |
// Allocate field object. |
Field& field = Field::ZoneHandle(reader->isolate(), NEW_OBJECT(Field)); |
@@ -557,7 +560,7 @@ |
intptr_t object_id, |
Snapshot::Kind kind) { |
ASSERT(writer != NULL); |
- ASSERT(kind != Snapshot::kMessage && |
+ ASSERT((kind != Snapshot::kMessage) && |
!RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
// Write out the serialization header value for this object. |
@@ -631,7 +634,8 @@ |
intptr_t tags, |
Snapshot::Kind kind) { |
ASSERT(reader != NULL); |
- ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); |
+ ASSERT((kind != Snapshot::kMessage) |
+ && !RawObject::IsCreatedFromSnapshot(tags)); |
// Read the length so that we can determine number of tokens to read. |
intptr_t len = reader->ReadSmiValue(); |
@@ -666,7 +670,7 @@ |
intptr_t object_id, |
Snapshot::Kind kind) { |
ASSERT(writer != NULL); |
- ASSERT(kind != Snapshot::kMessage && |
+ ASSERT((kind != Snapshot::kMessage) && |
!RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
// Write out the serialization header value for this object. |
@@ -693,7 +697,8 @@ |
intptr_t tags, |
Snapshot::Kind kind) { |
ASSERT(reader != NULL); |
- ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); |
+ ASSERT((kind != Snapshot::kMessage) && |
+ !RawObject::IsCreatedFromSnapshot(tags)); |
// Allocate script object. |
Script& script = Script::ZoneHandle(reader->isolate(), NEW_OBJECT(Script)); |
@@ -722,7 +727,7 @@ |
Snapshot::Kind kind) { |
ASSERT(writer != NULL); |
ASSERT(tokens_ != TokenStream::null()); |
- ASSERT(kind != Snapshot::kMessage && |
+ ASSERT((kind != Snapshot::kMessage) && |
!RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
// Write out the serialization header value for this object. |
@@ -834,7 +839,8 @@ |
intptr_t tags, |
Snapshot::Kind kind) { |
ASSERT(reader != NULL); |
- ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); |
+ ASSERT((kind != Snapshot::kMessage) && |
+ !RawObject::IsCreatedFromSnapshot(tags)); |
// Allocate library prefix object. |
LibraryPrefix& prefix = LibraryPrefix::ZoneHandle( |
@@ -863,7 +869,7 @@ |
intptr_t object_id, |
Snapshot::Kind kind) { |
ASSERT(writer != NULL); |
- ASSERT(kind != Snapshot::kMessage && |
+ ASSERT((kind != Snapshot::kMessage) && |
!RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
// Write out the serialization header value for this object. |
@@ -1140,14 +1146,14 @@ |
intptr_t tags, |
Snapshot::Kind kind) { |
UNREACHABLE(); |
- return Error::null(); |
+ return Error::null(); // Error is an abstract class. |
} |
void RawError::WriteTo(SnapshotWriter* writer, |
intptr_t object_id, |
Snapshot::Kind kind) { |
- UNREACHABLE(); |
+ UNREACHABLE(); // Error is an abstract class. |
} |
@@ -1155,15 +1161,43 @@ |
intptr_t object_id, |
intptr_t tags, |
Snapshot::Kind kind) { |
- UNREACHABLE(); |
- return ApiError::null(); |
+ ASSERT(reader != NULL); |
+ |
+ // Allocate ApiError object. |
+ ApiError& api_error = |
+ ApiError::ZoneHandle(reader->isolate(), NEW_OBJECT(ApiError)); |
+ reader->AddBackRef(object_id, &api_error, kIsDeserialized); |
+ |
+ // Set the object tags. |
+ api_error.set_tags(tags); |
+ |
+ // Set all the object fields. |
+ // TODO(5411462): Need to assert No GC can happen here, even though |
+ // allocations may happen. |
+ intptr_t num_flds = (api_error.raw()->to() - api_error.raw()->from()); |
+ for (intptr_t i = 0; i <= num_flds; i++) { |
+ *(api_error.raw()->from() + i) = reader->ReadObjectRef(); |
+ } |
+ |
+ return api_error.raw(); |
} |
void RawApiError::WriteTo(SnapshotWriter* writer, |
intptr_t object_id, |
Snapshot::Kind kind) { |
- UNREACHABLE(); |
+ ASSERT(writer != NULL); |
+ |
+ // Write out the serialization header value for this object. |
+ writer->WriteInlinedObjectHeader(object_id); |
+ |
+ // Write out the class and tags information. |
+ writer->WriteVMIsolateObject(kApiErrorCid); |
+ writer->WriteIntptrValue(writer->GetObjectTags(this)); |
+ |
+ // Write out all the object pointer fields. |
+ SnapshotWriterVisitor visitor(writer); |
+ visitor.VisitPointers(from(), to()); |
} |
@@ -1171,15 +1205,44 @@ |
intptr_t object_id, |
intptr_t tags, |
Snapshot::Kind kind) { |
- UNREACHABLE(); |
- return LanguageError::null(); |
+ ASSERT(reader != NULL); |
+ |
+ // Allocate LanguageError object. |
+ LanguageError& language_error = |
+ LanguageError::ZoneHandle(reader->isolate(), NEW_OBJECT(LanguageError)); |
+ reader->AddBackRef(object_id, &language_error, kIsDeserialized); |
+ |
+ // Set the object tags. |
+ language_error.set_tags(tags); |
+ |
+ // Set all the object fields. |
+ // TODO(5411462): Need to assert No GC can happen here, even though |
+ // allocations may happen. |
+ intptr_t num_flds = |
+ (language_error.raw()->to() - language_error.raw()->from()); |
+ for (intptr_t i = 0; i <= num_flds; i++) { |
+ *(language_error.raw()->from() + i) = reader->ReadObjectRef(); |
+ } |
+ |
+ return language_error.raw(); |
} |
void RawLanguageError::WriteTo(SnapshotWriter* writer, |
intptr_t object_id, |
Snapshot::Kind kind) { |
- UNREACHABLE(); |
+ ASSERT(writer != NULL); |
+ |
+ // Write out the serialization header value for this object. |
+ writer->WriteInlinedObjectHeader(object_id); |
+ |
+ // Write out the class and tags information. |
+ writer->WriteVMIsolateObject(kLanguageErrorCid); |
+ writer->WriteIntptrValue(writer->GetObjectTags(this)); |
+ |
+ // Write out all the object pointer fields. |
+ SnapshotWriterVisitor visitor(writer); |
+ visitor.VisitPointers(from(), to()); |
} |