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/visitor.h" | 9 #include "vm/visitor.h" |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 reader->AddBackwardReference(object_id, &cls); | 44 reader->AddBackwardReference(object_id, &cls); |
45 | 45 |
46 // Set the object tags. | 46 // Set the object tags. |
47 cls.set_tags(tags); | 47 cls.set_tags(tags); |
48 | 48 |
49 // Set all non object fields. | 49 // Set all non object fields. |
50 cls.set_instance_size(reader->ReadIntptrValue()); | 50 cls.set_instance_size(reader->ReadIntptrValue()); |
51 cls.set_type_arguments_instance_field_offset(reader->ReadIntptrValue()); | 51 cls.set_type_arguments_instance_field_offset(reader->ReadIntptrValue()); |
52 cls.set_next_field_offset(reader->ReadIntptrValue()); | 52 cls.set_next_field_offset(reader->ReadIntptrValue()); |
53 cls.set_num_native_fields(reader->ReadIntptrValue()); | 53 cls.set_num_native_fields(reader->ReadIntptrValue()); |
| 54 cls.set_token_index(reader->ReadIntptrValue()); |
54 cls.set_class_state(reader->Read<int8_t>()); | 55 cls.set_class_state(reader->Read<int8_t>()); |
55 if (reader->Read<bool>()) { | 56 if (reader->Read<bool>()) { |
56 cls.set_is_const(); | 57 cls.set_is_const(); |
57 } | 58 } |
58 if (reader->Read<bool>()) { | 59 if (reader->Read<bool>()) { |
59 cls.set_is_interface(); | 60 cls.set_is_interface(); |
60 } | 61 } |
61 | 62 |
62 // Set all the object fields. | 63 // Set all the object fields. |
63 // TODO(5411462): Need to assert No GC can happen here, even though | 64 // TODO(5411462): Need to assert No GC can happen here, even though |
(...skipping 22 matching lines...) Expand all Loading... |
86 // Write out the class and tags information. | 87 // Write out the class and tags information. |
87 writer->WriteObjectHeader(Object::kClassClass, ptr()->tags_); | 88 writer->WriteObjectHeader(Object::kClassClass, ptr()->tags_); |
88 | 89 |
89 // Write out all the non object pointer fields. | 90 // Write out all the non object pointer fields. |
90 // NOTE: cpp_vtable_ is not written. | 91 // NOTE: cpp_vtable_ is not written. |
91 writer->Write<ObjectKind>(ptr()->instance_kind_); | 92 writer->Write<ObjectKind>(ptr()->instance_kind_); |
92 writer->WriteIntptrValue(ptr()->instance_size_); | 93 writer->WriteIntptrValue(ptr()->instance_size_); |
93 writer->WriteIntptrValue(ptr()->type_arguments_instance_field_offset_); | 94 writer->WriteIntptrValue(ptr()->type_arguments_instance_field_offset_); |
94 writer->WriteIntptrValue(ptr()->next_field_offset_); | 95 writer->WriteIntptrValue(ptr()->next_field_offset_); |
95 writer->WriteIntptrValue(ptr()->num_native_fields_); | 96 writer->WriteIntptrValue(ptr()->num_native_fields_); |
| 97 writer->WriteIntptrValue(ptr()->token_index_); |
96 writer->Write<int8_t>(ptr()->class_state_); | 98 writer->Write<int8_t>(ptr()->class_state_); |
97 writer->Write<bool>(ptr()->is_const_); | 99 writer->Write<bool>(ptr()->is_const_); |
98 writer->Write<bool>(ptr()->is_interface_); | 100 writer->Write<bool>(ptr()->is_interface_); |
99 | 101 |
100 // Write out all the object pointer fields. | 102 // Write out all the object pointer fields. |
101 SnapshotWriterVisitor visitor(writer); | 103 SnapshotWriterVisitor visitor(writer); |
102 visitor.VisitPointers(from(), to()); | 104 visitor.VisitPointers(from(), to()); |
103 } else { | 105 } else { |
104 writer->WriteClassId(this); | 106 writer->WriteClassId(this); |
105 } | 107 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 181 |
180 // Allocate parameterized type object. | 182 // Allocate parameterized type object. |
181 Type& parameterized_type = Type::ZoneHandle( | 183 Type& parameterized_type = Type::ZoneHandle( |
182 reader->isolate(), NEW_OBJECT(Type)); | 184 reader->isolate(), NEW_OBJECT(Type)); |
183 reader->AddBackwardReference(object_id, ¶meterized_type); | 185 reader->AddBackwardReference(object_id, ¶meterized_type); |
184 | 186 |
185 // Set the object tags. | 187 // Set the object tags. |
186 parameterized_type.set_tags(tags); | 188 parameterized_type.set_tags(tags); |
187 | 189 |
188 // Set all non object fields. | 190 // Set all non object fields. |
| 191 parameterized_type.set_token_index(reader->ReadIntptrValue()); |
189 parameterized_type.set_type_state(reader->Read<int8_t>()); | 192 parameterized_type.set_type_state(reader->Read<int8_t>()); |
190 | 193 |
191 // Set all the object fields. | 194 // Set all the object fields. |
192 // TODO(5411462): Need to assert No GC can happen here, even though | 195 // TODO(5411462): Need to assert No GC can happen here, even though |
193 // allocations may happen. | 196 // allocations may happen. |
194 intptr_t num_flds = (parameterized_type.raw()->to() - | 197 intptr_t num_flds = (parameterized_type.raw()->to() - |
195 parameterized_type.raw()->from()); | 198 parameterized_type.raw()->from()); |
196 for (intptr_t i = 0; i <= num_flds; i++) { | 199 for (intptr_t i = 0; i <= num_flds; i++) { |
197 *(parameterized_type.raw()->from() + i) = reader->ReadObject(); | 200 *(parameterized_type.raw()->from() + i) = reader->ReadObject(); |
198 } | 201 } |
(...skipping 11 matching lines...) Expand all Loading... |
210 Snapshot::Kind kind) { | 213 Snapshot::Kind kind) { |
211 ASSERT(writer != NULL); | 214 ASSERT(writer != NULL); |
212 | 215 |
213 // Write out the serialization header value for this object. | 216 // Write out the serialization header value for this object. |
214 writer->WriteSerializationMarker(kInlined, object_id); | 217 writer->WriteSerializationMarker(kInlined, object_id); |
215 | 218 |
216 // Write out the class and tags information. | 219 // Write out the class and tags information. |
217 writer->WriteObjectHeader(Object::kTypeClass, ptr()->tags_); | 220 writer->WriteObjectHeader(Object::kTypeClass, ptr()->tags_); |
218 | 221 |
219 // Write out all the non object pointer fields. | 222 // Write out all the non object pointer fields. |
| 223 writer->WriteIntptrValue(ptr()->token_index_); |
220 writer->Write<int8_t>(ptr()->type_state_); | 224 writer->Write<int8_t>(ptr()->type_state_); |
221 | 225 |
222 // Write out all the object pointer fields. | 226 // Write out all the object pointer fields. |
223 SnapshotWriterVisitor visitor(writer); | 227 SnapshotWriterVisitor visitor(writer); |
224 visitor.VisitPointers(from(), to()); | 228 visitor.VisitPointers(from(), to()); |
225 } | 229 } |
226 | 230 |
227 | 231 |
228 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader, | 232 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader, |
229 intptr_t object_id, | 233 intptr_t object_id, |
230 intptr_t tags, | 234 intptr_t tags, |
231 Snapshot::Kind kind) { | 235 Snapshot::Kind kind) { |
232 ASSERT(reader != NULL); | 236 ASSERT(reader != NULL); |
233 | 237 |
234 // Allocate type parameter object. | 238 // Allocate type parameter object. |
235 TypeParameter& type_parameter = TypeParameter::ZoneHandle( | 239 TypeParameter& type_parameter = TypeParameter::ZoneHandle( |
236 reader->isolate(), NEW_OBJECT(TypeParameter)); | 240 reader->isolate(), NEW_OBJECT(TypeParameter)); |
237 reader->AddBackwardReference(object_id, &type_parameter); | 241 reader->AddBackwardReference(object_id, &type_parameter); |
238 | 242 |
239 // Set the object tags. | 243 // Set the object tags. |
240 type_parameter.set_tags(tags); | 244 type_parameter.set_tags(tags); |
241 | 245 |
242 // Set all non object fields. | 246 // Set all non object fields. |
243 type_parameter.set_index(reader->ReadIntptrValue()); | 247 type_parameter.set_index(reader->ReadIntptrValue()); |
| 248 type_parameter.set_token_index(reader->ReadIntptrValue()); |
244 type_parameter.set_type_state(reader->Read<int8_t>()); | 249 type_parameter.set_type_state(reader->Read<int8_t>()); |
245 | 250 |
246 // Set all the object fields. | 251 // Set all the object fields. |
247 // TODO(5411462): Need to assert No GC can happen here, even though | 252 // TODO(5411462): Need to assert No GC can happen here, even though |
248 // allocations may happen. | 253 // allocations may happen. |
249 intptr_t num_flds = (type_parameter.raw()->to() - | 254 intptr_t num_flds = (type_parameter.raw()->to() - |
250 type_parameter.raw()->from()); | 255 type_parameter.raw()->from()); |
251 for (intptr_t i = 0; i <= num_flds; i++) { | 256 for (intptr_t i = 0; i <= num_flds; i++) { |
252 *(type_parameter.raw()->from() + i) = reader->ReadObject(); | 257 *(type_parameter.raw()->from() + i) = reader->ReadObject(); |
253 } | 258 } |
254 | 259 |
255 return type_parameter.raw(); | 260 return type_parameter.raw(); |
256 } | 261 } |
257 | 262 |
258 | 263 |
259 void RawTypeParameter::WriteTo(SnapshotWriter* writer, | 264 void RawTypeParameter::WriteTo(SnapshotWriter* writer, |
260 intptr_t object_id, | 265 intptr_t object_id, |
261 Snapshot::Kind kind) { | 266 Snapshot::Kind kind) { |
262 ASSERT(writer != NULL); | 267 ASSERT(writer != NULL); |
263 | 268 |
264 // Write out the serialization header value for this object. | 269 // Write out the serialization header value for this object. |
265 writer->WriteSerializationMarker(kInlined, object_id); | 270 writer->WriteSerializationMarker(kInlined, object_id); |
266 | 271 |
267 // Write out the class and tags information. | 272 // Write out the class and tags information. |
268 writer->WriteObjectHeader(Object::kTypeParameterClass, ptr()->tags_); | 273 writer->WriteObjectHeader(Object::kTypeParameterClass, ptr()->tags_); |
269 | 274 |
270 // Write out all the non object pointer fields. | 275 // Write out all the non object pointer fields. |
271 writer->WriteIntptrValue(ptr()->index_); | 276 writer->WriteIntptrValue(ptr()->index_); |
| 277 writer->WriteIntptrValue(ptr()->token_index_); |
272 writer->Write<int8_t>(ptr()->type_state_); | 278 writer->Write<int8_t>(ptr()->type_state_); |
273 | 279 |
274 // Write out all the object pointer fields. | 280 // Write out all the object pointer fields. |
275 SnapshotWriterVisitor visitor(writer); | 281 SnapshotWriterVisitor visitor(writer); |
276 visitor.VisitPointers(from(), to()); | 282 visitor.VisitPointers(from(), to()); |
277 } | 283 } |
278 | 284 |
279 | 285 |
280 RawInstantiatedType* InstantiatedType::ReadFrom(SnapshotReader* reader, | 286 RawInstantiatedType* InstantiatedType::ReadFrom(SnapshotReader* reader, |
281 intptr_t object_id, | 287 intptr_t object_id, |
(...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1818 // Write out all the other fields. | 1824 // Write out all the other fields. |
1819 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); | 1825 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); |
1820 writer->WriteObject(ptr()->pattern_); | 1826 writer->WriteObject(ptr()->pattern_); |
1821 writer->WriteIntptrValue(ptr()->type_); | 1827 writer->WriteIntptrValue(ptr()->type_); |
1822 writer->WriteIntptrValue(ptr()->flags_); | 1828 writer->WriteIntptrValue(ptr()->flags_); |
1823 | 1829 |
1824 // Do not write out the data part which is native. | 1830 // Do not write out the data part which is native. |
1825 } | 1831 } |
1826 | 1832 |
1827 } // namespace dart | 1833 } // namespace dart |
OLD | NEW |