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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 } | 428 } |
429 | 429 |
430 | 430 |
431 void RawMixinAppType::WriteTo(SnapshotWriter* writer, | 431 void RawMixinAppType::WriteTo(SnapshotWriter* writer, |
432 intptr_t object_id, | 432 intptr_t object_id, |
433 Snapshot::Kind kind) { | 433 Snapshot::Kind kind) { |
434 UNREACHABLE(); // MixinAppType objects do not survive finalization. | 434 UNREACHABLE(); // MixinAppType objects do not survive finalization. |
435 } | 435 } |
436 | 436 |
437 | 437 |
438 RawAbstractTypeArguments* AbstractTypeArguments::ReadFrom( | |
439 SnapshotReader* reader, | |
440 intptr_t object_id, | |
441 intptr_t tags, | |
442 Snapshot::Kind kind) { | |
443 UNREACHABLE(); // AbstractTypeArguments is an abstract class. | |
444 return TypeArguments::null(); | |
445 } | |
446 | |
447 | |
448 void RawAbstractTypeArguments::WriteTo(SnapshotWriter* writer, | |
449 intptr_t object_id, | |
450 Snapshot::Kind kind) { | |
451 UNREACHABLE(); // AbstractTypeArguments is an abstract class. | |
452 } | |
453 | |
454 | |
455 RawTypeArguments* TypeArguments::ReadFrom(SnapshotReader* reader, | 438 RawTypeArguments* TypeArguments::ReadFrom(SnapshotReader* reader, |
456 intptr_t object_id, | 439 intptr_t object_id, |
457 intptr_t tags, | 440 intptr_t tags, |
458 Snapshot::Kind kind) { | 441 Snapshot::Kind kind) { |
459 ASSERT(reader != NULL); | 442 ASSERT(reader != NULL); |
460 | 443 |
461 // Read the length so that we can determine instance size to allocate. | 444 // Read the length so that we can determine instance size to allocate. |
462 intptr_t len = reader->ReadSmiValue(); | 445 intptr_t len = reader->ReadSmiValue(); |
463 | 446 |
464 TypeArguments& type_arguments = TypeArguments::ZoneHandle( | 447 TypeArguments& type_arguments = TypeArguments::ZoneHandle( |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 writer->Write<RawObject*>(ptr()->length_); | 494 writer->Write<RawObject*>(ptr()->length_); |
512 | 495 |
513 // Write out the individual types. | 496 // Write out the individual types. |
514 intptr_t len = Smi::Value(ptr()->length_); | 497 intptr_t len = Smi::Value(ptr()->length_); |
515 for (intptr_t i = 0; i < len; i++) { | 498 for (intptr_t i = 0; i < len; i++) { |
516 writer->WriteObjectImpl(ptr()->types_[i]); | 499 writer->WriteObjectImpl(ptr()->types_[i]); |
517 } | 500 } |
518 } | 501 } |
519 | 502 |
520 | 503 |
521 RawInstantiatedTypeArguments* InstantiatedTypeArguments::ReadFrom( | |
522 SnapshotReader* reader, | |
523 intptr_t object_id, | |
524 intptr_t tags, | |
525 Snapshot::Kind kind) { | |
526 ASSERT(reader != NULL); | |
527 ASSERT(kind == Snapshot::kMessage); | |
528 | |
529 // Allocate instantiated types object. | |
530 InstantiatedTypeArguments& instantiated_type_arguments = | |
531 InstantiatedTypeArguments::ZoneHandle(reader->isolate(), | |
532 InstantiatedTypeArguments::New()); | |
533 reader->AddBackRef(object_id, &instantiated_type_arguments, kIsDeserialized); | |
534 | |
535 // Set the object tags. | |
536 instantiated_type_arguments.set_tags(tags); | |
537 | |
538 // Set all the object fields. | |
539 // TODO(5411462): Need to assert No GC can happen here, even though | |
540 // allocations may happen. | |
541 intptr_t num_flds = (instantiated_type_arguments.raw()->to() - | |
542 instantiated_type_arguments.raw()->from()); | |
543 for (intptr_t i = 0; i <= num_flds; i++) { | |
544 (*reader->ObjectHandle()) = reader->ReadObjectRef(); | |
545 instantiated_type_arguments.StorePointer( | |
546 (instantiated_type_arguments.raw()->from() + i), | |
547 reader->ObjectHandle()->raw()); | |
548 } | |
549 return instantiated_type_arguments.raw(); | |
550 } | |
551 | |
552 | |
553 void RawInstantiatedTypeArguments::WriteTo(SnapshotWriter* writer, | |
554 intptr_t object_id, | |
555 Snapshot::Kind kind) { | |
556 ASSERT(writer != NULL); | |
557 ASSERT(kind == Snapshot::kMessage); | |
558 | |
559 // Write out the serialization header value for this object. | |
560 writer->WriteInlinedObjectHeader(object_id); | |
561 | |
562 // Write out the class and tags information. | |
563 writer->WriteVMIsolateObject(kInstantiatedTypeArgumentsCid); | |
564 writer->WriteIntptrValue(writer->GetObjectTags(this)); | |
565 | |
566 // Write out all the object pointer fields. | |
567 SnapshotWriterVisitor visitor(writer); | |
568 visitor.VisitPointers(from(), to()); | |
569 } | |
570 | |
571 | |
572 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader, | 504 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader, |
573 intptr_t object_id, | 505 intptr_t object_id, |
574 intptr_t tags, | 506 intptr_t tags, |
575 Snapshot::Kind kind) { | 507 Snapshot::Kind kind) { |
576 ASSERT(reader != NULL); | 508 ASSERT(reader != NULL); |
577 ASSERT(((kind == Snapshot::kScript) && | 509 ASSERT(((kind == Snapshot::kScript) && |
578 !RawObject::IsCreatedFromSnapshot(tags)) || | 510 !RawObject::IsCreatedFromSnapshot(tags)) || |
579 (kind == Snapshot::kFull)); | 511 (kind == Snapshot::kFull)); |
580 | 512 |
581 // Allocate function object. | 513 // Allocate function object. |
(...skipping 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2174 array = reader->NewGrowableObjectArray(); | 2106 array = reader->NewGrowableObjectArray(); |
2175 } else { | 2107 } else { |
2176 array = GrowableObjectArray::New(0, HEAP_SPACE(kind)); | 2108 array = GrowableObjectArray::New(0, HEAP_SPACE(kind)); |
2177 } | 2109 } |
2178 reader->AddBackRef(object_id, &array, kIsDeserialized); | 2110 reader->AddBackRef(object_id, &array, kIsDeserialized); |
2179 intptr_t length = reader->ReadSmiValue(); | 2111 intptr_t length = reader->ReadSmiValue(); |
2180 array.SetLength(length); | 2112 array.SetLength(length); |
2181 Array& contents = Array::Handle(); | 2113 Array& contents = Array::Handle(); |
2182 contents ^= reader->ReadObjectImpl(); | 2114 contents ^= reader->ReadObjectImpl(); |
2183 array.SetData(contents); | 2115 array.SetData(contents); |
2184 const AbstractTypeArguments& type_arguments = | 2116 const TypeArguments& type_arguments = |
2185 AbstractTypeArguments::Handle(contents.GetTypeArguments()); | 2117 TypeArguments::Handle(contents.GetTypeArguments()); |
2186 array.SetTypeArguments(type_arguments); | 2118 array.SetTypeArguments(type_arguments); |
2187 return array.raw(); | 2119 return array.raw(); |
2188 } | 2120 } |
2189 | 2121 |
2190 | 2122 |
2191 void RawGrowableObjectArray::WriteTo(SnapshotWriter* writer, | 2123 void RawGrowableObjectArray::WriteTo(SnapshotWriter* writer, |
2192 intptr_t object_id, | 2124 intptr_t object_id, |
2193 Snapshot::Kind kind) { | 2125 Snapshot::Kind kind) { |
2194 ASSERT(writer != NULL); | 2126 ASSERT(writer != NULL); |
2195 | 2127 |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2730 // We do not allow objects with native fields in an isolate message. | 2662 // We do not allow objects with native fields in an isolate message. |
2731 writer->SetWriteException(Exceptions::kArgument, | 2663 writer->SetWriteException(Exceptions::kArgument, |
2732 "Illegal argument in isolate message" | 2664 "Illegal argument in isolate message" |
2733 " : (object is a MirrorReference)"); | 2665 " : (object is a MirrorReference)"); |
2734 } else { | 2666 } else { |
2735 UNREACHABLE(); | 2667 UNREACHABLE(); |
2736 } | 2668 } |
2737 } | 2669 } |
2738 | 2670 |
2739 } // namespace dart | 2671 } // namespace dart |
OLD | NEW |