| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 writer->WriteObjectHeader(kInlined, object_id); | 276 writer->WriteObjectHeader(kInlined, object_id); |
| 277 | 277 |
| 278 // Write out the class information. | 278 // Write out the class information. |
| 279 writer->WriteObjectHeader(kObjectId, Object::kInstantiatedTypeClass); | 279 writer->WriteObjectHeader(kObjectId, Object::kInstantiatedTypeClass); |
| 280 | 280 |
| 281 // Write out all the object pointer fields. | 281 // Write out all the object pointer fields. |
| 282 visitor.VisitPointers(from(), to()); | 282 visitor.VisitPointers(from(), to()); |
| 283 } | 283 } |
| 284 | 284 |
| 285 | 285 |
| 286 RawAbstractTypeArguments* AbstractTypeArguments::ReadFrom( |
| 287 SnapshotReader* reader, |
| 288 intptr_t object_id, |
| 289 bool classes_serialized) { |
| 290 UNREACHABLE(); // AbstractTypeArguments is an abstract class. |
| 291 return TypeArguments::null(); |
| 292 } |
| 293 |
| 294 |
| 295 void RawAbstractTypeArguments::WriteTo(SnapshotWriter* writer, |
| 296 intptr_t object_id, |
| 297 bool serialize_classes) { |
| 298 UNREACHABLE(); // AbstractTypeArguments is an abstract class. |
| 299 } |
| 300 |
| 301 |
| 286 RawTypeArguments* TypeArguments::ReadFrom(SnapshotReader* reader, | 302 RawTypeArguments* TypeArguments::ReadFrom(SnapshotReader* reader, |
| 287 intptr_t object_id, | |
| 288 bool classes_serialized) { | |
| 289 UNREACHABLE(); // TypeArguments is an abstract class. | |
| 290 return TypeArray::null(); | |
| 291 } | |
| 292 | |
| 293 | |
| 294 void RawTypeArguments::WriteTo(SnapshotWriter* writer, | |
| 295 intptr_t object_id, | |
| 296 bool serialize_classes) { | |
| 297 UNREACHABLE(); // TypeArguments is an abstract class. | |
| 298 } | |
| 299 | |
| 300 | |
| 301 RawTypeArray* TypeArray::ReadFrom(SnapshotReader* reader, | |
| 302 intptr_t object_id, | 303 intptr_t object_id, |
| 303 bool classes_serialized) { | 304 bool classes_serialized) { |
| 304 ASSERT(reader != NULL); | 305 ASSERT(reader != NULL); |
| 305 | 306 |
| 306 // Read the length so that we can determine instance size to allocate. | 307 // Read the length so that we can determine instance size to allocate. |
| 307 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); | 308 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); |
| 308 intptr_t len = Smi::Value(smi_len); | 309 intptr_t len = Smi::Value(smi_len); |
| 309 | 310 |
| 310 TypeArray& type_array = TypeArray::Handle(TypeArray::New(len)); | 311 TypeArguments& type_array = TypeArguments::Handle(TypeArguments::New(len)); |
| 311 reader->AddBackwardReference(object_id, &type_array); | 312 reader->AddBackwardReference(object_id, &type_array); |
| 312 AbstractType& type = AbstractType::Handle(); | 313 AbstractType& type = AbstractType::Handle(); |
| 313 for (intptr_t i = 0; i < len; i++) { | 314 for (intptr_t i = 0; i < len; i++) { |
| 314 type ^= reader->ReadObject(); | 315 type ^= reader->ReadObject(); |
| 315 type_array.SetTypeAt(i, type); | 316 type_array.SetTypeAt(i, type); |
| 316 } | 317 } |
| 317 return type_array.raw(); | 318 return type_array.raw(); |
| 318 } | 319 } |
| 319 | 320 |
| 320 | 321 |
| 321 void RawTypeArray::WriteTo(SnapshotWriter* writer, | 322 void RawTypeArguments::WriteTo(SnapshotWriter* writer, |
| 322 intptr_t object_id, | 323 intptr_t object_id, |
| 323 bool serialize_classes) { | 324 bool serialize_classes) { |
| 324 ASSERT(writer != NULL); | 325 ASSERT(writer != NULL); |
| 325 | 326 |
| 326 // Write out the serialization header value for this object. | 327 // Write out the serialization header value for this object. |
| 327 writer->WriteObjectHeader(kInlined, object_id); | 328 writer->WriteObjectHeader(kInlined, object_id); |
| 328 | 329 |
| 329 // Write out the class information. | 330 // Write out the class information. |
| 330 writer->WriteObjectHeader(kObjectId, Object::kTypeArrayClass); | 331 writer->WriteObjectHeader(kObjectId, Object::kTypeArgumentsClass); |
| 331 | 332 |
| 332 // Write out the length field. | 333 // Write out the length field. |
| 333 writer->Write<RawObject*>(ptr()->length_); | 334 writer->Write<RawObject*>(ptr()->length_); |
| 334 | 335 |
| 335 // Write out the individual types. | 336 // Write out the individual types. |
| 336 intptr_t len = Smi::Value(ptr()->length_); | 337 intptr_t len = Smi::Value(ptr()->length_); |
| 337 for (intptr_t i = 0; i < len; i++) { | 338 for (intptr_t i = 0; i < len; i++) { |
| 338 writer->WriteObject(ptr()->types_[i]); | 339 writer->WriteObject(ptr()->types_[i]); |
| 339 } | 340 } |
| 340 } | 341 } |
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 bool classes_serialized) { | 1203 bool classes_serialized) { |
| 1203 ASSERT(reader != NULL); | 1204 ASSERT(reader != NULL); |
| 1204 | 1205 |
| 1205 // Read the length so that we can determine instance size to allocate. | 1206 // Read the length so that we can determine instance size to allocate. |
| 1206 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); | 1207 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); |
| 1207 intptr_t len = Smi::Value(smi_len); | 1208 intptr_t len = Smi::Value(smi_len); |
| 1208 T& result = T::Handle(T::New(len, | 1209 T& result = T::Handle(T::New(len, |
| 1209 classes_serialized ? Heap::kOld : Heap::kNew)); | 1210 classes_serialized ? Heap::kOld : Heap::kNew)); |
| 1210 reader->AddBackwardReference(object_id, &result); | 1211 reader->AddBackwardReference(object_id, &result); |
| 1211 | 1212 |
| 1212 TypeArguments& type_arguments = TypeArguments::Handle(); | 1213 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); |
| 1213 type_arguments ^= reader->ReadObject(); | 1214 type_arguments ^= reader->ReadObject(); |
| 1214 result.SetTypeArguments(type_arguments); | 1215 result.SetTypeArguments(type_arguments); |
| 1215 | 1216 |
| 1216 Object& obj = Object::Handle(); | 1217 Object& obj = Object::Handle(); |
| 1217 for (intptr_t i = 0; i < len; i++) { | 1218 for (intptr_t i = 0; i < len; i++) { |
| 1218 obj = reader->ReadObject(); | 1219 obj = reader->ReadObject(); |
| 1219 result.SetAt(i, obj); | 1220 result.SetAt(i, obj); |
| 1220 } | 1221 } |
| 1221 return result.raw(); | 1222 return result.raw(); |
| 1222 } | 1223 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1237 return reinterpret_cast<RawImmutableArray*>( | 1238 return reinterpret_cast<RawImmutableArray*>( |
| 1238 ArrayReadFrom<ImmutableArray>(reader, object_id, classes_serialized)); | 1239 ArrayReadFrom<ImmutableArray>(reader, object_id, classes_serialized)); |
| 1239 } | 1240 } |
| 1240 | 1241 |
| 1241 | 1242 |
| 1242 static void ArrayWriteTo(SnapshotWriter* writer, | 1243 static void ArrayWriteTo(SnapshotWriter* writer, |
| 1243 intptr_t object_id, | 1244 intptr_t object_id, |
| 1244 bool serialize_classes, | 1245 bool serialize_classes, |
| 1245 intptr_t kind, | 1246 intptr_t kind, |
| 1246 RawSmi* length, | 1247 RawSmi* length, |
| 1247 RawTypeArguments* type_arguments, | 1248 RawAbstractTypeArguments* type_arguments, |
| 1248 RawObject* data[]) { | 1249 RawObject* data[]) { |
| 1249 ASSERT(writer != NULL); | 1250 ASSERT(writer != NULL); |
| 1250 intptr_t len = Smi::Value(length); | 1251 intptr_t len = Smi::Value(length); |
| 1251 | 1252 |
| 1252 // Write out the serialization header value for this object. | 1253 // Write out the serialization header value for this object. |
| 1253 writer->WriteObjectHeader(kInlined, object_id); | 1254 writer->WriteObjectHeader(kInlined, object_id); |
| 1254 | 1255 |
| 1255 // Write out the class information. | 1256 // Write out the class information. |
| 1256 writer->WriteObjectHeader(kObjectId, kind); | 1257 writer->WriteObjectHeader(kObjectId, kind); |
| 1257 | 1258 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 // Write out all the other fields. | 1385 // Write out all the other fields. |
| 1385 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); | 1386 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); |
| 1386 writer->WriteObject(ptr()->pattern_); | 1387 writer->WriteObject(ptr()->pattern_); |
| 1387 writer->Write<intptr_t>(ptr()->type_); | 1388 writer->Write<intptr_t>(ptr()->type_); |
| 1388 writer->Write<intptr_t>(ptr()->flags_); | 1389 writer->Write<intptr_t>(ptr()->flags_); |
| 1389 | 1390 |
| 1390 // Do not write out the data part which is native. | 1391 // Do not write out the data part which is native. |
| 1391 } | 1392 } |
| 1392 | 1393 |
| 1393 } // namespace dart | 1394 } // namespace dart |
| OLD | NEW |