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 #include "vm/native_entry.h" | 5 #include "vm/native_entry.h" |
6 #include "vm/object.h" | 6 #include "vm/object.h" |
7 #include "vm/object_store.h" | 7 #include "vm/object_store.h" |
8 #include "vm/snapshot.h" | 8 #include "vm/snapshot.h" |
9 #include "vm/stub_code.h" | 9 #include "vm/stub_code.h" |
10 #include "vm/symbols.h" | 10 #include "vm/symbols.h" |
(...skipping 2063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2074 // Write out the class and tags information. | 2074 // Write out the class and tags information. |
2075 writer->WriteIndexedObject(kBigintCid); | 2075 writer->WriteIndexedObject(kBigintCid); |
2076 writer->WriteTags(writer->GetObjectTags(this)); | 2076 writer->WriteTags(writer->GetObjectTags(this)); |
2077 | 2077 |
2078 // Write out all the object pointer fields. | 2078 // Write out all the object pointer fields. |
2079 SnapshotWriterVisitor visitor(writer, kAsInlinedObject); | 2079 SnapshotWriterVisitor visitor(writer, kAsInlinedObject); |
2080 visitor.VisitPointers(from(), to()); | 2080 visitor.VisitPointers(from(), to()); |
2081 } | 2081 } |
2082 | 2082 |
2083 | 2083 |
| 2084 RawPixels* Pixels::ReadFrom(SnapshotReader* reader, |
| 2085 intptr_t object_id, |
| 2086 intptr_t tags, |
| 2087 Snapshot::Kind kind, |
| 2088 bool as_reference) { |
| 2089 ASSERT(reader != NULL); |
| 2090 |
| 2091 // Allocate pixels object. |
| 2092 Pixels& obj = Pixels::ZoneHandle(reader->zone(), NEW_OBJECT(Pixels)); |
| 2093 reader->AddBackRef(object_id, &obj, kIsDeserialized); |
| 2094 |
| 2095 // Set all the object fields. |
| 2096 READ_OBJECT_FIELDS(obj, obj.raw()->from(), obj.raw()->to(), kAsInlinedObject); |
| 2097 |
| 2098 // If it is a canonical constant make it one. |
| 2099 // When reading a full snapshot we don't need to canonicalize the object |
| 2100 // as it would already be a canonical object. |
| 2101 // When reading a script snapshot or a message snapshot we always have |
| 2102 // to canonicalize the object. |
| 2103 if (RawObject::IsCanonical(tags)) { |
| 2104 if (Snapshot::IsFull(kind)) { |
| 2105 // Set the canonical bit. |
| 2106 obj.SetCanonical(); |
| 2107 } else { |
| 2108 obj ^= obj.CheckAndCanonicalize(reader->thread(), NULL); |
| 2109 ASSERT(!obj.IsNull()); |
| 2110 ASSERT(obj.IsCanonical()); |
| 2111 } |
| 2112 } |
| 2113 return obj.raw(); |
| 2114 } |
| 2115 |
| 2116 |
| 2117 void RawPixels::WriteTo(SnapshotWriter* writer, |
| 2118 intptr_t object_id, |
| 2119 Snapshot::Kind kind, |
| 2120 bool as_reference) { |
| 2121 ASSERT(writer != NULL); |
| 2122 |
| 2123 // Write out the serialization header value for this object. |
| 2124 writer->WriteInlinedObjectHeader(object_id); |
| 2125 |
| 2126 // Write out the class and tags information. |
| 2127 writer->WriteIndexedObject(kPixelsCid); |
| 2128 writer->WriteTags(writer->GetObjectTags(this)); |
| 2129 |
| 2130 // Write out all the object pointer fields. |
| 2131 SnapshotWriterVisitor visitor(writer, kAsInlinedObject); |
| 2132 visitor.VisitPointers(from(), to()); |
| 2133 } |
| 2134 |
| 2135 |
2084 RawDouble* Double::ReadFrom(SnapshotReader* reader, | 2136 RawDouble* Double::ReadFrom(SnapshotReader* reader, |
2085 intptr_t object_id, | 2137 intptr_t object_id, |
2086 intptr_t tags, | 2138 intptr_t tags, |
2087 Snapshot::Kind kind, | 2139 Snapshot::Kind kind, |
2088 bool as_reference) { | 2140 bool as_reference) { |
2089 ASSERT(reader != NULL); | 2141 ASSERT(reader != NULL); |
2090 ASSERT(kind != Snapshot::kMessage); | 2142 ASSERT(kind != Snapshot::kMessage); |
2091 // Read the double value for the object. | 2143 // Read the double value for the object. |
2092 double value = reader->ReadDouble(); | 2144 double value = reader->ReadDouble(); |
2093 | 2145 |
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3319 // We do not allow objects with native fields in an isolate message. | 3371 // We do not allow objects with native fields in an isolate message. |
3320 writer->SetWriteException(Exceptions::kArgument, | 3372 writer->SetWriteException(Exceptions::kArgument, |
3321 "Illegal argument in isolate message" | 3373 "Illegal argument in isolate message" |
3322 " : (object is a UserTag)"); | 3374 " : (object is a UserTag)"); |
3323 } else { | 3375 } else { |
3324 UNREACHABLE(); | 3376 UNREACHABLE(); |
3325 } | 3377 } |
3326 } | 3378 } |
3327 | 3379 |
3328 } // namespace dart | 3380 } // namespace dart |
OLD | NEW |