| 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/object.h" | 5 #include "vm/object.h" |
| 6 #include "vm/object_store.h" | 6 #include "vm/object_store.h" |
| 7 #include "vm/snapshot.h" | 7 #include "vm/snapshot.h" |
| 8 #include "vm/stub_code.h" | 8 #include "vm/stub_code.h" |
| 9 #include "vm/symbols.h" | 9 #include "vm/symbols.h" |
| 10 #include "vm/visitor.h" | 10 #include "vm/visitor.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 cls.set_num_own_type_arguments(reader->Read<int16_t>()); | 61 cls.set_num_own_type_arguments(reader->Read<int16_t>()); |
| 62 cls.set_num_native_fields(reader->Read<uint16_t>()); | 62 cls.set_num_native_fields(reader->Read<uint16_t>()); |
| 63 cls.set_token_pos(reader->Read<int32_t>()); | 63 cls.set_token_pos(reader->Read<int32_t>()); |
| 64 cls.set_state_bits(reader->Read<uint16_t>()); | 64 cls.set_state_bits(reader->Read<uint16_t>()); |
| 65 | 65 |
| 66 // Set all the object fields. | 66 // Set all the object fields. |
| 67 // TODO(5411462): Need to assert No GC can happen here, even though | 67 // TODO(5411462): Need to assert No GC can happen here, even though |
| 68 // allocations may happen. | 68 // allocations may happen. |
| 69 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); | 69 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); |
| 70 for (intptr_t i = 0; i <= num_flds; i++) { | 70 for (intptr_t i = 0; i <= num_flds; i++) { |
| 71 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 71 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 72 cls.StorePointer((cls.raw()->from() + i), | 72 cls.StorePointer((cls.raw()->from() + i), |
| 73 reader->PassiveObjectHandle()->raw()); | 73 reader->PassiveObjectHandle()->raw()); |
| 74 } | 74 } |
| 75 } else { | 75 } else { |
| 76 cls ^= reader->ReadClassId(object_id); | 76 cls ^= reader->ReadClassId(object_id); |
| 77 } | 77 } |
| 78 return cls.raw(); | 78 return cls.raw(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 | 81 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 145 |
| 146 // Set all non object fields. | 146 // Set all non object fields. |
| 147 unresolved_class.set_token_pos(reader->Read<int32_t>()); | 147 unresolved_class.set_token_pos(reader->Read<int32_t>()); |
| 148 | 148 |
| 149 // Set all the object fields. | 149 // Set all the object fields. |
| 150 // TODO(5411462): Need to assert No GC can happen here, even though | 150 // TODO(5411462): Need to assert No GC can happen here, even though |
| 151 // allocations may happen. | 151 // allocations may happen. |
| 152 intptr_t num_flds = (unresolved_class.raw()->to() - | 152 intptr_t num_flds = (unresolved_class.raw()->to() - |
| 153 unresolved_class.raw()->from()); | 153 unresolved_class.raw()->from()); |
| 154 for (intptr_t i = 0; i <= num_flds; i++) { | 154 for (intptr_t i = 0; i <= num_flds; i++) { |
| 155 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 155 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 156 unresolved_class.StorePointer((unresolved_class.raw()->from() + i), | 156 unresolved_class.StorePointer((unresolved_class.raw()->from() + i), |
| 157 reader->PassiveObjectHandle()->raw()); | 157 reader->PassiveObjectHandle()->raw()); |
| 158 } | 158 } |
| 159 return unresolved_class.raw(); | 159 return unresolved_class.raw(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 | 162 |
| 163 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, | 163 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, |
| 164 intptr_t object_id, | 164 intptr_t object_id, |
| 165 Snapshot::Kind kind) { | 165 Snapshot::Kind kind) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 209 |
| 210 // Set all non object fields. | 210 // Set all non object fields. |
| 211 type.set_token_pos(reader->Read<int32_t>()); | 211 type.set_token_pos(reader->Read<int32_t>()); |
| 212 type.set_type_state(reader->Read<int8_t>()); | 212 type.set_type_state(reader->Read<int8_t>()); |
| 213 | 213 |
| 214 // Set all the object fields. | 214 // Set all the object fields. |
| 215 // TODO(5411462): Need to assert No GC can happen here, even though | 215 // TODO(5411462): Need to assert No GC can happen here, even though |
| 216 // allocations may happen. | 216 // allocations may happen. |
| 217 intptr_t num_flds = (type.raw()->to() - type.raw()->from()); | 217 intptr_t num_flds = (type.raw()->to() - type.raw()->from()); |
| 218 for (intptr_t i = 0; i <= num_flds; i++) { | 218 for (intptr_t i = 0; i <= num_flds; i++) { |
| 219 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(); | 219 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsInlinedObject); |
| 220 type.StorePointer((type.raw()->from() + i), | 220 type.StorePointer((type.raw()->from() + i), |
| 221 reader->PassiveObjectHandle()->raw()); | 221 reader->PassiveObjectHandle()->raw()); |
| 222 } | 222 } |
| 223 | 223 |
| 224 // If object needs to be a canonical object, Canonicalize it. | 224 // If object needs to be a canonical object, Canonicalize it. |
| 225 // When reading a full snapshot we don't need to canonicalize the object | 225 // When reading a full snapshot we don't need to canonicalize the object |
| 226 // as it would already be a canonical object. | 226 // as it would already be a canonical object. |
| 227 // When reading a script snapshot we need to canonicalize only those object | 227 // When reading a script snapshot we need to canonicalize only those object |
| 228 // references that are objects from the core library (loaded from a | 228 // references that are objects from the core library (loaded from a |
| 229 // full snapshot). Objects that are only in the script need not be | 229 // full snapshot). Objects that are only in the script need not be |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 reader->AddBackRef(object_id, &type_ref, kIsDeserialized); | 283 reader->AddBackRef(object_id, &type_ref, kIsDeserialized); |
| 284 | 284 |
| 285 // Set the object tags. | 285 // Set the object tags. |
| 286 type_ref.set_tags(tags); | 286 type_ref.set_tags(tags); |
| 287 | 287 |
| 288 // Set all the object fields. | 288 // Set all the object fields. |
| 289 // TODO(5411462): Need to assert No GC can happen here, even though | 289 // TODO(5411462): Need to assert No GC can happen here, even though |
| 290 // allocations may happen. | 290 // allocations may happen. |
| 291 intptr_t num_flds = (type_ref.raw()->to() - type_ref.raw()->from()); | 291 intptr_t num_flds = (type_ref.raw()->to() - type_ref.raw()->from()); |
| 292 for (intptr_t i = 0; i <= num_flds; i++) { | 292 for (intptr_t i = 0; i <= num_flds; i++) { |
| 293 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 293 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 294 type_ref.StorePointer((type_ref.raw()->from() + i), | 294 type_ref.StorePointer((type_ref.raw()->from() + i), |
| 295 reader->PassiveObjectHandle()->raw()); | 295 reader->PassiveObjectHandle()->raw()); |
| 296 } | 296 } |
| 297 | 297 |
| 298 return type_ref.raw(); | 298 return type_ref.raw(); |
| 299 } | 299 } |
| 300 | 300 |
| 301 | 301 |
| 302 void RawTypeRef::WriteTo(SnapshotWriter* writer, | 302 void RawTypeRef::WriteTo(SnapshotWriter* writer, |
| 303 intptr_t object_id, | 303 intptr_t object_id, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 type_parameter.set_token_pos(reader->Read<int32_t>()); | 335 type_parameter.set_token_pos(reader->Read<int32_t>()); |
| 336 type_parameter.set_index(reader->Read<int16_t>()); | 336 type_parameter.set_index(reader->Read<int16_t>()); |
| 337 type_parameter.set_type_state(reader->Read<int8_t>()); | 337 type_parameter.set_type_state(reader->Read<int8_t>()); |
| 338 | 338 |
| 339 // Set all the object fields. | 339 // Set all the object fields. |
| 340 // TODO(5411462): Need to assert No GC can happen here, even though | 340 // TODO(5411462): Need to assert No GC can happen here, even though |
| 341 // allocations may happen. | 341 // allocations may happen. |
| 342 intptr_t num_flds = (type_parameter.raw()->to() - | 342 intptr_t num_flds = (type_parameter.raw()->to() - |
| 343 type_parameter.raw()->from()); | 343 type_parameter.raw()->from()); |
| 344 for (intptr_t i = 0; i <= num_flds; i++) { | 344 for (intptr_t i = 0; i <= num_flds; i++) { |
| 345 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 345 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 346 type_parameter.StorePointer((type_parameter.raw()->from() + i), | 346 type_parameter.StorePointer((type_parameter.raw()->from() + i), |
| 347 reader->PassiveObjectHandle()->raw()); | 347 reader->PassiveObjectHandle()->raw()); |
| 348 } | 348 } |
| 349 | 349 |
| 350 return type_parameter.raw(); | 350 return type_parameter.raw(); |
| 351 } | 351 } |
| 352 | 352 |
| 353 | 353 |
| 354 void RawTypeParameter::WriteTo(SnapshotWriter* writer, | 354 void RawTypeParameter::WriteTo(SnapshotWriter* writer, |
| 355 intptr_t object_id, | 355 intptr_t object_id, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 | 390 |
| 391 // Set the object tags. | 391 // Set the object tags. |
| 392 bounded_type.set_tags(tags); | 392 bounded_type.set_tags(tags); |
| 393 | 393 |
| 394 // Set all the object fields. | 394 // Set all the object fields. |
| 395 // TODO(5411462): Need to assert No GC can happen here, even though | 395 // TODO(5411462): Need to assert No GC can happen here, even though |
| 396 // allocations may happen. | 396 // allocations may happen. |
| 397 intptr_t num_flds = (bounded_type.raw()->to() - | 397 intptr_t num_flds = (bounded_type.raw()->to() - |
| 398 bounded_type.raw()->from()); | 398 bounded_type.raw()->from()); |
| 399 for (intptr_t i = 0; i <= num_flds; i++) { | 399 for (intptr_t i = 0; i <= num_flds; i++) { |
| 400 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 400 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 401 bounded_type.StorePointer((bounded_type.raw()->from() + i), | 401 bounded_type.StorePointer((bounded_type.raw()->from() + i), |
| 402 reader->PassiveObjectHandle()->raw()); | 402 reader->PassiveObjectHandle()->raw()); |
| 403 } | 403 } |
| 404 | 404 |
| 405 return bounded_type.raw(); | 405 return bounded_type.raw(); |
| 406 } | 406 } |
| 407 | 407 |
| 408 | 408 |
| 409 void RawBoundedType::WriteTo(SnapshotWriter* writer, | 409 void RawBoundedType::WriteTo(SnapshotWriter* writer, |
| 410 intptr_t object_id, | 410 intptr_t object_id, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 | 448 |
| 449 // Read the length so that we can determine instance size to allocate. | 449 // Read the length so that we can determine instance size to allocate. |
| 450 intptr_t len = reader->ReadSmiValue(); | 450 intptr_t len = reader->ReadSmiValue(); |
| 451 | 451 |
| 452 TypeArguments& type_arguments = TypeArguments::ZoneHandle( | 452 TypeArguments& type_arguments = TypeArguments::ZoneHandle( |
| 453 reader->zone(), NEW_OBJECT_WITH_LEN_SPACE(TypeArguments, len, kind)); | 453 reader->zone(), NEW_OBJECT_WITH_LEN_SPACE(TypeArguments, len, kind)); |
| 454 reader->AddBackRef(object_id, &type_arguments, kIsDeserialized); | 454 reader->AddBackRef(object_id, &type_arguments, kIsDeserialized); |
| 455 | 455 |
| 456 // Set the instantiations field, which is only read from a full snapshot. | 456 // Set the instantiations field, which is only read from a full snapshot. |
| 457 if (kind == Snapshot::kFull) { | 457 if (kind == Snapshot::kFull) { |
| 458 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(); | 458 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); |
| 459 type_arguments.set_instantiations(*(reader->ArrayHandle())); | 459 type_arguments.set_instantiations(*(reader->ArrayHandle())); |
| 460 } else { | 460 } else { |
| 461 type_arguments.set_instantiations(Object::zero_array()); | 461 type_arguments.set_instantiations(Object::zero_array()); |
| 462 } | 462 } |
| 463 | 463 |
| 464 // Now set all the type fields. | 464 // Now set all the type fields. |
| 465 for (intptr_t i = 0; i < len; i++) { | 465 for (intptr_t i = 0; i < len; i++) { |
| 466 *reader->TypeHandle() ^= reader->ReadObjectImpl(); | 466 *reader->TypeHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); |
| 467 type_arguments.SetTypeAt(i, *reader->TypeHandle()); | 467 type_arguments.SetTypeAt(i, *reader->TypeHandle()); |
| 468 } | 468 } |
| 469 | 469 |
| 470 // If object needs to be a canonical object, Canonicalize it. | 470 // If object needs to be a canonical object, Canonicalize it. |
| 471 // When reading a full snapshot we don't need to canonicalize the object | 471 // When reading a full snapshot we don't need to canonicalize the object |
| 472 // as it would already be a canonical object. | 472 // as it would already be a canonical object. |
| 473 // When reading a script snapshot we need to canonicalize only those object | 473 // When reading a script snapshot we need to canonicalize only those object |
| 474 // references that are objects from the core library (loaded from a | 474 // references that are objects from the core library (loaded from a |
| 475 // full snapshot). Objects that are only in the script need not be | 475 // full snapshot). Objects that are only in the script need not be |
| 476 // canonicalized as they are already canonical. | 476 // canonicalized as they are already canonical. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 501 | 501 |
| 502 // Write out the class and tags information. | 502 // Write out the class and tags information. |
| 503 writer->WriteVMIsolateObject(kTypeArgumentsCid); | 503 writer->WriteVMIsolateObject(kTypeArgumentsCid); |
| 504 writer->WriteTags(writer->GetObjectTags(this)); | 504 writer->WriteTags(writer->GetObjectTags(this)); |
| 505 | 505 |
| 506 // Write out the length field. | 506 // Write out the length field. |
| 507 writer->Write<RawObject*>(ptr()->length_); | 507 writer->Write<RawObject*>(ptr()->length_); |
| 508 | 508 |
| 509 // Write out the instantiations field, but only in a full snapshot. | 509 // Write out the instantiations field, but only in a full snapshot. |
| 510 if (kind == Snapshot::kFull) { | 510 if (kind == Snapshot::kFull) { |
| 511 writer->WriteObjectImpl(ptr()->instantiations_); | 511 writer->WriteObjectImpl(ptr()->instantiations_, kAsInlinedObject); |
| 512 } | 512 } |
| 513 | 513 |
| 514 // Write out the individual types. | 514 // Write out the individual types. |
| 515 intptr_t len = Smi::Value(ptr()->length_); | 515 intptr_t len = Smi::Value(ptr()->length_); |
| 516 for (intptr_t i = 0; i < len; i++) { | 516 for (intptr_t i = 0; i < len; i++) { |
| 517 writer->WriteObjectImpl(ptr()->types()[i]); | 517 writer->WriteObjectImpl(ptr()->types()[i], kAsInlinedObject); |
| 518 } | 518 } |
| 519 } | 519 } |
| 520 | 520 |
| 521 | 521 |
| 522 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader, | 522 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader, |
| 523 intptr_t object_id, | 523 intptr_t object_id, |
| 524 intptr_t tags, | 524 intptr_t tags, |
| 525 Snapshot::Kind kind) { | 525 Snapshot::Kind kind) { |
| 526 ASSERT(reader != NULL); | 526 ASSERT(reader != NULL); |
| 527 ASSERT(((kind == Snapshot::kScript) && | 527 ASSERT(((kind == Snapshot::kScript) && |
| 528 !RawObject::IsCreatedFromSnapshot(tags)) || | 528 !RawObject::IsCreatedFromSnapshot(tags)) || |
| 529 (kind == Snapshot::kFull)); | 529 (kind == Snapshot::kFull)); |
| 530 | 530 |
| 531 // Allocate function object. | 531 // Allocate function object. |
| 532 PatchClass& cls = PatchClass::ZoneHandle(reader->zone(), | 532 PatchClass& cls = PatchClass::ZoneHandle(reader->zone(), |
| 533 NEW_OBJECT(PatchClass)); | 533 NEW_OBJECT(PatchClass)); |
| 534 reader->AddBackRef(object_id, &cls, kIsDeserialized); | 534 reader->AddBackRef(object_id, &cls, kIsDeserialized); |
| 535 | 535 |
| 536 // Set the object tags. | 536 // Set the object tags. |
| 537 cls.set_tags(tags); | 537 cls.set_tags(tags); |
| 538 | 538 |
| 539 // Set all the object fields. | 539 // Set all the object fields. |
| 540 // TODO(5411462): Need to assert No GC can happen here, even though | 540 // TODO(5411462): Need to assert No GC can happen here, even though |
| 541 // allocations may happen. | 541 // allocations may happen. |
| 542 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); | 542 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); |
| 543 for (intptr_t i = 0; i <= num_flds; i++) { | 543 for (intptr_t i = 0; i <= num_flds; i++) { |
| 544 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 544 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 545 cls.StorePointer((cls.raw()->from() + i), | 545 cls.StorePointer((cls.raw()->from() + i), |
| 546 reader->PassiveObjectHandle()->raw()); | 546 reader->PassiveObjectHandle()->raw()); |
| 547 } | 547 } |
| 548 | 548 |
| 549 return cls.raw(); | 549 return cls.raw(); |
| 550 } | 550 } |
| 551 | 551 |
| 552 | 552 |
| 553 void RawPatchClass::WriteTo(SnapshotWriter* writer, | 553 void RawPatchClass::WriteTo(SnapshotWriter* writer, |
| 554 intptr_t object_id, | 554 intptr_t object_id, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 585 reader->AddBackRef(object_id, &data, kIsDeserialized); | 585 reader->AddBackRef(object_id, &data, kIsDeserialized); |
| 586 | 586 |
| 587 // Set the object tags. | 587 // Set the object tags. |
| 588 data.set_tags(tags); | 588 data.set_tags(tags); |
| 589 | 589 |
| 590 // Set all the object fields. | 590 // Set all the object fields. |
| 591 // TODO(5411462): Need to assert No GC can happen here, even though | 591 // TODO(5411462): Need to assert No GC can happen here, even though |
| 592 // allocations may happen. | 592 // allocations may happen. |
| 593 intptr_t num_flds = (data.raw()->to() - data.raw()->from()); | 593 intptr_t num_flds = (data.raw()->to() - data.raw()->from()); |
| 594 for (intptr_t i = 0; i <= num_flds; i++) { | 594 for (intptr_t i = 0; i <= num_flds; i++) { |
| 595 *(data.raw()->from() + i) = reader->ReadObjectRef(); | 595 *(data.raw()->from() + i) = reader->ReadObjectImpl(kAsReference); |
| 596 } | 596 } |
| 597 | 597 |
| 598 return data.raw(); | 598 return data.raw(); |
| 599 } | 599 } |
| 600 | 600 |
| 601 | 601 |
| 602 void RawClosureData::WriteTo(SnapshotWriter* writer, | 602 void RawClosureData::WriteTo(SnapshotWriter* writer, |
| 603 intptr_t object_id, | 603 intptr_t object_id, |
| 604 Snapshot::Kind kind) { | 604 Snapshot::Kind kind) { |
| 605 ASSERT(writer != NULL); | 605 ASSERT(writer != NULL); |
| 606 ASSERT(((kind == Snapshot::kScript) && | 606 ASSERT(((kind == Snapshot::kScript) && |
| 607 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || | 607 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || |
| 608 (kind == Snapshot::kFull)); | 608 (kind == Snapshot::kFull)); |
| 609 | 609 |
| 610 // Write out the serialization header value for this object. | 610 // Write out the serialization header value for this object. |
| 611 writer->WriteInlinedObjectHeader(object_id); | 611 writer->WriteInlinedObjectHeader(object_id); |
| 612 | 612 |
| 613 // Write out the class and tags information. | 613 // Write out the class and tags information. |
| 614 writer->WriteVMIsolateObject(kClosureDataCid); | 614 writer->WriteVMIsolateObject(kClosureDataCid); |
| 615 writer->WriteTags(writer->GetObjectTags(this)); | 615 writer->WriteTags(writer->GetObjectTags(this)); |
| 616 | 616 |
| 617 // Context scope. | 617 // Context scope. |
| 618 // We don't write the context scope in the snapshot. | 618 // We don't write the context scope in the snapshot. |
| 619 writer->WriteObjectImpl(Object::null()); | 619 writer->WriteObjectImpl(Object::null(), kAsInlinedObject); |
| 620 | 620 |
| 621 // Parent function. | 621 // Parent function. |
| 622 writer->WriteObjectImpl(ptr()->parent_function_); | 622 writer->WriteObjectImpl(ptr()->parent_function_, kAsInlinedObject); |
| 623 | 623 |
| 624 // Signature class. | 624 // Signature class. |
| 625 writer->WriteObjectImpl(ptr()->signature_class_); | 625 writer->WriteObjectImpl(ptr()->signature_class_, kAsInlinedObject); |
| 626 | 626 |
| 627 // Static closure/Closure allocation stub. | 627 // Static closure/Closure allocation stub. |
| 628 // We don't write the closure or allocation stub in the snapshot. | 628 // We don't write the closure or allocation stub in the snapshot. |
| 629 writer->WriteObjectImpl(Object::null()); | 629 writer->WriteObjectImpl(Object::null(), kAsInlinedObject); |
| 630 } | 630 } |
| 631 | 631 |
| 632 | 632 |
| 633 RawRedirectionData* RedirectionData::ReadFrom(SnapshotReader* reader, | 633 RawRedirectionData* RedirectionData::ReadFrom(SnapshotReader* reader, |
| 634 intptr_t object_id, | 634 intptr_t object_id, |
| 635 intptr_t tags, | 635 intptr_t tags, |
| 636 Snapshot::Kind kind) { | 636 Snapshot::Kind kind) { |
| 637 ASSERT(reader != NULL); | 637 ASSERT(reader != NULL); |
| 638 ASSERT(((kind == Snapshot::kScript) && | 638 ASSERT(((kind == Snapshot::kScript) && |
| 639 !RawObject::IsCreatedFromSnapshot(tags)) || | 639 !RawObject::IsCreatedFromSnapshot(tags)) || |
| 640 (kind == Snapshot::kFull)); | 640 (kind == Snapshot::kFull)); |
| 641 | 641 |
| 642 // Allocate redirection data object. | 642 // Allocate redirection data object. |
| 643 RedirectionData& data = RedirectionData::ZoneHandle( | 643 RedirectionData& data = RedirectionData::ZoneHandle( |
| 644 reader->zone(), NEW_OBJECT(RedirectionData)); | 644 reader->zone(), NEW_OBJECT(RedirectionData)); |
| 645 reader->AddBackRef(object_id, &data, kIsDeserialized); | 645 reader->AddBackRef(object_id, &data, kIsDeserialized); |
| 646 | 646 |
| 647 // Set the object tags. | 647 // Set the object tags. |
| 648 data.set_tags(tags); | 648 data.set_tags(tags); |
| 649 | 649 |
| 650 // Set all the object fields. | 650 // Set all the object fields. |
| 651 // TODO(5411462): Need to assert No GC can happen here, even though | 651 // TODO(5411462): Need to assert No GC can happen here, even though |
| 652 // allocations may happen. | 652 // allocations may happen. |
| 653 intptr_t num_flds = (data.raw()->to() - data.raw()->from()); | 653 intptr_t num_flds = (data.raw()->to() - data.raw()->from()); |
| 654 for (intptr_t i = 0; i <= num_flds; i++) { | 654 for (intptr_t i = 0; i <= num_flds; i++) { |
| 655 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 655 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 656 data.StorePointer((data.raw()->from() + i), | 656 data.StorePointer((data.raw()->from() + i), |
| 657 reader->PassiveObjectHandle()->raw()); | 657 reader->PassiveObjectHandle()->raw()); |
| 658 } | 658 } |
| 659 | 659 |
| 660 return data.raw(); | 660 return data.raw(); |
| 661 } | 661 } |
| 662 | 662 |
| 663 | 663 |
| 664 void RawRedirectionData::WriteTo(SnapshotWriter* writer, | 664 void RawRedirectionData::WriteTo(SnapshotWriter* writer, |
| 665 intptr_t object_id, | 665 intptr_t object_id, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 func.set_regexp_cid(reader->ReadClassIDValue()); | 709 func.set_regexp_cid(reader->ReadClassIDValue()); |
| 710 func.set_kind_tag(reader->Read<uint32_t>()); | 710 func.set_kind_tag(reader->Read<uint32_t>()); |
| 711 func.set_optimized_instruction_count(reader->Read<uint16_t>()); | 711 func.set_optimized_instruction_count(reader->Read<uint16_t>()); |
| 712 func.set_optimized_call_site_count(reader->Read<uint16_t>()); | 712 func.set_optimized_call_site_count(reader->Read<uint16_t>()); |
| 713 | 713 |
| 714 // Set all the object fields. | 714 // Set all the object fields. |
| 715 // TODO(5411462): Need to assert No GC can happen here, even though | 715 // TODO(5411462): Need to assert No GC can happen here, even though |
| 716 // allocations may happen. | 716 // allocations may happen. |
| 717 intptr_t num_flds = (func.raw()->to_snapshot() - func.raw()->from()); | 717 intptr_t num_flds = (func.raw()->to_snapshot() - func.raw()->from()); |
| 718 for (intptr_t i = 0; i <= num_flds; i++) { | 718 for (intptr_t i = 0; i <= num_flds; i++) { |
| 719 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 719 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 720 func.StorePointer((func.raw()->from() + i), | 720 func.StorePointer((func.raw()->from() + i), |
| 721 reader->PassiveObjectHandle()->raw()); | 721 reader->PassiveObjectHandle()->raw()); |
| 722 } | 722 } |
| 723 | 723 |
| 724 // Initialize all fields that are not part of the snapshot. | 724 // Initialize all fields that are not part of the snapshot. |
| 725 func.ClearICDataArray(); | 725 func.ClearICDataArray(); |
| 726 func.ClearCode(); | 726 func.ClearCode(); |
| 727 return func.raw(); | 727 return func.raw(); |
| 728 } | 728 } |
| 729 | 729 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 field.set_token_pos(reader->Read<int32_t>()); | 781 field.set_token_pos(reader->Read<int32_t>()); |
| 782 field.set_guarded_cid(reader->Read<int32_t>()); | 782 field.set_guarded_cid(reader->Read<int32_t>()); |
| 783 field.set_is_nullable(reader->Read<int32_t>()); | 783 field.set_is_nullable(reader->Read<int32_t>()); |
| 784 field.set_kind_bits(reader->Read<uint8_t>()); | 784 field.set_kind_bits(reader->Read<uint8_t>()); |
| 785 | 785 |
| 786 // Set all the object fields. | 786 // Set all the object fields. |
| 787 // TODO(5411462): Need to assert No GC can happen here, even though | 787 // TODO(5411462): Need to assert No GC can happen here, even though |
| 788 // allocations may happen. | 788 // allocations may happen. |
| 789 intptr_t num_flds = (field.raw()->to() - field.raw()->from()); | 789 intptr_t num_flds = (field.raw()->to() - field.raw()->from()); |
| 790 for (intptr_t i = 0; i <= num_flds; i++) { | 790 for (intptr_t i = 0; i <= num_flds; i++) { |
| 791 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 791 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 792 field.StorePointer((field.raw()->from() + i), | 792 field.StorePointer((field.raw()->from() + i), |
| 793 reader->PassiveObjectHandle()->raw()); | 793 reader->PassiveObjectHandle()->raw()); |
| 794 } | 794 } |
| 795 | 795 |
| 796 field.InitializeGuardedListLengthInObjectOffset(); | 796 field.InitializeGuardedListLengthInObjectOffset(); |
| 797 | 797 |
| 798 return field.raw(); | 798 return field.raw(); |
| 799 } | 799 } |
| 800 | 800 |
| 801 | 801 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 | 843 |
| 844 // Read the token attributes. | 844 // Read the token attributes. |
| 845 Token::Kind token_kind = static_cast<Token::Kind>(reader->Read<int32_t>()); | 845 Token::Kind token_kind = static_cast<Token::Kind>(reader->Read<int32_t>()); |
| 846 literal_token.set_kind(token_kind); | 846 literal_token.set_kind(token_kind); |
| 847 | 847 |
| 848 // Set all the object fields. | 848 // Set all the object fields. |
| 849 // TODO(5411462): Need to assert No GC can happen here, even though | 849 // TODO(5411462): Need to assert No GC can happen here, even though |
| 850 // allocations may happen. | 850 // allocations may happen. |
| 851 intptr_t num_flds = (literal_token.raw()->to() - literal_token.raw()->from()); | 851 intptr_t num_flds = (literal_token.raw()->to() - literal_token.raw()->from()); |
| 852 for (intptr_t i = 0; i <= num_flds; i++) { | 852 for (intptr_t i = 0; i <= num_flds; i++) { |
| 853 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 853 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 854 literal_token.StorePointer((literal_token.raw()->from() + i), | 854 literal_token.StorePointer((literal_token.raw()->from() + i), |
| 855 reader->PassiveObjectHandle()->raw()); | 855 reader->PassiveObjectHandle()->raw()); |
| 856 } | 856 } |
| 857 | 857 |
| 858 return literal_token.raw(); | 858 return literal_token.raw(); |
| 859 } | 859 } |
| 860 | 860 |
| 861 | 861 |
| 862 void RawLiteralToken::WriteTo(SnapshotWriter* writer, | 862 void RawLiteralToken::WriteTo(SnapshotWriter* writer, |
| 863 intptr_t object_id, | 863 intptr_t object_id, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 | 903 |
| 904 // Read the stream of tokens into the TokenStream object for script | 904 // Read the stream of tokens into the TokenStream object for script |
| 905 // snapshots as we made a copy of token stream. | 905 // snapshots as we made a copy of token stream. |
| 906 if (kind == Snapshot::kScript) { | 906 if (kind == Snapshot::kScript) { |
| 907 NoSafepointScope no_safepoint; | 907 NoSafepointScope no_safepoint; |
| 908 RawExternalTypedData* stream = token_stream.GetStream(); | 908 RawExternalTypedData* stream = token_stream.GetStream(); |
| 909 reader->ReadBytes(stream->ptr()->data_, len); | 909 reader->ReadBytes(stream->ptr()->data_, len); |
| 910 } | 910 } |
| 911 | 911 |
| 912 // Read in the literal/identifier token array. | 912 // Read in the literal/identifier token array. |
| 913 *(reader->TokensHandle()) ^= reader->ReadObjectImpl(); | 913 *(reader->TokensHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); |
| 914 token_stream.SetTokenObjects(*(reader->TokensHandle())); | 914 token_stream.SetTokenObjects(*(reader->TokensHandle())); |
| 915 // Read in the private key in use by the token stream. | 915 // Read in the private key in use by the token stream. |
| 916 *(reader->StringHandle()) ^= reader->ReadObjectImpl(); | 916 *(reader->StringHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); |
| 917 token_stream.SetPrivateKey(*(reader->StringHandle())); | 917 token_stream.SetPrivateKey(*(reader->StringHandle())); |
| 918 | 918 |
| 919 return token_stream.raw(); | 919 return token_stream.raw(); |
| 920 } | 920 } |
| 921 | 921 |
| 922 | 922 |
| 923 void RawTokenStream::WriteTo(SnapshotWriter* writer, | 923 void RawTokenStream::WriteTo(SnapshotWriter* writer, |
| 924 intptr_t object_id, | 924 intptr_t object_id, |
| 925 Snapshot::Kind kind) { | 925 Snapshot::Kind kind) { |
| 926 ASSERT(writer != NULL); | 926 ASSERT(writer != NULL); |
| 927 ASSERT(((kind == Snapshot::kScript) && | 927 ASSERT(((kind == Snapshot::kScript) && |
| 928 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || | 928 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || |
| 929 (kind == Snapshot::kFull)); | 929 (kind == Snapshot::kFull)); |
| 930 | 930 |
| 931 // Write out the serialization header value for this object. | 931 // Write out the serialization header value for this object. |
| 932 writer->WriteInlinedObjectHeader(object_id); | 932 writer->WriteInlinedObjectHeader(object_id); |
| 933 | 933 |
| 934 // Write out the class and tags information. | 934 // Write out the class and tags information. |
| 935 writer->WriteVMIsolateObject(kTokenStreamCid); | 935 writer->WriteVMIsolateObject(kTokenStreamCid); |
| 936 writer->WriteTags(writer->GetObjectTags(this)); | 936 writer->WriteTags(writer->GetObjectTags(this)); |
| 937 | 937 |
| 938 // Write out the length field and the token stream. | 938 // Write out the length field and the token stream. |
| 939 RawExternalTypedData* stream = ptr()->stream_; | 939 RawExternalTypedData* stream = ptr()->stream_; |
| 940 intptr_t len = Smi::Value(stream->ptr()->length_); | 940 intptr_t len = Smi::Value(stream->ptr()->length_); |
| 941 writer->Write<RawObject*>(stream->ptr()->length_); | 941 writer->Write<RawObject*>(stream->ptr()->length_); |
| 942 writer->WriteBytes(stream->ptr()->data_, len); | 942 writer->WriteBytes(stream->ptr()->data_, len); |
| 943 | 943 |
| 944 // Write out the literal/identifier token array. | 944 // Write out the literal/identifier token array. |
| 945 writer->WriteObjectImpl(ptr()->token_objects_); | 945 writer->WriteObjectImpl(ptr()->token_objects_, kAsInlinedObject); |
| 946 // Write out the private key in use by the token stream. | 946 // Write out the private key in use by the token stream. |
| 947 writer->WriteObjectImpl(ptr()->private_key_); | 947 writer->WriteObjectImpl(ptr()->private_key_, kAsInlinedObject); |
| 948 } | 948 } |
| 949 | 949 |
| 950 | 950 |
| 951 RawScript* Script::ReadFrom(SnapshotReader* reader, | 951 RawScript* Script::ReadFrom(SnapshotReader* reader, |
| 952 intptr_t object_id, | 952 intptr_t object_id, |
| 953 intptr_t tags, | 953 intptr_t tags, |
| 954 Snapshot::Kind kind) { | 954 Snapshot::Kind kind) { |
| 955 ASSERT(reader != NULL); | 955 ASSERT(reader != NULL); |
| 956 ASSERT(((kind == Snapshot::kScript) && | 956 ASSERT(((kind == Snapshot::kScript) && |
| 957 !RawObject::IsCreatedFromSnapshot(tags)) || | 957 !RawObject::IsCreatedFromSnapshot(tags)) || |
| (...skipping 11 matching lines...) Expand all Loading... |
| 969 script.StoreNonPointer(&script.raw_ptr()->col_offset_, | 969 script.StoreNonPointer(&script.raw_ptr()->col_offset_, |
| 970 reader->Read<int32_t>()); | 970 reader->Read<int32_t>()); |
| 971 script.StoreNonPointer(&script.raw_ptr()->kind_, | 971 script.StoreNonPointer(&script.raw_ptr()->kind_, |
| 972 reader->Read<int8_t>()); | 972 reader->Read<int8_t>()); |
| 973 | 973 |
| 974 // Set all the object fields. | 974 // Set all the object fields. |
| 975 // TODO(5411462): Need to assert No GC can happen here, even though | 975 // TODO(5411462): Need to assert No GC can happen here, even though |
| 976 // allocations may happen. | 976 // allocations may happen. |
| 977 intptr_t num_flds = (script.raw()->to_snapshot() - script.raw()->from()); | 977 intptr_t num_flds = (script.raw()->to_snapshot() - script.raw()->from()); |
| 978 for (intptr_t i = 0; i <= num_flds; i++) { | 978 for (intptr_t i = 0; i <= num_flds; i++) { |
| 979 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 979 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 980 script.StorePointer((script.raw()->from() + i), | 980 script.StorePointer((script.raw()->from() + i), |
| 981 reader->PassiveObjectHandle()->raw()); | 981 reader->PassiveObjectHandle()->raw()); |
| 982 } | 982 } |
| 983 // Script wasn't allocated with nulls? | 983 // Script wasn't allocated with nulls? |
| 984 *reader->StringHandle() ^= String::null(); | 984 *reader->StringHandle() ^= String::null(); |
| 985 script.set_source(*reader->StringHandle()); | 985 script.set_source(*reader->StringHandle()); |
| 986 | 986 |
| 987 return script.raw(); | 987 return script.raw(); |
| 988 } | 988 } |
| 989 | 989 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 Snapshot::Kind kind) { | 1021 Snapshot::Kind kind) { |
| 1022 ASSERT(reader != NULL); | 1022 ASSERT(reader != NULL); |
| 1023 ASSERT(kind != Snapshot::kMessage); | 1023 ASSERT(kind != Snapshot::kMessage); |
| 1024 | 1024 |
| 1025 Library& library = Library::ZoneHandle(reader->zone(), Library::null()); | 1025 Library& library = Library::ZoneHandle(reader->zone(), Library::null()); |
| 1026 reader->AddBackRef(object_id, &library, kIsDeserialized); | 1026 reader->AddBackRef(object_id, &library, kIsDeserialized); |
| 1027 | 1027 |
| 1028 if ((kind == Snapshot::kScript) && RawObject::IsCreatedFromSnapshot(tags)) { | 1028 if ((kind == Snapshot::kScript) && RawObject::IsCreatedFromSnapshot(tags)) { |
| 1029 ASSERT(kind != Snapshot::kFull); | 1029 ASSERT(kind != Snapshot::kFull); |
| 1030 // Lookup the object as it should already exist in the heap. | 1030 // Lookup the object as it should already exist in the heap. |
| 1031 *reader->StringHandle() ^= reader->ReadObjectImpl(); | 1031 *reader->StringHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); |
| 1032 library = Library::LookupLibrary(*reader->StringHandle()); | 1032 library = Library::LookupLibrary(*reader->StringHandle()); |
| 1033 } else { | 1033 } else { |
| 1034 // Allocate library object. | 1034 // Allocate library object. |
| 1035 library = NEW_OBJECT(Library); | 1035 library = NEW_OBJECT(Library); |
| 1036 | 1036 |
| 1037 // Set the object tags. | 1037 // Set the object tags. |
| 1038 library.set_tags(tags); | 1038 library.set_tags(tags); |
| 1039 | 1039 |
| 1040 // Set all non object fields. | 1040 // Set all non object fields. |
| 1041 library.StoreNonPointer(&library.raw_ptr()->index_, | 1041 library.StoreNonPointer(&library.raw_ptr()->index_, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1056 library.set_native_entry_resolver(NULL); | 1056 library.set_native_entry_resolver(NULL); |
| 1057 library.set_native_entry_symbol_resolver(NULL); | 1057 library.set_native_entry_symbol_resolver(NULL); |
| 1058 // The cache of loaded scripts is not serialized. | 1058 // The cache of loaded scripts is not serialized. |
| 1059 library.StorePointer(&library.raw_ptr()->loaded_scripts_, Array::null()); | 1059 library.StorePointer(&library.raw_ptr()->loaded_scripts_, Array::null()); |
| 1060 | 1060 |
| 1061 // Set all the object fields. | 1061 // Set all the object fields. |
| 1062 // TODO(5411462): Need to assert No GC can happen here, even though | 1062 // TODO(5411462): Need to assert No GC can happen here, even though |
| 1063 // allocations may happen. | 1063 // allocations may happen. |
| 1064 intptr_t num_flds = (library.raw()->to() - library.raw()->from()); | 1064 intptr_t num_flds = (library.raw()->to() - library.raw()->from()); |
| 1065 for (intptr_t i = 0; i <= num_flds; i++) { | 1065 for (intptr_t i = 0; i <= num_flds; i++) { |
| 1066 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 1066 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 1067 library.StorePointer((library.raw()->from() + i), | 1067 library.StorePointer((library.raw()->from() + i), |
| 1068 reader->PassiveObjectHandle()->raw()); | 1068 reader->PassiveObjectHandle()->raw()); |
| 1069 } | 1069 } |
| 1070 if (kind != Snapshot::kFull) { | 1070 if (kind != Snapshot::kFull) { |
| 1071 library.Register(); | 1071 library.Register(); |
| 1072 } | 1072 } |
| 1073 } | 1073 } |
| 1074 return library.raw(); | 1074 return library.raw(); |
| 1075 } | 1075 } |
| 1076 | 1076 |
| 1077 | 1077 |
| 1078 void RawLibrary::WriteTo(SnapshotWriter* writer, | 1078 void RawLibrary::WriteTo(SnapshotWriter* writer, |
| 1079 intptr_t object_id, | 1079 intptr_t object_id, |
| 1080 Snapshot::Kind kind) { | 1080 Snapshot::Kind kind) { |
| 1081 ASSERT(writer != NULL); | 1081 ASSERT(writer != NULL); |
| 1082 ASSERT(kind != Snapshot::kMessage); | 1082 ASSERT(kind != Snapshot::kMessage); |
| 1083 | 1083 |
| 1084 // Write out the serialization header value for this object. | 1084 // Write out the serialization header value for this object. |
| 1085 writer->WriteInlinedObjectHeader(object_id); | 1085 writer->WriteInlinedObjectHeader(object_id); |
| 1086 | 1086 |
| 1087 // Write out the class and tags information. | 1087 // Write out the class and tags information. |
| 1088 writer->WriteVMIsolateObject(kLibraryCid); | 1088 writer->WriteVMIsolateObject(kLibraryCid); |
| 1089 writer->WriteTags(writer->GetObjectTags(this)); | 1089 writer->WriteTags(writer->GetObjectTags(this)); |
| 1090 | 1090 |
| 1091 if ((kind == Snapshot::kScript) && | 1091 if ((kind == Snapshot::kScript) && |
| 1092 RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) { | 1092 RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) { |
| 1093 ASSERT(kind != Snapshot::kFull); | 1093 ASSERT(kind != Snapshot::kFull); |
| 1094 // Write out library URL so that it can be looked up when reading. | 1094 // Write out library URL so that it can be looked up when reading. |
| 1095 writer->WriteObjectImpl(ptr()->url_); | 1095 writer->WriteObjectImpl(ptr()->url_, kAsInlinedObject); |
| 1096 } else { | 1096 } else { |
| 1097 // Write out all non object fields. | 1097 // Write out all non object fields. |
| 1098 writer->WriteClassIDValue(ptr()->index_); | 1098 writer->WriteClassIDValue(ptr()->index_); |
| 1099 writer->WriteClassIDValue(ptr()->num_anonymous_); | 1099 writer->WriteClassIDValue(ptr()->num_anonymous_); |
| 1100 writer->Write<uint16_t>(ptr()->num_imports_); | 1100 writer->Write<uint16_t>(ptr()->num_imports_); |
| 1101 writer->Write<int8_t>(ptr()->load_state_); | 1101 writer->Write<int8_t>(ptr()->load_state_); |
| 1102 writer->Write<bool>(ptr()->corelib_imported_); | 1102 writer->Write<bool>(ptr()->corelib_imported_); |
| 1103 writer->Write<bool>(ptr()->is_dart_scheme_); | 1103 writer->Write<bool>(ptr()->is_dart_scheme_); |
| 1104 writer->Write<bool>(ptr()->debuggable_); | 1104 writer->Write<bool>(ptr()->debuggable_); |
| 1105 // We do not serialize the native resolver or symbolizer. These need to be | 1105 // We do not serialize the native resolver or symbolizer. These need to be |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 reader->Read<int16_t>()); | 1137 reader->Read<int16_t>()); |
| 1138 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_, | 1138 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_, |
| 1139 reader->Read<bool>()); | 1139 reader->Read<bool>()); |
| 1140 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>()); | 1140 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>()); |
| 1141 | 1141 |
| 1142 // Set all the object fields. | 1142 // Set all the object fields. |
| 1143 // TODO(5411462): Need to assert No GC can happen here, even though | 1143 // TODO(5411462): Need to assert No GC can happen here, even though |
| 1144 // allocations may happen. | 1144 // allocations may happen. |
| 1145 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from()); | 1145 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from()); |
| 1146 for (intptr_t i = 0; i <= num_flds; i++) { | 1146 for (intptr_t i = 0; i <= num_flds; i++) { |
| 1147 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 1147 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 1148 prefix.StorePointer((prefix.raw()->from() + i), | 1148 prefix.StorePointer((prefix.raw()->from() + i), |
| 1149 reader->PassiveObjectHandle()->raw()); | 1149 reader->PassiveObjectHandle()->raw()); |
| 1150 } | 1150 } |
| 1151 | 1151 |
| 1152 return prefix.raw(); | 1152 return prefix.raw(); |
| 1153 } | 1153 } |
| 1154 | 1154 |
| 1155 | 1155 |
| 1156 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, | 1156 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, |
| 1157 intptr_t object_id, | 1157 intptr_t object_id, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 reader->AddBackRef(object_id, &ns, kIsDeserialized); | 1194 reader->AddBackRef(object_id, &ns, kIsDeserialized); |
| 1195 | 1195 |
| 1196 // Set the object tags. | 1196 // Set the object tags. |
| 1197 ns.set_tags(tags); | 1197 ns.set_tags(tags); |
| 1198 | 1198 |
| 1199 // Set all the object fields. | 1199 // Set all the object fields. |
| 1200 // TODO(5411462): Need to assert No GC can happen here, even though | 1200 // TODO(5411462): Need to assert No GC can happen here, even though |
| 1201 // allocations may happen. | 1201 // allocations may happen. |
| 1202 intptr_t num_flds = (ns.raw()->to() - ns.raw()->from()); | 1202 intptr_t num_flds = (ns.raw()->to() - ns.raw()->from()); |
| 1203 for (intptr_t i = 0; i <= num_flds; i++) { | 1203 for (intptr_t i = 0; i <= num_flds; i++) { |
| 1204 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 1204 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 1205 ns.StorePointer((ns.raw()->from() + i), | 1205 ns.StorePointer((ns.raw()->from() + i), |
| 1206 reader->PassiveObjectHandle()->raw()); | 1206 reader->PassiveObjectHandle()->raw()); |
| 1207 } | 1207 } |
| 1208 | 1208 |
| 1209 return ns.raw(); | 1209 return ns.raw(); |
| 1210 } | 1210 } |
| 1211 | 1211 |
| 1212 | 1212 |
| 1213 void RawNamespace::WriteTo(SnapshotWriter* writer, | 1213 void RawNamespace::WriteTo(SnapshotWriter* writer, |
| 1214 intptr_t object_id, | 1214 intptr_t object_id, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1383 | 1383 |
| 1384 LocalVarDescriptors& result = | 1384 LocalVarDescriptors& result = |
| 1385 LocalVarDescriptors::ZoneHandle(reader->zone(), | 1385 LocalVarDescriptors::ZoneHandle(reader->zone(), |
| 1386 LocalVarDescriptors::New(num_entries)); | 1386 LocalVarDescriptors::New(num_entries)); |
| 1387 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1387 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 1388 | 1388 |
| 1389 // Set the object tags. | 1389 // Set the object tags. |
| 1390 result.set_tags(tags); | 1390 result.set_tags(tags); |
| 1391 | 1391 |
| 1392 for (intptr_t i = 0; i < num_entries; i++) { | 1392 for (intptr_t i = 0; i < num_entries; i++) { |
| 1393 (*reader->StringHandle()) ^= reader->ReadObjectRef(); | 1393 (*reader->StringHandle()) ^= reader->ReadObjectImpl(kAsReference); |
| 1394 result.StorePointer(result.raw()->nameAddrAt(i), | 1394 result.StorePointer(result.raw()->nameAddrAt(i), |
| 1395 reader->StringHandle()->raw()); | 1395 reader->StringHandle()->raw()); |
| 1396 } | 1396 } |
| 1397 | 1397 |
| 1398 if (num_entries > 0) { | 1398 if (num_entries > 0) { |
| 1399 NoSafepointScope no_safepoint; | 1399 NoSafepointScope no_safepoint; |
| 1400 intptr_t len = num_entries * sizeof(RawLocalVarDescriptors::VarInfo); | 1400 intptr_t len = num_entries * sizeof(RawLocalVarDescriptors::VarInfo); |
| 1401 uint8_t* data = result.UnsafeMutableNonPointer( | 1401 uint8_t* data = result.UnsafeMutableNonPointer( |
| 1402 reinterpret_cast<const uint8_t*>(result.raw()->data())); | 1402 reinterpret_cast<const uint8_t*>(result.raw()->data())); |
| 1403 reader->ReadBytes(data, len); | 1403 reader->ReadBytes(data, len); |
| 1404 } | 1404 } |
| 1405 | 1405 |
| 1406 return result.raw(); | 1406 return result.raw(); |
| 1407 } | 1407 } |
| 1408 | 1408 |
| 1409 | 1409 |
| 1410 void RawLocalVarDescriptors::WriteTo(SnapshotWriter* writer, | 1410 void RawLocalVarDescriptors::WriteTo(SnapshotWriter* writer, |
| 1411 intptr_t object_id, | 1411 intptr_t object_id, |
| 1412 Snapshot::Kind kind) { | 1412 Snapshot::Kind kind) { |
| 1413 ASSERT(writer->allow_code()); | 1413 ASSERT(writer->allow_code()); |
| 1414 | 1414 |
| 1415 // Write out the serialization header value for this object. | 1415 // Write out the serialization header value for this object. |
| 1416 writer->WriteInlinedObjectHeader(object_id); | 1416 writer->WriteInlinedObjectHeader(object_id); |
| 1417 writer->WriteIndexedObject(kLocalVarDescriptorsCid); | 1417 writer->WriteIndexedObject(kLocalVarDescriptorsCid); |
| 1418 writer->WriteTags(writer->GetObjectTags(this)); | 1418 writer->WriteTags(writer->GetObjectTags(this)); |
| 1419 writer->Write<int32_t>(ptr()->num_entries_); | 1419 writer->Write<int32_t>(ptr()->num_entries_); |
| 1420 for (intptr_t i = 0; i < ptr()->num_entries_; i++) { | 1420 for (intptr_t i = 0; i < ptr()->num_entries_; i++) { |
| 1421 writer->WriteObjectImpl(ptr()->names()[i]); | 1421 writer->WriteObjectImpl(ptr()->names()[i], kAsInlinedObject); |
| 1422 } | 1422 } |
| 1423 if (ptr()->num_entries_ > 0) { | 1423 if (ptr()->num_entries_ > 0) { |
| 1424 intptr_t len = ptr()->num_entries_ * sizeof(VarInfo); | 1424 intptr_t len = ptr()->num_entries_ * sizeof(VarInfo); |
| 1425 uint8_t* data = reinterpret_cast<uint8_t*>(this->data()); | 1425 uint8_t* data = reinterpret_cast<uint8_t*>(this->data()); |
| 1426 writer->WriteBytes(data, len); | 1426 writer->WriteBytes(data, len); |
| 1427 } | 1427 } |
| 1428 } | 1428 } |
| 1429 | 1429 |
| 1430 | 1430 |
| 1431 RawExceptionHandlers* ExceptionHandlers::ReadFrom(SnapshotReader* reader, | 1431 RawExceptionHandlers* ExceptionHandlers::ReadFrom(SnapshotReader* reader, |
| 1432 intptr_t object_id, | 1432 intptr_t object_id, |
| 1433 intptr_t tags, | 1433 intptr_t tags, |
| 1434 Snapshot::Kind kind) { | 1434 Snapshot::Kind kind) { |
| 1435 ASSERT(reader->allow_code()); | 1435 ASSERT(reader->allow_code()); |
| 1436 | 1436 |
| 1437 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(); // handled_types_data_ | 1437 // handled_types_data. |
| 1438 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); |
| 1438 | 1439 |
| 1439 ExceptionHandlers& result = | 1440 ExceptionHandlers& result = |
| 1440 ExceptionHandlers::ZoneHandle(reader->zone(), | 1441 ExceptionHandlers::ZoneHandle(reader->zone(), |
| 1441 ExceptionHandlers::New(*reader->ArrayHandle())); | 1442 ExceptionHandlers::New(*reader->ArrayHandle())); |
| 1442 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1443 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 1443 | 1444 |
| 1444 // Set the object tags. | 1445 // Set the object tags. |
| 1445 result.set_tags(tags); | 1446 result.set_tags(tags); |
| 1446 | 1447 |
| 1447 if (result.num_entries() > 0) { | 1448 if (result.num_entries() > 0) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1459 | 1460 |
| 1460 void RawExceptionHandlers::WriteTo(SnapshotWriter* writer, | 1461 void RawExceptionHandlers::WriteTo(SnapshotWriter* writer, |
| 1461 intptr_t object_id, | 1462 intptr_t object_id, |
| 1462 Snapshot::Kind kind) { | 1463 Snapshot::Kind kind) { |
| 1463 ASSERT(writer->allow_code()); | 1464 ASSERT(writer->allow_code()); |
| 1464 | 1465 |
| 1465 // Write out the serialization header value for this object. | 1466 // Write out the serialization header value for this object. |
| 1466 writer->WriteInlinedObjectHeader(object_id); | 1467 writer->WriteInlinedObjectHeader(object_id); |
| 1467 writer->WriteIndexedObject(kExceptionHandlersCid); | 1468 writer->WriteIndexedObject(kExceptionHandlersCid); |
| 1468 writer->WriteTags(writer->GetObjectTags(this)); | 1469 writer->WriteTags(writer->GetObjectTags(this)); |
| 1469 writer->WriteObjectImpl(ptr()->handled_types_data_); | 1470 writer->WriteObjectImpl(ptr()->handled_types_data_, kAsInlinedObject); |
| 1470 | 1471 |
| 1471 if (ptr()->num_entries_ > 0) { | 1472 if (ptr()->num_entries_ > 0) { |
| 1472 intptr_t len = ptr()->num_entries_ * sizeof(HandlerInfo); | 1473 intptr_t len = ptr()->num_entries_ * sizeof(HandlerInfo); |
| 1473 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); | 1474 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); |
| 1474 writer->WriteBytes(data, len); | 1475 writer->WriteBytes(data, len); |
| 1475 } | 1476 } |
| 1476 } | 1477 } |
| 1477 | 1478 |
| 1478 | 1479 |
| 1479 RawContext* Context::ReadFrom(SnapshotReader* reader, | 1480 RawContext* Context::ReadFrom(SnapshotReader* reader, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1492 context ^= NEW_OBJECT_WITH_LEN(Context, num_vars); | 1493 context ^= NEW_OBJECT_WITH_LEN(Context, num_vars); |
| 1493 | 1494 |
| 1494 // Set the object tags. | 1495 // Set the object tags. |
| 1495 context.set_tags(tags); | 1496 context.set_tags(tags); |
| 1496 | 1497 |
| 1497 // Set all the object fields. | 1498 // Set all the object fields. |
| 1498 // TODO(5411462): Need to assert No GC can happen here, even though | 1499 // TODO(5411462): Need to assert No GC can happen here, even though |
| 1499 // allocations may happen. | 1500 // allocations may happen. |
| 1500 intptr_t num_flds = (context.raw()->to(num_vars) - context.raw()->from()); | 1501 intptr_t num_flds = (context.raw()->to(num_vars) - context.raw()->from()); |
| 1501 for (intptr_t i = 0; i <= num_flds; i++) { | 1502 for (intptr_t i = 0; i <= num_flds; i++) { |
| 1502 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 1503 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 1503 context.StorePointer((context.raw()->from() + i), | 1504 context.StorePointer((context.raw()->from() + i), |
| 1504 reader->PassiveObjectHandle()->raw()); | 1505 reader->PassiveObjectHandle()->raw()); |
| 1505 } | 1506 } |
| 1506 } | 1507 } |
| 1507 return context.raw(); | 1508 return context.raw(); |
| 1508 } | 1509 } |
| 1509 | 1510 |
| 1510 | 1511 |
| 1511 void RawContext::WriteTo(SnapshotWriter* writer, | 1512 void RawContext::WriteTo(SnapshotWriter* writer, |
| 1512 intptr_t object_id, | 1513 intptr_t object_id, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 reader->AddBackRef(object_id, &api_error, kIsDeserialized); | 1624 reader->AddBackRef(object_id, &api_error, kIsDeserialized); |
| 1624 | 1625 |
| 1625 // Set the object tags. | 1626 // Set the object tags. |
| 1626 api_error.set_tags(tags); | 1627 api_error.set_tags(tags); |
| 1627 | 1628 |
| 1628 // Set all the object fields. | 1629 // Set all the object fields. |
| 1629 // TODO(5411462): Need to assert No GC can happen here, even though | 1630 // TODO(5411462): Need to assert No GC can happen here, even though |
| 1630 // allocations may happen. | 1631 // allocations may happen. |
| 1631 intptr_t num_flds = (api_error.raw()->to() - api_error.raw()->from()); | 1632 intptr_t num_flds = (api_error.raw()->to() - api_error.raw()->from()); |
| 1632 for (intptr_t i = 0; i <= num_flds; i++) { | 1633 for (intptr_t i = 0; i <= num_flds; i++) { |
| 1633 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 1634 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 1634 api_error.StorePointer((api_error.raw()->from() + i), | 1635 api_error.StorePointer((api_error.raw()->from() + i), |
| 1635 reader->PassiveObjectHandle()->raw()); | 1636 reader->PassiveObjectHandle()->raw()); |
| 1636 } | 1637 } |
| 1637 | 1638 |
| 1638 return api_error.raw(); | 1639 return api_error.raw(); |
| 1639 } | 1640 } |
| 1640 | 1641 |
| 1641 | 1642 |
| 1642 void RawApiError::WriteTo(SnapshotWriter* writer, | 1643 void RawApiError::WriteTo(SnapshotWriter* writer, |
| 1643 intptr_t object_id, | 1644 intptr_t object_id, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1674 // Set all non object fields. | 1675 // Set all non object fields. |
| 1675 language_error.set_token_pos(reader->Read<int32_t>()); | 1676 language_error.set_token_pos(reader->Read<int32_t>()); |
| 1676 language_error.set_kind(reader->Read<uint8_t>()); | 1677 language_error.set_kind(reader->Read<uint8_t>()); |
| 1677 | 1678 |
| 1678 // Set all the object fields. | 1679 // Set all the object fields. |
| 1679 // TODO(5411462): Need to assert No GC can happen here, even though | 1680 // TODO(5411462): Need to assert No GC can happen here, even though |
| 1680 // allocations may happen. | 1681 // allocations may happen. |
| 1681 intptr_t num_flds = | 1682 intptr_t num_flds = |
| 1682 (language_error.raw()->to() - language_error.raw()->from()); | 1683 (language_error.raw()->to() - language_error.raw()->from()); |
| 1683 for (intptr_t i = 0; i <= num_flds; i++) { | 1684 for (intptr_t i = 0; i <= num_flds; i++) { |
| 1684 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 1685 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 1685 language_error.StorePointer((language_error.raw()->from() + i), | 1686 language_error.StorePointer((language_error.raw()->from() + i), |
| 1686 reader->PassiveObjectHandle()->raw()); | 1687 reader->PassiveObjectHandle()->raw()); |
| 1687 } | 1688 } |
| 1688 | 1689 |
| 1689 return language_error.raw(); | 1690 return language_error.raw(); |
| 1690 } | 1691 } |
| 1691 | 1692 |
| 1692 | 1693 |
| 1693 void RawLanguageError::WriteTo(SnapshotWriter* writer, | 1694 void RawLanguageError::WriteTo(SnapshotWriter* writer, |
| 1694 intptr_t object_id, | 1695 intptr_t object_id, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1721 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1722 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 1722 | 1723 |
| 1723 // Set the object tags. | 1724 // Set the object tags. |
| 1724 result.set_tags(tags); | 1725 result.set_tags(tags); |
| 1725 | 1726 |
| 1726 // Set all the object fields. | 1727 // Set all the object fields. |
| 1727 // TODO(5411462): Need to assert No GC can happen here, even though | 1728 // TODO(5411462): Need to assert No GC can happen here, even though |
| 1728 // allocations may happen. | 1729 // allocations may happen. |
| 1729 intptr_t num_flds = (result.raw()->to() - result.raw()->from()); | 1730 intptr_t num_flds = (result.raw()->to() - result.raw()->from()); |
| 1730 for (intptr_t i = 0; i <= num_flds; i++) { | 1731 for (intptr_t i = 0; i <= num_flds; i++) { |
| 1731 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 1732 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 1732 result.StorePointer((result.raw()->from() + i), | 1733 result.StorePointer((result.raw()->from() + i), |
| 1733 reader->PassiveObjectHandle()->raw()); | 1734 reader->PassiveObjectHandle()->raw()); |
| 1734 } | 1735 } |
| 1735 | 1736 |
| 1736 return result.raw(); | 1737 return result.raw(); |
| 1737 } | 1738 } |
| 1738 | 1739 |
| 1739 | 1740 |
| 1740 void RawUnhandledException::WriteTo(SnapshotWriter* writer, | 1741 void RawUnhandledException::WriteTo(SnapshotWriter* writer, |
| 1741 intptr_t object_id, | 1742 intptr_t object_id, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1887 | 1888 |
| 1888 // Allocate bigint object. | 1889 // Allocate bigint object. |
| 1889 Bigint& obj = Bigint::ZoneHandle(reader->zone(), NEW_OBJECT(Bigint)); | 1890 Bigint& obj = Bigint::ZoneHandle(reader->zone(), NEW_OBJECT(Bigint)); |
| 1890 reader->AddBackRef(object_id, &obj, kIsDeserialized); | 1891 reader->AddBackRef(object_id, &obj, kIsDeserialized); |
| 1891 | 1892 |
| 1892 // Set all the object fields. | 1893 // Set all the object fields. |
| 1893 // TODO(5411462): Need to assert No GC can happen here, even though | 1894 // TODO(5411462): Need to assert No GC can happen here, even though |
| 1894 // allocations may happen. | 1895 // allocations may happen. |
| 1895 intptr_t num_flds = (obj.raw()->to() - obj.raw()->from()); | 1896 intptr_t num_flds = (obj.raw()->to() - obj.raw()->from()); |
| 1896 for (intptr_t i = 0; i <= num_flds; i++) { | 1897 for (intptr_t i = 0; i <= num_flds; i++) { |
| 1897 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(); | 1898 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsInlinedObject); |
| 1898 obj.StorePointer(obj.raw()->from() + i, | 1899 obj.StorePointer(obj.raw()->from() + i, |
| 1899 reader->PassiveObjectHandle()->raw()); | 1900 reader->PassiveObjectHandle()->raw()); |
| 1900 } | 1901 } |
| 1901 | 1902 |
| 1902 // If it is a canonical constant make it one. | 1903 // If it is a canonical constant make it one. |
| 1903 // When reading a full snapshot we don't need to canonicalize the object | 1904 // When reading a full snapshot we don't need to canonicalize the object |
| 1904 // as it would already be a canonical object. | 1905 // as it would already be a canonical object. |
| 1905 // When reading a script snapshot we need to canonicalize only those object | 1906 // When reading a script snapshot we need to canonicalize only those object |
| 1906 // references that are objects from the core library (loaded from a | 1907 // references that are objects from the core library (loaded from a |
| 1907 // full snapshot). Objects that are only in the script need not be | 1908 // full snapshot). Objects that are only in the script need not be |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2323 GrowableObjectArray& array = GrowableObjectArray::ZoneHandle( | 2324 GrowableObjectArray& array = GrowableObjectArray::ZoneHandle( |
| 2324 reader->zone(), GrowableObjectArray::null()); | 2325 reader->zone(), GrowableObjectArray::null()); |
| 2325 if (kind == Snapshot::kFull) { | 2326 if (kind == Snapshot::kFull) { |
| 2326 array = reader->NewGrowableObjectArray(); | 2327 array = reader->NewGrowableObjectArray(); |
| 2327 } else { | 2328 } else { |
| 2328 array = GrowableObjectArray::New(0, HEAP_SPACE(kind)); | 2329 array = GrowableObjectArray::New(0, HEAP_SPACE(kind)); |
| 2329 } | 2330 } |
| 2330 reader->AddBackRef(object_id, &array, kIsDeserialized); | 2331 reader->AddBackRef(object_id, &array, kIsDeserialized); |
| 2331 intptr_t length = reader->ReadSmiValue(); | 2332 intptr_t length = reader->ReadSmiValue(); |
| 2332 array.SetLength(length); | 2333 array.SetLength(length); |
| 2333 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(); | 2334 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); |
| 2334 array.SetData(*(reader->ArrayHandle())); | 2335 array.SetData(*(reader->ArrayHandle())); |
| 2335 *(reader->TypeArgumentsHandle()) = reader->ArrayHandle()->GetTypeArguments(); | 2336 *(reader->TypeArgumentsHandle()) = reader->ArrayHandle()->GetTypeArguments(); |
| 2336 array.SetTypeArguments(*(reader->TypeArgumentsHandle())); | 2337 array.SetTypeArguments(*(reader->TypeArgumentsHandle())); |
| 2337 return array.raw(); | 2338 return array.raw(); |
| 2338 } | 2339 } |
| 2339 | 2340 |
| 2340 | 2341 |
| 2341 void RawGrowableObjectArray::WriteTo(SnapshotWriter* writer, | 2342 void RawGrowableObjectArray::WriteTo(SnapshotWriter* writer, |
| 2342 intptr_t object_id, | 2343 intptr_t object_id, |
| 2343 Snapshot::Kind kind) { | 2344 Snapshot::Kind kind) { |
| 2344 ASSERT(writer != NULL); | 2345 ASSERT(writer != NULL); |
| 2345 | 2346 |
| 2346 // Write out the serialization header value for this object. | 2347 // Write out the serialization header value for this object. |
| 2347 writer->WriteInlinedObjectHeader(object_id); | 2348 writer->WriteInlinedObjectHeader(object_id); |
| 2348 | 2349 |
| 2349 // Write out the class and tags information. | 2350 // Write out the class and tags information. |
| 2350 writer->WriteIndexedObject(kGrowableObjectArrayCid); | 2351 writer->WriteIndexedObject(kGrowableObjectArrayCid); |
| 2351 writer->WriteTags(writer->GetObjectTags(this)); | 2352 writer->WriteTags(writer->GetObjectTags(this)); |
| 2352 | 2353 |
| 2353 // Write out the used length field. | 2354 // Write out the used length field. |
| 2354 writer->Write<RawObject*>(ptr()->length_); | 2355 writer->Write<RawObject*>(ptr()->length_); |
| 2355 | 2356 |
| 2356 // Write out the Array object. | 2357 // Write out the Array object. |
| 2357 writer->WriteObjectImpl(ptr()->data_); | 2358 writer->WriteObjectImpl(ptr()->data_, kAsInlinedObject); |
| 2358 } | 2359 } |
| 2359 | 2360 |
| 2360 | 2361 |
| 2361 RawLinkedHashMap* LinkedHashMap::ReadFrom(SnapshotReader* reader, | 2362 RawLinkedHashMap* LinkedHashMap::ReadFrom(SnapshotReader* reader, |
| 2362 intptr_t object_id, | 2363 intptr_t object_id, |
| 2363 intptr_t tags, | 2364 intptr_t tags, |
| 2364 Snapshot::Kind kind) { | 2365 Snapshot::Kind kind) { |
| 2365 ASSERT(reader != NULL); | 2366 ASSERT(reader != NULL); |
| 2366 | 2367 |
| 2367 LinkedHashMap& map = LinkedHashMap::ZoneHandle( | 2368 LinkedHashMap& map = LinkedHashMap::ZoneHandle( |
| 2368 reader->zone(), LinkedHashMap::null()); | 2369 reader->zone(), LinkedHashMap::null()); |
| 2369 if (kind == Snapshot::kFull || kind == Snapshot::kScript) { | 2370 if (kind == Snapshot::kFull || kind == Snapshot::kScript) { |
| 2370 // The immutable maps that seed map literals are not yet VM-internal, so | 2371 // The immutable maps that seed map literals are not yet VM-internal, so |
| 2371 // we don't reach this. | 2372 // we don't reach this. |
| 2372 UNREACHABLE(); | 2373 UNREACHABLE(); |
| 2373 } else { | 2374 } else { |
| 2374 // Since the map might contain itself as a key or value, allocate first. | 2375 // Since the map might contain itself as a key or value, allocate first. |
| 2375 map = LinkedHashMap::NewUninitialized(HEAP_SPACE(kind)); | 2376 map = LinkedHashMap::NewUninitialized(HEAP_SPACE(kind)); |
| 2376 } | 2377 } |
| 2377 reader->AddBackRef(object_id, &map, kIsDeserialized); | 2378 reader->AddBackRef(object_id, &map, kIsDeserialized); |
| 2378 // Set the object tags. | 2379 // Set the object tags. |
| 2379 map.set_tags(tags); | 2380 map.set_tags(tags); |
| 2380 | 2381 |
| 2381 // Read the type arguments. | 2382 // Read the type arguments. |
| 2382 *reader->TypeArgumentsHandle() ^= reader->ReadObjectImpl(); | 2383 *reader->TypeArgumentsHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); |
| 2383 map.SetTypeArguments(*reader->TypeArgumentsHandle()); | 2384 map.SetTypeArguments(*reader->TypeArgumentsHandle()); |
| 2384 | 2385 |
| 2385 // Read the number of key/value pairs. | 2386 // Read the number of key/value pairs. |
| 2386 intptr_t len = reader->ReadSmiValue(); | 2387 intptr_t len = reader->ReadSmiValue(); |
| 2387 intptr_t used_data = (len << 1); | 2388 intptr_t used_data = (len << 1); |
| 2388 map.SetUsedData(used_data); | 2389 map.SetUsedData(used_data); |
| 2389 | 2390 |
| 2390 // Allocate the data array. | 2391 // Allocate the data array. |
| 2391 intptr_t data_size = Utils::Maximum( | 2392 intptr_t data_size = Utils::Maximum( |
| 2392 Utils::RoundUpToPowerOfTwo(used_data), | 2393 Utils::RoundUpToPowerOfTwo(used_data), |
| 2393 static_cast<uintptr_t>(LinkedHashMap::kInitialIndexSize)); | 2394 static_cast<uintptr_t>(LinkedHashMap::kInitialIndexSize)); |
| 2394 Array& data = Array::ZoneHandle(reader->zone(), | 2395 Array& data = Array::ZoneHandle(reader->zone(), |
| 2395 Array::New(data_size, HEAP_SPACE(kind))); | 2396 Array::New(data_size, HEAP_SPACE(kind))); |
| 2396 map.SetData(data); | 2397 map.SetData(data); |
| 2397 map.SetDeletedKeys(0); | 2398 map.SetDeletedKeys(0); |
| 2398 | 2399 |
| 2399 // The index and hashMask is regenerated by the maps themselves on demand. | 2400 // The index and hashMask is regenerated by the maps themselves on demand. |
| 2400 // Thus, the index will probably be allocated in new space (unless it's huge). | 2401 // Thus, the index will probably be allocated in new space (unless it's huge). |
| 2401 // TODO(koda): Eagerly rehash here when no keys have user-defined '==', and | 2402 // TODO(koda): Eagerly rehash here when no keys have user-defined '==', and |
| 2402 // in particular, if/when (const) maps are needed in the VM isolate snapshot. | 2403 // in particular, if/when (const) maps are needed in the VM isolate snapshot. |
| 2403 ASSERT(reader->isolate() != Dart::vm_isolate()); | 2404 ASSERT(reader->isolate() != Dart::vm_isolate()); |
| 2404 map.SetHashMask(0); // Prefer sentinel 0 over null for better type feedback. | 2405 map.SetHashMask(0); // Prefer sentinel 0 over null for better type feedback. |
| 2405 | 2406 |
| 2406 // Read the keys and values. | 2407 // Read the keys and values. |
| 2407 bool is_canonical = RawObject::IsCanonical(tags); | 2408 bool as_reference = RawObject::IsCanonical(tags) ? false : true; |
| 2408 for (intptr_t i = 0; i < used_data; i++) { | 2409 for (intptr_t i = 0; i < used_data; i++) { |
| 2409 *reader->PassiveObjectHandle() = | 2410 *reader->PassiveObjectHandle() = reader->ReadObjectImpl(as_reference); |
| 2410 is_canonical ? reader->ReadObjectImpl() : reader->ReadObjectRef(); | |
| 2411 data.SetAt(i, *reader->PassiveObjectHandle()); | 2411 data.SetAt(i, *reader->PassiveObjectHandle()); |
| 2412 } | 2412 } |
| 2413 return map.raw(); | 2413 return map.raw(); |
| 2414 } | 2414 } |
| 2415 | 2415 |
| 2416 | 2416 |
| 2417 void RawLinkedHashMap::WriteTo(SnapshotWriter* writer, | 2417 void RawLinkedHashMap::WriteTo(SnapshotWriter* writer, |
| 2418 intptr_t object_id, | 2418 intptr_t object_id, |
| 2419 Snapshot::Kind kind) { | 2419 Snapshot::Kind kind) { |
| 2420 if (kind == Snapshot::kFull || kind == Snapshot::kScript) { | 2420 if (kind == Snapshot::kFull || kind == Snapshot::kScript) { |
| 2421 // The immutable maps that seed map literals are not yet VM-internal, so | 2421 // The immutable maps that seed map literals are not yet VM-internal, so |
| 2422 // we don't reach this. | 2422 // we don't reach this. |
| 2423 UNREACHABLE(); | 2423 UNREACHABLE(); |
| 2424 } | 2424 } |
| 2425 ASSERT(writer != NULL); | 2425 ASSERT(writer != NULL); |
| 2426 | 2426 |
| 2427 // Write out the serialization header value for this object. | 2427 // Write out the serialization header value for this object. |
| 2428 writer->WriteInlinedObjectHeader(object_id); | 2428 writer->WriteInlinedObjectHeader(object_id); |
| 2429 | 2429 |
| 2430 // Write out the class and tags information. | 2430 // Write out the class and tags information. |
| 2431 writer->WriteIndexedObject(kLinkedHashMapCid); | 2431 writer->WriteIndexedObject(kLinkedHashMapCid); |
| 2432 const uword tags = writer->GetObjectTags(this); | 2432 const uword tags = writer->GetObjectTags(this); |
| 2433 writer->WriteTags(tags); | 2433 writer->WriteTags(tags); |
| 2434 | 2434 |
| 2435 // Write out the type arguments. | 2435 // Write out the type arguments. |
| 2436 writer->WriteObjectImpl(ptr()->type_arguments_); | 2436 writer->WriteObjectImpl(ptr()->type_arguments_, kAsInlinedObject); |
| 2437 | 2437 |
| 2438 const intptr_t used_data = Smi::Value(ptr()->used_data_); | 2438 const intptr_t used_data = Smi::Value(ptr()->used_data_); |
| 2439 ASSERT((used_data & 1) == 0); // Keys + values, so must be even. | 2439 ASSERT((used_data & 1) == 0); // Keys + values, so must be even. |
| 2440 const intptr_t deleted_keys = Smi::Value(ptr()->deleted_keys_); | 2440 const intptr_t deleted_keys = Smi::Value(ptr()->deleted_keys_); |
| 2441 | 2441 |
| 2442 // Write out the number of (not deleted) key/value pairs that will follow. | 2442 // Write out the number of (not deleted) key/value pairs that will follow. |
| 2443 writer->Write<RawObject*>(Smi::New((used_data >> 1) - deleted_keys)); | 2443 writer->Write<RawObject*>(Smi::New((used_data >> 1) - deleted_keys)); |
| 2444 | 2444 |
| 2445 // Write out the keys and values. | 2445 // Write out the keys and values. |
| 2446 const bool is_canonical = RawObject::IsCanonical(tags); | 2446 const bool as_reference = RawObject::IsCanonical(tags) ? false : true; |
| 2447 RawArray* data_array = ptr()->data_; | 2447 RawArray* data_array = ptr()->data_; |
| 2448 RawObject** data_elements = data_array->ptr()->data(); | 2448 RawObject** data_elements = data_array->ptr()->data(); |
| 2449 ASSERT(used_data <= Smi::Value(data_array->ptr()->length_)); | 2449 ASSERT(used_data <= Smi::Value(data_array->ptr()->length_)); |
| 2450 #if defined(DEBUG) | 2450 #if defined(DEBUG) |
| 2451 intptr_t deleted_keys_found = 0; | 2451 intptr_t deleted_keys_found = 0; |
| 2452 #endif // DEBUG | 2452 #endif // DEBUG |
| 2453 for (intptr_t i = 0; i < used_data; i += 2) { | 2453 for (intptr_t i = 0; i < used_data; i += 2) { |
| 2454 RawObject* key = data_elements[i]; | 2454 RawObject* key = data_elements[i]; |
| 2455 if (key == data_array) { | 2455 if (key == data_array) { |
| 2456 #if defined(DEBUG) | 2456 #if defined(DEBUG) |
| 2457 ++deleted_keys_found; | 2457 ++deleted_keys_found; |
| 2458 #endif // DEBUG | 2458 #endif // DEBUG |
| 2459 continue; | 2459 continue; |
| 2460 } | 2460 } |
| 2461 RawObject* value = data_elements[i + 1]; | 2461 RawObject* value = data_elements[i + 1]; |
| 2462 if (is_canonical) { | 2462 writer->WriteObjectImpl(key, as_reference); |
| 2463 writer->WriteObjectImpl(key); | 2463 writer->WriteObjectImpl(value, as_reference); |
| 2464 writer->WriteObjectImpl(value); | |
| 2465 } else { | |
| 2466 writer->WriteObjectRef(key); | |
| 2467 writer->WriteObjectRef(value); | |
| 2468 } | |
| 2469 } | 2464 } |
| 2470 DEBUG_ASSERT(deleted_keys_found == deleted_keys); | 2465 DEBUG_ASSERT(deleted_keys_found == deleted_keys); |
| 2471 } | 2466 } |
| 2472 | 2467 |
| 2473 | 2468 |
| 2474 RawFloat32x4* Float32x4::ReadFrom(SnapshotReader* reader, | 2469 RawFloat32x4* Float32x4::ReadFrom(SnapshotReader* reader, |
| 2475 intptr_t object_id, | 2470 intptr_t object_id, |
| 2476 intptr_t tags, | 2471 intptr_t tags, |
| 2477 Snapshot::Kind kind) { | 2472 Snapshot::Kind kind) { |
| 2478 ASSERT(reader != NULL); | 2473 ASSERT(reader != NULL); |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2911 if (kind == Snapshot::kFull) { | 2906 if (kind == Snapshot::kFull) { |
| 2912 Stacktrace& result = Stacktrace::ZoneHandle(reader->zone(), | 2907 Stacktrace& result = Stacktrace::ZoneHandle(reader->zone(), |
| 2913 reader->NewStacktrace()); | 2908 reader->NewStacktrace()); |
| 2914 reader->AddBackRef(object_id, &result, kIsDeserialized); | 2909 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 2915 | 2910 |
| 2916 // Set all the object fields. | 2911 // Set all the object fields. |
| 2917 // TODO(5411462): Need to assert No GC can happen here, even though | 2912 // TODO(5411462): Need to assert No GC can happen here, even though |
| 2918 // allocations may happen. | 2913 // allocations may happen. |
| 2919 intptr_t num_flds = (result.raw()->to() - result.raw()->from()); | 2914 intptr_t num_flds = (result.raw()->to() - result.raw()->from()); |
| 2920 for (intptr_t i = 0; i <= num_flds; i++) { | 2915 for (intptr_t i = 0; i <= num_flds; i++) { |
| 2921 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 2916 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 2922 result.StorePointer((result.raw()->from() + i), | 2917 result.StorePointer((result.raw()->from() + i), |
| 2923 reader->PassiveObjectHandle()->raw()); | 2918 reader->PassiveObjectHandle()->raw()); |
| 2924 } | 2919 } |
| 2925 | 2920 |
| 2926 bool expand_inlined = reader->Read<bool>(); | 2921 bool expand_inlined = reader->Read<bool>(); |
| 2927 result.set_expand_inlined(expand_inlined); | 2922 result.set_expand_inlined(expand_inlined); |
| 2928 | 2923 |
| 2929 return result.raw(); | 2924 return result.raw(); |
| 2930 } | 2925 } |
| 2931 UNREACHABLE(); // Stacktraces are not sent in a snapshot. | 2926 UNREACHABLE(); // Stacktraces are not sent in a snapshot. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2973 JSRegExp& regex = JSRegExp::ZoneHandle( | 2968 JSRegExp& regex = JSRegExp::ZoneHandle( |
| 2974 reader->zone(), JSRegExp::New(HEAP_SPACE(kind))); | 2969 reader->zone(), JSRegExp::New(HEAP_SPACE(kind))); |
| 2975 reader->AddBackRef(object_id, ®ex, kIsDeserialized); | 2970 reader->AddBackRef(object_id, ®ex, kIsDeserialized); |
| 2976 | 2971 |
| 2977 // Set the object tags. | 2972 // Set the object tags. |
| 2978 regex.set_tags(tags); | 2973 regex.set_tags(tags); |
| 2979 | 2974 |
| 2980 // Read and Set all the other fields. | 2975 // Read and Set all the other fields. |
| 2981 regex.StoreSmi(®ex.raw_ptr()->num_bracket_expressions_, | 2976 regex.StoreSmi(®ex.raw_ptr()->num_bracket_expressions_, |
| 2982 reader->ReadAsSmi()); | 2977 reader->ReadAsSmi()); |
| 2983 *reader->StringHandle() ^= reader->ReadObjectImpl(); | 2978 *reader->StringHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); |
| 2984 regex.set_pattern(*reader->StringHandle()); | 2979 regex.set_pattern(*reader->StringHandle()); |
| 2985 regex.StoreNonPointer(®ex.raw_ptr()->num_registers_, | 2980 regex.StoreNonPointer(®ex.raw_ptr()->num_registers_, |
| 2986 reader->Read<int32_t>()); | 2981 reader->Read<int32_t>()); |
| 2987 regex.StoreNonPointer(®ex.raw_ptr()->type_flags_, | 2982 regex.StoreNonPointer(®ex.raw_ptr()->type_flags_, |
| 2988 reader->Read<int8_t>()); | 2983 reader->Read<int8_t>()); |
| 2989 | 2984 |
| 2990 // TODO(18854): Need to implement a way of recreating the irrexp functions. | 2985 // TODO(18854): Need to implement a way of recreating the irrexp functions. |
| 2991 return regex.raw(); | 2986 return regex.raw(); |
| 2992 } | 2987 } |
| 2993 | 2988 |
| 2994 | 2989 |
| 2995 void RawJSRegExp::WriteTo(SnapshotWriter* writer, | 2990 void RawJSRegExp::WriteTo(SnapshotWriter* writer, |
| 2996 intptr_t object_id, | 2991 intptr_t object_id, |
| 2997 Snapshot::Kind kind) { | 2992 Snapshot::Kind kind) { |
| 2998 ASSERT(writer != NULL); | 2993 ASSERT(writer != NULL); |
| 2999 ASSERT(kind == Snapshot::kMessage); | 2994 ASSERT(kind == Snapshot::kMessage); |
| 3000 | 2995 |
| 3001 // Write out the serialization header value for this object. | 2996 // Write out the serialization header value for this object. |
| 3002 writer->WriteInlinedObjectHeader(object_id); | 2997 writer->WriteInlinedObjectHeader(object_id); |
| 3003 | 2998 |
| 3004 // Write out the class and tags information. | 2999 // Write out the class and tags information. |
| 3005 writer->WriteIndexedObject(kJSRegExpCid); | 3000 writer->WriteIndexedObject(kJSRegExpCid); |
| 3006 writer->WriteTags(writer->GetObjectTags(this)); | 3001 writer->WriteTags(writer->GetObjectTags(this)); |
| 3007 | 3002 |
| 3008 // Write out all the other fields. | 3003 // Write out all the other fields. |
| 3009 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); | 3004 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); |
| 3010 writer->WriteObjectImpl(ptr()->pattern_); | 3005 writer->WriteObjectImpl(ptr()->pattern_, kAsInlinedObject); |
| 3011 writer->Write<int32_t>(ptr()->num_registers_); | 3006 writer->Write<int32_t>(ptr()->num_registers_); |
| 3012 writer->Write<int8_t>(ptr()->type_flags_); | 3007 writer->Write<int8_t>(ptr()->type_flags_); |
| 3013 } | 3008 } |
| 3014 | 3009 |
| 3015 | 3010 |
| 3016 RawWeakProperty* WeakProperty::ReadFrom(SnapshotReader* reader, | 3011 RawWeakProperty* WeakProperty::ReadFrom(SnapshotReader* reader, |
| 3017 intptr_t object_id, | 3012 intptr_t object_id, |
| 3018 intptr_t tags, | 3013 intptr_t tags, |
| 3019 Snapshot::Kind kind) { | 3014 Snapshot::Kind kind) { |
| 3020 ASSERT(reader != NULL); | 3015 ASSERT(reader != NULL); |
| 3021 | 3016 |
| 3022 // Allocate the weak property object. | 3017 // Allocate the weak property object. |
| 3023 WeakProperty& weak_property = WeakProperty::ZoneHandle( | 3018 WeakProperty& weak_property = WeakProperty::ZoneHandle( |
| 3024 reader->zone(), WeakProperty::New(HEAP_SPACE(kind))); | 3019 reader->zone(), WeakProperty::New(HEAP_SPACE(kind))); |
| 3025 reader->AddBackRef(object_id, &weak_property, kIsDeserialized); | 3020 reader->AddBackRef(object_id, &weak_property, kIsDeserialized); |
| 3026 | 3021 |
| 3027 // Set the object tags. | 3022 // Set the object tags. |
| 3028 weak_property.set_tags(tags); | 3023 weak_property.set_tags(tags); |
| 3029 | 3024 |
| 3030 // Set all the object fields. | 3025 // Set all the object fields. |
| 3031 // TODO(5411462): Need to assert No GC can happen here, even though | 3026 // TODO(5411462): Need to assert No GC can happen here, even though |
| 3032 // allocations may happen. | 3027 // allocations may happen. |
| 3033 intptr_t num_flds = (weak_property.raw()->to() - | 3028 intptr_t num_flds = (weak_property.raw()->to() - |
| 3034 weak_property.raw()->from()); | 3029 weak_property.raw()->from()); |
| 3035 for (intptr_t i = 0; i <= num_flds; i++) { | 3030 for (intptr_t i = 0; i <= num_flds; i++) { |
| 3036 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | 3031 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 3037 weak_property.StorePointer((weak_property.raw()->from() + i), | 3032 weak_property.StorePointer((weak_property.raw()->from() + i), |
| 3038 reader->PassiveObjectHandle()->raw()); | 3033 reader->PassiveObjectHandle()->raw()); |
| 3039 } | 3034 } |
| 3040 | 3035 |
| 3041 return weak_property.raw(); | 3036 return weak_property.raw(); |
| 3042 } | 3037 } |
| 3043 | 3038 |
| 3044 | 3039 |
| 3045 void RawWeakProperty::WriteTo(SnapshotWriter* writer, | 3040 void RawWeakProperty::WriteTo(SnapshotWriter* writer, |
| 3046 intptr_t object_id, | 3041 intptr_t object_id, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3099 // We do not allow objects with native fields in an isolate message. | 3094 // We do not allow objects with native fields in an isolate message. |
| 3100 writer->SetWriteException(Exceptions::kArgument, | 3095 writer->SetWriteException(Exceptions::kArgument, |
| 3101 "Illegal argument in isolate message" | 3096 "Illegal argument in isolate message" |
| 3102 " : (object is a UserTag)"); | 3097 " : (object is a UserTag)"); |
| 3103 } else { | 3098 } else { |
| 3104 UNREACHABLE(); | 3099 UNREACHABLE(); |
| 3105 } | 3100 } |
| 3106 } | 3101 } |
| 3107 | 3102 |
| 3108 } // namespace dart | 3103 } // namespace dart |
| OLD | NEW |