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/bigint_operations.h" | 5 #include "vm/bigint_operations.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/symbols.h" | 9 #include "vm/symbols.h" |
10 #include "vm/visitor.h" | 10 #include "vm/visitor.h" |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 writer->Write<int8_t>(ptr()->type_state_); | 300 writer->Write<int8_t>(ptr()->type_state_); |
301 | 301 |
302 // Write out all the object pointer fields. Since we will be canonicalizing | 302 // Write out all the object pointer fields. Since we will be canonicalizing |
303 // the type object when reading it back we should write out all the fields | 303 // the type object when reading it back we should write out all the fields |
304 // inline and not as references. | 304 // inline and not as references. |
305 SnapshotWriterVisitor visitor(writer, false); | 305 SnapshotWriterVisitor visitor(writer, false); |
306 visitor.VisitPointers(from(), to()); | 306 visitor.VisitPointers(from(), to()); |
307 } | 307 } |
308 | 308 |
309 | 309 |
| 310 RawTypeRef* TypeRef::ReadFrom(SnapshotReader* reader, |
| 311 intptr_t object_id, |
| 312 intptr_t tags, |
| 313 Snapshot::Kind kind) { |
| 314 ASSERT(reader != NULL); |
| 315 |
| 316 // Allocate type ref object. |
| 317 TypeRef& type_ref = TypeRef::ZoneHandle( |
| 318 reader->isolate(), NEW_OBJECT(TypeRef)); |
| 319 reader->AddBackRef(object_id, &type_ref, kIsDeserialized); |
| 320 |
| 321 // Set the object tags. |
| 322 type_ref.set_tags(tags); |
| 323 |
| 324 // Set all the object fields. |
| 325 // TODO(5411462): Need to assert No GC can happen here, even though |
| 326 // allocations may happen. |
| 327 intptr_t num_flds = (type_ref.raw()->to() - type_ref.raw()->from()); |
| 328 for (intptr_t i = 0; i <= num_flds; i++) { |
| 329 (*reader->ObjectHandle()) = reader->ReadObjectRef(); |
| 330 type_ref.StorePointer((type_ref.raw()->from() + i), |
| 331 reader->ObjectHandle()->raw()); |
| 332 } |
| 333 |
| 334 type_ref.set_is_being_checked(false); |
| 335 |
| 336 return type_ref.raw(); |
| 337 } |
| 338 |
| 339 |
| 340 void RawTypeRef::WriteTo(SnapshotWriter* writer, |
| 341 intptr_t object_id, |
| 342 Snapshot::Kind kind) { |
| 343 ASSERT(writer != NULL); |
| 344 |
| 345 // Write out the serialization header value for this object. |
| 346 writer->WriteInlinedObjectHeader(object_id); |
| 347 |
| 348 // Write out the class and tags information. |
| 349 writer->WriteIndexedObject(kTypeRefCid); |
| 350 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 351 |
| 352 // Write out all the object pointer fields. |
| 353 SnapshotWriterVisitor visitor(writer); |
| 354 visitor.VisitPointers(from(), to()); |
| 355 } |
| 356 |
| 357 |
310 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader, | 358 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader, |
311 intptr_t object_id, | 359 intptr_t object_id, |
312 intptr_t tags, | 360 intptr_t tags, |
313 Snapshot::Kind kind) { | 361 Snapshot::Kind kind) { |
314 ASSERT(reader != NULL); | 362 ASSERT(reader != NULL); |
315 | 363 |
316 // Allocate type parameter object. | 364 // Allocate type parameter object. |
317 TypeParameter& type_parameter = TypeParameter::ZoneHandle( | 365 TypeParameter& type_parameter = TypeParameter::ZoneHandle( |
318 reader->isolate(), NEW_OBJECT(TypeParameter)); | 366 reader->isolate(), NEW_OBJECT(TypeParameter)); |
319 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized); | 367 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized); |
(...skipping 2346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2666 // We do not allow objects with native fields in an isolate message. | 2714 // We do not allow objects with native fields in an isolate message. |
2667 writer->SetWriteException(Exceptions::kArgument, | 2715 writer->SetWriteException(Exceptions::kArgument, |
2668 "Illegal argument in isolate message" | 2716 "Illegal argument in isolate message" |
2669 " : (object is a MirrorReference)"); | 2717 " : (object is a MirrorReference)"); |
2670 } else { | 2718 } else { |
2671 UNREACHABLE(); | 2719 UNREACHABLE(); |
2672 } | 2720 } |
2673 } | 2721 } |
2674 | 2722 |
2675 } // namespace dart | 2723 } // namespace dart |
OLD | NEW |