| 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/object.h" | 5 #include "vm/object.h" |
| 6 #include "vm/object_store.h" | 6 #include "vm/object_store.h" |
| 7 #include "vm/snapshot.h" | 7 #include "vm/snapshot.h" |
| 8 #include "vm/stub_code.h" | 8 #include "vm/stub_code.h" |
| 9 #include "vm/symbols.h" | 9 #include "vm/symbols.h" |
| 10 #include "vm/visitor.h" | 10 #include "vm/visitor.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 UNREACHABLE(); // AbstractType is an abstract class. | 202 UNREACHABLE(); // AbstractType is an abstract class. |
| 203 } | 203 } |
| 204 | 204 |
| 205 | 205 |
| 206 RawType* Type::ReadFrom(SnapshotReader* reader, | 206 RawType* Type::ReadFrom(SnapshotReader* reader, |
| 207 intptr_t object_id, | 207 intptr_t object_id, |
| 208 intptr_t tags, | 208 intptr_t tags, |
| 209 Snapshot::Kind kind) { | 209 Snapshot::Kind kind) { |
| 210 ASSERT(reader != NULL); | 210 ASSERT(reader != NULL); |
| 211 | 211 |
| 212 // Determine if the type class of this type is in the full snapshot. |
| 213 bool typeclass_is_in_fullsnapshot = reader->Read<bool>(); |
| 214 |
| 212 // Allocate type object. | 215 // Allocate type object. |
| 213 Type& type = Type::ZoneHandle(reader->zone(), NEW_OBJECT(Type)); | 216 Type& type = Type::ZoneHandle(reader->zone(), NEW_OBJECT(Type)); |
| 214 bool is_canonical = RawObject::IsCanonical(tags); | 217 bool is_canonical = RawObject::IsCanonical(tags); |
| 215 bool defer_canonicalization = is_canonical && (kind != Snapshot::kFull); | 218 bool defer_canonicalization = is_canonical && |
| 219 (kind != Snapshot::kFull && typeclass_is_in_fullsnapshot); |
| 216 reader->AddBackRef(object_id, &type, kIsDeserialized, defer_canonicalization); | 220 reader->AddBackRef(object_id, &type, kIsDeserialized, defer_canonicalization); |
| 217 | 221 |
| 218 // Set all non object fields. | 222 // Set all non object fields. |
| 219 type.set_token_pos(reader->Read<int32_t>()); | 223 type.set_token_pos(reader->Read<int32_t>()); |
| 220 type.set_type_state(reader->Read<int8_t>()); | 224 type.set_type_state(reader->Read<int8_t>()); |
| 221 | 225 |
| 222 // Set all the object fields. | 226 // Set all the object fields. |
| 223 // TODO(5411462): Need to assert No GC can happen here, even though | 227 // TODO(5411462): Need to assert No GC can happen here, even though |
| 224 // allocations may happen. | 228 // allocations may happen. |
| 225 intptr_t num_flds = (type.raw()->to() - type.raw()->from()); | 229 intptr_t num_flds = (type.raw()->to() - type.raw()->from()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 250 (ptr()->type_state_ == RawType::kFinalizedUninstantiated)); | 254 (ptr()->type_state_ == RawType::kFinalizedUninstantiated)); |
| 251 ASSERT(ptr()->type_class_ != Object::null()); | 255 ASSERT(ptr()->type_class_ != Object::null()); |
| 252 | 256 |
| 253 // Write out the serialization header value for this object. | 257 // Write out the serialization header value for this object. |
| 254 writer->WriteInlinedObjectHeader(object_id); | 258 writer->WriteInlinedObjectHeader(object_id); |
| 255 | 259 |
| 256 // Write out the class and tags information. | 260 // Write out the class and tags information. |
| 257 writer->WriteIndexedObject(kTypeCid); | 261 writer->WriteIndexedObject(kTypeCid); |
| 258 writer->WriteTags(writer->GetObjectTags(this)); | 262 writer->WriteTags(writer->GetObjectTags(this)); |
| 259 | 263 |
| 264 // Write out typeclass_is_in_fullsnapshot first as this will |
| 265 // help the reader decide on how to canonicalize the type object. |
| 266 intptr_t tags = writer->GetObjectTags(ptr()->type_class_); |
| 267 bool typeclass_is_in_fullsnapshot = |
| 268 (ClassIdTag::decode(tags) == kClassCid) && |
| 269 Class::IsInFullSnapshot(reinterpret_cast<RawClass*>(ptr()->type_class_)); |
| 270 writer->Write<bool>(typeclass_is_in_fullsnapshot); |
| 271 |
| 260 // Write out all the non object pointer fields. | 272 // Write out all the non object pointer fields. |
| 261 writer->Write<int32_t>(ptr()->token_pos_); | 273 writer->Write<int32_t>(ptr()->token_pos_); |
| 262 writer->Write<int8_t>(ptr()->type_state_); | 274 writer->Write<int8_t>(ptr()->type_state_); |
| 263 | 275 |
| 264 // Write out all the object pointer fields. Since we will be canonicalizing | 276 // Write out all the object pointer fields. Since we will be canonicalizing |
| 265 // the type object when reading it back we should write out all the fields | 277 // the type object when reading it back we should write out all the fields |
| 266 // inline and not as references. | 278 // inline and not as references. |
| 267 ASSERT(ptr()->type_class_ != Object::null()); | 279 ASSERT(ptr()->type_class_ != Object::null()); |
| 268 SnapshotWriterVisitor visitor(writer); | 280 SnapshotWriterVisitor visitor(writer); |
| 269 visitor.VisitPointers(from(), to()); | 281 visitor.VisitPointers(from(), to()); |
| (...skipping 2727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2997 // We do not allow objects with native fields in an isolate message. | 3009 // We do not allow objects with native fields in an isolate message. |
| 2998 writer->SetWriteException(Exceptions::kArgument, | 3010 writer->SetWriteException(Exceptions::kArgument, |
| 2999 "Illegal argument in isolate message" | 3011 "Illegal argument in isolate message" |
| 3000 " : (object is a UserTag)"); | 3012 " : (object is a UserTag)"); |
| 3001 } else { | 3013 } else { |
| 3002 UNREACHABLE(); | 3014 UNREACHABLE(); |
| 3003 } | 3015 } |
| 3004 } | 3016 } |
| 3005 | 3017 |
| 3006 } // namespace dart | 3018 } // namespace dart |
| OLD | NEW |