| 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/native_entry.h" | 5 #include "vm/native_entry.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/stub_code.h" | 9 #include "vm/stub_code.h" |
| 10 #include "vm/symbols.h" | 10 #include "vm/symbols.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 for (intptr_t i = 0; i <= num_flds; i++) { \ | 35 for (intptr_t i = 0; i <= num_flds; i++) { \ |
| 36 (*reader->PassiveObjectHandle()) = \ | 36 (*reader->PassiveObjectHandle()) = \ |
| 37 reader->ReadObjectImpl(as_reference, object_id, (i + from_offset)); \ | 37 reader->ReadObjectImpl(as_reference, object_id, (i + from_offset)); \ |
| 38 object.StorePointer(((from) + i), \ | 38 object.StorePointer(((from) + i), \ |
| 39 reader->PassiveObjectHandle()->raw()); \ | 39 reader->PassiveObjectHandle()->raw()); \ |
| 40 } | 40 } |
| 41 | 41 |
| 42 RawClass* Class::ReadFrom(SnapshotReader* reader, | 42 RawClass* Class::ReadFrom(SnapshotReader* reader, |
| 43 intptr_t object_id, | 43 intptr_t object_id, |
| 44 intptr_t tags, | 44 intptr_t tags, |
| 45 Snapshot::Kind kind) { | 45 Snapshot::Kind kind, |
| 46 bool as_reference) { |
| 46 ASSERT(reader != NULL); | 47 ASSERT(reader != NULL); |
| 47 | 48 |
| 48 Class& cls = Class::ZoneHandle(reader->zone(), Class::null()); | 49 Class& cls = Class::ZoneHandle(reader->zone(), Class::null()); |
| 49 bool is_in_fullsnapshot = reader->Read<bool>(); | 50 bool is_in_fullsnapshot = reader->Read<bool>(); |
| 50 if ((kind == Snapshot::kFull) || | 51 if ((kind == Snapshot::kFull) || |
| 51 (kind == Snapshot::kScript && !is_in_fullsnapshot)) { | 52 (kind == Snapshot::kScript && !is_in_fullsnapshot)) { |
| 52 // Read in the base information. | 53 // Read in the base information. |
| 53 classid_t class_id = reader->ReadClassIDValue(); | 54 classid_t class_id = reader->ReadClassIDValue(); |
| 54 | 55 |
| 55 // Allocate class object of specified kind. | 56 // Allocate class object of specified kind. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 85 } else { | 86 } else { |
| 86 cls ^= reader->ReadClassId(object_id); | 87 cls ^= reader->ReadClassId(object_id); |
| 87 ASSERT((kind == Snapshot::kMessage) || cls.IsInFullSnapshot()); | 88 ASSERT((kind == Snapshot::kMessage) || cls.IsInFullSnapshot()); |
| 88 } | 89 } |
| 89 return cls.raw(); | 90 return cls.raw(); |
| 90 } | 91 } |
| 91 | 92 |
| 92 | 93 |
| 93 void RawClass::WriteTo(SnapshotWriter* writer, | 94 void RawClass::WriteTo(SnapshotWriter* writer, |
| 94 intptr_t object_id, | 95 intptr_t object_id, |
| 95 Snapshot::Kind kind) { | 96 Snapshot::Kind kind, |
| 97 bool as_reference) { |
| 96 ASSERT(writer != NULL); | 98 ASSERT(writer != NULL); |
| 97 bool is_in_fullsnapshot = Class::IsInFullSnapshot(this); | 99 bool is_in_fullsnapshot = Class::IsInFullSnapshot(this); |
| 98 | 100 |
| 99 // Write out the serialization header value for this object. | 101 // Write out the serialization header value for this object. |
| 100 writer->WriteInlinedObjectHeader(object_id); | 102 writer->WriteInlinedObjectHeader(object_id); |
| 101 | 103 |
| 102 // Write out the class and tags information. | 104 // Write out the class and tags information. |
| 103 writer->WriteVMIsolateObject(kClassCid); | 105 writer->WriteVMIsolateObject(kClassCid); |
| 104 writer->WriteTags(writer->GetObjectTags(this)); | 106 writer->WriteTags(writer->GetObjectTags(this)); |
| 105 | 107 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 "Illegal argument in isolate message" | 143 "Illegal argument in isolate message" |
| 142 " : (object is a regular Dart Instance)"); | 144 " : (object is a regular Dart Instance)"); |
| 143 } | 145 } |
| 144 } | 146 } |
| 145 } | 147 } |
| 146 | 148 |
| 147 | 149 |
| 148 RawUnresolvedClass* UnresolvedClass::ReadFrom(SnapshotReader* reader, | 150 RawUnresolvedClass* UnresolvedClass::ReadFrom(SnapshotReader* reader, |
| 149 intptr_t object_id, | 151 intptr_t object_id, |
| 150 intptr_t tags, | 152 intptr_t tags, |
| 151 Snapshot::Kind kind) { | 153 Snapshot::Kind kind, |
| 154 bool as_reference) { |
| 152 ASSERT(reader != NULL); | 155 ASSERT(reader != NULL); |
| 153 | 156 |
| 154 // Allocate unresolved class object. | 157 // Allocate unresolved class object. |
| 155 UnresolvedClass& unresolved_class = UnresolvedClass::ZoneHandle( | 158 UnresolvedClass& unresolved_class = UnresolvedClass::ZoneHandle( |
| 156 reader->zone(), NEW_OBJECT(UnresolvedClass)); | 159 reader->zone(), NEW_OBJECT(UnresolvedClass)); |
| 157 reader->AddBackRef(object_id, &unresolved_class, kIsDeserialized); | 160 reader->AddBackRef(object_id, &unresolved_class, kIsDeserialized); |
| 158 | 161 |
| 159 // Set all non object fields. | 162 // Set all non object fields. |
| 160 unresolved_class.set_token_pos(reader->Read<int32_t>()); | 163 unresolved_class.set_token_pos(reader->Read<int32_t>()); |
| 161 | 164 |
| 162 // Set all the object fields. | 165 // Set all the object fields. |
| 163 READ_OBJECT_FIELDS(unresolved_class, | 166 READ_OBJECT_FIELDS(unresolved_class, |
| 164 unresolved_class.raw()->from(), | 167 unresolved_class.raw()->from(), |
| 165 unresolved_class.raw()->to(), | 168 unresolved_class.raw()->to(), |
| 166 kAsReference); | 169 kAsReference); |
| 167 | 170 |
| 168 return unresolved_class.raw(); | 171 return unresolved_class.raw(); |
| 169 } | 172 } |
| 170 | 173 |
| 171 | 174 |
| 172 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, | 175 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, |
| 173 intptr_t object_id, | 176 intptr_t object_id, |
| 174 Snapshot::Kind kind) { | 177 Snapshot::Kind kind, |
| 178 bool as_reference) { |
| 175 ASSERT(writer != NULL); | 179 ASSERT(writer != NULL); |
| 176 | 180 |
| 177 // Write out the serialization header value for this object. | 181 // Write out the serialization header value for this object. |
| 178 writer->WriteInlinedObjectHeader(object_id); | 182 writer->WriteInlinedObjectHeader(object_id); |
| 179 | 183 |
| 180 // Write out the class and tags information. | 184 // Write out the class and tags information. |
| 181 writer->WriteVMIsolateObject(kUnresolvedClassCid); | 185 writer->WriteVMIsolateObject(kUnresolvedClassCid); |
| 182 writer->WriteTags(writer->GetObjectTags(this)); | 186 writer->WriteTags(writer->GetObjectTags(this)); |
| 183 | 187 |
| 184 // Write out all the non object pointer fields. | 188 // Write out all the non object pointer fields. |
| 185 writer->Write<int32_t>(ptr()->token_pos_); | 189 writer->Write<int32_t>(ptr()->token_pos_); |
| 186 | 190 |
| 187 // Write out all the object pointer fields. | 191 // Write out all the object pointer fields. |
| 188 SnapshotWriterVisitor visitor(writer, kAsReference); | 192 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 189 visitor.VisitPointers(from(), to()); | 193 visitor.VisitPointers(from(), to()); |
| 190 } | 194 } |
| 191 | 195 |
| 192 | 196 |
| 193 RawAbstractType* AbstractType::ReadFrom(SnapshotReader* reader, | 197 RawAbstractType* AbstractType::ReadFrom(SnapshotReader* reader, |
| 194 intptr_t object_id, | 198 intptr_t object_id, |
| 195 intptr_t tags, | 199 intptr_t tags, |
| 196 Snapshot::Kind kind) { | 200 Snapshot::Kind kind, |
| 201 bool as_reference) { |
| 197 UNREACHABLE(); // AbstractType is an abstract class. | 202 UNREACHABLE(); // AbstractType is an abstract class. |
| 198 return NULL; | 203 return NULL; |
| 199 } | 204 } |
| 200 | 205 |
| 201 | 206 |
| 202 void RawAbstractType::WriteTo(SnapshotWriter* writer, | 207 void RawAbstractType::WriteTo(SnapshotWriter* writer, |
| 203 intptr_t object_id, | 208 intptr_t object_id, |
| 204 Snapshot::Kind kind) { | 209 Snapshot::Kind kind, |
| 210 bool as_reference) { |
| 205 UNREACHABLE(); // AbstractType is an abstract class. | 211 UNREACHABLE(); // AbstractType is an abstract class. |
| 206 } | 212 } |
| 207 | 213 |
| 208 | 214 |
| 209 RawType* Type::ReadFrom(SnapshotReader* reader, | 215 RawType* Type::ReadFrom(SnapshotReader* reader, |
| 210 intptr_t object_id, | 216 intptr_t object_id, |
| 211 intptr_t tags, | 217 intptr_t tags, |
| 212 Snapshot::Kind kind) { | 218 Snapshot::Kind kind, |
| 219 bool as_reference) { |
| 213 ASSERT(reader != NULL); | 220 ASSERT(reader != NULL); |
| 214 | 221 |
| 215 // Determine if the type class of this type is in the full snapshot. | 222 // Determine if the type class of this type is in the full snapshot. |
| 216 bool typeclass_is_in_fullsnapshot = reader->Read<bool>(); | 223 bool typeclass_is_in_fullsnapshot = reader->Read<bool>(); |
| 217 | 224 |
| 218 // Allocate type object. | 225 // Allocate type object. |
| 219 Type& type = Type::ZoneHandle(reader->zone(), NEW_OBJECT(Type)); | 226 Type& type = Type::ZoneHandle(reader->zone(), NEW_OBJECT(Type)); |
| 220 bool is_canonical = RawObject::IsCanonical(tags); | 227 bool is_canonical = RawObject::IsCanonical(tags); |
| 221 bool defer_canonicalization = is_canonical && | 228 bool defer_canonicalization = is_canonical && |
| 222 (kind != Snapshot::kFull && typeclass_is_in_fullsnapshot); | 229 (kind != Snapshot::kFull && typeclass_is_in_fullsnapshot); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 233 if (!defer_canonicalization && RawObject::IsCanonical(tags)) { | 240 if (!defer_canonicalization && RawObject::IsCanonical(tags)) { |
| 234 type.SetCanonical(); | 241 type.SetCanonical(); |
| 235 } | 242 } |
| 236 | 243 |
| 237 return type.raw(); | 244 return type.raw(); |
| 238 } | 245 } |
| 239 | 246 |
| 240 | 247 |
| 241 void RawType::WriteTo(SnapshotWriter* writer, | 248 void RawType::WriteTo(SnapshotWriter* writer, |
| 242 intptr_t object_id, | 249 intptr_t object_id, |
| 243 Snapshot::Kind kind) { | 250 Snapshot::Kind kind, |
| 251 bool as_reference) { |
| 244 ASSERT(writer != NULL); | 252 ASSERT(writer != NULL); |
| 245 | 253 |
| 246 // Only resolved and finalized types should be written to a snapshot. | 254 // Only resolved and finalized types should be written to a snapshot. |
| 247 ASSERT((ptr()->type_state_ == RawType::kFinalizedInstantiated) || | 255 ASSERT((ptr()->type_state_ == RawType::kFinalizedInstantiated) || |
| 248 (ptr()->type_state_ == RawType::kFinalizedUninstantiated)); | 256 (ptr()->type_state_ == RawType::kFinalizedUninstantiated)); |
| 249 ASSERT(ptr()->type_class_ != Object::null()); | 257 ASSERT(ptr()->type_class_ != Object::null()); |
| 250 | 258 |
| 251 // Write out the serialization header value for this object. | 259 // Write out the serialization header value for this object. |
| 252 writer->WriteInlinedObjectHeader(object_id); | 260 writer->WriteInlinedObjectHeader(object_id); |
| 253 | 261 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 272 // inline and not as references. | 280 // inline and not as references. |
| 273 ASSERT(ptr()->type_class_ != Object::null()); | 281 ASSERT(ptr()->type_class_ != Object::null()); |
| 274 SnapshotWriterVisitor visitor(writer, kAsReference); | 282 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 275 visitor.VisitPointers(from(), to()); | 283 visitor.VisitPointers(from(), to()); |
| 276 } | 284 } |
| 277 | 285 |
| 278 | 286 |
| 279 RawTypeRef* TypeRef::ReadFrom(SnapshotReader* reader, | 287 RawTypeRef* TypeRef::ReadFrom(SnapshotReader* reader, |
| 280 intptr_t object_id, | 288 intptr_t object_id, |
| 281 intptr_t tags, | 289 intptr_t tags, |
| 282 Snapshot::Kind kind) { | 290 Snapshot::Kind kind, |
| 291 bool as_reference) { |
| 283 ASSERT(reader != NULL); | 292 ASSERT(reader != NULL); |
| 284 | 293 |
| 285 // Allocate type ref object. | 294 // Allocate type ref object. |
| 286 TypeRef& type_ref = TypeRef::ZoneHandle( | 295 TypeRef& type_ref = TypeRef::ZoneHandle( |
| 287 reader->zone(), NEW_OBJECT(TypeRef)); | 296 reader->zone(), NEW_OBJECT(TypeRef)); |
| 288 reader->AddBackRef(object_id, &type_ref, kIsDeserialized); | 297 reader->AddBackRef(object_id, &type_ref, kIsDeserialized); |
| 289 | 298 |
| 290 // Set all the object fields. | 299 // Set all the object fields. |
| 291 READ_OBJECT_FIELDS(type_ref, | 300 READ_OBJECT_FIELDS(type_ref, |
| 292 type_ref.raw()->from(), type_ref.raw()->to(), | 301 type_ref.raw()->from(), type_ref.raw()->to(), |
| 293 kAsReference); | 302 kAsReference); |
| 294 | 303 |
| 295 return type_ref.raw(); | 304 return type_ref.raw(); |
| 296 } | 305 } |
| 297 | 306 |
| 298 | 307 |
| 299 void RawTypeRef::WriteTo(SnapshotWriter* writer, | 308 void RawTypeRef::WriteTo(SnapshotWriter* writer, |
| 300 intptr_t object_id, | 309 intptr_t object_id, |
| 301 Snapshot::Kind kind) { | 310 Snapshot::Kind kind, |
| 311 bool as_reference) { |
| 302 ASSERT(writer != NULL); | 312 ASSERT(writer != NULL); |
| 303 | 313 |
| 304 // Write out the serialization header value for this object. | 314 // Write out the serialization header value for this object. |
| 305 writer->WriteInlinedObjectHeader(object_id); | 315 writer->WriteInlinedObjectHeader(object_id); |
| 306 | 316 |
| 307 // Write out the class and tags information. | 317 // Write out the class and tags information. |
| 308 writer->WriteIndexedObject(kTypeRefCid); | 318 writer->WriteIndexedObject(kTypeRefCid); |
| 309 writer->WriteTags(writer->GetObjectTags(this)); | 319 writer->WriteTags(writer->GetObjectTags(this)); |
| 310 | 320 |
| 311 // Write out all the object pointer fields. | 321 // Write out all the object pointer fields. |
| 312 SnapshotWriterVisitor visitor(writer, kAsReference); | 322 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 313 visitor.VisitPointers(from(), to()); | 323 visitor.VisitPointers(from(), to()); |
| 314 } | 324 } |
| 315 | 325 |
| 316 | 326 |
| 317 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader, | 327 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader, |
| 318 intptr_t object_id, | 328 intptr_t object_id, |
| 319 intptr_t tags, | 329 intptr_t tags, |
| 320 Snapshot::Kind kind) { | 330 Snapshot::Kind kind, |
| 331 bool as_reference) { |
| 321 ASSERT(reader != NULL); | 332 ASSERT(reader != NULL); |
| 322 | 333 |
| 323 // Allocate type parameter object. | 334 // Allocate type parameter object. |
| 324 TypeParameter& type_parameter = TypeParameter::ZoneHandle( | 335 TypeParameter& type_parameter = TypeParameter::ZoneHandle( |
| 325 reader->zone(), NEW_OBJECT(TypeParameter)); | 336 reader->zone(), NEW_OBJECT(TypeParameter)); |
| 326 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized); | 337 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized); |
| 327 | 338 |
| 328 // Set all non object fields. | 339 // Set all non object fields. |
| 329 type_parameter.set_token_pos(reader->Read<int32_t>()); | 340 type_parameter.set_token_pos(reader->Read<int32_t>()); |
| 330 type_parameter.set_index(reader->Read<int16_t>()); | 341 type_parameter.set_index(reader->Read<int16_t>()); |
| 331 type_parameter.set_type_state(reader->Read<int8_t>()); | 342 type_parameter.set_type_state(reader->Read<int8_t>()); |
| 332 | 343 |
| 333 // Set all the object fields. | 344 // Set all the object fields. |
| 334 READ_OBJECT_FIELDS(type_parameter, | 345 READ_OBJECT_FIELDS(type_parameter, |
| 335 type_parameter.raw()->from(), type_parameter.raw()->to(), | 346 type_parameter.raw()->from(), type_parameter.raw()->to(), |
| 336 kAsReference); | 347 kAsReference); |
| 337 | 348 |
| 338 return type_parameter.raw(); | 349 return type_parameter.raw(); |
| 339 } | 350 } |
| 340 | 351 |
| 341 | 352 |
| 342 void RawTypeParameter::WriteTo(SnapshotWriter* writer, | 353 void RawTypeParameter::WriteTo(SnapshotWriter* writer, |
| 343 intptr_t object_id, | 354 intptr_t object_id, |
| 344 Snapshot::Kind kind) { | 355 Snapshot::Kind kind, |
| 356 bool as_reference) { |
| 345 ASSERT(writer != NULL); | 357 ASSERT(writer != NULL); |
| 346 | 358 |
| 347 // Only finalized type parameters should be written to a snapshot. | 359 // Only finalized type parameters should be written to a snapshot. |
| 348 ASSERT(ptr()->type_state_ == RawTypeParameter::kFinalizedUninstantiated); | 360 ASSERT(ptr()->type_state_ == RawTypeParameter::kFinalizedUninstantiated); |
| 349 | 361 |
| 350 // Write out the serialization header value for this object. | 362 // Write out the serialization header value for this object. |
| 351 writer->WriteInlinedObjectHeader(object_id); | 363 writer->WriteInlinedObjectHeader(object_id); |
| 352 | 364 |
| 353 // Write out the class and tags information. | 365 // Write out the class and tags information. |
| 354 writer->WriteIndexedObject(kTypeParameterCid); | 366 writer->WriteIndexedObject(kTypeParameterCid); |
| 355 writer->WriteTags(writer->GetObjectTags(this)); | 367 writer->WriteTags(writer->GetObjectTags(this)); |
| 356 | 368 |
| 357 // Write out all the non object pointer fields. | 369 // Write out all the non object pointer fields. |
| 358 writer->Write<int32_t>(ptr()->token_pos_); | 370 writer->Write<int32_t>(ptr()->token_pos_); |
| 359 writer->Write<int16_t>(ptr()->index_); | 371 writer->Write<int16_t>(ptr()->index_); |
| 360 writer->Write<int8_t>(ptr()->type_state_); | 372 writer->Write<int8_t>(ptr()->type_state_); |
| 361 | 373 |
| 362 // Write out all the object pointer fields. | 374 // Write out all the object pointer fields. |
| 363 SnapshotWriterVisitor visitor(writer, kAsReference); | 375 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 364 visitor.VisitPointers(from(), to()); | 376 visitor.VisitPointers(from(), to()); |
| 365 } | 377 } |
| 366 | 378 |
| 367 | 379 |
| 368 RawBoundedType* BoundedType::ReadFrom(SnapshotReader* reader, | 380 RawBoundedType* BoundedType::ReadFrom(SnapshotReader* reader, |
| 369 intptr_t object_id, | 381 intptr_t object_id, |
| 370 intptr_t tags, | 382 intptr_t tags, |
| 371 Snapshot::Kind kind) { | 383 Snapshot::Kind kind, |
| 384 bool as_reference) { |
| 372 ASSERT(reader != NULL); | 385 ASSERT(reader != NULL); |
| 373 | 386 |
| 374 // Allocate bounded type object. | 387 // Allocate bounded type object. |
| 375 BoundedType& bounded_type = BoundedType::ZoneHandle( | 388 BoundedType& bounded_type = BoundedType::ZoneHandle( |
| 376 reader->zone(), NEW_OBJECT(BoundedType)); | 389 reader->zone(), NEW_OBJECT(BoundedType)); |
| 377 reader->AddBackRef(object_id, &bounded_type, kIsDeserialized); | 390 reader->AddBackRef(object_id, &bounded_type, kIsDeserialized); |
| 378 | 391 |
| 379 // Set all the object fields. | 392 // Set all the object fields. |
| 380 READ_OBJECT_FIELDS(bounded_type, | 393 READ_OBJECT_FIELDS(bounded_type, |
| 381 bounded_type.raw()->from(), bounded_type.raw()->to(), | 394 bounded_type.raw()->from(), bounded_type.raw()->to(), |
| 382 kAsReference); | 395 kAsReference); |
| 383 | 396 |
| 384 return bounded_type.raw(); | 397 return bounded_type.raw(); |
| 385 } | 398 } |
| 386 | 399 |
| 387 | 400 |
| 388 void RawBoundedType::WriteTo(SnapshotWriter* writer, | 401 void RawBoundedType::WriteTo(SnapshotWriter* writer, |
| 389 intptr_t object_id, | 402 intptr_t object_id, |
| 390 Snapshot::Kind kind) { | 403 Snapshot::Kind kind, |
| 404 bool as_reference) { |
| 391 ASSERT(writer != NULL); | 405 ASSERT(writer != NULL); |
| 392 | 406 |
| 393 // Write out the serialization header value for this object. | 407 // Write out the serialization header value for this object. |
| 394 writer->WriteInlinedObjectHeader(object_id); | 408 writer->WriteInlinedObjectHeader(object_id); |
| 395 | 409 |
| 396 // Write out the class and tags information. | 410 // Write out the class and tags information. |
| 397 writer->WriteIndexedObject(kBoundedTypeCid); | 411 writer->WriteIndexedObject(kBoundedTypeCid); |
| 398 writer->WriteTags(writer->GetObjectTags(this)); | 412 writer->WriteTags(writer->GetObjectTags(this)); |
| 399 | 413 |
| 400 // Write out all the object pointer fields. | 414 // Write out all the object pointer fields. |
| 401 SnapshotWriterVisitor visitor(writer, kAsReference); | 415 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 402 visitor.VisitPointers(from(), to()); | 416 visitor.VisitPointers(from(), to()); |
| 403 } | 417 } |
| 404 | 418 |
| 405 | 419 |
| 406 RawMixinAppType* MixinAppType::ReadFrom(SnapshotReader* reader, | 420 RawMixinAppType* MixinAppType::ReadFrom(SnapshotReader* reader, |
| 407 intptr_t object_id, | 421 intptr_t object_id, |
| 408 intptr_t tags, | 422 intptr_t tags, |
| 409 Snapshot::Kind kind) { | 423 Snapshot::Kind kind, |
| 424 bool as_reference) { |
| 410 UNREACHABLE(); // MixinAppType objects do not survive finalization. | 425 UNREACHABLE(); // MixinAppType objects do not survive finalization. |
| 411 return MixinAppType::null(); | 426 return MixinAppType::null(); |
| 412 } | 427 } |
| 413 | 428 |
| 414 | 429 |
| 415 void RawMixinAppType::WriteTo(SnapshotWriter* writer, | 430 void RawMixinAppType::WriteTo(SnapshotWriter* writer, |
| 416 intptr_t object_id, | 431 intptr_t object_id, |
| 417 Snapshot::Kind kind) { | 432 Snapshot::Kind kind, |
| 433 bool as_reference) { |
| 418 UNREACHABLE(); // MixinAppType objects do not survive finalization. | 434 UNREACHABLE(); // MixinAppType objects do not survive finalization. |
| 419 } | 435 } |
| 420 | 436 |
| 421 | 437 |
| 422 RawTypeArguments* TypeArguments::ReadFrom(SnapshotReader* reader, | 438 RawTypeArguments* TypeArguments::ReadFrom(SnapshotReader* reader, |
| 423 intptr_t object_id, | 439 intptr_t object_id, |
| 424 intptr_t tags, | 440 intptr_t tags, |
| 425 Snapshot::Kind kind) { | 441 Snapshot::Kind kind, |
| 442 bool as_reference) { |
| 426 ASSERT(reader != NULL); | 443 ASSERT(reader != NULL); |
| 427 | 444 |
| 428 // Read the length so that we can determine instance size to allocate. | 445 // Read the length so that we can determine instance size to allocate. |
| 429 intptr_t len = reader->ReadSmiValue(); | 446 intptr_t len = reader->ReadSmiValue(); |
| 430 | 447 |
| 431 TypeArguments& type_arguments = TypeArguments::ZoneHandle( | 448 TypeArguments& type_arguments = TypeArguments::ZoneHandle( |
| 432 reader->zone(), NEW_OBJECT_WITH_LEN_SPACE(TypeArguments, len, kind)); | 449 reader->zone(), NEW_OBJECT_WITH_LEN_SPACE(TypeArguments, len, kind)); |
| 433 bool is_canonical = RawObject::IsCanonical(tags); | 450 bool is_canonical = RawObject::IsCanonical(tags); |
| 434 bool defer_canonicalization = is_canonical && (kind != Snapshot::kFull); | 451 bool defer_canonicalization = is_canonical && (kind != Snapshot::kFull); |
| 435 reader->AddBackRef(object_id, | 452 reader->AddBackRef(object_id, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 458 if (!defer_canonicalization && RawObject::IsCanonical(tags)) { | 475 if (!defer_canonicalization && RawObject::IsCanonical(tags)) { |
| 459 type_arguments.SetCanonical(); | 476 type_arguments.SetCanonical(); |
| 460 } | 477 } |
| 461 | 478 |
| 462 return type_arguments.raw(); | 479 return type_arguments.raw(); |
| 463 } | 480 } |
| 464 | 481 |
| 465 | 482 |
| 466 void RawTypeArguments::WriteTo(SnapshotWriter* writer, | 483 void RawTypeArguments::WriteTo(SnapshotWriter* writer, |
| 467 intptr_t object_id, | 484 intptr_t object_id, |
| 468 Snapshot::Kind kind) { | 485 Snapshot::Kind kind, |
| 486 bool as_reference) { |
| 469 ASSERT(writer != NULL); | 487 ASSERT(writer != NULL); |
| 470 | 488 |
| 471 // Write out the serialization header value for this object. | 489 // Write out the serialization header value for this object. |
| 472 writer->WriteInlinedObjectHeader(object_id); | 490 writer->WriteInlinedObjectHeader(object_id); |
| 473 | 491 |
| 474 // Write out the class and tags information. | 492 // Write out the class and tags information. |
| 475 writer->WriteVMIsolateObject(kTypeArgumentsCid); | 493 writer->WriteVMIsolateObject(kTypeArgumentsCid); |
| 476 writer->WriteTags(writer->GetObjectTags(this)); | 494 writer->WriteTags(writer->GetObjectTags(this)); |
| 477 | 495 |
| 478 // Write out the length field. | 496 // Write out the length field. |
| 479 writer->Write<RawObject*>(ptr()->length_); | 497 writer->Write<RawObject*>(ptr()->length_); |
| 480 | 498 |
| 481 // Write out the instantiations field, but only in a full snapshot. | 499 // Write out the instantiations field, but only in a full snapshot. |
| 482 if (kind == Snapshot::kFull) { | 500 if (kind == Snapshot::kFull) { |
| 483 writer->WriteObjectImpl(ptr()->instantiations_, kAsInlinedObject); | 501 writer->WriteObjectImpl(ptr()->instantiations_, kAsInlinedObject); |
| 484 } | 502 } |
| 485 | 503 |
| 486 // Write out the individual types. | 504 // Write out the individual types. |
| 487 intptr_t len = Smi::Value(ptr()->length_); | 505 intptr_t len = Smi::Value(ptr()->length_); |
| 488 for (intptr_t i = 0; i < len; i++) { | 506 for (intptr_t i = 0; i < len; i++) { |
| 489 writer->WriteObjectImpl(ptr()->types()[i], kAsReference); | 507 writer->WriteObjectImpl(ptr()->types()[i], kAsReference); |
| 490 } | 508 } |
| 491 } | 509 } |
| 492 | 510 |
| 493 | 511 |
| 494 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader, | 512 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader, |
| 495 intptr_t object_id, | 513 intptr_t object_id, |
| 496 intptr_t tags, | 514 intptr_t tags, |
| 497 Snapshot::Kind kind) { | 515 Snapshot::Kind kind, |
| 516 bool as_reference) { |
| 498 ASSERT(reader != NULL); | 517 ASSERT(reader != NULL); |
| 499 | 518 |
| 500 // Allocate function object. | 519 // Allocate function object. |
| 501 PatchClass& cls = PatchClass::ZoneHandle(reader->zone(), | 520 PatchClass& cls = PatchClass::ZoneHandle(reader->zone(), |
| 502 NEW_OBJECT(PatchClass)); | 521 NEW_OBJECT(PatchClass)); |
| 503 reader->AddBackRef(object_id, &cls, kIsDeserialized); | 522 reader->AddBackRef(object_id, &cls, kIsDeserialized); |
| 504 | 523 |
| 505 // Set all the object fields. | 524 // Set all the object fields. |
| 506 READ_OBJECT_FIELDS(cls, cls.raw()->from(), cls.raw()->to(), kAsReference); | 525 READ_OBJECT_FIELDS(cls, cls.raw()->from(), cls.raw()->to(), kAsReference); |
| 507 | 526 |
| 508 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 527 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 509 return cls.raw(); | 528 return cls.raw(); |
| 510 } | 529 } |
| 511 | 530 |
| 512 | 531 |
| 513 void RawPatchClass::WriteTo(SnapshotWriter* writer, | 532 void RawPatchClass::WriteTo(SnapshotWriter* writer, |
| 514 intptr_t object_id, | 533 intptr_t object_id, |
| 515 Snapshot::Kind kind) { | 534 Snapshot::Kind kind, |
| 535 bool as_reference) { |
| 516 ASSERT(writer != NULL); | 536 ASSERT(writer != NULL); |
| 517 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 537 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 518 | 538 |
| 519 // Write out the serialization header value for this object. | 539 // Write out the serialization header value for this object. |
| 520 writer->WriteInlinedObjectHeader(object_id); | 540 writer->WriteInlinedObjectHeader(object_id); |
| 521 | 541 |
| 522 // Write out the class and tags information. | 542 // Write out the class and tags information. |
| 523 writer->WriteVMIsolateObject(kPatchClassCid); | 543 writer->WriteVMIsolateObject(kPatchClassCid); |
| 524 writer->WriteTags(writer->GetObjectTags(this)); | 544 writer->WriteTags(writer->GetObjectTags(this)); |
| 525 // Write out all the object pointer fields. | 545 // Write out all the object pointer fields. |
| 526 SnapshotWriterVisitor visitor(writer, kAsReference); | 546 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 527 visitor.VisitPointers(from(), to()); | 547 visitor.VisitPointers(from(), to()); |
| 528 } | 548 } |
| 529 | 549 |
| 530 | 550 |
| 531 RawClosureData* ClosureData::ReadFrom(SnapshotReader* reader, | 551 RawClosureData* ClosureData::ReadFrom(SnapshotReader* reader, |
| 532 intptr_t object_id, | 552 intptr_t object_id, |
| 533 intptr_t tags, | 553 intptr_t tags, |
| 534 Snapshot::Kind kind) { | 554 Snapshot::Kind kind, |
| 555 bool as_reference) { |
| 535 ASSERT(reader != NULL); | 556 ASSERT(reader != NULL); |
| 536 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 557 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 537 | 558 |
| 538 // Allocate closure data object. | 559 // Allocate closure data object. |
| 539 ClosureData& data = ClosureData::ZoneHandle( | 560 ClosureData& data = ClosureData::ZoneHandle( |
| 540 reader->zone(), NEW_OBJECT(ClosureData)); | 561 reader->zone(), NEW_OBJECT(ClosureData)); |
| 541 reader->AddBackRef(object_id, &data, kIsDeserialized); | 562 reader->AddBackRef(object_id, &data, kIsDeserialized); |
| 542 | 563 |
| 543 // Set all the object fields. | 564 // Set all the object fields. |
| 544 READ_OBJECT_FIELDS(data, | 565 READ_OBJECT_FIELDS(data, |
| 545 data.raw()->from(), data.raw()->to(), | 566 data.raw()->from(), data.raw()->to(), |
| 546 kAsInlinedObject); | 567 kAsInlinedObject); |
| 547 | 568 |
| 548 return data.raw(); | 569 return data.raw(); |
| 549 } | 570 } |
| 550 | 571 |
| 551 | 572 |
| 552 void RawClosureData::WriteTo(SnapshotWriter* writer, | 573 void RawClosureData::WriteTo(SnapshotWriter* writer, |
| 553 intptr_t object_id, | 574 intptr_t object_id, |
| 554 Snapshot::Kind kind) { | 575 Snapshot::Kind kind, |
| 576 bool as_reference) { |
| 555 ASSERT(writer != NULL); | 577 ASSERT(writer != NULL); |
| 556 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 578 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 557 | 579 |
| 558 // Write out the serialization header value for this object. | 580 // Write out the serialization header value for this object. |
| 559 writer->WriteInlinedObjectHeader(object_id); | 581 writer->WriteInlinedObjectHeader(object_id); |
| 560 | 582 |
| 561 // Write out the class and tags information. | 583 // Write out the class and tags information. |
| 562 writer->WriteVMIsolateObject(kClosureDataCid); | 584 writer->WriteVMIsolateObject(kClosureDataCid); |
| 563 writer->WriteTags(writer->GetObjectTags(this)); | 585 writer->WriteTags(writer->GetObjectTags(this)); |
| 564 | 586 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 582 | 604 |
| 583 // Static closure/Closure allocation stub. | 605 // Static closure/Closure allocation stub. |
| 584 // We don't write the closure or allocation stub in the snapshot. | 606 // We don't write the closure or allocation stub in the snapshot. |
| 585 writer->WriteVMIsolateObject(kNullObject); | 607 writer->WriteVMIsolateObject(kNullObject); |
| 586 } | 608 } |
| 587 | 609 |
| 588 | 610 |
| 589 RawRedirectionData* RedirectionData::ReadFrom(SnapshotReader* reader, | 611 RawRedirectionData* RedirectionData::ReadFrom(SnapshotReader* reader, |
| 590 intptr_t object_id, | 612 intptr_t object_id, |
| 591 intptr_t tags, | 613 intptr_t tags, |
| 592 Snapshot::Kind kind) { | 614 Snapshot::Kind kind, |
| 615 bool as_reference) { |
| 593 ASSERT(reader != NULL); | 616 ASSERT(reader != NULL); |
| 594 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 617 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 595 | 618 |
| 596 // Allocate redirection data object. | 619 // Allocate redirection data object. |
| 597 RedirectionData& data = RedirectionData::ZoneHandle( | 620 RedirectionData& data = RedirectionData::ZoneHandle( |
| 598 reader->zone(), NEW_OBJECT(RedirectionData)); | 621 reader->zone(), NEW_OBJECT(RedirectionData)); |
| 599 reader->AddBackRef(object_id, &data, kIsDeserialized); | 622 reader->AddBackRef(object_id, &data, kIsDeserialized); |
| 600 | 623 |
| 601 // Set all the object fields. | 624 // Set all the object fields. |
| 602 READ_OBJECT_FIELDS(data, | 625 READ_OBJECT_FIELDS(data, |
| 603 data.raw()->from(), data.raw()->to(), | 626 data.raw()->from(), data.raw()->to(), |
| 604 kAsReference); | 627 kAsReference); |
| 605 | 628 |
| 606 return data.raw(); | 629 return data.raw(); |
| 607 } | 630 } |
| 608 | 631 |
| 609 | 632 |
| 610 void RawRedirectionData::WriteTo(SnapshotWriter* writer, | 633 void RawRedirectionData::WriteTo(SnapshotWriter* writer, |
| 611 intptr_t object_id, | 634 intptr_t object_id, |
| 612 Snapshot::Kind kind) { | 635 Snapshot::Kind kind, |
| 636 bool as_reference) { |
| 613 ASSERT(writer != NULL); | 637 ASSERT(writer != NULL); |
| 614 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 638 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 615 | 639 |
| 616 // Write out the serialization header value for this object. | 640 // Write out the serialization header value for this object. |
| 617 writer->WriteInlinedObjectHeader(object_id); | 641 writer->WriteInlinedObjectHeader(object_id); |
| 618 | 642 |
| 619 // Write out the class and tags information. | 643 // Write out the class and tags information. |
| 620 writer->WriteVMIsolateObject(kRedirectionDataCid); | 644 writer->WriteVMIsolateObject(kRedirectionDataCid); |
| 621 writer->WriteTags(writer->GetObjectTags(this)); | 645 writer->WriteTags(writer->GetObjectTags(this)); |
| 622 | 646 |
| 623 // Write out all the object pointer fields. | 647 // Write out all the object pointer fields. |
| 624 SnapshotWriterVisitor visitor(writer, kAsReference); | 648 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 625 visitor.VisitPointers(from(), to()); | 649 visitor.VisitPointers(from(), to()); |
| 626 } | 650 } |
| 627 | 651 |
| 628 | 652 |
| 629 RawFunction* Function::ReadFrom(SnapshotReader* reader, | 653 RawFunction* Function::ReadFrom(SnapshotReader* reader, |
| 630 intptr_t object_id, | 654 intptr_t object_id, |
| 631 intptr_t tags, | 655 intptr_t tags, |
| 632 Snapshot::Kind kind) { | 656 Snapshot::Kind kind, |
| 657 bool as_reference) { |
| 633 ASSERT(reader != NULL); | 658 ASSERT(reader != NULL); |
| 634 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 659 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 635 | 660 |
| 636 bool is_in_fullsnapshot = reader->Read<bool>(); | 661 bool is_in_fullsnapshot = reader->Read<bool>(); |
| 637 if ((kind == Snapshot::kFull) || !is_in_fullsnapshot) { | 662 if ((kind == Snapshot::kFull) || !is_in_fullsnapshot) { |
| 638 // Allocate function object. | 663 // Allocate function object. |
| 639 Function& func = Function::ZoneHandle( | 664 Function& func = Function::ZoneHandle( |
| 640 reader->zone(), NEW_OBJECT(Function)); | 665 reader->zone(), NEW_OBJECT(Function)); |
| 641 reader->AddBackRef(object_id, &func, kIsDeserialized); | 666 reader->AddBackRef(object_id, &func, kIsDeserialized); |
| 642 | 667 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 } | 700 } |
| 676 return func.raw(); | 701 return func.raw(); |
| 677 } else { | 702 } else { |
| 678 return reader->ReadFunctionId(object_id); | 703 return reader->ReadFunctionId(object_id); |
| 679 } | 704 } |
| 680 } | 705 } |
| 681 | 706 |
| 682 | 707 |
| 683 void RawFunction::WriteTo(SnapshotWriter* writer, | 708 void RawFunction::WriteTo(SnapshotWriter* writer, |
| 684 intptr_t object_id, | 709 intptr_t object_id, |
| 685 Snapshot::Kind kind) { | 710 Snapshot::Kind kind, |
| 711 bool as_reference) { |
| 686 ASSERT(writer != NULL); | 712 ASSERT(writer != NULL); |
| 687 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 713 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 688 bool is_in_fullsnapshot = false; | 714 bool is_in_fullsnapshot = false; |
| 689 bool owner_is_class = false; | 715 bool owner_is_class = false; |
| 690 if (kind == Snapshot::kScript) { | 716 if (kind == Snapshot::kScript) { |
| 691 intptr_t tags = writer->GetObjectTags(ptr()->owner_); | 717 intptr_t tags = writer->GetObjectTags(ptr()->owner_); |
| 692 intptr_t cid = ClassIdTag::decode(tags); | 718 intptr_t cid = ClassIdTag::decode(tags); |
| 693 owner_is_class = (cid == kClassCid); | 719 owner_is_class = (cid == kClassCid); |
| 694 is_in_fullsnapshot = owner_is_class ? | 720 is_in_fullsnapshot = owner_is_class ? |
| 695 Class::IsInFullSnapshot(reinterpret_cast<RawClass*>(ptr()->owner_)) : | 721 Class::IsInFullSnapshot(reinterpret_cast<RawClass*>(ptr()->owner_)) : |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 } | 769 } |
| 744 } else { | 770 } else { |
| 745 writer->WriteFunctionId(this, owner_is_class); | 771 writer->WriteFunctionId(this, owner_is_class); |
| 746 } | 772 } |
| 747 } | 773 } |
| 748 | 774 |
| 749 | 775 |
| 750 RawField* Field::ReadFrom(SnapshotReader* reader, | 776 RawField* Field::ReadFrom(SnapshotReader* reader, |
| 751 intptr_t object_id, | 777 intptr_t object_id, |
| 752 intptr_t tags, | 778 intptr_t tags, |
| 753 Snapshot::Kind kind) { | 779 Snapshot::Kind kind, |
| 780 bool as_reference) { |
| 754 ASSERT(reader != NULL); | 781 ASSERT(reader != NULL); |
| 755 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 782 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 756 | 783 |
| 757 // Allocate field object. | 784 // Allocate field object. |
| 758 Field& field = Field::ZoneHandle(reader->zone(), NEW_OBJECT(Field)); | 785 Field& field = Field::ZoneHandle(reader->zone(), NEW_OBJECT(Field)); |
| 759 reader->AddBackRef(object_id, &field, kIsDeserialized); | 786 reader->AddBackRef(object_id, &field, kIsDeserialized); |
| 760 | 787 |
| 761 // Set all non object fields. | 788 // Set all non object fields. |
| 762 field.set_token_pos(reader->Read<int32_t>()); | 789 field.set_token_pos(reader->Read<int32_t>()); |
| 763 field.set_guarded_cid(reader->Read<int32_t>()); | 790 field.set_guarded_cid(reader->Read<int32_t>()); |
| 764 field.set_is_nullable(reader->Read<int32_t>()); | 791 field.set_is_nullable(reader->Read<int32_t>()); |
| 765 field.set_kind_bits(reader->Read<uint8_t>()); | 792 field.set_kind_bits(reader->Read<uint8_t>()); |
| 766 | 793 |
| 767 // Set all the object fields. | 794 // Set all the object fields. |
| 768 READ_OBJECT_FIELDS(field, | 795 READ_OBJECT_FIELDS(field, |
| 769 field.raw()->from(), field.raw()->to(), | 796 field.raw()->from(), field.raw()->to(), |
| 770 kAsReference); | 797 kAsReference); |
| 771 | 798 |
| 772 field.InitializeGuardedListLengthInObjectOffset(); | 799 field.InitializeGuardedListLengthInObjectOffset(); |
| 773 | 800 |
| 774 return field.raw(); | 801 return field.raw(); |
| 775 } | 802 } |
| 776 | 803 |
| 777 | 804 |
| 778 void RawField::WriteTo(SnapshotWriter* writer, | 805 void RawField::WriteTo(SnapshotWriter* writer, |
| 779 intptr_t object_id, | 806 intptr_t object_id, |
| 780 Snapshot::Kind kind) { | 807 Snapshot::Kind kind, |
| 808 bool as_reference) { |
| 781 ASSERT(writer != NULL); | 809 ASSERT(writer != NULL); |
| 782 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 810 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 783 | 811 |
| 784 // Write out the serialization header value for this object. | 812 // Write out the serialization header value for this object. |
| 785 writer->WriteInlinedObjectHeader(object_id); | 813 writer->WriteInlinedObjectHeader(object_id); |
| 786 | 814 |
| 787 // Write out the class and tags information. | 815 // Write out the class and tags information. |
| 788 writer->WriteVMIsolateObject(kFieldCid); | 816 writer->WriteVMIsolateObject(kFieldCid); |
| 789 writer->WriteTags(writer->GetObjectTags(this)); | 817 writer->WriteTags(writer->GetObjectTags(this)); |
| 790 | 818 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 writer->WriteObjectImpl(ptr()->initializer_.saved_value_, kAsReference); | 850 writer->WriteObjectImpl(ptr()->initializer_.saved_value_, kAsReference); |
| 823 } | 851 } |
| 824 // Write out the guarded list length. | 852 // Write out the guarded list length. |
| 825 writer->WriteObjectImpl(ptr()->guarded_list_length_, kAsReference); | 853 writer->WriteObjectImpl(ptr()->guarded_list_length_, kAsReference); |
| 826 } | 854 } |
| 827 | 855 |
| 828 | 856 |
| 829 RawLiteralToken* LiteralToken::ReadFrom(SnapshotReader* reader, | 857 RawLiteralToken* LiteralToken::ReadFrom(SnapshotReader* reader, |
| 830 intptr_t object_id, | 858 intptr_t object_id, |
| 831 intptr_t tags, | 859 intptr_t tags, |
| 832 Snapshot::Kind kind) { | 860 Snapshot::Kind kind, |
| 861 bool as_reference) { |
| 833 ASSERT(reader != NULL); | 862 ASSERT(reader != NULL); |
| 834 ASSERT(kind != Snapshot::kMessage); | 863 ASSERT(kind != Snapshot::kMessage); |
| 835 | 864 |
| 836 // Create the literal token object. | 865 // Create the literal token object. |
| 837 LiteralToken& literal_token = LiteralToken::ZoneHandle( | 866 LiteralToken& literal_token = LiteralToken::ZoneHandle( |
| 838 reader->zone(), NEW_OBJECT(LiteralToken)); | 867 reader->zone(), NEW_OBJECT(LiteralToken)); |
| 839 reader->AddBackRef(object_id, &literal_token, kIsDeserialized); | 868 reader->AddBackRef(object_id, &literal_token, kIsDeserialized); |
| 840 | 869 |
| 841 // Read the token attributes. | 870 // Read the token attributes. |
| 842 Token::Kind token_kind = static_cast<Token::Kind>(reader->Read<int32_t>()); | 871 Token::Kind token_kind = static_cast<Token::Kind>(reader->Read<int32_t>()); |
| 843 literal_token.set_kind(token_kind); | 872 literal_token.set_kind(token_kind); |
| 844 | 873 |
| 845 // Set all the object fields. | 874 // Set all the object fields. |
| 846 READ_OBJECT_FIELDS(literal_token, | 875 READ_OBJECT_FIELDS(literal_token, |
| 847 literal_token.raw()->from(), literal_token.raw()->to(), | 876 literal_token.raw()->from(), literal_token.raw()->to(), |
| 848 kAsReference); | 877 kAsReference); |
| 849 | 878 |
| 850 return literal_token.raw(); | 879 return literal_token.raw(); |
| 851 } | 880 } |
| 852 | 881 |
| 853 | 882 |
| 854 void RawLiteralToken::WriteTo(SnapshotWriter* writer, | 883 void RawLiteralToken::WriteTo(SnapshotWriter* writer, |
| 855 intptr_t object_id, | 884 intptr_t object_id, |
| 856 Snapshot::Kind kind) { | 885 Snapshot::Kind kind, |
| 886 bool as_reference) { |
| 857 ASSERT(writer != NULL); | 887 ASSERT(writer != NULL); |
| 858 ASSERT(kind != Snapshot::kMessage); | 888 ASSERT(kind != Snapshot::kMessage); |
| 859 | 889 |
| 860 // Write out the serialization header value for this object. | 890 // Write out the serialization header value for this object. |
| 861 writer->WriteInlinedObjectHeader(object_id); | 891 writer->WriteInlinedObjectHeader(object_id); |
| 862 | 892 |
| 863 // Write out the class and tags information. | 893 // Write out the class and tags information. |
| 864 writer->WriteVMIsolateObject(kLiteralTokenCid); | 894 writer->WriteVMIsolateObject(kLiteralTokenCid); |
| 865 writer->WriteTags(writer->GetObjectTags(this)); | 895 writer->WriteTags(writer->GetObjectTags(this)); |
| 866 | 896 |
| 867 // Write out the kind field. | 897 // Write out the kind field. |
| 868 writer->Write<int32_t>(ptr()->kind_); | 898 writer->Write<int32_t>(ptr()->kind_); |
| 869 | 899 |
| 870 // Write out all the object pointer fields. | 900 // Write out all the object pointer fields. |
| 871 SnapshotWriterVisitor visitor(writer, kAsReference); | 901 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 872 visitor.VisitPointers(from(), to()); | 902 visitor.VisitPointers(from(), to()); |
| 873 } | 903 } |
| 874 | 904 |
| 875 | 905 |
| 876 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, | 906 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, |
| 877 intptr_t object_id, | 907 intptr_t object_id, |
| 878 intptr_t tags, | 908 intptr_t tags, |
| 879 Snapshot::Kind kind) { | 909 Snapshot::Kind kind, |
| 910 bool as_reference) { |
| 880 ASSERT(reader != NULL); | 911 ASSERT(reader != NULL); |
| 881 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 912 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 882 | 913 |
| 883 // Read the length so that we can determine number of tokens to read. | 914 // Read the length so that we can determine number of tokens to read. |
| 884 intptr_t len = reader->ReadSmiValue(); | 915 intptr_t len = reader->ReadSmiValue(); |
| 885 | 916 |
| 886 // Create the token stream object. | 917 // Create the token stream object. |
| 887 TokenStream& token_stream = TokenStream::ZoneHandle( | 918 TokenStream& token_stream = TokenStream::ZoneHandle( |
| 888 reader->zone(), NEW_OBJECT_WITH_LEN(TokenStream, len)); | 919 reader->zone(), NEW_OBJECT_WITH_LEN(TokenStream, len)); |
| 889 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); | 920 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 902 // Read in the private key in use by the token stream. | 933 // Read in the private key in use by the token stream. |
| 903 *(reader->StringHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); | 934 *(reader->StringHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); |
| 904 token_stream.SetPrivateKey(*(reader->StringHandle())); | 935 token_stream.SetPrivateKey(*(reader->StringHandle())); |
| 905 | 936 |
| 906 return token_stream.raw(); | 937 return token_stream.raw(); |
| 907 } | 938 } |
| 908 | 939 |
| 909 | 940 |
| 910 void RawTokenStream::WriteTo(SnapshotWriter* writer, | 941 void RawTokenStream::WriteTo(SnapshotWriter* writer, |
| 911 intptr_t object_id, | 942 intptr_t object_id, |
| 912 Snapshot::Kind kind) { | 943 Snapshot::Kind kind, |
| 944 bool as_reference) { |
| 913 ASSERT(writer != NULL); | 945 ASSERT(writer != NULL); |
| 914 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 946 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 915 | 947 |
| 916 // Write out the serialization header value for this object. | 948 // Write out the serialization header value for this object. |
| 917 writer->WriteInlinedObjectHeader(object_id); | 949 writer->WriteInlinedObjectHeader(object_id); |
| 918 | 950 |
| 919 // Write out the class and tags information. | 951 // Write out the class and tags information. |
| 920 writer->WriteVMIsolateObject(kTokenStreamCid); | 952 writer->WriteVMIsolateObject(kTokenStreamCid); |
| 921 writer->WriteTags(writer->GetObjectTags(this)); | 953 writer->WriteTags(writer->GetObjectTags(this)); |
| 922 | 954 |
| 923 // Write out the length field and the token stream. | 955 // Write out the length field and the token stream. |
| 924 RawExternalTypedData* stream = ptr()->stream_; | 956 RawExternalTypedData* stream = ptr()->stream_; |
| 925 intptr_t len = Smi::Value(stream->ptr()->length_); | 957 intptr_t len = Smi::Value(stream->ptr()->length_); |
| 926 writer->Write<RawObject*>(stream->ptr()->length_); | 958 writer->Write<RawObject*>(stream->ptr()->length_); |
| 927 writer->WriteBytes(stream->ptr()->data_, len); | 959 writer->WriteBytes(stream->ptr()->data_, len); |
| 928 | 960 |
| 929 // Write out the literal/identifier token array. | 961 // Write out the literal/identifier token array. |
| 930 writer->WriteObjectImpl(ptr()->token_objects_, kAsInlinedObject); | 962 writer->WriteObjectImpl(ptr()->token_objects_, kAsInlinedObject); |
| 931 // Write out the private key in use by the token stream. | 963 // Write out the private key in use by the token stream. |
| 932 writer->WriteObjectImpl(ptr()->private_key_, kAsInlinedObject); | 964 writer->WriteObjectImpl(ptr()->private_key_, kAsInlinedObject); |
| 933 } | 965 } |
| 934 | 966 |
| 935 | 967 |
| 936 RawScript* Script::ReadFrom(SnapshotReader* reader, | 968 RawScript* Script::ReadFrom(SnapshotReader* reader, |
| 937 intptr_t object_id, | 969 intptr_t object_id, |
| 938 intptr_t tags, | 970 intptr_t tags, |
| 939 Snapshot::Kind kind) { | 971 Snapshot::Kind kind, |
| 972 bool as_reference) { |
| 940 ASSERT(reader != NULL); | 973 ASSERT(reader != NULL); |
| 941 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 974 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 942 | 975 |
| 943 // Allocate script object. | 976 // Allocate script object. |
| 944 Script& script = Script::ZoneHandle(reader->zone(), NEW_OBJECT(Script)); | 977 Script& script = Script::ZoneHandle(reader->zone(), NEW_OBJECT(Script)); |
| 945 reader->AddBackRef(object_id, &script, kIsDeserialized); | 978 reader->AddBackRef(object_id, &script, kIsDeserialized); |
| 946 | 979 |
| 947 script.StoreNonPointer(&script.raw_ptr()->line_offset_, | 980 script.StoreNonPointer(&script.raw_ptr()->line_offset_, |
| 948 reader->Read<int32_t>()); | 981 reader->Read<int32_t>()); |
| 949 script.StoreNonPointer(&script.raw_ptr()->col_offset_, | 982 script.StoreNonPointer(&script.raw_ptr()->col_offset_, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 963 // Script wasn't allocated with nulls? | 996 // Script wasn't allocated with nulls? |
| 964 *reader->StringHandle() ^= String::null(); | 997 *reader->StringHandle() ^= String::null(); |
| 965 script.set_source(*reader->StringHandle()); | 998 script.set_source(*reader->StringHandle()); |
| 966 | 999 |
| 967 return script.raw(); | 1000 return script.raw(); |
| 968 } | 1001 } |
| 969 | 1002 |
| 970 | 1003 |
| 971 void RawScript::WriteTo(SnapshotWriter* writer, | 1004 void RawScript::WriteTo(SnapshotWriter* writer, |
| 972 intptr_t object_id, | 1005 intptr_t object_id, |
| 973 Snapshot::Kind kind) { | 1006 Snapshot::Kind kind, |
| 1007 bool as_reference) { |
| 974 ASSERT(writer != NULL); | 1008 ASSERT(writer != NULL); |
| 975 ASSERT(tokens_ != TokenStream::null()); | 1009 ASSERT(tokens_ != TokenStream::null()); |
| 976 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 1010 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 977 | 1011 |
| 978 // Write out the serialization header value for this object. | 1012 // Write out the serialization header value for this object. |
| 979 writer->WriteInlinedObjectHeader(object_id); | 1013 writer->WriteInlinedObjectHeader(object_id); |
| 980 | 1014 |
| 981 // Write out the class and tags information. | 1015 // Write out the class and tags information. |
| 982 writer->WriteVMIsolateObject(kScriptCid); | 1016 writer->WriteVMIsolateObject(kScriptCid); |
| 983 writer->WriteTags(writer->GetObjectTags(this)); | 1017 writer->WriteTags(writer->GetObjectTags(this)); |
| 984 | 1018 |
| 985 // Write out all the non object fields. | 1019 // Write out all the non object fields. |
| 986 writer->Write<int32_t>(ptr()->line_offset_); | 1020 writer->Write<int32_t>(ptr()->line_offset_); |
| 987 writer->Write<int32_t>(ptr()->col_offset_); | 1021 writer->Write<int32_t>(ptr()->col_offset_); |
| 988 writer->Write<int8_t>(ptr()->kind_); | 1022 writer->Write<int8_t>(ptr()->kind_); |
| 989 | 1023 |
| 990 // Write out all the object pointer fields. | 1024 // Write out all the object pointer fields. |
| 991 SnapshotWriterVisitor visitor(writer, kAsReference); | 1025 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 992 visitor.VisitPointers(from(), to_snapshot()); | 1026 visitor.VisitPointers(from(), to_snapshot()); |
| 993 } | 1027 } |
| 994 | 1028 |
| 995 | 1029 |
| 996 RawLibrary* Library::ReadFrom(SnapshotReader* reader, | 1030 RawLibrary* Library::ReadFrom(SnapshotReader* reader, |
| 997 intptr_t object_id, | 1031 intptr_t object_id, |
| 998 intptr_t tags, | 1032 intptr_t tags, |
| 999 Snapshot::Kind kind) { | 1033 Snapshot::Kind kind, |
| 1034 bool as_reference) { |
| 1000 ASSERT(reader != NULL); | 1035 ASSERT(reader != NULL); |
| 1001 ASSERT(kind != Snapshot::kMessage); | 1036 ASSERT(kind != Snapshot::kMessage); |
| 1002 | 1037 |
| 1003 Library& library = Library::ZoneHandle(reader->zone(), Library::null()); | 1038 Library& library = Library::ZoneHandle(reader->zone(), Library::null()); |
| 1004 reader->AddBackRef(object_id, &library, kIsDeserialized); | 1039 reader->AddBackRef(object_id, &library, kIsDeserialized); |
| 1005 | 1040 |
| 1006 bool is_in_fullsnapshot = reader->Read<bool>(); | 1041 bool is_in_fullsnapshot = reader->Read<bool>(); |
| 1007 if ((kind == Snapshot::kScript) && is_in_fullsnapshot) { | 1042 if ((kind == Snapshot::kScript) && is_in_fullsnapshot) { |
| 1008 // Lookup the object as it should already exist in the heap. | 1043 // Lookup the object as it should already exist in the heap. |
| 1009 *reader->StringHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); | 1044 *reader->StringHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 library.InitResolvedNamesCache(kInitialNameCacheSize); | 1091 library.InitResolvedNamesCache(kInitialNameCacheSize); |
| 1057 library.Register(); | 1092 library.Register(); |
| 1058 } | 1093 } |
| 1059 } | 1094 } |
| 1060 return library.raw(); | 1095 return library.raw(); |
| 1061 } | 1096 } |
| 1062 | 1097 |
| 1063 | 1098 |
| 1064 void RawLibrary::WriteTo(SnapshotWriter* writer, | 1099 void RawLibrary::WriteTo(SnapshotWriter* writer, |
| 1065 intptr_t object_id, | 1100 intptr_t object_id, |
| 1066 Snapshot::Kind kind) { | 1101 Snapshot::Kind kind, |
| 1102 bool as_reference) { |
| 1067 ASSERT(writer != NULL); | 1103 ASSERT(writer != NULL); |
| 1068 ASSERT(kind != Snapshot::kMessage); | 1104 ASSERT(kind != Snapshot::kMessage); |
| 1069 | 1105 |
| 1070 // Write out the serialization header value for this object. | 1106 // Write out the serialization header value for this object. |
| 1071 writer->WriteInlinedObjectHeader(object_id); | 1107 writer->WriteInlinedObjectHeader(object_id); |
| 1072 | 1108 |
| 1073 // Write out the class and tags information. | 1109 // Write out the class and tags information. |
| 1074 writer->WriteVMIsolateObject(kLibraryCid); | 1110 writer->WriteVMIsolateObject(kLibraryCid); |
| 1075 writer->WriteTags(writer->GetObjectTags(this)); | 1111 writer->WriteTags(writer->GetObjectTags(this)); |
| 1076 | 1112 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1102 RawObject** toobj = (kind == Snapshot::kFull) ? to() : to_snapshot(); | 1138 RawObject** toobj = (kind == Snapshot::kFull) ? to() : to_snapshot(); |
| 1103 SnapshotWriterVisitor visitor(writer, kAsReference); | 1139 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 1104 visitor.VisitPointers(from(), toobj); | 1140 visitor.VisitPointers(from(), toobj); |
| 1105 } | 1141 } |
| 1106 } | 1142 } |
| 1107 | 1143 |
| 1108 | 1144 |
| 1109 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader, | 1145 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader, |
| 1110 intptr_t object_id, | 1146 intptr_t object_id, |
| 1111 intptr_t tags, | 1147 intptr_t tags, |
| 1112 Snapshot::Kind kind) { | 1148 Snapshot::Kind kind, |
| 1149 bool as_reference) { |
| 1113 ASSERT(reader != NULL); | 1150 ASSERT(reader != NULL); |
| 1114 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 1151 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 1115 | 1152 |
| 1116 // Allocate library prefix object. | 1153 // Allocate library prefix object. |
| 1117 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle( | 1154 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle( |
| 1118 reader->zone(), NEW_OBJECT(LibraryPrefix)); | 1155 reader->zone(), NEW_OBJECT(LibraryPrefix)); |
| 1119 reader->AddBackRef(object_id, &prefix, kIsDeserialized); | 1156 reader->AddBackRef(object_id, &prefix, kIsDeserialized); |
| 1120 | 1157 |
| 1121 // Set all non object fields. | 1158 // Set all non object fields. |
| 1122 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_, | 1159 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_, |
| 1123 reader->Read<int16_t>()); | 1160 reader->Read<int16_t>()); |
| 1124 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_, | 1161 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_, |
| 1125 reader->Read<bool>()); | 1162 reader->Read<bool>()); |
| 1126 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>()); | 1163 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>()); |
| 1127 | 1164 |
| 1128 // Set all the object fields. | 1165 // Set all the object fields. |
| 1129 READ_OBJECT_FIELDS(prefix, | 1166 READ_OBJECT_FIELDS(prefix, |
| 1130 prefix.raw()->from(), prefix.raw()->to(), | 1167 prefix.raw()->from(), prefix.raw()->to(), |
| 1131 kAsReference); | 1168 kAsReference); |
| 1132 | 1169 |
| 1133 return prefix.raw(); | 1170 return prefix.raw(); |
| 1134 } | 1171 } |
| 1135 | 1172 |
| 1136 | 1173 |
| 1137 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, | 1174 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, |
| 1138 intptr_t object_id, | 1175 intptr_t object_id, |
| 1139 Snapshot::Kind kind) { | 1176 Snapshot::Kind kind, |
| 1177 bool as_reference) { |
| 1140 ASSERT(writer != NULL); | 1178 ASSERT(writer != NULL); |
| 1141 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 1179 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 1142 | 1180 |
| 1143 // Write out the serialization header value for this object. | 1181 // Write out the serialization header value for this object. |
| 1144 writer->WriteInlinedObjectHeader(object_id); | 1182 writer->WriteInlinedObjectHeader(object_id); |
| 1145 | 1183 |
| 1146 // Write out the class and tags information. | 1184 // Write out the class and tags information. |
| 1147 writer->WriteIndexedObject(kLibraryPrefixCid); | 1185 writer->WriteIndexedObject(kLibraryPrefixCid); |
| 1148 writer->WriteTags(writer->GetObjectTags(this)); | 1186 writer->WriteTags(writer->GetObjectTags(this)); |
| 1149 | 1187 |
| 1150 // Write out all non object fields. | 1188 // Write out all non object fields. |
| 1151 writer->Write<int16_t>(ptr()->num_imports_); | 1189 writer->Write<int16_t>(ptr()->num_imports_); |
| 1152 writer->Write<bool>(ptr()->is_deferred_load_); | 1190 writer->Write<bool>(ptr()->is_deferred_load_); |
| 1153 writer->Write<bool>(ptr()->is_loaded_); | 1191 writer->Write<bool>(ptr()->is_loaded_); |
| 1154 | 1192 |
| 1155 // Write out all the object pointer fields. | 1193 // Write out all the object pointer fields. |
| 1156 SnapshotWriterVisitor visitor(writer, kAsReference); | 1194 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 1157 visitor.VisitPointers(from(), to()); | 1195 visitor.VisitPointers(from(), to()); |
| 1158 } | 1196 } |
| 1159 | 1197 |
| 1160 | 1198 |
| 1161 RawNamespace* Namespace::ReadFrom(SnapshotReader* reader, | 1199 RawNamespace* Namespace::ReadFrom(SnapshotReader* reader, |
| 1162 intptr_t object_id, | 1200 intptr_t object_id, |
| 1163 intptr_t tags, | 1201 intptr_t tags, |
| 1164 Snapshot::Kind kind) { | 1202 Snapshot::Kind kind, |
| 1203 bool as_reference) { |
| 1165 ASSERT(reader != NULL); | 1204 ASSERT(reader != NULL); |
| 1166 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 1205 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 1167 | 1206 |
| 1168 // Allocate Namespace object. | 1207 // Allocate Namespace object. |
| 1169 Namespace& ns = Namespace::ZoneHandle( | 1208 Namespace& ns = Namespace::ZoneHandle( |
| 1170 reader->zone(), NEW_OBJECT(Namespace)); | 1209 reader->zone(), NEW_OBJECT(Namespace)); |
| 1171 reader->AddBackRef(object_id, &ns, kIsDeserialized); | 1210 reader->AddBackRef(object_id, &ns, kIsDeserialized); |
| 1172 | 1211 |
| 1173 // Set all the object fields. | 1212 // Set all the object fields. |
| 1174 READ_OBJECT_FIELDS(ns, ns.raw()->from(), ns.raw()->to(), kAsReference); | 1213 READ_OBJECT_FIELDS(ns, ns.raw()->from(), ns.raw()->to(), kAsReference); |
| 1175 | 1214 |
| 1176 return ns.raw(); | 1215 return ns.raw(); |
| 1177 } | 1216 } |
| 1178 | 1217 |
| 1179 | 1218 |
| 1180 void RawNamespace::WriteTo(SnapshotWriter* writer, | 1219 void RawNamespace::WriteTo(SnapshotWriter* writer, |
| 1181 intptr_t object_id, | 1220 intptr_t object_id, |
| 1182 Snapshot::Kind kind) { | 1221 Snapshot::Kind kind, |
| 1222 bool as_reference) { |
| 1183 ASSERT(writer != NULL); | 1223 ASSERT(writer != NULL); |
| 1184 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 1224 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 1185 | 1225 |
| 1186 // Write out the serialization header value for this object. | 1226 // Write out the serialization header value for this object. |
| 1187 writer->WriteInlinedObjectHeader(object_id); | 1227 writer->WriteInlinedObjectHeader(object_id); |
| 1188 | 1228 |
| 1189 // Write out the class and tags information. | 1229 // Write out the class and tags information. |
| 1190 writer->WriteVMIsolateObject(kNamespaceCid); | 1230 writer->WriteVMIsolateObject(kNamespaceCid); |
| 1191 writer->WriteTags(writer->GetObjectTags(this)); | 1231 writer->WriteTags(writer->GetObjectTags(this)); |
| 1192 | 1232 |
| 1193 // Write out all the object pointer fields. | 1233 // Write out all the object pointer fields. |
| 1194 SnapshotWriterVisitor visitor(writer, kAsReference); | 1234 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 1195 visitor.VisitPointers(from(), to()); | 1235 visitor.VisitPointers(from(), to()); |
| 1196 } | 1236 } |
| 1197 | 1237 |
| 1198 | 1238 |
| 1199 RawCode* Code::ReadFrom(SnapshotReader* reader, | 1239 RawCode* Code::ReadFrom(SnapshotReader* reader, |
| 1200 intptr_t object_id, | 1240 intptr_t object_id, |
| 1201 intptr_t tags, | 1241 intptr_t tags, |
| 1202 Snapshot::Kind kind) { | 1242 Snapshot::Kind kind, |
| 1243 bool as_reference) { |
| 1203 ASSERT(reader->snapshot_code()); | 1244 ASSERT(reader->snapshot_code()); |
| 1204 ASSERT(kind == Snapshot::kFull); | 1245 ASSERT(kind == Snapshot::kFull); |
| 1205 | 1246 |
| 1206 Code& result = Code::ZoneHandle(reader->zone(), NEW_OBJECT_WITH_LEN(Code, 0)); | 1247 Code& result = Code::ZoneHandle(reader->zone(), NEW_OBJECT_WITH_LEN(Code, 0)); |
| 1207 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1248 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 1208 | 1249 |
| 1209 result.set_compile_timestamp(reader->Read<int64_t>()); | 1250 result.set_compile_timestamp(reader->Read<int64_t>()); |
| 1210 result.set_state_bits(reader->Read<int32_t>()); | 1251 result.set_state_bits(reader->Read<int32_t>()); |
| 1211 result.set_lazy_deopt_pc_offset(reader->Read<int32_t>()); | 1252 result.set_lazy_deopt_pc_offset(reader->Read<int32_t>()); |
| 1212 | 1253 |
| 1213 // Set all the object fields. | 1254 // Set all the object fields. |
| 1214 READ_OBJECT_FIELDS(result, | 1255 READ_OBJECT_FIELDS(result, |
| 1215 result.raw()->from(), result.raw()->to(), | 1256 result.raw()->from(), result.raw()->to(), |
| 1216 kAsReference); | 1257 kAsReference); |
| 1217 | 1258 |
| 1218 // Fix entry point. | 1259 // Fix entry point. |
| 1219 uword new_entry = result.EntryPoint(); | 1260 uword new_entry = result.EntryPoint(); |
| 1220 ASSERT(Dart::vm_isolate()->heap()->CodeContains(new_entry)); | 1261 ASSERT(Dart::vm_isolate()->heap()->CodeContains(new_entry)); |
| 1221 result.StoreNonPointer(&result.raw_ptr()->entry_point_, new_entry); | 1262 result.StoreNonPointer(&result.raw_ptr()->entry_point_, new_entry); |
| 1222 | 1263 |
| 1223 return result.raw(); | 1264 return result.raw(); |
| 1224 } | 1265 } |
| 1225 | 1266 |
| 1226 | 1267 |
| 1227 void RawCode::WriteTo(SnapshotWriter* writer, | 1268 void RawCode::WriteTo(SnapshotWriter* writer, |
| 1228 intptr_t object_id, | 1269 intptr_t object_id, |
| 1229 Snapshot::Kind kind) { | 1270 Snapshot::Kind kind, |
| 1271 bool as_reference) { |
| 1230 ASSERT(writer->snapshot_code()); | 1272 ASSERT(writer->snapshot_code()); |
| 1231 ASSERT(kind == Snapshot::kFull); | 1273 ASSERT(kind == Snapshot::kFull); |
| 1232 | 1274 |
| 1233 intptr_t pointer_offsets_length = | 1275 intptr_t pointer_offsets_length = |
| 1234 Code::PtrOffBits::decode(ptr()->state_bits_); | 1276 Code::PtrOffBits::decode(ptr()->state_bits_); |
| 1235 if (pointer_offsets_length != 0) { | 1277 if (pointer_offsets_length != 0) { |
| 1236 // Should only be IA32. | 1278 // Should only be IA32. |
| 1237 FATAL("Serializing embedded pointer offsets unimplemented"); | 1279 FATAL("Serializing embedded pointer offsets unimplemented"); |
| 1238 } | 1280 } |
| 1239 | 1281 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1253 SnapshotWriterVisitor visitor(writer, kAsReference); | 1295 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 1254 visitor.VisitPointers(from(), to()); | 1296 visitor.VisitPointers(from(), to()); |
| 1255 | 1297 |
| 1256 writer->SetInstructionsCode(ptr()->instructions_, this); | 1298 writer->SetInstructionsCode(ptr()->instructions_, this); |
| 1257 } | 1299 } |
| 1258 | 1300 |
| 1259 | 1301 |
| 1260 RawInstructions* Instructions::ReadFrom(SnapshotReader* reader, | 1302 RawInstructions* Instructions::ReadFrom(SnapshotReader* reader, |
| 1261 intptr_t object_id, | 1303 intptr_t object_id, |
| 1262 intptr_t tags, | 1304 intptr_t tags, |
| 1263 Snapshot::Kind kind) { | 1305 Snapshot::Kind kind, |
| 1306 bool as_reference) { |
| 1264 ASSERT(reader->snapshot_code()); | 1307 ASSERT(reader->snapshot_code()); |
| 1265 ASSERT(kind == Snapshot::kFull); | 1308 ASSERT(kind == Snapshot::kFull); |
| 1266 | 1309 |
| 1267 intptr_t full_tags = static_cast<uword>(reader->Read<intptr_t>()); | 1310 intptr_t full_tags = static_cast<uword>(reader->Read<intptr_t>()); |
| 1268 intptr_t offset = reader->Read<int32_t>(); | 1311 intptr_t offset = reader->Read<int32_t>(); |
| 1269 Instructions& result = | 1312 Instructions& result = |
| 1270 Instructions::ZoneHandle(reader->zone(), | 1313 Instructions::ZoneHandle(reader->zone(), |
| 1271 reader->GetInstructionsAt(offset, full_tags)); | 1314 reader->GetInstructionsAt(offset, full_tags)); |
| 1272 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1315 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 1273 | 1316 |
| 1274 return result.raw(); | 1317 return result.raw(); |
| 1275 } | 1318 } |
| 1276 | 1319 |
| 1277 | 1320 |
| 1278 void RawInstructions::WriteTo(SnapshotWriter* writer, | 1321 void RawInstructions::WriteTo(SnapshotWriter* writer, |
| 1279 intptr_t object_id, | 1322 intptr_t object_id, |
| 1280 Snapshot::Kind kind) { | 1323 Snapshot::Kind kind, |
| 1324 bool as_reference) { |
| 1281 ASSERT(writer->snapshot_code()); | 1325 ASSERT(writer->snapshot_code()); |
| 1282 ASSERT(kind == Snapshot::kFull); | 1326 ASSERT(kind == Snapshot::kFull); |
| 1283 | 1327 |
| 1284 writer->WriteInlinedObjectHeader(object_id); | 1328 writer->WriteInlinedObjectHeader(object_id); |
| 1285 writer->WriteVMIsolateObject(kInstructionsCid); | 1329 writer->WriteVMIsolateObject(kInstructionsCid); |
| 1286 writer->WriteTags(writer->GetObjectTags(this)); | 1330 writer->WriteTags(writer->GetObjectTags(this)); |
| 1287 | 1331 |
| 1288 // Instructions will be written pre-marked and in the VM heap. Write out | 1332 // Instructions will be written pre-marked and in the VM heap. Write out |
| 1289 // the tags we expect to find when reading the snapshot for a sanity check | 1333 // the tags we expect to find when reading the snapshot for a sanity check |
| 1290 // that our offsets/alignment didn't get out of sync. | 1334 // that our offsets/alignment didn't get out of sync. |
| 1291 uword written_tags = writer->GetObjectTags(this); | 1335 uword written_tags = writer->GetObjectTags(this); |
| 1292 written_tags = RawObject::VMHeapObjectTag::update(true, written_tags); | 1336 written_tags = RawObject::VMHeapObjectTag::update(true, written_tags); |
| 1293 written_tags = RawObject::MarkBit::update(true, written_tags); | 1337 written_tags = RawObject::MarkBit::update(true, written_tags); |
| 1294 writer->Write<intptr_t>(written_tags); | 1338 writer->Write<intptr_t>(written_tags); |
| 1295 | 1339 |
| 1296 writer->Write<int32_t>(writer->GetInstructionsId(this)); | 1340 writer->Write<int32_t>(writer->GetInstructionsId(this)); |
| 1297 } | 1341 } |
| 1298 | 1342 |
| 1299 | 1343 |
| 1300 RawObjectPool* ObjectPool::ReadFrom(SnapshotReader* reader, | 1344 RawObjectPool* ObjectPool::ReadFrom(SnapshotReader* reader, |
| 1301 intptr_t object_id, | 1345 intptr_t object_id, |
| 1302 intptr_t tags, | 1346 intptr_t tags, |
| 1303 Snapshot::Kind kind) { | 1347 Snapshot::Kind kind, |
| 1348 bool as_reference) { |
| 1304 ASSERT(reader->snapshot_code()); | 1349 ASSERT(reader->snapshot_code()); |
| 1305 ASSERT(kind == Snapshot::kFull); | 1350 ASSERT(kind == Snapshot::kFull); |
| 1306 | 1351 |
| 1307 intptr_t length = reader->Read<intptr_t>(); | 1352 intptr_t length = reader->Read<intptr_t>(); |
| 1308 | 1353 |
| 1309 ObjectPool* result = | 1354 ObjectPool* result = |
| 1310 reinterpret_cast<ObjectPool*>(reader->GetBackRef(object_id)); | 1355 reinterpret_cast<ObjectPool*>(reader->GetBackRef(object_id)); |
| 1311 if (result == NULL) { | 1356 if (result == NULL) { |
| 1312 result = | 1357 result = |
| 1313 &(ObjectPool::ZoneHandle(reader->zone(), | 1358 &(ObjectPool::ZoneHandle(reader->zone(), |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 UNREACHABLE(); | 1391 UNREACHABLE(); |
| 1347 } | 1392 } |
| 1348 } | 1393 } |
| 1349 | 1394 |
| 1350 return result->raw(); | 1395 return result->raw(); |
| 1351 } | 1396 } |
| 1352 | 1397 |
| 1353 | 1398 |
| 1354 void RawObjectPool::WriteTo(SnapshotWriter* writer, | 1399 void RawObjectPool::WriteTo(SnapshotWriter* writer, |
| 1355 intptr_t object_id, | 1400 intptr_t object_id, |
| 1356 Snapshot::Kind kind) { | 1401 Snapshot::Kind kind, |
| 1402 bool as_reference) { |
| 1357 ASSERT(writer->snapshot_code()); | 1403 ASSERT(writer->snapshot_code()); |
| 1358 ASSERT(kind == Snapshot::kFull); | 1404 ASSERT(kind == Snapshot::kFull); |
| 1405 intptr_t tags = writer->GetObjectTags(this); |
| 1406 intptr_t length = ptr()->length_; |
| 1359 | 1407 |
| 1360 // Write out the serialization header value for this object. | 1408 if (as_reference) { |
| 1361 writer->WriteInlinedObjectHeader(object_id); | 1409 // Write out the serialization header value for this object. |
| 1410 writer->WriteInlinedObjectHeader(kOmittedObjectId); |
| 1362 | 1411 |
| 1363 // Write out the class and tags information. | 1412 // Write out the class information. |
| 1364 writer->WriteVMIsolateObject(kObjectPoolCid); | 1413 writer->WriteVMIsolateObject(kObjectPoolCid); |
| 1365 writer->WriteTags(writer->GetObjectTags(this)); | 1414 writer->WriteTags(tags); |
| 1366 | 1415 |
| 1367 intptr_t length = ptr()->length_; | 1416 // Write out the length field. |
| 1368 RawTypedData* info_array = ptr()->info_array_->ptr(); | 1417 writer->Write<intptr_t>(length); |
| 1369 ASSERT(info_array != TypedData::null()); | 1418 } else { |
| 1419 // Write out the serialization header value for this object. |
| 1420 writer->WriteInlinedObjectHeader(object_id); |
| 1370 | 1421 |
| 1371 writer->Write<intptr_t>(length); | 1422 // Write out the class and tags information. |
| 1372 for (intptr_t i = 0; i < length; i++) { | 1423 writer->WriteVMIsolateObject(kObjectPoolCid); |
| 1373 ObjectPool::EntryType entry_type = | 1424 writer->WriteTags(tags); |
| 1374 static_cast<ObjectPool::EntryType>(info_array->data()[i]); | 1425 |
| 1375 writer->Write<int8_t>(entry_type); | 1426 RawTypedData* info_array = ptr()->info_array_->ptr(); |
| 1376 Entry& entry = ptr()->data()[i]; | 1427 ASSERT(info_array != TypedData::null()); |
| 1377 switch (entry_type) { | 1428 |
| 1378 case ObjectPool::kTaggedObject: { | 1429 writer->Write<intptr_t>(length); |
| 1379 if (entry.raw_obj_ == StubCode::CallNativeCFunction_entry()->code()) { | 1430 for (intptr_t i = 0; i < length; i++) { |
| 1380 // Natives can run while precompiling, becoming linked and switching | 1431 ObjectPool::EntryType entry_type = |
| 1381 // their stub. Reset to the initial stub used for lazy-linking. | 1432 static_cast<ObjectPool::EntryType>(info_array->data()[i]); |
| 1382 writer->WriteObjectImpl( | 1433 writer->Write<int8_t>(entry_type); |
| 1383 StubCode::CallBootstrapCFunction_entry()->code(), kAsReference); | 1434 Entry& entry = ptr()->data()[i]; |
| 1384 } else { | 1435 switch (entry_type) { |
| 1385 writer->WriteObjectImpl(entry.raw_obj_, kAsReference); | 1436 case ObjectPool::kTaggedObject: { |
| 1437 if (entry.raw_obj_ == StubCode::CallNativeCFunction_entry()->code()) { |
| 1438 // Natives can run while precompiling, becoming linked and switching |
| 1439 // their stub. Reset to the initial stub used for lazy-linking. |
| 1440 writer->WriteObjectImpl( |
| 1441 StubCode::CallBootstrapCFunction_entry()->code(), kAsReference); |
| 1442 } else { |
| 1443 writer->WriteObjectImpl(entry.raw_obj_, kAsReference); |
| 1444 } |
| 1445 break; |
| 1386 } | 1446 } |
| 1387 break; | 1447 case ObjectPool::kImmediate: { |
| 1448 writer->Write<intptr_t>(entry.raw_value_); |
| 1449 break; |
| 1450 } |
| 1451 case ObjectPool::kNativeEntry: { |
| 1452 // Write nothing. Will initialize with the lazy link entry. |
| 1453 break; |
| 1454 } |
| 1455 default: |
| 1456 UNREACHABLE(); |
| 1388 } | 1457 } |
| 1389 case ObjectPool::kImmediate: { | |
| 1390 writer->Write<intptr_t>(entry.raw_value_); | |
| 1391 break; | |
| 1392 } | |
| 1393 case ObjectPool::kNativeEntry: { | |
| 1394 // Write nothing. Will initialize with the lazy link entry. | |
| 1395 break; | |
| 1396 } | |
| 1397 default: | |
| 1398 UNREACHABLE(); | |
| 1399 } | 1458 } |
| 1400 } | 1459 } |
| 1401 } | 1460 } |
| 1402 | 1461 |
| 1403 | 1462 |
| 1404 RawPcDescriptors* PcDescriptors::ReadFrom(SnapshotReader* reader, | 1463 RawPcDescriptors* PcDescriptors::ReadFrom(SnapshotReader* reader, |
| 1405 intptr_t object_id, | 1464 intptr_t object_id, |
| 1406 intptr_t tags, | 1465 intptr_t tags, |
| 1407 Snapshot::Kind kind) { | 1466 Snapshot::Kind kind, |
| 1467 bool as_reference) { |
| 1408 ASSERT(reader->snapshot_code()); | 1468 ASSERT(reader->snapshot_code()); |
| 1409 ASSERT(kind == Snapshot::kFull); | 1469 ASSERT(kind == Snapshot::kFull); |
| 1410 | 1470 |
| 1411 const int32_t length = reader->Read<int32_t>(); | 1471 const int32_t length = reader->Read<int32_t>(); |
| 1412 PcDescriptors& result = | 1472 PcDescriptors& result = |
| 1413 PcDescriptors::ZoneHandle(reader->zone(), | 1473 PcDescriptors::ZoneHandle(reader->zone(), |
| 1414 NEW_OBJECT_WITH_LEN(PcDescriptors, length)); | 1474 NEW_OBJECT_WITH_LEN(PcDescriptors, length)); |
| 1415 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1475 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 1416 | 1476 |
| 1417 if (result.Length() > 0) { | 1477 if (result.Length() > 0) { |
| 1418 NoSafepointScope no_safepoint; | 1478 NoSafepointScope no_safepoint; |
| 1419 intptr_t len = result.Length(); | 1479 intptr_t len = result.Length(); |
| 1420 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data()); | 1480 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data()); |
| 1421 reader->ReadBytes(data, len); | 1481 reader->ReadBytes(data, len); |
| 1422 } | 1482 } |
| 1423 | 1483 |
| 1424 return result.raw(); | 1484 return result.raw(); |
| 1425 } | 1485 } |
| 1426 | 1486 |
| 1427 | 1487 |
| 1428 void RawPcDescriptors::WriteTo(SnapshotWriter* writer, | 1488 void RawPcDescriptors::WriteTo(SnapshotWriter* writer, |
| 1429 intptr_t object_id, | 1489 intptr_t object_id, |
| 1430 Snapshot::Kind kind) { | 1490 Snapshot::Kind kind, |
| 1491 bool as_reference) { |
| 1431 ASSERT(writer->snapshot_code()); | 1492 ASSERT(writer->snapshot_code()); |
| 1432 ASSERT(kind == Snapshot::kFull); | 1493 ASSERT(kind == Snapshot::kFull); |
| 1433 | 1494 |
| 1434 // Write out the serialization header value for this object. | 1495 // Write out the serialization header value for this object. |
| 1435 writer->WriteInlinedObjectHeader(object_id); | 1496 writer->WriteInlinedObjectHeader(object_id); |
| 1436 writer->WriteIndexedObject(kPcDescriptorsCid); | 1497 writer->WriteIndexedObject(kPcDescriptorsCid); |
| 1437 writer->WriteTags(writer->GetObjectTags(this)); | 1498 writer->WriteTags(writer->GetObjectTags(this)); |
| 1438 writer->Write<int32_t>(ptr()->length_); | 1499 writer->Write<int32_t>(ptr()->length_); |
| 1439 if (ptr()->length_ > 0) { | 1500 if (ptr()->length_ > 0) { |
| 1440 intptr_t len = ptr()->length_; | 1501 intptr_t len = ptr()->length_; |
| 1441 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); | 1502 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); |
| 1442 writer->WriteBytes(data, len); | 1503 writer->WriteBytes(data, len); |
| 1443 } | 1504 } |
| 1444 } | 1505 } |
| 1445 | 1506 |
| 1446 | 1507 |
| 1447 RawStackmap* Stackmap::ReadFrom(SnapshotReader* reader, | 1508 RawStackmap* Stackmap::ReadFrom(SnapshotReader* reader, |
| 1448 intptr_t object_id, | 1509 intptr_t object_id, |
| 1449 intptr_t tags, | 1510 intptr_t tags, |
| 1450 Snapshot::Kind kind) { | 1511 Snapshot::Kind kind, |
| 1512 bool as_reference) { |
| 1451 ASSERT(reader->snapshot_code()); | 1513 ASSERT(reader->snapshot_code()); |
| 1452 ASSERT(kind == Snapshot::kFull); | 1514 ASSERT(kind == Snapshot::kFull); |
| 1453 | 1515 |
| 1454 const int32_t length = reader->Read<int32_t>(); | 1516 const int32_t length = reader->Read<int32_t>(); |
| 1455 Stackmap& result = | 1517 Stackmap& result = |
| 1456 Stackmap::ZoneHandle(reader->zone(), | 1518 Stackmap::ZoneHandle(reader->zone(), |
| 1457 reader->NewStackmap(length)); | 1519 reader->NewStackmap(length)); |
| 1458 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1520 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 1459 | 1521 |
| 1460 result.SetRegisterBitCount(reader->Read<int32_t>()); | 1522 result.SetRegisterBitCount(reader->Read<int32_t>()); |
| 1461 result.SetPcOffset(reader->Read<uint32_t>()); | 1523 result.SetPcOffset(reader->Read<uint32_t>()); |
| 1462 | 1524 |
| 1463 if (length > 0) { | 1525 if (length > 0) { |
| 1464 NoSafepointScope no_safepoint; | 1526 NoSafepointScope no_safepoint; |
| 1465 intptr_t len = (result.Length() + 7) / 8; | 1527 intptr_t len = (result.Length() + 7) / 8; |
| 1466 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data()); | 1528 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data()); |
| 1467 reader->ReadBytes(data, len); | 1529 reader->ReadBytes(data, len); |
| 1468 } | 1530 } |
| 1469 | 1531 |
| 1470 return result.raw(); | 1532 return result.raw(); |
| 1471 } | 1533 } |
| 1472 | 1534 |
| 1473 | 1535 |
| 1474 void RawStackmap::WriteTo(SnapshotWriter* writer, | 1536 void RawStackmap::WriteTo(SnapshotWriter* writer, |
| 1475 intptr_t object_id, | 1537 intptr_t object_id, |
| 1476 Snapshot::Kind kind) { | 1538 Snapshot::Kind kind, |
| 1539 bool as_reference) { |
| 1477 ASSERT(writer->snapshot_code()); | 1540 ASSERT(writer->snapshot_code()); |
| 1478 ASSERT(kind == Snapshot::kFull); | 1541 ASSERT(kind == Snapshot::kFull); |
| 1479 | 1542 |
| 1480 // Write out the serialization header value for this object. | 1543 // Write out the serialization header value for this object. |
| 1481 writer->WriteInlinedObjectHeader(object_id); | 1544 writer->WriteInlinedObjectHeader(object_id); |
| 1482 writer->WriteIndexedObject(kStackmapCid); | 1545 writer->WriteIndexedObject(kStackmapCid); |
| 1483 writer->WriteTags(writer->GetObjectTags(this)); | 1546 writer->WriteTags(writer->GetObjectTags(this)); |
| 1484 | 1547 |
| 1485 writer->Write<int32_t>(ptr()->length_); | 1548 writer->Write<int32_t>(ptr()->length_); |
| 1486 writer->Write<int32_t>(ptr()->register_bit_count_); | 1549 writer->Write<int32_t>(ptr()->register_bit_count_); |
| 1487 writer->Write<uint32_t>(ptr()->pc_offset_); | 1550 writer->Write<uint32_t>(ptr()->pc_offset_); |
| 1488 if (ptr()->length_ > 0) { | 1551 if (ptr()->length_ > 0) { |
| 1489 intptr_t len = (ptr()->length_ + 7) / 8; | 1552 intptr_t len = (ptr()->length_ + 7) / 8; |
| 1490 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); | 1553 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); |
| 1491 writer->WriteBytes(data, len); | 1554 writer->WriteBytes(data, len); |
| 1492 } | 1555 } |
| 1493 } | 1556 } |
| 1494 | 1557 |
| 1495 | 1558 |
| 1496 RawLocalVarDescriptors* LocalVarDescriptors::ReadFrom(SnapshotReader* reader, | 1559 RawLocalVarDescriptors* LocalVarDescriptors::ReadFrom(SnapshotReader* reader, |
| 1497 intptr_t object_id, | 1560 intptr_t object_id, |
| 1498 intptr_t tags, | 1561 intptr_t tags, |
| 1499 Snapshot::Kind kind) { | 1562 Snapshot::Kind kind, |
| 1563 bool as_reference) { |
| 1500 ASSERT(reader->snapshot_code()); | 1564 ASSERT(reader->snapshot_code()); |
| 1501 ASSERT(kind == Snapshot::kFull); | 1565 ASSERT(kind == Snapshot::kFull); |
| 1502 | 1566 |
| 1503 const int32_t num_entries = reader->Read<int32_t>(); | 1567 const int32_t num_entries = reader->Read<int32_t>(); |
| 1504 | 1568 |
| 1505 LocalVarDescriptors& result = | 1569 LocalVarDescriptors& result = |
| 1506 LocalVarDescriptors::ZoneHandle(reader->zone(), | 1570 LocalVarDescriptors::ZoneHandle(reader->zone(), |
| 1507 NEW_OBJECT_WITH_LEN(LocalVarDescriptors, | 1571 NEW_OBJECT_WITH_LEN(LocalVarDescriptors, |
| 1508 num_entries)); | 1572 num_entries)); |
| 1509 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1573 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1521 reinterpret_cast<const uint8_t*>(result.raw()->data())); | 1585 reinterpret_cast<const uint8_t*>(result.raw()->data())); |
| 1522 reader->ReadBytes(data, len); | 1586 reader->ReadBytes(data, len); |
| 1523 } | 1587 } |
| 1524 | 1588 |
| 1525 return result.raw(); | 1589 return result.raw(); |
| 1526 } | 1590 } |
| 1527 | 1591 |
| 1528 | 1592 |
| 1529 void RawLocalVarDescriptors::WriteTo(SnapshotWriter* writer, | 1593 void RawLocalVarDescriptors::WriteTo(SnapshotWriter* writer, |
| 1530 intptr_t object_id, | 1594 intptr_t object_id, |
| 1531 Snapshot::Kind kind) { | 1595 Snapshot::Kind kind, |
| 1596 bool as_reference) { |
| 1532 ASSERT(writer->snapshot_code()); | 1597 ASSERT(writer->snapshot_code()); |
| 1533 ASSERT(kind == Snapshot::kFull); | 1598 ASSERT(kind == Snapshot::kFull); |
| 1534 | 1599 |
| 1535 // Write out the serialization header value for this object. | 1600 // Write out the serialization header value for this object. |
| 1536 writer->WriteInlinedObjectHeader(object_id); | 1601 writer->WriteInlinedObjectHeader(object_id); |
| 1537 writer->WriteIndexedObject(kLocalVarDescriptorsCid); | 1602 writer->WriteIndexedObject(kLocalVarDescriptorsCid); |
| 1538 writer->WriteTags(writer->GetObjectTags(this)); | 1603 writer->WriteTags(writer->GetObjectTags(this)); |
| 1539 writer->Write<int32_t>(ptr()->num_entries_); | 1604 writer->Write<int32_t>(ptr()->num_entries_); |
| 1540 for (intptr_t i = 0; i < ptr()->num_entries_; i++) { | 1605 for (intptr_t i = 0; i < ptr()->num_entries_; i++) { |
| 1541 writer->WriteObjectImpl(ptr()->names()[i], kAsReference); | 1606 writer->WriteObjectImpl(ptr()->names()[i], kAsReference); |
| 1542 } | 1607 } |
| 1543 if (ptr()->num_entries_ > 0) { | 1608 if (ptr()->num_entries_ > 0) { |
| 1544 intptr_t len = ptr()->num_entries_ * sizeof(VarInfo); | 1609 intptr_t len = ptr()->num_entries_ * sizeof(VarInfo); |
| 1545 uint8_t* data = reinterpret_cast<uint8_t*>(this->data()); | 1610 uint8_t* data = reinterpret_cast<uint8_t*>(this->data()); |
| 1546 writer->WriteBytes(data, len); | 1611 writer->WriteBytes(data, len); |
| 1547 } | 1612 } |
| 1548 } | 1613 } |
| 1549 | 1614 |
| 1550 | 1615 |
| 1551 RawExceptionHandlers* ExceptionHandlers::ReadFrom(SnapshotReader* reader, | 1616 RawExceptionHandlers* ExceptionHandlers::ReadFrom(SnapshotReader* reader, |
| 1552 intptr_t object_id, | 1617 intptr_t object_id, |
| 1553 intptr_t tags, | 1618 intptr_t tags, |
| 1554 Snapshot::Kind kind) { | 1619 Snapshot::Kind kind, |
| 1620 bool as_reference) { |
| 1555 ASSERT(reader->snapshot_code()); | 1621 ASSERT(reader->snapshot_code()); |
| 1556 ASSERT(kind == Snapshot::kFull); | 1622 ASSERT(kind == Snapshot::kFull); |
| 1557 | 1623 |
| 1558 const int32_t num_entries = reader->Read<int32_t>(); | 1624 const int32_t num_entries = reader->Read<int32_t>(); |
| 1559 ExceptionHandlers& result = | 1625 ExceptionHandlers& result = |
| 1560 ExceptionHandlers::ZoneHandle(reader->zone(), | 1626 ExceptionHandlers::ZoneHandle(reader->zone(), |
| 1561 NEW_OBJECT_WITH_LEN(ExceptionHandlers, | 1627 NEW_OBJECT_WITH_LEN(ExceptionHandlers, |
| 1562 num_entries)); | 1628 num_entries)); |
| 1563 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1629 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 1564 | 1630 |
| 1565 if (result.num_entries() > 0) { | 1631 if (result.num_entries() > 0) { |
| 1566 NoSafepointScope no_safepoint; | 1632 NoSafepointScope no_safepoint; |
| 1567 const intptr_t len = | 1633 const intptr_t len = |
| 1568 result.num_entries() * sizeof(RawExceptionHandlers::HandlerInfo); | 1634 result.num_entries() * sizeof(RawExceptionHandlers::HandlerInfo); |
| 1569 uint8_t* data = result.UnsafeMutableNonPointer( | 1635 uint8_t* data = result.UnsafeMutableNonPointer( |
| 1570 reinterpret_cast<const uint8_t*>(result.raw_ptr()->data())); | 1636 reinterpret_cast<const uint8_t*>(result.raw_ptr()->data())); |
| 1571 reader->ReadBytes(data, len); | 1637 reader->ReadBytes(data, len); |
| 1572 } | 1638 } |
| 1573 | 1639 |
| 1574 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); | 1640 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); |
| 1575 result.StorePointer(&result.raw_ptr()->handled_types_data_, | 1641 result.StorePointer(&result.raw_ptr()->handled_types_data_, |
| 1576 reader->ArrayHandle()->raw()); | 1642 reader->ArrayHandle()->raw()); |
| 1577 | 1643 |
| 1578 return result.raw(); | 1644 return result.raw(); |
| 1579 } | 1645 } |
| 1580 | 1646 |
| 1581 | 1647 |
| 1582 void RawExceptionHandlers::WriteTo(SnapshotWriter* writer, | 1648 void RawExceptionHandlers::WriteTo(SnapshotWriter* writer, |
| 1583 intptr_t object_id, | 1649 intptr_t object_id, |
| 1584 Snapshot::Kind kind) { | 1650 Snapshot::Kind kind, |
| 1651 bool as_reference) { |
| 1585 ASSERT(writer->snapshot_code()); | 1652 ASSERT(writer->snapshot_code()); |
| 1586 ASSERT(kind == Snapshot::kFull); | 1653 ASSERT(kind == Snapshot::kFull); |
| 1587 | 1654 |
| 1588 // Write out the serialization header value for this object. | 1655 // Write out the serialization header value for this object. |
| 1589 writer->WriteInlinedObjectHeader(object_id); | 1656 writer->WriteInlinedObjectHeader(object_id); |
| 1590 writer->WriteIndexedObject(kExceptionHandlersCid); | 1657 writer->WriteIndexedObject(kExceptionHandlersCid); |
| 1591 writer->WriteTags(writer->GetObjectTags(this)); | 1658 writer->WriteTags(writer->GetObjectTags(this)); |
| 1592 writer->Write<int32_t>(ptr()->num_entries_); | 1659 writer->Write<int32_t>(ptr()->num_entries_); |
| 1593 | 1660 |
| 1594 if (ptr()->num_entries_ > 0) { | 1661 if (ptr()->num_entries_ > 0) { |
| 1595 intptr_t len = ptr()->num_entries_ * sizeof(HandlerInfo); | 1662 intptr_t len = ptr()->num_entries_ * sizeof(HandlerInfo); |
| 1596 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); | 1663 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); |
| 1597 writer->WriteBytes(data, len); | 1664 writer->WriteBytes(data, len); |
| 1598 } | 1665 } |
| 1599 | 1666 |
| 1600 writer->WriteObjectImpl(ptr()->handled_types_data_, kAsInlinedObject); | 1667 writer->WriteObjectImpl(ptr()->handled_types_data_, kAsInlinedObject); |
| 1601 } | 1668 } |
| 1602 | 1669 |
| 1603 | 1670 |
| 1604 RawContext* Context::ReadFrom(SnapshotReader* reader, | 1671 RawContext* Context::ReadFrom(SnapshotReader* reader, |
| 1605 intptr_t object_id, | 1672 intptr_t object_id, |
| 1606 intptr_t tags, | 1673 intptr_t tags, |
| 1607 Snapshot::Kind kind) { | 1674 Snapshot::Kind kind, |
| 1675 bool as_reference) { |
| 1608 ASSERT(reader != NULL); | 1676 ASSERT(reader != NULL); |
| 1609 | 1677 |
| 1610 // Allocate context object. | 1678 // Allocate context object. |
| 1611 int32_t num_vars = reader->Read<int32_t>(); | 1679 int32_t num_vars = reader->Read<int32_t>(); |
| 1612 Context& context = Context::ZoneHandle(reader->zone()); | 1680 Context& context = Context::ZoneHandle(reader->zone()); |
| 1613 reader->AddBackRef(object_id, &context, kIsDeserialized); | 1681 reader->AddBackRef(object_id, &context, kIsDeserialized); |
| 1614 if (num_vars == 0) { | 1682 if (num_vars == 0) { |
| 1615 context ^= reader->object_store()->empty_context(); | 1683 context ^= reader->object_store()->empty_context(); |
| 1616 } else { | 1684 } else { |
| 1617 context ^= NEW_OBJECT_WITH_LEN(Context, num_vars); | 1685 context ^= NEW_OBJECT_WITH_LEN(Context, num_vars); |
| 1618 | 1686 |
| 1619 // Set all the object fields. | 1687 // Set all the object fields. |
| 1620 // TODO(5411462): Need to assert No GC can happen here, even though | 1688 // TODO(5411462): Need to assert No GC can happen here, even though |
| 1621 // allocations may happen. | 1689 // allocations may happen. |
| 1622 intptr_t num_flds = (context.raw()->to(num_vars) - context.raw()->from()); | 1690 intptr_t num_flds = (context.raw()->to(num_vars) - context.raw()->from()); |
| 1623 for (intptr_t i = 0; i <= num_flds; i++) { | 1691 for (intptr_t i = 0; i <= num_flds; i++) { |
| 1624 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | 1692 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 1625 context.StorePointer((context.raw()->from() + i), | 1693 context.StorePointer((context.raw()->from() + i), |
| 1626 reader->PassiveObjectHandle()->raw()); | 1694 reader->PassiveObjectHandle()->raw()); |
| 1627 } | 1695 } |
| 1628 } | 1696 } |
| 1629 return context.raw(); | 1697 return context.raw(); |
| 1630 } | 1698 } |
| 1631 | 1699 |
| 1632 | 1700 |
| 1633 void RawContext::WriteTo(SnapshotWriter* writer, | 1701 void RawContext::WriteTo(SnapshotWriter* writer, |
| 1634 intptr_t object_id, | 1702 intptr_t object_id, |
| 1635 Snapshot::Kind kind) { | 1703 Snapshot::Kind kind, |
| 1704 bool as_reference) { |
| 1636 ASSERT(writer != NULL); | 1705 ASSERT(writer != NULL); |
| 1637 | 1706 |
| 1638 // Write out the serialization header value for this object. | 1707 // Write out the serialization header value for this object. |
| 1639 writer->WriteInlinedObjectHeader(object_id); | 1708 writer->WriteInlinedObjectHeader(object_id); |
| 1640 | 1709 |
| 1641 // Write out the class and tags information. | 1710 // Write out the class and tags information. |
| 1642 writer->WriteVMIsolateObject(kContextCid); | 1711 writer->WriteVMIsolateObject(kContextCid); |
| 1643 writer->WriteTags(writer->GetObjectTags(this)); | 1712 writer->WriteTags(writer->GetObjectTags(this)); |
| 1644 | 1713 |
| 1645 // Write out num of variables in the context. | 1714 // Write out num of variables in the context. |
| 1646 int32_t num_variables = ptr()->num_variables_; | 1715 int32_t num_variables = ptr()->num_variables_; |
| 1647 writer->Write<int32_t>(num_variables); | 1716 writer->Write<int32_t>(num_variables); |
| 1648 if (num_variables != 0) { | 1717 if (num_variables != 0) { |
| 1649 // Write out all the object pointer fields. | 1718 // Write out all the object pointer fields. |
| 1650 SnapshotWriterVisitor visitor(writer, kAsReference); | 1719 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 1651 visitor.VisitPointers(from(), to(num_variables)); | 1720 visitor.VisitPointers(from(), to(num_variables)); |
| 1652 } | 1721 } |
| 1653 } | 1722 } |
| 1654 | 1723 |
| 1655 | 1724 |
| 1656 RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader, | 1725 RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader, |
| 1657 intptr_t object_id, | 1726 intptr_t object_id, |
| 1658 intptr_t tags, | 1727 intptr_t tags, |
| 1659 Snapshot::Kind kind) { | 1728 Snapshot::Kind kind, |
| 1729 bool as_reference) { |
| 1660 ASSERT(reader != NULL); | 1730 ASSERT(reader != NULL); |
| 1661 | 1731 |
| 1662 // Allocate context object. | 1732 // Allocate context object. |
| 1663 bool is_implicit = reader->Read<bool>(); | 1733 bool is_implicit = reader->Read<bool>(); |
| 1664 if (is_implicit) { | 1734 if (is_implicit) { |
| 1665 ContextScope& context_scope = ContextScope::ZoneHandle(); | 1735 ContextScope& context_scope = ContextScope::ZoneHandle(); |
| 1666 if (kind == Snapshot::kFull) { | 1736 if (kind == Snapshot::kFull) { |
| 1667 context_scope = reader->NewContextScope(1); | 1737 context_scope = reader->NewContextScope(1); |
| 1668 context_scope.set_is_implicit(true); | 1738 context_scope.set_is_implicit(true); |
| 1669 } else { | 1739 } else { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1683 context_scope.SetContextLevelAt(0, 0); | 1753 context_scope.SetContextLevelAt(0, 0); |
| 1684 return context_scope.raw(); | 1754 return context_scope.raw(); |
| 1685 } | 1755 } |
| 1686 UNREACHABLE(); | 1756 UNREACHABLE(); |
| 1687 return NULL; | 1757 return NULL; |
| 1688 } | 1758 } |
| 1689 | 1759 |
| 1690 | 1760 |
| 1691 void RawContextScope::WriteTo(SnapshotWriter* writer, | 1761 void RawContextScope::WriteTo(SnapshotWriter* writer, |
| 1692 intptr_t object_id, | 1762 intptr_t object_id, |
| 1693 Snapshot::Kind kind) { | 1763 Snapshot::Kind kind, |
| 1764 bool as_reference) { |
| 1694 ASSERT(writer != NULL); | 1765 ASSERT(writer != NULL); |
| 1695 | 1766 |
| 1696 if (ptr()->is_implicit_) { | 1767 if (ptr()->is_implicit_) { |
| 1697 ASSERT(ptr()->num_variables_ == 1); | 1768 ASSERT(ptr()->num_variables_ == 1); |
| 1698 const VariableDesc* var = ptr()->VariableDescAddr(0); | 1769 const VariableDesc* var = ptr()->VariableDescAddr(0); |
| 1699 | 1770 |
| 1700 // Write out the serialization header value for this object. | 1771 // Write out the serialization header value for this object. |
| 1701 writer->WriteInlinedObjectHeader(object_id); | 1772 writer->WriteInlinedObjectHeader(object_id); |
| 1702 | 1773 |
| 1703 // Write out the class and tags information. | 1774 // Write out the class and tags information. |
| 1704 writer->WriteVMIsolateObject(kContextScopeCid); | 1775 writer->WriteVMIsolateObject(kContextScopeCid); |
| 1705 writer->WriteTags(writer->GetObjectTags(this)); | 1776 writer->WriteTags(writer->GetObjectTags(this)); |
| 1706 | 1777 |
| 1707 // Write out is_implicit flag for the context scope. | 1778 // Write out is_implicit flag for the context scope. |
| 1708 writer->Write<bool>(true); | 1779 writer->Write<bool>(true); |
| 1709 | 1780 |
| 1710 // Write out the type of 'this' the variable. | 1781 // Write out the type of 'this' the variable. |
| 1711 writer->WriteObjectImpl(var->type, kAsInlinedObject); | 1782 writer->WriteObjectImpl(var->type, kAsInlinedObject); |
| 1712 | 1783 |
| 1713 return; | 1784 return; |
| 1714 } | 1785 } |
| 1715 UNREACHABLE(); | 1786 UNREACHABLE(); |
| 1716 } | 1787 } |
| 1717 | 1788 |
| 1718 | 1789 |
| 1719 RawICData* ICData::ReadFrom(SnapshotReader* reader, | 1790 RawICData* ICData::ReadFrom(SnapshotReader* reader, |
| 1720 intptr_t object_id, | 1791 intptr_t object_id, |
| 1721 intptr_t tags, | 1792 intptr_t tags, |
| 1722 Snapshot::Kind kind) { | 1793 Snapshot::Kind kind, |
| 1794 bool as_reference) { |
| 1723 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 1795 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 1724 | 1796 |
| 1725 ICData& result = ICData::ZoneHandle(reader->zone(), NEW_OBJECT(ICData)); | 1797 ICData& result = ICData::ZoneHandle(reader->zone(), NEW_OBJECT(ICData)); |
| 1726 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1798 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 1727 | 1799 |
| 1728 result.set_deopt_id(reader->Read<int32_t>()); | 1800 result.set_deopt_id(reader->Read<int32_t>()); |
| 1729 result.set_state_bits(reader->Read<uint32_t>()); | 1801 result.set_state_bits(reader->Read<uint32_t>()); |
| 1730 | 1802 |
| 1731 // Set all the object fields. | 1803 // Set all the object fields. |
| 1732 READ_OBJECT_FIELDS(result, | 1804 READ_OBJECT_FIELDS(result, |
| 1733 result.raw()->from(), result.raw()->to(), | 1805 result.raw()->from(), result.raw()->to(), |
| 1734 kAsReference); | 1806 kAsReference); |
| 1735 | 1807 |
| 1736 return result.raw(); | 1808 return result.raw(); |
| 1737 } | 1809 } |
| 1738 | 1810 |
| 1739 | 1811 |
| 1740 void RawICData::WriteTo(SnapshotWriter* writer, | 1812 void RawICData::WriteTo(SnapshotWriter* writer, |
| 1741 intptr_t object_id, | 1813 intptr_t object_id, |
| 1742 Snapshot::Kind kind) { | 1814 Snapshot::Kind kind, |
| 1815 bool as_reference) { |
| 1743 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 1816 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 1744 | 1817 |
| 1745 // Write out the serialization header value for this object. | 1818 // Write out the serialization header value for this object. |
| 1746 writer->WriteInlinedObjectHeader(object_id); | 1819 writer->WriteInlinedObjectHeader(object_id); |
| 1747 | 1820 |
| 1748 // Write out the class and tags information. | 1821 // Write out the class and tags information. |
| 1749 writer->WriteVMIsolateObject(kICDataCid); | 1822 writer->WriteVMIsolateObject(kICDataCid); |
| 1750 writer->WriteTags(writer->GetObjectTags(this)); | 1823 writer->WriteTags(writer->GetObjectTags(this)); |
| 1751 | 1824 |
| 1752 // Write out all the non object fields. | 1825 // Write out all the non object fields. |
| 1753 writer->Write<int32_t>(ptr()->deopt_id_); | 1826 writer->Write<int32_t>(ptr()->deopt_id_); |
| 1754 writer->Write<uint32_t>(ptr()->state_bits_); | 1827 writer->Write<uint32_t>(ptr()->state_bits_); |
| 1755 | 1828 |
| 1756 // Write out all the object pointer fields. | 1829 // Write out all the object pointer fields. |
| 1757 SnapshotWriterVisitor visitor(writer, kAsReference); | 1830 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 1758 visitor.VisitPointers(from(), to()); | 1831 visitor.VisitPointers(from(), to()); |
| 1759 } | 1832 } |
| 1760 | 1833 |
| 1761 | 1834 |
| 1762 RawMegamorphicCache* MegamorphicCache::ReadFrom(SnapshotReader* reader, | 1835 RawMegamorphicCache* MegamorphicCache::ReadFrom(SnapshotReader* reader, |
| 1763 intptr_t object_id, | 1836 intptr_t object_id, |
| 1764 intptr_t tags, | 1837 intptr_t tags, |
| 1765 Snapshot::Kind kind) { | 1838 Snapshot::Kind kind, |
| 1839 bool as_reference) { |
| 1766 ASSERT(reader->snapshot_code()); | 1840 ASSERT(reader->snapshot_code()); |
| 1767 ASSERT(kind == Snapshot::kFull); | 1841 ASSERT(kind == Snapshot::kFull); |
| 1768 | 1842 |
| 1769 MegamorphicCache& result = | 1843 MegamorphicCache& result = |
| 1770 MegamorphicCache::ZoneHandle(reader->zone(), | 1844 MegamorphicCache::ZoneHandle(reader->zone(), |
| 1771 NEW_OBJECT(MegamorphicCache)); | 1845 NEW_OBJECT(MegamorphicCache)); |
| 1772 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1846 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 1773 | 1847 |
| 1774 result.set_filled_entry_count(reader->Read<int32_t>()); | 1848 result.set_filled_entry_count(reader->Read<int32_t>()); |
| 1775 | 1849 |
| 1776 // Set all the object fields. | 1850 // Set all the object fields. |
| 1777 READ_OBJECT_FIELDS(result, | 1851 READ_OBJECT_FIELDS(result, |
| 1778 result.raw()->from(), result.raw()->to(), | 1852 result.raw()->from(), result.raw()->to(), |
| 1779 kAsReference); | 1853 kAsReference); |
| 1780 | 1854 |
| 1781 return result.raw(); | 1855 return result.raw(); |
| 1782 } | 1856 } |
| 1783 | 1857 |
| 1784 | 1858 |
| 1785 void RawMegamorphicCache::WriteTo(SnapshotWriter* writer, | 1859 void RawMegamorphicCache::WriteTo(SnapshotWriter* writer, |
| 1786 intptr_t object_id, | 1860 intptr_t object_id, |
| 1787 Snapshot::Kind kind) { | 1861 Snapshot::Kind kind, |
| 1862 bool as_reference) { |
| 1788 ASSERT(writer->snapshot_code()); | 1863 ASSERT(writer->snapshot_code()); |
| 1789 ASSERT(kind == Snapshot::kFull); | 1864 ASSERT(kind == Snapshot::kFull); |
| 1790 | 1865 |
| 1791 // Write out the serialization header value for this object. | 1866 // Write out the serialization header value for this object. |
| 1792 writer->WriteInlinedObjectHeader(object_id); | 1867 writer->WriteInlinedObjectHeader(object_id); |
| 1793 | 1868 |
| 1794 // Write out the class and tags information. | 1869 // Write out the class and tags information. |
| 1795 writer->WriteVMIsolateObject(kMegamorphicCacheCid); | 1870 writer->WriteVMIsolateObject(kMegamorphicCacheCid); |
| 1796 writer->WriteTags(writer->GetObjectTags(this)); | 1871 writer->WriteTags(writer->GetObjectTags(this)); |
| 1797 | 1872 |
| 1798 // Write out all the non object fields. | 1873 // Write out all the non object fields. |
| 1799 writer->Write<int32_t>(ptr()->filled_entry_count_); | 1874 writer->Write<int32_t>(ptr()->filled_entry_count_); |
| 1800 | 1875 |
| 1801 // Write out all the object pointer fields. | 1876 // Write out all the object pointer fields. |
| 1802 SnapshotWriterVisitor visitor(writer, kAsReference); | 1877 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 1803 visitor.VisitPointers(from(), to()); | 1878 visitor.VisitPointers(from(), to()); |
| 1804 } | 1879 } |
| 1805 | 1880 |
| 1806 | 1881 |
| 1807 RawSubtypeTestCache* SubtypeTestCache::ReadFrom(SnapshotReader* reader, | 1882 RawSubtypeTestCache* SubtypeTestCache::ReadFrom(SnapshotReader* reader, |
| 1808 intptr_t object_id, | 1883 intptr_t object_id, |
| 1809 intptr_t tags, | 1884 intptr_t tags, |
| 1810 Snapshot::Kind kind) { | 1885 Snapshot::Kind kind, |
| 1886 bool as_reference) { |
| 1811 ASSERT(reader->snapshot_code()); | 1887 ASSERT(reader->snapshot_code()); |
| 1812 ASSERT(kind == Snapshot::kFull); | 1888 ASSERT(kind == Snapshot::kFull); |
| 1813 | 1889 |
| 1814 SubtypeTestCache& result = | 1890 SubtypeTestCache& result = |
| 1815 SubtypeTestCache::ZoneHandle(reader->zone(), | 1891 SubtypeTestCache::ZoneHandle(reader->zone(), |
| 1816 NEW_OBJECT(SubtypeTestCache)); | 1892 NEW_OBJECT(SubtypeTestCache)); |
| 1817 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1893 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 1818 | 1894 |
| 1819 // Set all the object fields. | 1895 // Set all the object fields. |
| 1820 // TODO(5411462): Need to assert No GC can happen here, even though | 1896 // TODO(5411462): Need to assert No GC can happen here, even though |
| 1821 // allocations may happen. | 1897 // allocations may happen. |
| 1822 (*reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsReference); | 1898 (*reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsReference); |
| 1823 result.StorePointer(&result.raw_ptr()->cache_, | 1899 result.StorePointer(&result.raw_ptr()->cache_, |
| 1824 reader->ArrayHandle()->raw()); | 1900 reader->ArrayHandle()->raw()); |
| 1825 | 1901 |
| 1826 return result.raw(); | 1902 return result.raw(); |
| 1827 } | 1903 } |
| 1828 | 1904 |
| 1829 | 1905 |
| 1830 void RawSubtypeTestCache::WriteTo(SnapshotWriter* writer, | 1906 void RawSubtypeTestCache::WriteTo(SnapshotWriter* writer, |
| 1831 intptr_t object_id, | 1907 intptr_t object_id, |
| 1832 Snapshot::Kind kind) { | 1908 Snapshot::Kind kind, |
| 1909 bool as_reference) { |
| 1833 ASSERT(writer->snapshot_code()); | 1910 ASSERT(writer->snapshot_code()); |
| 1834 ASSERT(kind == Snapshot::kFull); | 1911 ASSERT(kind == Snapshot::kFull); |
| 1835 | 1912 |
| 1836 // Write out the serialization header value for this object. | 1913 // Write out the serialization header value for this object. |
| 1837 writer->WriteInlinedObjectHeader(object_id); | 1914 writer->WriteInlinedObjectHeader(object_id); |
| 1838 | 1915 |
| 1839 // Write out the class and tags information. | 1916 // Write out the class and tags information. |
| 1840 writer->WriteVMIsolateObject(kSubtypeTestCacheCid); | 1917 writer->WriteVMIsolateObject(kSubtypeTestCacheCid); |
| 1841 writer->WriteTags(writer->GetObjectTags(this)); | 1918 writer->WriteTags(writer->GetObjectTags(this)); |
| 1842 | 1919 |
| 1843 // Write out all the object pointer fields. | 1920 // Write out all the object pointer fields. |
| 1844 writer->WriteObjectImpl(ptr()->cache_, kAsReference); | 1921 writer->WriteObjectImpl(ptr()->cache_, kAsReference); |
| 1845 } | 1922 } |
| 1846 | 1923 |
| 1847 | 1924 |
| 1848 RawError* Error::ReadFrom(SnapshotReader* reader, | 1925 RawError* Error::ReadFrom(SnapshotReader* reader, |
| 1849 intptr_t object_id, | 1926 intptr_t object_id, |
| 1850 intptr_t tags, | 1927 intptr_t tags, |
| 1851 Snapshot::Kind kind) { | 1928 Snapshot::Kind kind, |
| 1929 bool as_referenec) { |
| 1852 UNREACHABLE(); | 1930 UNREACHABLE(); |
| 1853 return Error::null(); // Error is an abstract class. | 1931 return Error::null(); // Error is an abstract class. |
| 1854 } | 1932 } |
| 1855 | 1933 |
| 1856 | 1934 |
| 1857 void RawError::WriteTo(SnapshotWriter* writer, | 1935 void RawError::WriteTo(SnapshotWriter* writer, |
| 1858 intptr_t object_id, | 1936 intptr_t object_id, |
| 1859 Snapshot::Kind kind) { | 1937 Snapshot::Kind kind, |
| 1938 bool as_reference) { |
| 1860 UNREACHABLE(); // Error is an abstract class. | 1939 UNREACHABLE(); // Error is an abstract class. |
| 1861 } | 1940 } |
| 1862 | 1941 |
| 1863 | 1942 |
| 1864 RawApiError* ApiError::ReadFrom(SnapshotReader* reader, | 1943 RawApiError* ApiError::ReadFrom(SnapshotReader* reader, |
| 1865 intptr_t object_id, | 1944 intptr_t object_id, |
| 1866 intptr_t tags, | 1945 intptr_t tags, |
| 1867 Snapshot::Kind kind) { | 1946 Snapshot::Kind kind, |
| 1947 bool as_reference) { |
| 1868 ASSERT(reader != NULL); | 1948 ASSERT(reader != NULL); |
| 1869 | 1949 |
| 1870 // Allocate ApiError object. | 1950 // Allocate ApiError object. |
| 1871 ApiError& api_error = | 1951 ApiError& api_error = |
| 1872 ApiError::ZoneHandle(reader->zone(), NEW_OBJECT(ApiError)); | 1952 ApiError::ZoneHandle(reader->zone(), NEW_OBJECT(ApiError)); |
| 1873 reader->AddBackRef(object_id, &api_error, kIsDeserialized); | 1953 reader->AddBackRef(object_id, &api_error, kIsDeserialized); |
| 1874 | 1954 |
| 1875 // Set all the object fields. | 1955 // Set all the object fields. |
| 1876 READ_OBJECT_FIELDS(api_error, | 1956 READ_OBJECT_FIELDS(api_error, |
| 1877 api_error.raw()->from(), api_error.raw()->to(), | 1957 api_error.raw()->from(), api_error.raw()->to(), |
| 1878 kAsReference); | 1958 kAsReference); |
| 1879 | 1959 |
| 1880 return api_error.raw(); | 1960 return api_error.raw(); |
| 1881 } | 1961 } |
| 1882 | 1962 |
| 1883 | 1963 |
| 1884 void RawApiError::WriteTo(SnapshotWriter* writer, | 1964 void RawApiError::WriteTo(SnapshotWriter* writer, |
| 1885 intptr_t object_id, | 1965 intptr_t object_id, |
| 1886 Snapshot::Kind kind) { | 1966 Snapshot::Kind kind, |
| 1967 bool as_reference) { |
| 1887 ASSERT(writer != NULL); | 1968 ASSERT(writer != NULL); |
| 1888 | 1969 |
| 1889 // Write out the serialization header value for this object. | 1970 // Write out the serialization header value for this object. |
| 1890 writer->WriteInlinedObjectHeader(object_id); | 1971 writer->WriteInlinedObjectHeader(object_id); |
| 1891 | 1972 |
| 1892 // Write out the class and tags information. | 1973 // Write out the class and tags information. |
| 1893 writer->WriteVMIsolateObject(kApiErrorCid); | 1974 writer->WriteVMIsolateObject(kApiErrorCid); |
| 1894 writer->WriteTags(writer->GetObjectTags(this)); | 1975 writer->WriteTags(writer->GetObjectTags(this)); |
| 1895 | 1976 |
| 1896 // Write out all the object pointer fields. | 1977 // Write out all the object pointer fields. |
| 1897 SnapshotWriterVisitor visitor(writer, kAsReference); | 1978 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 1898 visitor.VisitPointers(from(), to()); | 1979 visitor.VisitPointers(from(), to()); |
| 1899 } | 1980 } |
| 1900 | 1981 |
| 1901 | 1982 |
| 1902 RawLanguageError* LanguageError::ReadFrom(SnapshotReader* reader, | 1983 RawLanguageError* LanguageError::ReadFrom(SnapshotReader* reader, |
| 1903 intptr_t object_id, | 1984 intptr_t object_id, |
| 1904 intptr_t tags, | 1985 intptr_t tags, |
| 1905 Snapshot::Kind kind) { | 1986 Snapshot::Kind kind, |
| 1987 bool as_reference) { |
| 1906 ASSERT(reader != NULL); | 1988 ASSERT(reader != NULL); |
| 1907 | 1989 |
| 1908 // Allocate LanguageError object. | 1990 // Allocate LanguageError object. |
| 1909 LanguageError& language_error = | 1991 LanguageError& language_error = |
| 1910 LanguageError::ZoneHandle(reader->zone(), NEW_OBJECT(LanguageError)); | 1992 LanguageError::ZoneHandle(reader->zone(), NEW_OBJECT(LanguageError)); |
| 1911 reader->AddBackRef(object_id, &language_error, kIsDeserialized); | 1993 reader->AddBackRef(object_id, &language_error, kIsDeserialized); |
| 1912 | 1994 |
| 1913 // Set all non object fields. | 1995 // Set all non object fields. |
| 1914 language_error.set_token_pos(reader->Read<int32_t>()); | 1996 language_error.set_token_pos(reader->Read<int32_t>()); |
| 1915 language_error.set_kind(reader->Read<uint8_t>()); | 1997 language_error.set_kind(reader->Read<uint8_t>()); |
| 1916 | 1998 |
| 1917 // Set all the object fields. | 1999 // Set all the object fields. |
| 1918 READ_OBJECT_FIELDS(language_error, | 2000 READ_OBJECT_FIELDS(language_error, |
| 1919 language_error.raw()->from(), language_error.raw()->to(), | 2001 language_error.raw()->from(), language_error.raw()->to(), |
| 1920 kAsReference); | 2002 kAsReference); |
| 1921 | 2003 |
| 1922 return language_error.raw(); | 2004 return language_error.raw(); |
| 1923 } | 2005 } |
| 1924 | 2006 |
| 1925 | 2007 |
| 1926 void RawLanguageError::WriteTo(SnapshotWriter* writer, | 2008 void RawLanguageError::WriteTo(SnapshotWriter* writer, |
| 1927 intptr_t object_id, | 2009 intptr_t object_id, |
| 1928 Snapshot::Kind kind) { | 2010 Snapshot::Kind kind, |
| 2011 bool as_reference) { |
| 1929 ASSERT(writer != NULL); | 2012 ASSERT(writer != NULL); |
| 1930 | 2013 |
| 1931 // Write out the serialization header value for this object. | 2014 // Write out the serialization header value for this object. |
| 1932 writer->WriteInlinedObjectHeader(object_id); | 2015 writer->WriteInlinedObjectHeader(object_id); |
| 1933 | 2016 |
| 1934 // Write out the class and tags information. | 2017 // Write out the class and tags information. |
| 1935 writer->WriteVMIsolateObject(kLanguageErrorCid); | 2018 writer->WriteVMIsolateObject(kLanguageErrorCid); |
| 1936 writer->WriteTags(writer->GetObjectTags(this)); | 2019 writer->WriteTags(writer->GetObjectTags(this)); |
| 1937 | 2020 |
| 1938 // Write out all the non object fields. | 2021 // Write out all the non object fields. |
| 1939 writer->Write<int32_t>(ptr()->token_pos_); | 2022 writer->Write<int32_t>(ptr()->token_pos_); |
| 1940 writer->Write<uint8_t>(ptr()->kind_); | 2023 writer->Write<uint8_t>(ptr()->kind_); |
| 1941 | 2024 |
| 1942 // Write out all the object pointer fields. | 2025 // Write out all the object pointer fields. |
| 1943 SnapshotWriterVisitor visitor(writer, kAsReference); | 2026 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 1944 visitor.VisitPointers(from(), to()); | 2027 visitor.VisitPointers(from(), to()); |
| 1945 } | 2028 } |
| 1946 | 2029 |
| 1947 | 2030 |
| 1948 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader, | 2031 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader, |
| 1949 intptr_t object_id, | 2032 intptr_t object_id, |
| 1950 intptr_t tags, | 2033 intptr_t tags, |
| 1951 Snapshot::Kind kind) { | 2034 Snapshot::Kind kind, |
| 2035 bool as_reference) { |
| 1952 UnhandledException& result = UnhandledException::ZoneHandle( | 2036 UnhandledException& result = UnhandledException::ZoneHandle( |
| 1953 reader->zone(), NEW_OBJECT(UnhandledException)); | 2037 reader->zone(), NEW_OBJECT(UnhandledException)); |
| 1954 reader->AddBackRef(object_id, &result, kIsDeserialized); | 2038 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 1955 | 2039 |
| 1956 // Set all the object fields. | 2040 // Set all the object fields. |
| 1957 READ_OBJECT_FIELDS(result, | 2041 READ_OBJECT_FIELDS(result, |
| 1958 result.raw()->from(), result.raw()->to(), | 2042 result.raw()->from(), result.raw()->to(), |
| 1959 kAsReference); | 2043 kAsReference); |
| 1960 | 2044 |
| 1961 return result.raw(); | 2045 return result.raw(); |
| 1962 } | 2046 } |
| 1963 | 2047 |
| 1964 | 2048 |
| 1965 void RawUnhandledException::WriteTo(SnapshotWriter* writer, | 2049 void RawUnhandledException::WriteTo(SnapshotWriter* writer, |
| 1966 intptr_t object_id, | 2050 intptr_t object_id, |
| 1967 Snapshot::Kind kind) { | 2051 Snapshot::Kind kind, |
| 2052 bool as_reference) { |
| 1968 // Write out the serialization header value for this object. | 2053 // Write out the serialization header value for this object. |
| 1969 writer->WriteInlinedObjectHeader(object_id); | 2054 writer->WriteInlinedObjectHeader(object_id); |
| 1970 | 2055 |
| 1971 // Write out the class and tags information. | 2056 // Write out the class and tags information. |
| 1972 writer->WriteVMIsolateObject(kUnhandledExceptionCid); | 2057 writer->WriteVMIsolateObject(kUnhandledExceptionCid); |
| 1973 writer->WriteTags(writer->GetObjectTags(this)); | 2058 writer->WriteTags(writer->GetObjectTags(this)); |
| 1974 // Write out all the object pointer fields. | 2059 // Write out all the object pointer fields. |
| 1975 SnapshotWriterVisitor visitor(writer, kAsReference); | 2060 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 1976 visitor.VisitPointers(from(), to()); | 2061 visitor.VisitPointers(from(), to()); |
| 1977 } | 2062 } |
| 1978 | 2063 |
| 1979 | 2064 |
| 1980 RawUnwindError* UnwindError::ReadFrom(SnapshotReader* reader, | 2065 RawUnwindError* UnwindError::ReadFrom(SnapshotReader* reader, |
| 1981 intptr_t object_id, | 2066 intptr_t object_id, |
| 1982 intptr_t tags, | 2067 intptr_t tags, |
| 1983 Snapshot::Kind kind) { | 2068 Snapshot::Kind kind, |
| 2069 bool as_reference) { |
| 1984 UNREACHABLE(); | 2070 UNREACHABLE(); |
| 1985 return UnwindError::null(); | 2071 return UnwindError::null(); |
| 1986 } | 2072 } |
| 1987 | 2073 |
| 1988 | 2074 |
| 1989 void RawUnwindError::WriteTo(SnapshotWriter* writer, | 2075 void RawUnwindError::WriteTo(SnapshotWriter* writer, |
| 1990 intptr_t object_id, | 2076 intptr_t object_id, |
| 1991 Snapshot::Kind kind) { | 2077 Snapshot::Kind kind, |
| 2078 bool as_reference) { |
| 1992 UNREACHABLE(); | 2079 UNREACHABLE(); |
| 1993 } | 2080 } |
| 1994 | 2081 |
| 1995 | 2082 |
| 1996 RawInstance* Instance::ReadFrom(SnapshotReader* reader, | 2083 RawInstance* Instance::ReadFrom(SnapshotReader* reader, |
| 1997 intptr_t object_id, | 2084 intptr_t object_id, |
| 1998 intptr_t tags, | 2085 intptr_t tags, |
| 1999 Snapshot::Kind kind) { | 2086 Snapshot::Kind kind, |
| 2087 bool as_reference) { |
| 2000 ASSERT(reader != NULL); | 2088 ASSERT(reader != NULL); |
| 2001 | 2089 |
| 2002 // Create an Instance object or get canonical one if it is a canonical | 2090 // Create an Instance object or get canonical one if it is a canonical |
| 2003 // constant. | 2091 // constant. |
| 2004 Instance& obj = Instance::ZoneHandle(reader->zone(), Instance::null()); | 2092 Instance& obj = Instance::ZoneHandle(reader->zone(), Instance::null()); |
| 2005 if (kind == Snapshot::kFull) { | 2093 if (kind == Snapshot::kFull) { |
| 2006 obj = reader->NewInstance(); | 2094 obj = reader->NewInstance(); |
| 2007 // Set the canonical bit. | 2095 // Set the canonical bit. |
| 2008 if (RawObject::IsCanonical(tags)) { | 2096 if (RawObject::IsCanonical(tags)) { |
| 2009 obj.SetCanonical(); | 2097 obj.SetCanonical(); |
| 2010 } | 2098 } |
| 2011 } else { | 2099 } else { |
| 2012 obj ^= Object::Allocate(kInstanceCid, | 2100 obj ^= Object::Allocate(kInstanceCid, |
| 2013 Instance::InstanceSize(), | 2101 Instance::InstanceSize(), |
| 2014 HEAP_SPACE(kind)); | 2102 HEAP_SPACE(kind)); |
| 2015 if (RawObject::IsCanonical(tags)) { | 2103 if (RawObject::IsCanonical(tags)) { |
| 2016 obj = obj.CheckAndCanonicalize(NULL); | 2104 obj = obj.CheckAndCanonicalize(NULL); |
| 2017 } | 2105 } |
| 2018 } | 2106 } |
| 2019 reader->AddBackRef(object_id, &obj, kIsDeserialized); | 2107 reader->AddBackRef(object_id, &obj, kIsDeserialized); |
| 2020 | 2108 |
| 2021 return obj.raw(); | 2109 return obj.raw(); |
| 2022 } | 2110 } |
| 2023 | 2111 |
| 2024 | 2112 |
| 2025 void RawInstance::WriteTo(SnapshotWriter* writer, | 2113 void RawInstance::WriteTo(SnapshotWriter* writer, |
| 2026 intptr_t object_id, | 2114 intptr_t object_id, |
| 2027 Snapshot::Kind kind) { | 2115 Snapshot::Kind kind, |
| 2116 bool as_reference) { |
| 2028 ASSERT(writer != NULL); | 2117 ASSERT(writer != NULL); |
| 2029 | 2118 |
| 2030 // Write out the serialization header value for this object. | 2119 // Write out the serialization header value for this object. |
| 2031 writer->WriteInlinedObjectHeader(object_id); | 2120 writer->WriteInlinedObjectHeader(object_id); |
| 2032 | 2121 |
| 2033 // Write out the class and tags information. | 2122 // Write out the class and tags information. |
| 2034 writer->WriteIndexedObject(kInstanceCid); | 2123 writer->WriteIndexedObject(kInstanceCid); |
| 2035 writer->WriteTags(writer->GetObjectTags(this)); | 2124 writer->WriteTags(writer->GetObjectTags(this)); |
| 2036 } | 2125 } |
| 2037 | 2126 |
| 2038 | 2127 |
| 2039 RawInteger* Mint::ReadFrom(SnapshotReader* reader, | 2128 RawInteger* Mint::ReadFrom(SnapshotReader* reader, |
| 2040 intptr_t object_id, | 2129 intptr_t object_id, |
| 2041 intptr_t tags, | 2130 intptr_t tags, |
| 2042 Snapshot::Kind kind) { | 2131 Snapshot::Kind kind, |
| 2132 bool as_reference) { |
| 2043 ASSERT(reader != NULL); | 2133 ASSERT(reader != NULL); |
| 2044 | 2134 |
| 2045 // Read the 64 bit value for the object. | 2135 // Read the 64 bit value for the object. |
| 2046 int64_t value = reader->Read<int64_t>(); | 2136 int64_t value = reader->Read<int64_t>(); |
| 2047 | 2137 |
| 2048 // Check if the value could potentially fit in a Smi in our current | 2138 // Check if the value could potentially fit in a Smi in our current |
| 2049 // architecture, if so return the object as a Smi. | 2139 // architecture, if so return the object as a Smi. |
| 2050 if (Smi::IsValid(value)) { | 2140 if (Smi::IsValid(value)) { |
| 2051 Smi& smi = Smi::ZoneHandle(reader->zone(), | 2141 Smi& smi = Smi::ZoneHandle(reader->zone(), |
| 2052 Smi::New(static_cast<intptr_t>(value))); | 2142 Smi::New(static_cast<intptr_t>(value))); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2075 mint = Mint::New(value, HEAP_SPACE(kind)); | 2165 mint = Mint::New(value, HEAP_SPACE(kind)); |
| 2076 } | 2166 } |
| 2077 } | 2167 } |
| 2078 reader->AddBackRef(object_id, &mint, kIsDeserialized); | 2168 reader->AddBackRef(object_id, &mint, kIsDeserialized); |
| 2079 return mint.raw(); | 2169 return mint.raw(); |
| 2080 } | 2170 } |
| 2081 | 2171 |
| 2082 | 2172 |
| 2083 void RawMint::WriteTo(SnapshotWriter* writer, | 2173 void RawMint::WriteTo(SnapshotWriter* writer, |
| 2084 intptr_t object_id, | 2174 intptr_t object_id, |
| 2085 Snapshot::Kind kind) { | 2175 Snapshot::Kind kind, |
| 2176 bool as_reference) { |
| 2086 ASSERT(writer != NULL); | 2177 ASSERT(writer != NULL); |
| 2087 | 2178 |
| 2088 // Write out the serialization header value for this object. | 2179 // Write out the serialization header value for this object. |
| 2089 writer->WriteInlinedObjectHeader(object_id); | 2180 writer->WriteInlinedObjectHeader(object_id); |
| 2090 | 2181 |
| 2091 // Write out the class and tags information. | 2182 // Write out the class and tags information. |
| 2092 writer->WriteIndexedObject(kMintCid); | 2183 writer->WriteIndexedObject(kMintCid); |
| 2093 writer->WriteTags(writer->GetObjectTags(this)); | 2184 writer->WriteTags(writer->GetObjectTags(this)); |
| 2094 | 2185 |
| 2095 // Write out the 64 bit value. | 2186 // Write out the 64 bit value. |
| 2096 writer->Write<int64_t>(ptr()->value_); | 2187 writer->Write<int64_t>(ptr()->value_); |
| 2097 } | 2188 } |
| 2098 | 2189 |
| 2099 | 2190 |
| 2100 RawBigint* Bigint::ReadFrom(SnapshotReader* reader, | 2191 RawBigint* Bigint::ReadFrom(SnapshotReader* reader, |
| 2101 intptr_t object_id, | 2192 intptr_t object_id, |
| 2102 intptr_t tags, | 2193 intptr_t tags, |
| 2103 Snapshot::Kind kind) { | 2194 Snapshot::Kind kind, |
| 2195 bool as_reference) { |
| 2104 ASSERT(reader != NULL); | 2196 ASSERT(reader != NULL); |
| 2105 | 2197 |
| 2106 // Allocate bigint object. | 2198 // Allocate bigint object. |
| 2107 Bigint& obj = Bigint::ZoneHandle(reader->zone(), NEW_OBJECT(Bigint)); | 2199 Bigint& obj = Bigint::ZoneHandle(reader->zone(), NEW_OBJECT(Bigint)); |
| 2108 reader->AddBackRef(object_id, &obj, kIsDeserialized); | 2200 reader->AddBackRef(object_id, &obj, kIsDeserialized); |
| 2109 | 2201 |
| 2110 // Set all the object fields. | 2202 // Set all the object fields. |
| 2111 READ_OBJECT_FIELDS(obj, obj.raw()->from(), obj.raw()->to(), kAsInlinedObject); | 2203 READ_OBJECT_FIELDS(obj, obj.raw()->from(), obj.raw()->to(), kAsInlinedObject); |
| 2112 | 2204 |
| 2113 // If it is a canonical constant make it one. | 2205 // If it is a canonical constant make it one. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2124 ASSERT(!obj.IsNull()); | 2216 ASSERT(!obj.IsNull()); |
| 2125 ASSERT(obj.IsCanonical()); | 2217 ASSERT(obj.IsCanonical()); |
| 2126 } | 2218 } |
| 2127 } | 2219 } |
| 2128 return obj.raw(); | 2220 return obj.raw(); |
| 2129 } | 2221 } |
| 2130 | 2222 |
| 2131 | 2223 |
| 2132 void RawBigint::WriteTo(SnapshotWriter* writer, | 2224 void RawBigint::WriteTo(SnapshotWriter* writer, |
| 2133 intptr_t object_id, | 2225 intptr_t object_id, |
| 2134 Snapshot::Kind kind) { | 2226 Snapshot::Kind kind, |
| 2227 bool as_reference) { |
| 2135 ASSERT(writer != NULL); | 2228 ASSERT(writer != NULL); |
| 2136 | 2229 |
| 2137 // Write out the serialization header value for this object. | 2230 // Write out the serialization header value for this object. |
| 2138 writer->WriteInlinedObjectHeader(object_id); | 2231 writer->WriteInlinedObjectHeader(object_id); |
| 2139 | 2232 |
| 2140 // Write out the class and tags information. | 2233 // Write out the class and tags information. |
| 2141 writer->WriteIndexedObject(kBigintCid); | 2234 writer->WriteIndexedObject(kBigintCid); |
| 2142 writer->WriteTags(writer->GetObjectTags(this)); | 2235 writer->WriteTags(writer->GetObjectTags(this)); |
| 2143 | 2236 |
| 2144 // Write out all the object pointer fields. | 2237 // Write out all the object pointer fields. |
| 2145 SnapshotWriterVisitor visitor(writer, kAsInlinedObject); | 2238 SnapshotWriterVisitor visitor(writer, kAsInlinedObject); |
| 2146 visitor.VisitPointers(from(), to()); | 2239 visitor.VisitPointers(from(), to()); |
| 2147 } | 2240 } |
| 2148 | 2241 |
| 2149 | 2242 |
| 2150 RawDouble* Double::ReadFrom(SnapshotReader* reader, | 2243 RawDouble* Double::ReadFrom(SnapshotReader* reader, |
| 2151 intptr_t object_id, | 2244 intptr_t object_id, |
| 2152 intptr_t tags, | 2245 intptr_t tags, |
| 2153 Snapshot::Kind kind) { | 2246 Snapshot::Kind kind, |
| 2247 bool as_reference) { |
| 2154 ASSERT(reader != NULL); | 2248 ASSERT(reader != NULL); |
| 2155 ASSERT(kind != Snapshot::kMessage); | 2249 ASSERT(kind != Snapshot::kMessage); |
| 2156 // Read the double value for the object. | 2250 // Read the double value for the object. |
| 2157 double value = reader->ReadDouble(); | 2251 double value = reader->ReadDouble(); |
| 2158 | 2252 |
| 2159 // Create a Double object or get canonical one if it is a canonical constant. | 2253 // Create a Double object or get canonical one if it is a canonical constant. |
| 2160 Double& dbl = Double::ZoneHandle(reader->zone(), Double::null()); | 2254 Double& dbl = Double::ZoneHandle(reader->zone(), Double::null()); |
| 2161 if (kind == Snapshot::kFull) { | 2255 if (kind == Snapshot::kFull) { |
| 2162 dbl = reader->NewDouble(value); | 2256 dbl = reader->NewDouble(value); |
| 2163 // Set the canonical bit. | 2257 // Set the canonical bit. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2176 dbl = Double::New(value, HEAP_SPACE(kind)); | 2270 dbl = Double::New(value, HEAP_SPACE(kind)); |
| 2177 } | 2271 } |
| 2178 } | 2272 } |
| 2179 reader->AddBackRef(object_id, &dbl, kIsDeserialized); | 2273 reader->AddBackRef(object_id, &dbl, kIsDeserialized); |
| 2180 return dbl.raw(); | 2274 return dbl.raw(); |
| 2181 } | 2275 } |
| 2182 | 2276 |
| 2183 | 2277 |
| 2184 void RawDouble::WriteTo(SnapshotWriter* writer, | 2278 void RawDouble::WriteTo(SnapshotWriter* writer, |
| 2185 intptr_t object_id, | 2279 intptr_t object_id, |
| 2186 Snapshot::Kind kind) { | 2280 Snapshot::Kind kind, |
| 2281 bool as_reference) { |
| 2187 ASSERT(writer != NULL); | 2282 ASSERT(writer != NULL); |
| 2188 | 2283 |
| 2189 // Write out the serialization header value for this object. | 2284 // Write out the serialization header value for this object. |
| 2190 writer->WriteInlinedObjectHeader(object_id); | 2285 writer->WriteInlinedObjectHeader(object_id); |
| 2191 | 2286 |
| 2192 // Write out the class and tags information. | 2287 // Write out the class and tags information. |
| 2193 writer->WriteIndexedObject(kDoubleCid); | 2288 writer->WriteIndexedObject(kDoubleCid); |
| 2194 writer->WriteTags(writer->GetObjectTags(this)); | 2289 writer->WriteTags(writer->GetObjectTags(this)); |
| 2195 | 2290 |
| 2196 // Write out the double value. | 2291 // Write out the double value. |
| 2197 writer->WriteDouble(ptr()->value_); | 2292 writer->WriteDouble(ptr()->value_); |
| 2198 } | 2293 } |
| 2199 | 2294 |
| 2200 | 2295 |
| 2201 RawString* String::ReadFrom(SnapshotReader* reader, | 2296 RawString* String::ReadFrom(SnapshotReader* reader, |
| 2202 intptr_t object_id, | 2297 intptr_t object_id, |
| 2203 intptr_t tags, | 2298 intptr_t tags, |
| 2204 Snapshot::Kind kind) { | 2299 Snapshot::Kind kind, |
| 2300 bool as_reference) { |
| 2205 UNREACHABLE(); // String is an abstract class. | 2301 UNREACHABLE(); // String is an abstract class. |
| 2206 return String::null(); | 2302 return String::null(); |
| 2207 } | 2303 } |
| 2208 | 2304 |
| 2209 | 2305 |
| 2210 void RawString::WriteTo(SnapshotWriter* writer, | 2306 void RawString::WriteTo(SnapshotWriter* writer, |
| 2211 intptr_t object_id, | 2307 intptr_t object_id, |
| 2212 Snapshot::Kind kind) { | 2308 Snapshot::Kind kind, |
| 2309 bool as_reference) { |
| 2213 UNREACHABLE(); // String is an abstract class. | 2310 UNREACHABLE(); // String is an abstract class. |
| 2214 } | 2311 } |
| 2215 | 2312 |
| 2216 | 2313 |
| 2217 template<typename StringType, typename CharacterType, typename CallbackType> | 2314 template<typename StringType, typename CharacterType, typename CallbackType> |
| 2218 void String::ReadFromImpl(SnapshotReader* reader, | 2315 void String::ReadFromImpl(SnapshotReader* reader, |
| 2219 String* str_obj, | 2316 String* str_obj, |
| 2220 intptr_t len, | 2317 intptr_t len, |
| 2221 intptr_t tags, | 2318 intptr_t tags, |
| 2222 CallbackType new_symbol, | 2319 CallbackType new_symbol, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2243 *str_addr = reader->Read<CharacterType>(); | 2340 *str_addr = reader->Read<CharacterType>(); |
| 2244 str_addr++; | 2341 str_addr++; |
| 2245 } | 2342 } |
| 2246 } | 2343 } |
| 2247 } | 2344 } |
| 2248 | 2345 |
| 2249 | 2346 |
| 2250 RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader, | 2347 RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader, |
| 2251 intptr_t object_id, | 2348 intptr_t object_id, |
| 2252 intptr_t tags, | 2349 intptr_t tags, |
| 2253 Snapshot::Kind kind) { | 2350 Snapshot::Kind kind, |
| 2351 bool as_reference) { |
| 2254 // Read the length so that we can determine instance size to allocate. | 2352 // Read the length so that we can determine instance size to allocate. |
| 2255 ASSERT(reader != NULL); | 2353 ASSERT(reader != NULL); |
| 2256 intptr_t len = reader->ReadSmiValue(); | 2354 intptr_t len = reader->ReadSmiValue(); |
| 2257 intptr_t hash = reader->ReadSmiValue(); | 2355 intptr_t hash = reader->ReadSmiValue(); |
| 2258 String& str_obj = String::ZoneHandle(reader->zone(), String::null()); | 2356 String& str_obj = String::ZoneHandle(reader->zone(), String::null()); |
| 2259 | 2357 |
| 2260 if (kind == Snapshot::kFull) { | 2358 if (kind == Snapshot::kFull) { |
| 2261 // We currently only expect the Dart mutator to read snapshots. | 2359 // We currently only expect the Dart mutator to read snapshots. |
| 2262 reader->isolate()->AssertCurrentThreadIsMutator(); | 2360 reader->isolate()->AssertCurrentThreadIsMutator(); |
| 2263 ASSERT(Thread::Current()->no_safepoint_scope_depth() != 0); | 2361 ASSERT(Thread::Current()->no_safepoint_scope_depth() != 0); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2277 reader, &str_obj, len, tags, Symbols::FromLatin1, kind); | 2375 reader, &str_obj, len, tags, Symbols::FromLatin1, kind); |
| 2278 } | 2376 } |
| 2279 reader->AddBackRef(object_id, &str_obj, kIsDeserialized); | 2377 reader->AddBackRef(object_id, &str_obj, kIsDeserialized); |
| 2280 return raw(str_obj); | 2378 return raw(str_obj); |
| 2281 } | 2379 } |
| 2282 | 2380 |
| 2283 | 2381 |
| 2284 RawTwoByteString* TwoByteString::ReadFrom(SnapshotReader* reader, | 2382 RawTwoByteString* TwoByteString::ReadFrom(SnapshotReader* reader, |
| 2285 intptr_t object_id, | 2383 intptr_t object_id, |
| 2286 intptr_t tags, | 2384 intptr_t tags, |
| 2287 Snapshot::Kind kind) { | 2385 Snapshot::Kind kind, |
| 2386 bool as_reference) { |
| 2288 // Read the length so that we can determine instance size to allocate. | 2387 // Read the length so that we can determine instance size to allocate. |
| 2289 ASSERT(reader != NULL); | 2388 ASSERT(reader != NULL); |
| 2290 intptr_t len = reader->ReadSmiValue(); | 2389 intptr_t len = reader->ReadSmiValue(); |
| 2291 intptr_t hash = reader->ReadSmiValue(); | 2390 intptr_t hash = reader->ReadSmiValue(); |
| 2292 String& str_obj = String::ZoneHandle(reader->zone(), String::null()); | 2391 String& str_obj = String::ZoneHandle(reader->zone(), String::null()); |
| 2293 | 2392 |
| 2294 if (kind == Snapshot::kFull) { | 2393 if (kind == Snapshot::kFull) { |
| 2295 RawTwoByteString* obj = reader->NewTwoByteString(len); | 2394 RawTwoByteString* obj = reader->NewTwoByteString(len); |
| 2296 str_obj = obj; | 2395 str_obj = obj; |
| 2297 if (RawObject::IsCanonical(tags)) { | 2396 if (RawObject::IsCanonical(tags)) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2348 for (intptr_t i = 0; i < len; i++) { | 2447 for (intptr_t i = 0; i < len; i++) { |
| 2349 writer->Write(data[i]); | 2448 writer->Write(data[i]); |
| 2350 } | 2449 } |
| 2351 } | 2450 } |
| 2352 } | 2451 } |
| 2353 } | 2452 } |
| 2354 | 2453 |
| 2355 | 2454 |
| 2356 void RawOneByteString::WriteTo(SnapshotWriter* writer, | 2455 void RawOneByteString::WriteTo(SnapshotWriter* writer, |
| 2357 intptr_t object_id, | 2456 intptr_t object_id, |
| 2358 Snapshot::Kind kind) { | 2457 Snapshot::Kind kind, |
| 2458 bool as_reference) { |
| 2359 StringWriteTo(writer, | 2459 StringWriteTo(writer, |
| 2360 object_id, | 2460 object_id, |
| 2361 kind, | 2461 kind, |
| 2362 kOneByteStringCid, | 2462 kOneByteStringCid, |
| 2363 writer->GetObjectTags(this), | 2463 writer->GetObjectTags(this), |
| 2364 ptr()->length_, | 2464 ptr()->length_, |
| 2365 ptr()->hash_, | 2465 ptr()->hash_, |
| 2366 ptr()->data()); | 2466 ptr()->data()); |
| 2367 } | 2467 } |
| 2368 | 2468 |
| 2369 | 2469 |
| 2370 void RawTwoByteString::WriteTo(SnapshotWriter* writer, | 2470 void RawTwoByteString::WriteTo(SnapshotWriter* writer, |
| 2371 intptr_t object_id, | 2471 intptr_t object_id, |
| 2372 Snapshot::Kind kind) { | 2472 Snapshot::Kind kind, |
| 2473 bool as_reference) { |
| 2373 StringWriteTo(writer, | 2474 StringWriteTo(writer, |
| 2374 object_id, | 2475 object_id, |
| 2375 kind, | 2476 kind, |
| 2376 kTwoByteStringCid, | 2477 kTwoByteStringCid, |
| 2377 writer->GetObjectTags(this), | 2478 writer->GetObjectTags(this), |
| 2378 ptr()->length_, | 2479 ptr()->length_, |
| 2379 ptr()->hash_, | 2480 ptr()->hash_, |
| 2380 ptr()->data()); | 2481 ptr()->data()); |
| 2381 } | 2482 } |
| 2382 | 2483 |
| 2383 | 2484 |
| 2384 RawExternalOneByteString* ExternalOneByteString::ReadFrom( | 2485 RawExternalOneByteString* ExternalOneByteString::ReadFrom( |
| 2385 SnapshotReader* reader, | 2486 SnapshotReader* reader, |
| 2386 intptr_t object_id, | 2487 intptr_t object_id, |
| 2387 intptr_t tags, | 2488 intptr_t tags, |
| 2388 Snapshot::Kind kind) { | 2489 Snapshot::Kind kind, |
| 2490 bool as_reference) { |
| 2389 UNREACHABLE(); | 2491 UNREACHABLE(); |
| 2390 return ExternalOneByteString::null(); | 2492 return ExternalOneByteString::null(); |
| 2391 } | 2493 } |
| 2392 | 2494 |
| 2393 | 2495 |
| 2394 RawExternalTwoByteString* ExternalTwoByteString::ReadFrom( | 2496 RawExternalTwoByteString* ExternalTwoByteString::ReadFrom( |
| 2395 SnapshotReader* reader, | 2497 SnapshotReader* reader, |
| 2396 intptr_t object_id, | 2498 intptr_t object_id, |
| 2397 intptr_t tags, | 2499 intptr_t tags, |
| 2398 Snapshot::Kind kind) { | 2500 Snapshot::Kind kind, |
| 2501 bool as_reference) { |
| 2399 UNREACHABLE(); | 2502 UNREACHABLE(); |
| 2400 return ExternalTwoByteString::null(); | 2503 return ExternalTwoByteString::null(); |
| 2401 } | 2504 } |
| 2402 | 2505 |
| 2403 | 2506 |
| 2404 void RawExternalOneByteString::WriteTo(SnapshotWriter* writer, | 2507 void RawExternalOneByteString::WriteTo(SnapshotWriter* writer, |
| 2405 intptr_t object_id, | 2508 intptr_t object_id, |
| 2406 Snapshot::Kind kind) { | 2509 Snapshot::Kind kind, |
| 2510 bool as_reference) { |
| 2407 // Serialize as a non-external one byte string. | 2511 // Serialize as a non-external one byte string. |
| 2408 StringWriteTo(writer, | 2512 StringWriteTo(writer, |
| 2409 object_id, | 2513 object_id, |
| 2410 kind, | 2514 kind, |
| 2411 kOneByteStringCid, | 2515 kOneByteStringCid, |
| 2412 writer->GetObjectTags(this), | 2516 writer->GetObjectTags(this), |
| 2413 ptr()->length_, | 2517 ptr()->length_, |
| 2414 ptr()->hash_, | 2518 ptr()->hash_, |
| 2415 ptr()->external_data_->data()); | 2519 ptr()->external_data_->data()); |
| 2416 } | 2520 } |
| 2417 | 2521 |
| 2418 | 2522 |
| 2419 void RawExternalTwoByteString::WriteTo(SnapshotWriter* writer, | 2523 void RawExternalTwoByteString::WriteTo(SnapshotWriter* writer, |
| 2420 intptr_t object_id, | 2524 intptr_t object_id, |
| 2421 Snapshot::Kind kind) { | 2525 Snapshot::Kind kind, |
| 2526 bool as_reference) { |
| 2422 // Serialize as a non-external two byte string. | 2527 // Serialize as a non-external two byte string. |
| 2423 StringWriteTo(writer, | 2528 StringWriteTo(writer, |
| 2424 object_id, | 2529 object_id, |
| 2425 kind, | 2530 kind, |
| 2426 kTwoByteStringCid, | 2531 kTwoByteStringCid, |
| 2427 writer->GetObjectTags(this), | 2532 writer->GetObjectTags(this), |
| 2428 ptr()->length_, | 2533 ptr()->length_, |
| 2429 ptr()->hash_, | 2534 ptr()->hash_, |
| 2430 ptr()->external_data_->data()); | 2535 ptr()->external_data_->data()); |
| 2431 } | 2536 } |
| 2432 | 2537 |
| 2433 | 2538 |
| 2434 RawBool* Bool::ReadFrom(SnapshotReader* reader, | 2539 RawBool* Bool::ReadFrom(SnapshotReader* reader, |
| 2435 intptr_t object_id, | 2540 intptr_t object_id, |
| 2436 intptr_t tags, | 2541 intptr_t tags, |
| 2437 Snapshot::Kind kind) { | 2542 Snapshot::Kind kind, |
| 2543 bool as_reference) { |
| 2438 UNREACHABLE(); | 2544 UNREACHABLE(); |
| 2439 return Bool::null(); | 2545 return Bool::null(); |
| 2440 } | 2546 } |
| 2441 | 2547 |
| 2442 | 2548 |
| 2443 void RawBool::WriteTo(SnapshotWriter* writer, | 2549 void RawBool::WriteTo(SnapshotWriter* writer, |
| 2444 intptr_t object_id, | 2550 intptr_t object_id, |
| 2445 Snapshot::Kind kind) { | 2551 Snapshot::Kind kind, |
| 2552 bool as_reference) { |
| 2446 UNREACHABLE(); | 2553 UNREACHABLE(); |
| 2447 } | 2554 } |
| 2448 | 2555 |
| 2449 | 2556 |
| 2450 RawArray* Array::ReadFrom(SnapshotReader* reader, | 2557 RawArray* Array::ReadFrom(SnapshotReader* reader, |
| 2451 intptr_t object_id, | 2558 intptr_t object_id, |
| 2452 intptr_t tags, | 2559 intptr_t tags, |
| 2453 Snapshot::Kind kind) { | 2560 Snapshot::Kind kind, |
| 2561 bool as_reference) { |
| 2454 ASSERT(reader != NULL); | 2562 ASSERT(reader != NULL); |
| 2455 | 2563 |
| 2456 // Read the length so that we can determine instance size to allocate. | 2564 // Read the length so that we can determine instance size to allocate. |
| 2457 intptr_t len = reader->ReadSmiValue(); | 2565 intptr_t len = reader->ReadSmiValue(); |
| 2458 Array* array = reinterpret_cast<Array*>( | 2566 Array* array = reinterpret_cast<Array*>( |
| 2459 reader->GetBackRef(object_id)); | 2567 reader->GetBackRef(object_id)); |
| 2460 if (array == NULL) { | 2568 if (array == NULL) { |
| 2461 array = &(Array::ZoneHandle(reader->zone(), | 2569 array = &(Array::ZoneHandle(reader->zone(), |
| 2462 NEW_OBJECT_WITH_LEN_SPACE(Array, len, kind))); | 2570 NEW_OBJECT_WITH_LEN_SPACE(Array, len, kind))); |
| 2463 reader->AddBackRef(object_id, array, kIsDeserialized); | 2571 reader->AddBackRef(object_id, array, kIsDeserialized); |
| 2464 } | 2572 } |
| 2465 ASSERT(!RawObject::IsCanonical(tags)); | 2573 ASSERT(!RawObject::IsCanonical(tags)); |
| 2466 reader->ArrayReadFrom(object_id, *array, len, tags); | 2574 reader->ArrayReadFrom(object_id, *array, len, tags); |
| 2467 return array->raw(); | 2575 return array->raw(); |
| 2468 } | 2576 } |
| 2469 | 2577 |
| 2470 | 2578 |
| 2471 RawImmutableArray* ImmutableArray::ReadFrom(SnapshotReader* reader, | 2579 RawImmutableArray* ImmutableArray::ReadFrom(SnapshotReader* reader, |
| 2472 intptr_t object_id, | 2580 intptr_t object_id, |
| 2473 intptr_t tags, | 2581 intptr_t tags, |
| 2474 Snapshot::Kind kind) { | 2582 Snapshot::Kind kind, |
| 2583 bool as_reference) { |
| 2475 ASSERT(reader != NULL); | 2584 ASSERT(reader != NULL); |
| 2476 | 2585 |
| 2477 // Read the length so that we can determine instance size to allocate. | 2586 // Read the length so that we can determine instance size to allocate. |
| 2478 intptr_t len = reader->ReadSmiValue(); | 2587 intptr_t len = reader->ReadSmiValue(); |
| 2479 Array* array = reinterpret_cast<Array*>(reader->GetBackRef(object_id)); | 2588 Array* array = reinterpret_cast<Array*>(reader->GetBackRef(object_id)); |
| 2480 if (array == NULL) { | 2589 if (array == NULL) { |
| 2481 array = &(Array::ZoneHandle( | 2590 array = &(Array::ZoneHandle( |
| 2482 reader->zone(), | 2591 reader->zone(), |
| 2483 NEW_OBJECT_WITH_LEN_SPACE(ImmutableArray, len, kind))); | 2592 NEW_OBJECT_WITH_LEN_SPACE(ImmutableArray, len, kind))); |
| 2484 reader->AddBackRef(object_id, array, kIsDeserialized); | 2593 reader->AddBackRef(object_id, array, kIsDeserialized); |
| 2485 } | 2594 } |
| 2486 reader->ArrayReadFrom(object_id, *array, len, tags); | 2595 reader->ArrayReadFrom(object_id, *array, len, tags); |
| 2487 if (RawObject::IsCanonical(tags)) { | 2596 if (RawObject::IsCanonical(tags)) { |
| 2488 if (kind == Snapshot::kFull) { | 2597 if (kind == Snapshot::kFull) { |
| 2489 array->SetCanonical(); | 2598 array->SetCanonical(); |
| 2490 } else { | 2599 } else { |
| 2491 *array ^= array->CheckAndCanonicalize(NULL); | 2600 *array ^= array->CheckAndCanonicalize(NULL); |
| 2492 } | 2601 } |
| 2493 } | 2602 } |
| 2494 return raw(*array); | 2603 return raw(*array); |
| 2495 } | 2604 } |
| 2496 | 2605 |
| 2497 | 2606 |
| 2498 void RawArray::WriteTo(SnapshotWriter* writer, | 2607 void RawArray::WriteTo(SnapshotWriter* writer, |
| 2499 intptr_t object_id, | 2608 intptr_t object_id, |
| 2500 Snapshot::Kind kind) { | 2609 Snapshot::Kind kind, |
| 2610 bool as_reference) { |
| 2501 ASSERT(!RawObject::IsCanonical(writer->GetObjectTags(this))); | 2611 ASSERT(!RawObject::IsCanonical(writer->GetObjectTags(this))); |
| 2502 writer->ArrayWriteTo(object_id, | 2612 writer->ArrayWriteTo(object_id, |
| 2503 kArrayCid, | 2613 kArrayCid, |
| 2504 writer->GetObjectTags(this), | 2614 writer->GetObjectTags(this), |
| 2505 ptr()->length_, | 2615 ptr()->length_, |
| 2506 ptr()->type_arguments_, | 2616 ptr()->type_arguments_, |
| 2507 ptr()->data()); | 2617 ptr()->data(), |
| 2618 as_reference); |
| 2508 } | 2619 } |
| 2509 | 2620 |
| 2510 | 2621 |
| 2511 void RawImmutableArray::WriteTo(SnapshotWriter* writer, | 2622 void RawImmutableArray::WriteTo(SnapshotWriter* writer, |
| 2512 intptr_t object_id, | 2623 intptr_t object_id, |
| 2513 Snapshot::Kind kind) { | 2624 Snapshot::Kind kind, |
| 2625 bool as_reference) { |
| 2514 writer->ArrayWriteTo(object_id, | 2626 writer->ArrayWriteTo(object_id, |
| 2515 kImmutableArrayCid, | 2627 kImmutableArrayCid, |
| 2516 writer->GetObjectTags(this), | 2628 writer->GetObjectTags(this), |
| 2517 ptr()->length_, | 2629 ptr()->length_, |
| 2518 ptr()->type_arguments_, | 2630 ptr()->type_arguments_, |
| 2519 ptr()->data()); | 2631 ptr()->data(), |
| 2632 as_reference); |
| 2520 } | 2633 } |
| 2521 | 2634 |
| 2522 | 2635 |
| 2523 RawGrowableObjectArray* GrowableObjectArray::ReadFrom(SnapshotReader* reader, | 2636 RawGrowableObjectArray* GrowableObjectArray::ReadFrom(SnapshotReader* reader, |
| 2524 intptr_t object_id, | 2637 intptr_t object_id, |
| 2525 intptr_t tags, | 2638 intptr_t tags, |
| 2526 Snapshot::Kind kind) { | 2639 Snapshot::Kind kind, |
| 2640 bool as_reference) { |
| 2527 ASSERT(reader != NULL); | 2641 ASSERT(reader != NULL); |
| 2528 | 2642 |
| 2529 // Read the length so that we can determine instance size to allocate. | 2643 // Read the length so that we can determine instance size to allocate. |
| 2530 GrowableObjectArray& array = GrowableObjectArray::ZoneHandle( | 2644 GrowableObjectArray& array = GrowableObjectArray::ZoneHandle( |
| 2531 reader->zone(), GrowableObjectArray::null()); | 2645 reader->zone(), GrowableObjectArray::null()); |
| 2532 if (kind == Snapshot::kFull) { | 2646 if (kind == Snapshot::kFull) { |
| 2533 array = reader->NewGrowableObjectArray(); | 2647 array = reader->NewGrowableObjectArray(); |
| 2534 } else { | 2648 } else { |
| 2535 array = GrowableObjectArray::New(0, HEAP_SPACE(kind)); | 2649 array = GrowableObjectArray::New(0, HEAP_SPACE(kind)); |
| 2536 } | 2650 } |
| 2537 reader->AddBackRef(object_id, &array, kIsDeserialized); | 2651 reader->AddBackRef(object_id, &array, kIsDeserialized); |
| 2538 | 2652 |
| 2539 // Read type arguments of growable array object. | 2653 // Read type arguments of growable array object. |
| 2540 const intptr_t typeargs_offset = | 2654 const intptr_t typeargs_offset = |
| 2541 GrowableObjectArray::type_arguments_offset() / kWordSize; | 2655 GrowableObjectArray::type_arguments_offset() / kWordSize; |
| 2542 *reader->TypeArgumentsHandle() ^= | 2656 *reader->TypeArgumentsHandle() ^= |
| 2543 reader->ReadObjectImpl(kAsInlinedObject, object_id, typeargs_offset); | 2657 reader->ReadObjectImpl(kAsInlinedObject, object_id, typeargs_offset); |
| 2544 array.StorePointer(&array.raw_ptr()->type_arguments_, | 2658 array.StorePointer(&array.raw_ptr()->type_arguments_, |
| 2545 reader->TypeArgumentsHandle()->raw()); | 2659 reader->TypeArgumentsHandle()->raw()); |
| 2546 | 2660 |
| 2547 // Read length of growable array object. | 2661 // Read length of growable array object. |
| 2548 array.SetLength(reader->ReadSmiValue()); | 2662 array.SetLength(reader->ReadSmiValue()); |
| 2549 | 2663 |
| 2550 // Read the backing array of growable array object. | 2664 // Read the backing array of growable array object. |
| 2551 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); | 2665 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsReference); |
| 2552 array.SetData(*(reader->ArrayHandle())); | 2666 array.SetData(*(reader->ArrayHandle())); |
| 2553 | 2667 |
| 2554 return array.raw(); | 2668 return array.raw(); |
| 2555 } | 2669 } |
| 2556 | 2670 |
| 2557 | 2671 |
| 2558 void RawGrowableObjectArray::WriteTo(SnapshotWriter* writer, | 2672 void RawGrowableObjectArray::WriteTo(SnapshotWriter* writer, |
| 2559 intptr_t object_id, | 2673 intptr_t object_id, |
| 2560 Snapshot::Kind kind) { | 2674 Snapshot::Kind kind, |
| 2675 bool as_reference) { |
| 2561 ASSERT(writer != NULL); | 2676 ASSERT(writer != NULL); |
| 2562 | 2677 |
| 2563 // Write out the serialization header value for this object. | 2678 // Write out the serialization header value for this object. |
| 2564 writer->WriteInlinedObjectHeader(object_id); | 2679 writer->WriteInlinedObjectHeader(object_id); |
| 2565 | 2680 |
| 2566 // Write out the class and tags information. | 2681 // Write out the class and tags information. |
| 2567 writer->WriteIndexedObject(kGrowableObjectArrayCid); | 2682 writer->WriteIndexedObject(kGrowableObjectArrayCid); |
| 2568 writer->WriteTags(writer->GetObjectTags(this)); | 2683 writer->WriteTags(writer->GetObjectTags(this)); |
| 2569 | 2684 |
| 2570 // Write out the type arguments field. | 2685 // Write out the type arguments field. |
| 2571 writer->WriteObjectImpl(ptr()->type_arguments_, kAsInlinedObject); | 2686 writer->WriteObjectImpl(ptr()->type_arguments_, kAsInlinedObject); |
| 2572 | 2687 |
| 2573 // Write out the used length field. | 2688 // Write out the used length field. |
| 2574 writer->Write<RawObject*>(ptr()->length_); | 2689 writer->Write<RawObject*>(ptr()->length_); |
| 2575 | 2690 |
| 2576 // Write out the Array object. | 2691 // Write out the Array object. |
| 2577 writer->WriteObjectImpl(ptr()->data_, kAsInlinedObject); | 2692 writer->WriteObjectImpl(ptr()->data_, kAsReference); |
| 2578 } | 2693 } |
| 2579 | 2694 |
| 2580 | 2695 |
| 2581 RawLinkedHashMap* LinkedHashMap::ReadFrom(SnapshotReader* reader, | 2696 RawLinkedHashMap* LinkedHashMap::ReadFrom(SnapshotReader* reader, |
| 2582 intptr_t object_id, | 2697 intptr_t object_id, |
| 2583 intptr_t tags, | 2698 intptr_t tags, |
| 2584 Snapshot::Kind kind) { | 2699 Snapshot::Kind kind, |
| 2700 bool as_reference) { |
| 2585 ASSERT(reader != NULL); | 2701 ASSERT(reader != NULL); |
| 2586 | 2702 |
| 2587 LinkedHashMap& map = LinkedHashMap::ZoneHandle( | 2703 LinkedHashMap& map = LinkedHashMap::ZoneHandle( |
| 2588 reader->zone(), LinkedHashMap::null()); | 2704 reader->zone(), LinkedHashMap::null()); |
| 2589 if ((kind == Snapshot::kFull && !reader->snapshot_code()) || | 2705 if ((kind == Snapshot::kFull && !reader->snapshot_code()) || |
| 2590 kind == Snapshot::kScript) { | 2706 kind == Snapshot::kScript) { |
| 2591 // The immutable maps that seed map literals are not yet VM-internal, so | 2707 // The immutable maps that seed map literals are not yet VM-internal, so |
| 2592 // we don't reach this. | 2708 // we don't reach this. |
| 2593 UNREACHABLE(); | 2709 UNREACHABLE(); |
| 2594 } else { | 2710 } else { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2625 map.SetDeletedKeys(0); | 2741 map.SetDeletedKeys(0); |
| 2626 | 2742 |
| 2627 // The index and hashMask is regenerated by the maps themselves on demand. | 2743 // The index and hashMask is regenerated by the maps themselves on demand. |
| 2628 // Thus, the index will probably be allocated in new space (unless it's huge). | 2744 // Thus, the index will probably be allocated in new space (unless it's huge). |
| 2629 // TODO(koda): Eagerly rehash here when no keys have user-defined '==', and | 2745 // TODO(koda): Eagerly rehash here when no keys have user-defined '==', and |
| 2630 // in particular, if/when (const) maps are needed in the VM isolate snapshot. | 2746 // in particular, if/when (const) maps are needed in the VM isolate snapshot. |
| 2631 ASSERT(reader->isolate() != Dart::vm_isolate()); | 2747 ASSERT(reader->isolate() != Dart::vm_isolate()); |
| 2632 map.SetHashMask(0); // Prefer sentinel 0 over null for better type feedback. | 2748 map.SetHashMask(0); // Prefer sentinel 0 over null for better type feedback. |
| 2633 | 2749 |
| 2634 // Read the keys and values. | 2750 // Read the keys and values. |
| 2635 bool as_reference = RawObject::IsCanonical(tags) ? false : true; | 2751 bool read_as_reference = RawObject::IsCanonical(tags) ? false : true; |
| 2636 for (intptr_t i = 0; i < used_data; i++) { | 2752 for (intptr_t i = 0; i < used_data; i++) { |
| 2637 *reader->PassiveObjectHandle() = reader->ReadObjectImpl(as_reference); | 2753 *reader->PassiveObjectHandle() = reader->ReadObjectImpl(read_as_reference); |
| 2638 data.SetAt(i, *reader->PassiveObjectHandle()); | 2754 data.SetAt(i, *reader->PassiveObjectHandle()); |
| 2639 } | 2755 } |
| 2640 return map.raw(); | 2756 return map.raw(); |
| 2641 } | 2757 } |
| 2642 | 2758 |
| 2643 | 2759 |
| 2644 void RawLinkedHashMap::WriteTo(SnapshotWriter* writer, | 2760 void RawLinkedHashMap::WriteTo(SnapshotWriter* writer, |
| 2645 intptr_t object_id, | 2761 intptr_t object_id, |
| 2646 Snapshot::Kind kind) { | 2762 Snapshot::Kind kind, |
| 2763 bool as_reference) { |
| 2647 if ((kind == Snapshot::kFull && !writer->snapshot_code()) || | 2764 if ((kind == Snapshot::kFull && !writer->snapshot_code()) || |
| 2648 kind == Snapshot::kScript) { | 2765 kind == Snapshot::kScript) { |
| 2649 // The immutable maps that seed map literals are not yet VM-internal, so | 2766 // The immutable maps that seed map literals are not yet VM-internal, so |
| 2650 // we don't reach this. | 2767 // we don't reach this. |
| 2651 } | 2768 } |
| 2652 ASSERT(writer != NULL); | 2769 ASSERT(writer != NULL); |
| 2653 | 2770 |
| 2654 // Write out the serialization header value for this object. | 2771 // Write out the serialization header value for this object. |
| 2655 writer->WriteInlinedObjectHeader(object_id); | 2772 writer->WriteInlinedObjectHeader(object_id); |
| 2656 | 2773 |
| 2657 // Write out the class and tags information. | 2774 // Write out the class and tags information. |
| 2658 writer->WriteIndexedObject(kLinkedHashMapCid); | 2775 writer->WriteIndexedObject(kLinkedHashMapCid); |
| 2659 const uword tags = writer->GetObjectTags(this); | 2776 const uword tags = writer->GetObjectTags(this); |
| 2660 writer->WriteTags(tags); | 2777 writer->WriteTags(tags); |
| 2661 | 2778 |
| 2662 // Write out the type arguments. | 2779 // Write out the type arguments. |
| 2663 writer->WriteObjectImpl(ptr()->type_arguments_, kAsInlinedObject); | 2780 writer->WriteObjectImpl(ptr()->type_arguments_, kAsInlinedObject); |
| 2664 | 2781 |
| 2665 const intptr_t used_data = Smi::Value(ptr()->used_data_); | 2782 const intptr_t used_data = Smi::Value(ptr()->used_data_); |
| 2666 ASSERT((used_data & 1) == 0); // Keys + values, so must be even. | 2783 ASSERT((used_data & 1) == 0); // Keys + values, so must be even. |
| 2667 const intptr_t deleted_keys = Smi::Value(ptr()->deleted_keys_); | 2784 const intptr_t deleted_keys = Smi::Value(ptr()->deleted_keys_); |
| 2668 | 2785 |
| 2669 // Write out the number of (not deleted) key/value pairs that will follow. | 2786 // Write out the number of (not deleted) key/value pairs that will follow. |
| 2670 writer->Write<RawObject*>(Smi::New((used_data >> 1) - deleted_keys)); | 2787 writer->Write<RawObject*>(Smi::New((used_data >> 1) - deleted_keys)); |
| 2671 | 2788 |
| 2672 // Write out the keys and values. | 2789 // Write out the keys and values. |
| 2673 const bool as_reference = RawObject::IsCanonical(tags) ? false : true; | 2790 bool write_as_reference = RawObject::IsCanonical(tags) ? false : true; |
| 2674 RawArray* data_array = ptr()->data_; | 2791 RawArray* data_array = ptr()->data_; |
| 2675 RawObject** data_elements = data_array->ptr()->data(); | 2792 RawObject** data_elements = data_array->ptr()->data(); |
| 2676 ASSERT(used_data <= Smi::Value(data_array->ptr()->length_)); | 2793 ASSERT(used_data <= Smi::Value(data_array->ptr()->length_)); |
| 2677 #if defined(DEBUG) | 2794 #if defined(DEBUG) |
| 2678 intptr_t deleted_keys_found = 0; | 2795 intptr_t deleted_keys_found = 0; |
| 2679 #endif // DEBUG | 2796 #endif // DEBUG |
| 2680 for (intptr_t i = 0; i < used_data; i += 2) { | 2797 for (intptr_t i = 0; i < used_data; i += 2) { |
| 2681 RawObject* key = data_elements[i]; | 2798 RawObject* key = data_elements[i]; |
| 2682 if (key == data_array) { | 2799 if (key == data_array) { |
| 2683 #if defined(DEBUG) | 2800 #if defined(DEBUG) |
| 2684 ++deleted_keys_found; | 2801 ++deleted_keys_found; |
| 2685 #endif // DEBUG | 2802 #endif // DEBUG |
| 2686 continue; | 2803 continue; |
| 2687 } | 2804 } |
| 2688 RawObject* value = data_elements[i + 1]; | 2805 RawObject* value = data_elements[i + 1]; |
| 2689 writer->WriteObjectImpl(key, as_reference); | 2806 writer->WriteObjectImpl(key, write_as_reference); |
| 2690 writer->WriteObjectImpl(value, as_reference); | 2807 writer->WriteObjectImpl(value, write_as_reference); |
| 2691 } | 2808 } |
| 2692 DEBUG_ASSERT(deleted_keys_found == deleted_keys); | 2809 DEBUG_ASSERT(deleted_keys_found == deleted_keys); |
| 2693 } | 2810 } |
| 2694 | 2811 |
| 2695 | 2812 |
| 2696 RawFloat32x4* Float32x4::ReadFrom(SnapshotReader* reader, | 2813 RawFloat32x4* Float32x4::ReadFrom(SnapshotReader* reader, |
| 2697 intptr_t object_id, | 2814 intptr_t object_id, |
| 2698 intptr_t tags, | 2815 intptr_t tags, |
| 2699 Snapshot::Kind kind) { | 2816 Snapshot::Kind kind, |
| 2817 bool as_reference) { |
| 2700 ASSERT(reader != NULL); | 2818 ASSERT(reader != NULL); |
| 2701 // Read the values. | 2819 // Read the values. |
| 2702 float value0 = reader->Read<float>(); | 2820 float value0 = reader->Read<float>(); |
| 2703 float value1 = reader->Read<float>(); | 2821 float value1 = reader->Read<float>(); |
| 2704 float value2 = reader->Read<float>(); | 2822 float value2 = reader->Read<float>(); |
| 2705 float value3 = reader->Read<float>(); | 2823 float value3 = reader->Read<float>(); |
| 2706 | 2824 |
| 2707 // Create a Float32x4 object. | 2825 // Create a Float32x4 object. |
| 2708 Float32x4& simd = Float32x4::ZoneHandle(reader->zone(), | 2826 Float32x4& simd = Float32x4::ZoneHandle(reader->zone(), |
| 2709 Float32x4::null()); | 2827 Float32x4::null()); |
| 2710 if (kind == Snapshot::kFull) { | 2828 if (kind == Snapshot::kFull) { |
| 2711 simd = reader->NewFloat32x4(value0, value1, value2, value3); | 2829 simd = reader->NewFloat32x4(value0, value1, value2, value3); |
| 2712 } else { | 2830 } else { |
| 2713 simd = Float32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind)); | 2831 simd = Float32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind)); |
| 2714 } | 2832 } |
| 2715 reader->AddBackRef(object_id, &simd, kIsDeserialized); | 2833 reader->AddBackRef(object_id, &simd, kIsDeserialized); |
| 2716 return simd.raw(); | 2834 return simd.raw(); |
| 2717 } | 2835 } |
| 2718 | 2836 |
| 2719 | 2837 |
| 2720 void RawFloat32x4::WriteTo(SnapshotWriter* writer, | 2838 void RawFloat32x4::WriteTo(SnapshotWriter* writer, |
| 2721 intptr_t object_id, | 2839 intptr_t object_id, |
| 2722 Snapshot::Kind kind) { | 2840 Snapshot::Kind kind, |
| 2841 bool as_reference) { |
| 2723 ASSERT(writer != NULL); | 2842 ASSERT(writer != NULL); |
| 2724 | 2843 |
| 2725 // Write out the serialization header value for this object. | 2844 // Write out the serialization header value for this object. |
| 2726 writer->WriteInlinedObjectHeader(object_id); | 2845 writer->WriteInlinedObjectHeader(object_id); |
| 2727 | 2846 |
| 2728 // Write out the class and tags information. | 2847 // Write out the class and tags information. |
| 2729 writer->WriteIndexedObject(kFloat32x4Cid); | 2848 writer->WriteIndexedObject(kFloat32x4Cid); |
| 2730 writer->WriteTags(writer->GetObjectTags(this)); | 2849 writer->WriteTags(writer->GetObjectTags(this)); |
| 2731 | 2850 |
| 2732 // Write out the float values. | 2851 // Write out the float values. |
| 2733 writer->Write<float>(ptr()->value_[0]); | 2852 writer->Write<float>(ptr()->value_[0]); |
| 2734 writer->Write<float>(ptr()->value_[1]); | 2853 writer->Write<float>(ptr()->value_[1]); |
| 2735 writer->Write<float>(ptr()->value_[2]); | 2854 writer->Write<float>(ptr()->value_[2]); |
| 2736 writer->Write<float>(ptr()->value_[3]); | 2855 writer->Write<float>(ptr()->value_[3]); |
| 2737 } | 2856 } |
| 2738 | 2857 |
| 2739 | 2858 |
| 2740 RawInt32x4* Int32x4::ReadFrom(SnapshotReader* reader, | 2859 RawInt32x4* Int32x4::ReadFrom(SnapshotReader* reader, |
| 2741 intptr_t object_id, | 2860 intptr_t object_id, |
| 2742 intptr_t tags, | 2861 intptr_t tags, |
| 2743 Snapshot::Kind kind) { | 2862 Snapshot::Kind kind, |
| 2863 bool as_reference) { |
| 2744 ASSERT(reader != NULL); | 2864 ASSERT(reader != NULL); |
| 2745 // Read the values. | 2865 // Read the values. |
| 2746 uint32_t value0 = reader->Read<uint32_t>(); | 2866 uint32_t value0 = reader->Read<uint32_t>(); |
| 2747 uint32_t value1 = reader->Read<uint32_t>(); | 2867 uint32_t value1 = reader->Read<uint32_t>(); |
| 2748 uint32_t value2 = reader->Read<uint32_t>(); | 2868 uint32_t value2 = reader->Read<uint32_t>(); |
| 2749 uint32_t value3 = reader->Read<uint32_t>(); | 2869 uint32_t value3 = reader->Read<uint32_t>(); |
| 2750 | 2870 |
| 2751 // Create a Float32x4 object. | 2871 // Create a Float32x4 object. |
| 2752 Int32x4& simd = Int32x4::ZoneHandle(reader->zone(), Int32x4::null()); | 2872 Int32x4& simd = Int32x4::ZoneHandle(reader->zone(), Int32x4::null()); |
| 2753 | 2873 |
| 2754 if (kind == Snapshot::kFull) { | 2874 if (kind == Snapshot::kFull) { |
| 2755 simd = reader->NewInt32x4(value0, value1, value2, value3); | 2875 simd = reader->NewInt32x4(value0, value1, value2, value3); |
| 2756 } else { | 2876 } else { |
| 2757 simd = Int32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind)); | 2877 simd = Int32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind)); |
| 2758 } | 2878 } |
| 2759 reader->AddBackRef(object_id, &simd, kIsDeserialized); | 2879 reader->AddBackRef(object_id, &simd, kIsDeserialized); |
| 2760 return simd.raw(); | 2880 return simd.raw(); |
| 2761 } | 2881 } |
| 2762 | 2882 |
| 2763 | 2883 |
| 2764 void RawInt32x4::WriteTo(SnapshotWriter* writer, | 2884 void RawInt32x4::WriteTo(SnapshotWriter* writer, |
| 2765 intptr_t object_id, | 2885 intptr_t object_id, |
| 2766 Snapshot::Kind kind) { | 2886 Snapshot::Kind kind, |
| 2887 bool as_reference) { |
| 2767 ASSERT(writer != NULL); | 2888 ASSERT(writer != NULL); |
| 2768 | 2889 |
| 2769 // Write out the serialization header value for this object. | 2890 // Write out the serialization header value for this object. |
| 2770 writer->WriteInlinedObjectHeader(object_id); | 2891 writer->WriteInlinedObjectHeader(object_id); |
| 2771 | 2892 |
| 2772 // Write out the class and tags information. | 2893 // Write out the class and tags information. |
| 2773 writer->WriteIndexedObject(kInt32x4Cid); | 2894 writer->WriteIndexedObject(kInt32x4Cid); |
| 2774 writer->WriteTags(writer->GetObjectTags(this)); | 2895 writer->WriteTags(writer->GetObjectTags(this)); |
| 2775 | 2896 |
| 2776 // Write out the mask values. | 2897 // Write out the mask values. |
| 2777 writer->Write<uint32_t>(ptr()->value_[0]); | 2898 writer->Write<uint32_t>(ptr()->value_[0]); |
| 2778 writer->Write<uint32_t>(ptr()->value_[1]); | 2899 writer->Write<uint32_t>(ptr()->value_[1]); |
| 2779 writer->Write<uint32_t>(ptr()->value_[2]); | 2900 writer->Write<uint32_t>(ptr()->value_[2]); |
| 2780 writer->Write<uint32_t>(ptr()->value_[3]); | 2901 writer->Write<uint32_t>(ptr()->value_[3]); |
| 2781 } | 2902 } |
| 2782 | 2903 |
| 2783 | 2904 |
| 2784 RawFloat64x2* Float64x2::ReadFrom(SnapshotReader* reader, | 2905 RawFloat64x2* Float64x2::ReadFrom(SnapshotReader* reader, |
| 2785 intptr_t object_id, | 2906 intptr_t object_id, |
| 2786 intptr_t tags, | 2907 intptr_t tags, |
| 2787 Snapshot::Kind kind) { | 2908 Snapshot::Kind kind, |
| 2909 bool as_reference) { |
| 2788 ASSERT(reader != NULL); | 2910 ASSERT(reader != NULL); |
| 2789 // Read the values. | 2911 // Read the values. |
| 2790 double value0 = reader->Read<double>(); | 2912 double value0 = reader->Read<double>(); |
| 2791 double value1 = reader->Read<double>(); | 2913 double value1 = reader->Read<double>(); |
| 2792 | 2914 |
| 2793 // Create a Float64x2 object. | 2915 // Create a Float64x2 object. |
| 2794 Float64x2& simd = Float64x2::ZoneHandle(reader->zone(), | 2916 Float64x2& simd = Float64x2::ZoneHandle(reader->zone(), |
| 2795 Float64x2::null()); | 2917 Float64x2::null()); |
| 2796 if (kind == Snapshot::kFull) { | 2918 if (kind == Snapshot::kFull) { |
| 2797 simd = reader->NewFloat64x2(value0, value1); | 2919 simd = reader->NewFloat64x2(value0, value1); |
| 2798 } else { | 2920 } else { |
| 2799 simd = Float64x2::New(value0, value1, HEAP_SPACE(kind)); | 2921 simd = Float64x2::New(value0, value1, HEAP_SPACE(kind)); |
| 2800 } | 2922 } |
| 2801 reader->AddBackRef(object_id, &simd, kIsDeserialized); | 2923 reader->AddBackRef(object_id, &simd, kIsDeserialized); |
| 2802 return simd.raw(); | 2924 return simd.raw(); |
| 2803 } | 2925 } |
| 2804 | 2926 |
| 2805 | 2927 |
| 2806 void RawFloat64x2::WriteTo(SnapshotWriter* writer, | 2928 void RawFloat64x2::WriteTo(SnapshotWriter* writer, |
| 2807 intptr_t object_id, | 2929 intptr_t object_id, |
| 2808 Snapshot::Kind kind) { | 2930 Snapshot::Kind kind, |
| 2931 bool as_reference) { |
| 2809 ASSERT(writer != NULL); | 2932 ASSERT(writer != NULL); |
| 2810 | 2933 |
| 2811 // Write out the serialization header value for this object. | 2934 // Write out the serialization header value for this object. |
| 2812 writer->WriteInlinedObjectHeader(object_id); | 2935 writer->WriteInlinedObjectHeader(object_id); |
| 2813 | 2936 |
| 2814 // Write out the class and tags information. | 2937 // Write out the class and tags information. |
| 2815 writer->WriteIndexedObject(kFloat64x2Cid); | 2938 writer->WriteIndexedObject(kFloat64x2Cid); |
| 2816 writer->WriteTags(writer->GetObjectTags(this)); | 2939 writer->WriteTags(writer->GetObjectTags(this)); |
| 2817 | 2940 |
| 2818 // Write out the float values. | 2941 // Write out the float values. |
| 2819 writer->Write<double>(ptr()->value_[0]); | 2942 writer->Write<double>(ptr()->value_[0]); |
| 2820 writer->Write<double>(ptr()->value_[1]); | 2943 writer->Write<double>(ptr()->value_[1]); |
| 2821 } | 2944 } |
| 2822 | 2945 |
| 2823 | 2946 |
| 2824 #define TYPED_DATA_READ(setter, type) \ | 2947 #define TYPED_DATA_READ(setter, type) \ |
| 2825 for (intptr_t i = 0; i < length_in_bytes; i += element_size) { \ | 2948 for (intptr_t i = 0; i < length_in_bytes; i += element_size) { \ |
| 2826 result.Set##setter(i, reader->Read<type>()); \ | 2949 result.Set##setter(i, reader->Read<type>()); \ |
| 2827 } \ | 2950 } \ |
| 2828 | 2951 |
| 2829 | 2952 |
| 2830 RawTypedData* TypedData::ReadFrom(SnapshotReader* reader, | 2953 RawTypedData* TypedData::ReadFrom(SnapshotReader* reader, |
| 2831 intptr_t object_id, | 2954 intptr_t object_id, |
| 2832 intptr_t tags, | 2955 intptr_t tags, |
| 2833 Snapshot::Kind kind) { | 2956 Snapshot::Kind kind, |
| 2957 bool as_reference) { |
| 2834 ASSERT(reader != NULL); | 2958 ASSERT(reader != NULL); |
| 2835 | 2959 |
| 2836 intptr_t cid = RawObject::ClassIdTag::decode(tags); | 2960 intptr_t cid = RawObject::ClassIdTag::decode(tags); |
| 2837 intptr_t len = reader->ReadSmiValue(); | 2961 intptr_t len = reader->ReadSmiValue(); |
| 2838 TypedData& result = TypedData::ZoneHandle(reader->zone(), | 2962 TypedData& result = TypedData::ZoneHandle(reader->zone(), |
| 2839 (kind == Snapshot::kFull) ? reader->NewTypedData(cid, len) | 2963 (kind == Snapshot::kFull) ? reader->NewTypedData(cid, len) |
| 2840 : TypedData::New(cid, len, HEAP_SPACE(kind))); | 2964 : TypedData::New(cid, len, HEAP_SPACE(kind))); |
| 2841 reader->AddBackRef(object_id, &result, kIsDeserialized); | 2965 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 2842 | 2966 |
| 2843 // Setup the array elements. | 2967 // Setup the array elements. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2880 UNREACHABLE(); | 3004 UNREACHABLE(); |
| 2881 } | 3005 } |
| 2882 return result.raw(); | 3006 return result.raw(); |
| 2883 } | 3007 } |
| 2884 #undef TYPED_DATA_READ | 3008 #undef TYPED_DATA_READ |
| 2885 | 3009 |
| 2886 | 3010 |
| 2887 RawExternalTypedData* ExternalTypedData::ReadFrom(SnapshotReader* reader, | 3011 RawExternalTypedData* ExternalTypedData::ReadFrom(SnapshotReader* reader, |
| 2888 intptr_t object_id, | 3012 intptr_t object_id, |
| 2889 intptr_t tags, | 3013 intptr_t tags, |
| 2890 Snapshot::Kind kind) { | 3014 Snapshot::Kind kind, |
| 3015 bool as_reference) { |
| 2891 ASSERT(kind != Snapshot::kFull); | 3016 ASSERT(kind != Snapshot::kFull); |
| 2892 intptr_t cid = RawObject::ClassIdTag::decode(tags); | 3017 intptr_t cid = RawObject::ClassIdTag::decode(tags); |
| 2893 intptr_t length = reader->ReadSmiValue(); | 3018 intptr_t length = reader->ReadSmiValue(); |
| 2894 uint8_t* data = reinterpret_cast<uint8_t*>(reader->ReadRawPointerValue()); | 3019 uint8_t* data = reinterpret_cast<uint8_t*>(reader->ReadRawPointerValue()); |
| 2895 ExternalTypedData& obj = ExternalTypedData::ZoneHandle( | 3020 ExternalTypedData& obj = ExternalTypedData::ZoneHandle( |
| 2896 ExternalTypedData::New(cid, data, length)); | 3021 ExternalTypedData::New(cid, data, length)); |
| 2897 reader->AddBackRef(object_id, &obj, kIsDeserialized); | 3022 reader->AddBackRef(object_id, &obj, kIsDeserialized); |
| 2898 void* peer = reinterpret_cast<void*>(reader->ReadRawPointerValue()); | 3023 void* peer = reinterpret_cast<void*>(reader->ReadRawPointerValue()); |
| 2899 Dart_WeakPersistentHandleFinalizer callback = | 3024 Dart_WeakPersistentHandleFinalizer callback = |
| 2900 reinterpret_cast<Dart_WeakPersistentHandleFinalizer>( | 3025 reinterpret_cast<Dart_WeakPersistentHandleFinalizer>( |
| 2901 reader->ReadRawPointerValue()); | 3026 reader->ReadRawPointerValue()); |
| 2902 obj.AddFinalizer(peer, callback); | 3027 obj.AddFinalizer(peer, callback); |
| 2903 return obj.raw(); | 3028 return obj.raw(); |
| 2904 } | 3029 } |
| 2905 | 3030 |
| 2906 | 3031 |
| 2907 #define TYPED_DATA_WRITE(type) \ | 3032 #define TYPED_DATA_WRITE(type) \ |
| 2908 { \ | 3033 { \ |
| 2909 type* data = reinterpret_cast<type*>(ptr()->data()); \ | 3034 type* data = reinterpret_cast<type*>(ptr()->data()); \ |
| 2910 for (intptr_t i = 0; i < len; i++) { \ | 3035 for (intptr_t i = 0; i < len; i++) { \ |
| 2911 writer->Write(data[i]); \ | 3036 writer->Write(data[i]); \ |
| 2912 } \ | 3037 } \ |
| 2913 } \ | 3038 } \ |
| 2914 | 3039 |
| 2915 | 3040 |
| 2916 void RawTypedData::WriteTo(SnapshotWriter* writer, | 3041 void RawTypedData::WriteTo(SnapshotWriter* writer, |
| 2917 intptr_t object_id, | 3042 intptr_t object_id, |
| 2918 Snapshot::Kind kind) { | 3043 Snapshot::Kind kind, |
| 3044 bool as_reference) { |
| 2919 ASSERT(writer != NULL); | 3045 ASSERT(writer != NULL); |
| 2920 intptr_t tags = writer->GetObjectTags(this); | 3046 intptr_t tags = writer->GetObjectTags(this); |
| 2921 intptr_t cid = ClassIdTag::decode(tags); | 3047 intptr_t cid = ClassIdTag::decode(tags); |
| 2922 intptr_t len = Smi::Value(ptr()->length_); | 3048 intptr_t len = Smi::Value(ptr()->length_); |
| 2923 | 3049 |
| 2924 // Write out the serialization header value for this object. | 3050 // Write out the serialization header value for this object. |
| 2925 writer->WriteInlinedObjectHeader(object_id); | 3051 writer->WriteInlinedObjectHeader(object_id); |
| 2926 | 3052 |
| 2927 // Write out the class and tags information. | 3053 // Write out the class and tags information. |
| 2928 writer->WriteIndexedObject(cid); | 3054 writer->WriteIndexedObject(cid); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2981 | 3107 |
| 2982 #define EXT_TYPED_DATA_WRITE(cid, type) \ | 3108 #define EXT_TYPED_DATA_WRITE(cid, type) \ |
| 2983 writer->WriteIndexedObject(cid); \ | 3109 writer->WriteIndexedObject(cid); \ |
| 2984 writer->WriteTags(RawObject::ClassIdTag::update(cid, tags)); \ | 3110 writer->WriteTags(RawObject::ClassIdTag::update(cid, tags)); \ |
| 2985 writer->Write<RawObject*>(ptr()->length_); \ | 3111 writer->Write<RawObject*>(ptr()->length_); \ |
| 2986 TYPED_EXT_DATA_WRITE(type) \ | 3112 TYPED_EXT_DATA_WRITE(type) \ |
| 2987 | 3113 |
| 2988 | 3114 |
| 2989 void RawExternalTypedData::WriteTo(SnapshotWriter* writer, | 3115 void RawExternalTypedData::WriteTo(SnapshotWriter* writer, |
| 2990 intptr_t object_id, | 3116 intptr_t object_id, |
| 2991 Snapshot::Kind kind) { | 3117 Snapshot::Kind kind, |
| 3118 bool as_reference) { |
| 2992 ASSERT(writer != NULL); | 3119 ASSERT(writer != NULL); |
| 2993 intptr_t tags = writer->GetObjectTags(this); | 3120 intptr_t tags = writer->GetObjectTags(this); |
| 2994 intptr_t cid = ClassIdTag::decode(tags); | 3121 intptr_t cid = ClassIdTag::decode(tags); |
| 2995 intptr_t len = Smi::Value(ptr()->length_); | 3122 intptr_t len = Smi::Value(ptr()->length_); |
| 2996 | 3123 |
| 2997 // Write out the serialization header value for this object. | 3124 // Write out the serialization header value for this object. |
| 2998 writer->WriteInlinedObjectHeader(object_id); | 3125 writer->WriteInlinedObjectHeader(object_id); |
| 2999 | 3126 |
| 3000 switch (cid) { | 3127 switch (cid) { |
| 3001 case kExternalTypedDataInt8ArrayCid: | 3128 case kExternalTypedDataInt8ArrayCid: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3035 UNREACHABLE(); | 3162 UNREACHABLE(); |
| 3036 } | 3163 } |
| 3037 } | 3164 } |
| 3038 #undef TYPED_DATA_WRITE | 3165 #undef TYPED_DATA_WRITE |
| 3039 #undef EXT_TYPED_DATA_WRITE | 3166 #undef EXT_TYPED_DATA_WRITE |
| 3040 | 3167 |
| 3041 | 3168 |
| 3042 RawCapability* Capability::ReadFrom(SnapshotReader* reader, | 3169 RawCapability* Capability::ReadFrom(SnapshotReader* reader, |
| 3043 intptr_t object_id, | 3170 intptr_t object_id, |
| 3044 intptr_t tags, | 3171 intptr_t tags, |
| 3045 Snapshot::Kind kind) { | 3172 Snapshot::Kind kind, |
| 3173 bool as_reference) { |
| 3046 uint64_t id = reader->Read<uint64_t>(); | 3174 uint64_t id = reader->Read<uint64_t>(); |
| 3047 | 3175 |
| 3048 Capability& result = Capability::ZoneHandle(reader->zone(), | 3176 Capability& result = Capability::ZoneHandle(reader->zone(), |
| 3049 Capability::New(id)); | 3177 Capability::New(id)); |
| 3050 reader->AddBackRef(object_id, &result, kIsDeserialized); | 3178 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 3051 return result.raw(); | 3179 return result.raw(); |
| 3052 } | 3180 } |
| 3053 | 3181 |
| 3054 | 3182 |
| 3055 void RawCapability::WriteTo(SnapshotWriter* writer, | 3183 void RawCapability::WriteTo(SnapshotWriter* writer, |
| 3056 intptr_t object_id, | 3184 intptr_t object_id, |
| 3057 Snapshot::Kind kind) { | 3185 Snapshot::Kind kind, |
| 3186 bool as_reference) { |
| 3058 // Write out the serialization header value for this object. | 3187 // Write out the serialization header value for this object. |
| 3059 writer->WriteInlinedObjectHeader(object_id); | 3188 writer->WriteInlinedObjectHeader(object_id); |
| 3060 | 3189 |
| 3061 // Write out the class and tags information. | 3190 // Write out the class and tags information. |
| 3062 writer->WriteIndexedObject(kCapabilityCid); | 3191 writer->WriteIndexedObject(kCapabilityCid); |
| 3063 writer->WriteTags(writer->GetObjectTags(this)); | 3192 writer->WriteTags(writer->GetObjectTags(this)); |
| 3064 | 3193 |
| 3065 writer->Write<uint64_t>(ptr()->id_); | 3194 writer->Write<uint64_t>(ptr()->id_); |
| 3066 } | 3195 } |
| 3067 | 3196 |
| 3068 | 3197 |
| 3069 RawReceivePort* ReceivePort::ReadFrom(SnapshotReader* reader, | 3198 RawReceivePort* ReceivePort::ReadFrom(SnapshotReader* reader, |
| 3070 intptr_t object_id, | 3199 intptr_t object_id, |
| 3071 intptr_t tags, | 3200 intptr_t tags, |
| 3072 Snapshot::Kind kind) { | 3201 Snapshot::Kind kind, |
| 3202 bool as_reference) { |
| 3073 UNREACHABLE(); | 3203 UNREACHABLE(); |
| 3074 return ReceivePort::null(); | 3204 return ReceivePort::null(); |
| 3075 } | 3205 } |
| 3076 | 3206 |
| 3077 | 3207 |
| 3078 void RawReceivePort::WriteTo(SnapshotWriter* writer, | 3208 void RawReceivePort::WriteTo(SnapshotWriter* writer, |
| 3079 intptr_t object_id, | 3209 intptr_t object_id, |
| 3080 Snapshot::Kind kind) { | 3210 Snapshot::Kind kind, |
| 3211 bool as_reference) { |
| 3081 if (kind == Snapshot::kMessage) { | 3212 if (kind == Snapshot::kMessage) { |
| 3082 // We do not allow objects with native fields in an isolate message. | 3213 // We do not allow objects with native fields in an isolate message. |
| 3083 writer->SetWriteException(Exceptions::kArgument, | 3214 writer->SetWriteException(Exceptions::kArgument, |
| 3084 "Illegal argument in isolate message" | 3215 "Illegal argument in isolate message" |
| 3085 " : (object is a RawReceivePort)"); | 3216 " : (object is a RawReceivePort)"); |
| 3086 } else { | 3217 } else { |
| 3087 UNREACHABLE(); | 3218 UNREACHABLE(); |
| 3088 } | 3219 } |
| 3089 } | 3220 } |
| 3090 | 3221 |
| 3091 | 3222 |
| 3092 RawSendPort* SendPort::ReadFrom(SnapshotReader* reader, | 3223 RawSendPort* SendPort::ReadFrom(SnapshotReader* reader, |
| 3093 intptr_t object_id, | 3224 intptr_t object_id, |
| 3094 intptr_t tags, | 3225 intptr_t tags, |
| 3095 Snapshot::Kind kind) { | 3226 Snapshot::Kind kind, |
| 3227 bool as_reference) { |
| 3096 ASSERT(kind == Snapshot::kMessage || reader->snapshot_code()); | 3228 ASSERT(kind == Snapshot::kMessage || reader->snapshot_code()); |
| 3097 | 3229 |
| 3098 uint64_t id = reader->Read<uint64_t>(); | 3230 uint64_t id = reader->Read<uint64_t>(); |
| 3099 uint64_t origin_id = reader->Read<uint64_t>(); | 3231 uint64_t origin_id = reader->Read<uint64_t>(); |
| 3100 | 3232 |
| 3101 SendPort& result = SendPort::ZoneHandle(reader->zone()); | 3233 SendPort& result = SendPort::ZoneHandle(reader->zone()); |
| 3102 if (reader->snapshot_code()) { | 3234 if (reader->snapshot_code()) { |
| 3103 // TODO(rmacnak): Reset fields in precompiled snapshots and assert | 3235 // TODO(rmacnak): Reset fields in precompiled snapshots and assert |
| 3104 // this is unreachable. | 3236 // this is unreachable. |
| 3105 } else { | 3237 } else { |
| 3106 result = SendPort::New(id, origin_id); | 3238 result = SendPort::New(id, origin_id); |
| 3107 } | 3239 } |
| 3108 reader->AddBackRef(object_id, &result, kIsDeserialized); | 3240 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 3109 return result.raw(); | 3241 return result.raw(); |
| 3110 } | 3242 } |
| 3111 | 3243 |
| 3112 | 3244 |
| 3113 void RawSendPort::WriteTo(SnapshotWriter* writer, | 3245 void RawSendPort::WriteTo(SnapshotWriter* writer, |
| 3114 intptr_t object_id, | 3246 intptr_t object_id, |
| 3115 Snapshot::Kind kind) { | 3247 Snapshot::Kind kind, |
| 3248 bool as_reference) { |
| 3116 // Write out the serialization header value for this object. | 3249 // Write out the serialization header value for this object. |
| 3117 writer->WriteInlinedObjectHeader(object_id); | 3250 writer->WriteInlinedObjectHeader(object_id); |
| 3118 | 3251 |
| 3119 // Write out the class and tags information. | 3252 // Write out the class and tags information. |
| 3120 writer->WriteIndexedObject(kSendPortCid); | 3253 writer->WriteIndexedObject(kSendPortCid); |
| 3121 writer->WriteTags(writer->GetObjectTags(this)); | 3254 writer->WriteTags(writer->GetObjectTags(this)); |
| 3122 | 3255 |
| 3123 writer->Write<uint64_t>(ptr()->id_); | 3256 writer->Write<uint64_t>(ptr()->id_); |
| 3124 writer->Write<uint64_t>(ptr()->origin_id_); | 3257 writer->Write<uint64_t>(ptr()->origin_id_); |
| 3125 } | 3258 } |
| 3126 | 3259 |
| 3127 | 3260 |
| 3128 RawStacktrace* Stacktrace::ReadFrom(SnapshotReader* reader, | 3261 RawStacktrace* Stacktrace::ReadFrom(SnapshotReader* reader, |
| 3129 intptr_t object_id, | 3262 intptr_t object_id, |
| 3130 intptr_t tags, | 3263 intptr_t tags, |
| 3131 Snapshot::Kind kind) { | 3264 Snapshot::Kind kind, |
| 3265 bool as_reference) { |
| 3132 if (kind == Snapshot::kFull) { | 3266 if (kind == Snapshot::kFull) { |
| 3133 Stacktrace& result = Stacktrace::ZoneHandle(reader->zone(), | 3267 Stacktrace& result = Stacktrace::ZoneHandle(reader->zone(), |
| 3134 reader->NewStacktrace()); | 3268 reader->NewStacktrace()); |
| 3135 reader->AddBackRef(object_id, &result, kIsDeserialized); | 3269 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 3136 | 3270 |
| 3137 bool expand_inlined = reader->Read<bool>(); | 3271 bool expand_inlined = reader->Read<bool>(); |
| 3138 result.set_expand_inlined(expand_inlined); | 3272 result.set_expand_inlined(expand_inlined); |
| 3139 | 3273 |
| 3140 // Set all the object fields. | 3274 // Set all the object fields. |
| 3141 READ_OBJECT_FIELDS(result, | 3275 READ_OBJECT_FIELDS(result, |
| 3142 result.raw()->from(), result.raw()->to(), | 3276 result.raw()->from(), result.raw()->to(), |
| 3143 kAsReference); | 3277 kAsReference); |
| 3144 | 3278 |
| 3145 return result.raw(); | 3279 return result.raw(); |
| 3146 } | 3280 } |
| 3147 UNREACHABLE(); // Stacktraces are not sent in a snapshot. | 3281 UNREACHABLE(); // Stacktraces are not sent in a snapshot. |
| 3148 return Stacktrace::null(); | 3282 return Stacktrace::null(); |
| 3149 } | 3283 } |
| 3150 | 3284 |
| 3151 | 3285 |
| 3152 void RawStacktrace::WriteTo(SnapshotWriter* writer, | 3286 void RawStacktrace::WriteTo(SnapshotWriter* writer, |
| 3153 intptr_t object_id, | 3287 intptr_t object_id, |
| 3154 Snapshot::Kind kind) { | 3288 Snapshot::Kind kind, |
| 3289 bool as_reference) { |
| 3155 if (kind == Snapshot::kFull) { | 3290 if (kind == Snapshot::kFull) { |
| 3156 ASSERT(writer != NULL); | 3291 ASSERT(writer != NULL); |
| 3157 ASSERT(this == Isolate::Current()->object_store()-> | 3292 ASSERT(this == Isolate::Current()->object_store()-> |
| 3158 preallocated_stack_trace()); | 3293 preallocated_stack_trace()); |
| 3159 | 3294 |
| 3160 // Write out the serialization header value for this object. | 3295 // Write out the serialization header value for this object. |
| 3161 writer->WriteInlinedObjectHeader(object_id); | 3296 writer->WriteInlinedObjectHeader(object_id); |
| 3162 | 3297 |
| 3163 // Write out the class and tags information. | 3298 // Write out the class and tags information. |
| 3164 writer->WriteIndexedObject(kStacktraceCid); | 3299 writer->WriteIndexedObject(kStacktraceCid); |
| 3165 writer->WriteTags(writer->GetObjectTags(this)); | 3300 writer->WriteTags(writer->GetObjectTags(this)); |
| 3166 | 3301 |
| 3167 writer->Write(ptr()->expand_inlined_); | 3302 writer->Write(ptr()->expand_inlined_); |
| 3168 | 3303 |
| 3169 // Write out all the object pointer fields. | 3304 // Write out all the object pointer fields. |
| 3170 SnapshotWriterVisitor visitor(writer, kAsReference); | 3305 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 3171 visitor.VisitPointers(from(), to()); | 3306 visitor.VisitPointers(from(), to()); |
| 3172 } else { | 3307 } else { |
| 3173 // Stacktraces are not allowed in other snapshot forms. | 3308 // Stacktraces are not allowed in other snapshot forms. |
| 3174 writer->SetWriteException(Exceptions::kArgument, | 3309 writer->SetWriteException(Exceptions::kArgument, |
| 3175 "Illegal argument in isolate message" | 3310 "Illegal argument in isolate message" |
| 3176 " : (object is a stacktrace)"); | 3311 " : (object is a stacktrace)"); |
| 3177 } | 3312 } |
| 3178 } | 3313 } |
| 3179 | 3314 |
| 3180 | 3315 |
| 3181 RawJSRegExp* JSRegExp::ReadFrom(SnapshotReader* reader, | 3316 RawJSRegExp* JSRegExp::ReadFrom(SnapshotReader* reader, |
| 3182 intptr_t object_id, | 3317 intptr_t object_id, |
| 3183 intptr_t tags, | 3318 intptr_t tags, |
| 3184 Snapshot::Kind kind) { | 3319 Snapshot::Kind kind, |
| 3320 bool as_reference) { |
| 3185 ASSERT(reader != NULL); | 3321 ASSERT(reader != NULL); |
| 3186 ASSERT(kind == Snapshot::kMessage); | 3322 ASSERT(kind == Snapshot::kMessage); |
| 3187 | 3323 |
| 3188 // Allocate JSRegExp object. | 3324 // Allocate JSRegExp object. |
| 3189 JSRegExp& regex = JSRegExp::ZoneHandle( | 3325 JSRegExp& regex = JSRegExp::ZoneHandle( |
| 3190 reader->zone(), JSRegExp::New(HEAP_SPACE(kind))); | 3326 reader->zone(), JSRegExp::New(HEAP_SPACE(kind))); |
| 3191 reader->AddBackRef(object_id, ®ex, kIsDeserialized); | 3327 reader->AddBackRef(object_id, ®ex, kIsDeserialized); |
| 3192 | 3328 |
| 3193 // Read and Set all the other fields. | 3329 // Read and Set all the other fields. |
| 3194 regex.StoreSmi(®ex.raw_ptr()->num_bracket_expressions_, | 3330 regex.StoreSmi(®ex.raw_ptr()->num_bracket_expressions_, |
| 3195 reader->ReadAsSmi()); | 3331 reader->ReadAsSmi()); |
| 3196 *reader->StringHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); | 3332 *reader->StringHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); |
| 3197 regex.set_pattern(*reader->StringHandle()); | 3333 regex.set_pattern(*reader->StringHandle()); |
| 3198 regex.StoreNonPointer(®ex.raw_ptr()->num_registers_, | 3334 regex.StoreNonPointer(®ex.raw_ptr()->num_registers_, |
| 3199 reader->Read<int32_t>()); | 3335 reader->Read<int32_t>()); |
| 3200 regex.StoreNonPointer(®ex.raw_ptr()->type_flags_, | 3336 regex.StoreNonPointer(®ex.raw_ptr()->type_flags_, |
| 3201 reader->Read<int8_t>()); | 3337 reader->Read<int8_t>()); |
| 3202 | 3338 |
| 3203 // TODO(18854): Need to implement a way of recreating the irrexp functions. | 3339 // TODO(18854): Need to implement a way of recreating the irrexp functions. |
| 3204 return regex.raw(); | 3340 return regex.raw(); |
| 3205 } | 3341 } |
| 3206 | 3342 |
| 3207 | 3343 |
| 3208 void RawJSRegExp::WriteTo(SnapshotWriter* writer, | 3344 void RawJSRegExp::WriteTo(SnapshotWriter* writer, |
| 3209 intptr_t object_id, | 3345 intptr_t object_id, |
| 3210 Snapshot::Kind kind) { | 3346 Snapshot::Kind kind, |
| 3347 bool as_reference) { |
| 3211 ASSERT(writer != NULL); | 3348 ASSERT(writer != NULL); |
| 3212 ASSERT(kind == Snapshot::kMessage); | 3349 ASSERT(kind == Snapshot::kMessage); |
| 3213 | 3350 |
| 3214 // Write out the serialization header value for this object. | 3351 // Write out the serialization header value for this object. |
| 3215 writer->WriteInlinedObjectHeader(object_id); | 3352 writer->WriteInlinedObjectHeader(object_id); |
| 3216 | 3353 |
| 3217 // Write out the class and tags information. | 3354 // Write out the class and tags information. |
| 3218 writer->WriteIndexedObject(kJSRegExpCid); | 3355 writer->WriteIndexedObject(kJSRegExpCid); |
| 3219 writer->WriteTags(writer->GetObjectTags(this)); | 3356 writer->WriteTags(writer->GetObjectTags(this)); |
| 3220 | 3357 |
| 3221 // Write out all the other fields. | 3358 // Write out all the other fields. |
| 3222 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); | 3359 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); |
| 3223 writer->WriteObjectImpl(ptr()->pattern_, kAsInlinedObject); | 3360 writer->WriteObjectImpl(ptr()->pattern_, kAsInlinedObject); |
| 3224 writer->Write<int32_t>(ptr()->num_registers_); | 3361 writer->Write<int32_t>(ptr()->num_registers_); |
| 3225 writer->Write<int8_t>(ptr()->type_flags_); | 3362 writer->Write<int8_t>(ptr()->type_flags_); |
| 3226 } | 3363 } |
| 3227 | 3364 |
| 3228 | 3365 |
| 3229 RawWeakProperty* WeakProperty::ReadFrom(SnapshotReader* reader, | 3366 RawWeakProperty* WeakProperty::ReadFrom(SnapshotReader* reader, |
| 3230 intptr_t object_id, | 3367 intptr_t object_id, |
| 3231 intptr_t tags, | 3368 intptr_t tags, |
| 3232 Snapshot::Kind kind) { | 3369 Snapshot::Kind kind, |
| 3370 bool as_reference) { |
| 3233 ASSERT(reader != NULL); | 3371 ASSERT(reader != NULL); |
| 3234 | 3372 |
| 3235 // Allocate the weak property object. | 3373 // Allocate the weak property object. |
| 3236 WeakProperty& weak_property = WeakProperty::ZoneHandle( | 3374 WeakProperty& weak_property = WeakProperty::ZoneHandle( |
| 3237 reader->zone(), WeakProperty::New(HEAP_SPACE(kind))); | 3375 reader->zone(), WeakProperty::New(HEAP_SPACE(kind))); |
| 3238 reader->AddBackRef(object_id, &weak_property, kIsDeserialized); | 3376 reader->AddBackRef(object_id, &weak_property, kIsDeserialized); |
| 3239 | 3377 |
| 3240 // Set all the object fields. | 3378 // Set all the object fields. |
| 3241 READ_OBJECT_FIELDS(weak_property, | 3379 READ_OBJECT_FIELDS(weak_property, |
| 3242 weak_property.raw()->from(), weak_property.raw()->to(), | 3380 weak_property.raw()->from(), weak_property.raw()->to(), |
| 3243 kAsReference); | 3381 kAsReference); |
| 3244 | 3382 |
| 3245 return weak_property.raw(); | 3383 return weak_property.raw(); |
| 3246 } | 3384 } |
| 3247 | 3385 |
| 3248 | 3386 |
| 3249 void RawWeakProperty::WriteTo(SnapshotWriter* writer, | 3387 void RawWeakProperty::WriteTo(SnapshotWriter* writer, |
| 3250 intptr_t object_id, | 3388 intptr_t object_id, |
| 3251 Snapshot::Kind kind) { | 3389 Snapshot::Kind kind, |
| 3390 bool as_reference) { |
| 3252 ASSERT(writer != NULL); | 3391 ASSERT(writer != NULL); |
| 3253 | 3392 |
| 3254 // Write out the serialization header value for this object. | 3393 // Write out the serialization header value for this object. |
| 3255 writer->WriteInlinedObjectHeader(object_id); | 3394 writer->WriteInlinedObjectHeader(object_id); |
| 3256 | 3395 |
| 3257 // Write out the class and tags information. | 3396 // Write out the class and tags information. |
| 3258 writer->WriteIndexedObject(kWeakPropertyCid); | 3397 writer->WriteIndexedObject(kWeakPropertyCid); |
| 3259 writer->WriteTags(writer->GetObjectTags(this)); | 3398 writer->WriteTags(writer->GetObjectTags(this)); |
| 3260 | 3399 |
| 3261 // Write out all the object pointer fields. | 3400 // Write out all the object pointer fields. |
| 3262 SnapshotWriterVisitor visitor(writer, kAsReference); | 3401 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 3263 visitor.VisitPointers(from(), to()); | 3402 visitor.VisitPointers(from(), to()); |
| 3264 } | 3403 } |
| 3265 | 3404 |
| 3266 | 3405 |
| 3267 RawMirrorReference* MirrorReference::ReadFrom(SnapshotReader* reader, | 3406 RawMirrorReference* MirrorReference::ReadFrom(SnapshotReader* reader, |
| 3268 intptr_t object_id, | 3407 intptr_t object_id, |
| 3269 intptr_t tags, | 3408 intptr_t tags, |
| 3270 Snapshot::Kind kind) { | 3409 Snapshot::Kind kind, |
| 3410 bool as_referenec) { |
| 3271 UNREACHABLE(); | 3411 UNREACHABLE(); |
| 3272 return MirrorReference::null(); | 3412 return MirrorReference::null(); |
| 3273 } | 3413 } |
| 3274 | 3414 |
| 3275 | 3415 |
| 3276 void RawMirrorReference::WriteTo(SnapshotWriter* writer, | 3416 void RawMirrorReference::WriteTo(SnapshotWriter* writer, |
| 3277 intptr_t object_id, | 3417 intptr_t object_id, |
| 3278 Snapshot::Kind kind) { | 3418 Snapshot::Kind kind, |
| 3419 bool as_reference) { |
| 3279 if (kind == Snapshot::kMessage) { | 3420 if (kind == Snapshot::kMessage) { |
| 3280 // We do not allow objects with native fields in an isolate message. | 3421 // We do not allow objects with native fields in an isolate message. |
| 3281 writer->SetWriteException(Exceptions::kArgument, | 3422 writer->SetWriteException(Exceptions::kArgument, |
| 3282 "Illegal argument in isolate message" | 3423 "Illegal argument in isolate message" |
| 3283 " : (object is a MirrorReference)"); | 3424 " : (object is a MirrorReference)"); |
| 3284 } else { | 3425 } else { |
| 3285 UNREACHABLE(); | 3426 UNREACHABLE(); |
| 3286 } | 3427 } |
| 3287 } | 3428 } |
| 3288 | 3429 |
| 3289 | 3430 |
| 3290 RawUserTag* UserTag::ReadFrom(SnapshotReader* reader, | 3431 RawUserTag* UserTag::ReadFrom(SnapshotReader* reader, |
| 3291 intptr_t object_id, | 3432 intptr_t object_id, |
| 3292 intptr_t tags, | 3433 intptr_t tags, |
| 3293 Snapshot::Kind kind) { | 3434 Snapshot::Kind kind, |
| 3435 bool as_reference) { |
| 3294 UNREACHABLE(); | 3436 UNREACHABLE(); |
| 3295 return UserTag::null(); | 3437 return UserTag::null(); |
| 3296 } | 3438 } |
| 3297 | 3439 |
| 3298 | 3440 |
| 3299 void RawUserTag::WriteTo(SnapshotWriter* writer, | 3441 void RawUserTag::WriteTo(SnapshotWriter* writer, |
| 3300 intptr_t object_id, | 3442 intptr_t object_id, |
| 3301 Snapshot::Kind kind) { | 3443 Snapshot::Kind kind, |
| 3444 bool as_reference) { |
| 3302 if (kind == Snapshot::kMessage) { | 3445 if (kind == Snapshot::kMessage) { |
| 3303 // We do not allow objects with native fields in an isolate message. | 3446 // We do not allow objects with native fields in an isolate message. |
| 3304 writer->SetWriteException(Exceptions::kArgument, | 3447 writer->SetWriteException(Exceptions::kArgument, |
| 3305 "Illegal argument in isolate message" | 3448 "Illegal argument in isolate message" |
| 3306 " : (object is a UserTag)"); | 3449 " : (object is a UserTag)"); |
| 3307 } else { | 3450 } else { |
| 3308 UNREACHABLE(); | 3451 UNREACHABLE(); |
| 3309 } | 3452 } |
| 3310 } | 3453 } |
| 3311 | 3454 |
| 3312 } // namespace dart | 3455 } // namespace dart |
| OLD | NEW |