| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 } else { | 53 } else { |
| 54 cls = New<Instance>(kIllegalCid); | 54 cls = New<Instance>(kIllegalCid); |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 reader->AddBackRef(object_id, &cls, kIsDeserialized); | 57 reader->AddBackRef(object_id, &cls, kIsDeserialized); |
| 58 | 58 |
| 59 // Set the object tags. | 59 // Set the object tags. |
| 60 cls.set_tags(tags); | 60 cls.set_tags(tags); |
| 61 | 61 |
| 62 // Set all non object fields. | 62 // Set all non object fields. |
| 63 cls.set_instance_size_in_words(reader->ReadIntptrValue()); | 63 if (!RawObject::IsInternalVMdefinedClassId(class_id)) { |
| 64 // Instance size of a VM defined class is already set up. |
| 65 cls.set_instance_size_in_words(reader->ReadIntptrValue()); |
| 66 cls.set_next_field_offset_in_words(reader->ReadIntptrValue()); |
| 67 } |
| 64 cls.set_type_arguments_field_offset_in_words(reader->ReadIntptrValue()); | 68 cls.set_type_arguments_field_offset_in_words(reader->ReadIntptrValue()); |
| 65 cls.set_next_field_offset_in_words(reader->ReadIntptrValue()); | |
| 66 cls.set_num_native_fields(reader->ReadIntptrValue()); | 69 cls.set_num_native_fields(reader->ReadIntptrValue()); |
| 67 cls.set_token_pos(reader->ReadIntptrValue()); | 70 cls.set_token_pos(reader->ReadIntptrValue()); |
| 68 cls.set_state_bits(reader->Read<uint16_t>()); | 71 cls.set_state_bits(reader->Read<uint16_t>()); |
| 69 | 72 |
| 70 // Set all the object fields. | 73 // Set all the object fields. |
| 71 // TODO(5411462): Need to assert No GC can happen here, even though | 74 // TODO(5411462): Need to assert No GC can happen here, even though |
| 72 // allocations may happen. | 75 // allocations may happen. |
| 73 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); | 76 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); |
| 74 for (intptr_t i = 0; i <= num_flds; i++) { | 77 for (intptr_t i = 0; i <= num_flds; i++) { |
| 75 *(cls.raw()->from() + i) = reader->ReadObjectRef(); | 78 *(cls.raw()->from() + i) = reader->ReadObjectRef(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 91 | 94 |
| 92 if ((kind == Snapshot::kFull) || | 95 if ((kind == Snapshot::kFull) || |
| 93 (kind == Snapshot::kScript && | 96 (kind == Snapshot::kScript && |
| 94 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this)))) { | 97 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this)))) { |
| 95 // Write out the class and tags information. | 98 // Write out the class and tags information. |
| 96 writer->WriteVMIsolateObject(kClassCid); | 99 writer->WriteVMIsolateObject(kClassCid); |
| 97 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 100 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 98 | 101 |
| 99 // Write out all the non object pointer fields. | 102 // Write out all the non object pointer fields. |
| 100 // NOTE: cpp_vtable_ is not written. | 103 // NOTE: cpp_vtable_ is not written. |
| 101 writer->WriteIntptrValue(ptr()->id_); | 104 intptr_t class_id = ptr()->id_; |
| 102 writer->WriteIntptrValue(ptr()->instance_size_in_words_); | 105 writer->WriteIntptrValue(class_id); |
| 106 if (!RawObject::IsInternalVMdefinedClassId(class_id)) { |
| 107 // We don't write the instance size of VM defined classes as they |
| 108 // are already setup during initialization as part of pre populating |
| 109 // the class table. |
| 110 writer->WriteIntptrValue(ptr()->instance_size_in_words_); |
| 111 writer->WriteIntptrValue(ptr()->next_field_offset_in_words_); |
| 112 } |
| 103 writer->WriteIntptrValue(ptr()->type_arguments_field_offset_in_words_); | 113 writer->WriteIntptrValue(ptr()->type_arguments_field_offset_in_words_); |
| 104 writer->WriteIntptrValue(ptr()->next_field_offset_in_words_); | |
| 105 writer->WriteIntptrValue(ptr()->num_native_fields_); | 114 writer->WriteIntptrValue(ptr()->num_native_fields_); |
| 106 writer->WriteIntptrValue(ptr()->token_pos_); | 115 writer->WriteIntptrValue(ptr()->token_pos_); |
| 107 writer->Write<uint16_t>(ptr()->state_bits_); | 116 writer->Write<uint16_t>(ptr()->state_bits_); |
| 108 | 117 |
| 109 // Write out all the object pointer fields. | 118 // Write out all the object pointer fields. |
| 110 SnapshotWriterVisitor visitor(writer); | 119 SnapshotWriterVisitor visitor(writer); |
| 111 visitor.VisitPointers(from(), to()); | 120 visitor.VisitPointers(from(), to()); |
| 112 } else { | 121 } else { |
| 113 writer->WriteClassId(this); | 122 writer->WriteClassId(this); |
| 114 } | 123 } |
| (...skipping 2523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2638 } | 2647 } |
| 2639 | 2648 |
| 2640 | 2649 |
| 2641 void RawMirrorReference::WriteTo(SnapshotWriter* writer, | 2650 void RawMirrorReference::WriteTo(SnapshotWriter* writer, |
| 2642 intptr_t object_id, | 2651 intptr_t object_id, |
| 2643 Snapshot::Kind kind) { | 2652 Snapshot::Kind kind) { |
| 2644 UNREACHABLE(); | 2653 UNREACHABLE(); |
| 2645 } | 2654 } |
| 2646 | 2655 |
| 2647 } // namespace dart | 2656 } // namespace dart |
| OLD | NEW |