| 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" |
| 11 #include "vm/visitor.h" | 11 #include "vm/visitor.h" |
| 12 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 DECLARE_FLAG(bool, remove_script_timestamps_for_test); | 15 DECLARE_FLAG(bool, remove_script_timestamps_for_test); |
| 16 | 16 |
| 17 #define OFFSET_OF_FROM(obj) \ | 17 #define OFFSET_OF_FROM(obj) \ |
| 18 obj.raw()->from() - reinterpret_cast<RawObject**>(obj.raw()->ptr()) | 18 obj.raw()->from() - reinterpret_cast<RawObject**>(obj.raw()->ptr()) |
| 19 | 19 |
| 20 // TODO(18854): Need to assert No GC can happen here, even though | 20 // TODO(18854): Need to assert No GC can happen here, even though |
| 21 // allocations may happen. | 21 // allocations may happen. |
| 22 #define READ_OBJECT_FIELDS(object, from, to, as_reference) \ | 22 #define READ_OBJECT_FIELDS(object, from, to, as_reference) \ |
| 23 intptr_t num_flds = (to) - (from); \ | 23 intptr_t num_flds = (to) - (from); \ |
| 24 intptr_t from_offset = OFFSET_OF_FROM(object); \ | 24 intptr_t from_offset = OFFSET_OF_FROM(object); \ |
| 25 for (intptr_t i = 0; i <= num_flds; i++) { \ | 25 for (intptr_t i = 0; i <= num_flds; i++) { \ |
| 26 (*reader->PassiveObjectHandle()) = \ | 26 (*reader->PassiveObjectHandle()) = \ |
| 27 reader->ReadObjectImpl(as_reference, object_id, (i + from_offset)); \ | 27 reader->ReadObjectImpl(as_reference, object_id, (i + from_offset)); \ |
| 28 object.StorePointer(((from) + i), \ | 28 object.StorePointer(((from) + i), reader->PassiveObjectHandle()->raw()); \ |
| 29 reader->PassiveObjectHandle()->raw()); \ | |
| 30 } | 29 } |
| 31 | 30 |
| 32 RawClass* Class::ReadFrom(SnapshotReader* reader, | 31 RawClass* Class::ReadFrom(SnapshotReader* reader, |
| 33 intptr_t object_id, | 32 intptr_t object_id, |
| 34 intptr_t tags, | 33 intptr_t tags, |
| 35 Snapshot::Kind kind, | 34 Snapshot::Kind kind, |
| 36 bool as_reference) { | 35 bool as_reference) { |
| 37 ASSERT(reader != NULL); | 36 ASSERT(reader != NULL); |
| 38 | 37 |
| 39 Class& cls = Class::ZoneHandle(reader->zone(), Class::null()); | 38 Class& cls = Class::ZoneHandle(reader->zone(), Class::null()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 58 cls.set_next_field_offset_in_words(reader->Read<int32_t>()); | 57 cls.set_next_field_offset_in_words(reader->Read<int32_t>()); |
| 59 } | 58 } |
| 60 cls.set_type_arguments_field_offset_in_words(reader->Read<int32_t>()); | 59 cls.set_type_arguments_field_offset_in_words(reader->Read<int32_t>()); |
| 61 cls.set_num_type_arguments(reader->Read<int16_t>()); | 60 cls.set_num_type_arguments(reader->Read<int16_t>()); |
| 62 cls.set_num_own_type_arguments(reader->Read<int16_t>()); | 61 cls.set_num_own_type_arguments(reader->Read<int16_t>()); |
| 63 cls.set_num_native_fields(reader->Read<uint16_t>()); | 62 cls.set_num_native_fields(reader->Read<uint16_t>()); |
| 64 cls.set_token_pos(TokenPosition::SnapshotDecode(reader->Read<int32_t>())); | 63 cls.set_token_pos(TokenPosition::SnapshotDecode(reader->Read<int32_t>())); |
| 65 cls.set_state_bits(reader->Read<uint16_t>()); | 64 cls.set_state_bits(reader->Read<uint16_t>()); |
| 66 | 65 |
| 67 // Set all the object fields. | 66 // Set all the object fields. |
| 68 READ_OBJECT_FIELDS(cls, | 67 READ_OBJECT_FIELDS(cls, cls.raw()->from(), cls.raw()->to_snapshot(kind), |
| 69 cls.raw()->from(), | |
| 70 cls.raw()->to_snapshot(kind), | |
| 71 kAsReference); | 68 kAsReference); |
| 72 cls.StorePointer(&cls.raw_ptr()->dependent_code_, Array::null()); | 69 cls.StorePointer(&cls.raw_ptr()->dependent_code_, Array::null()); |
| 73 ASSERT(!cls.IsInFullSnapshot()); | 70 ASSERT(!cls.IsInFullSnapshot()); |
| 74 } else { | 71 } else { |
| 75 cls ^= reader->ReadClassId(object_id); | 72 cls ^= reader->ReadClassId(object_id); |
| 76 ASSERT((kind == Snapshot::kMessage) || cls.IsInFullSnapshot()); | 73 ASSERT((kind == Snapshot::kMessage) || cls.IsInFullSnapshot()); |
| 77 } | 74 } |
| 78 return cls.raw(); | 75 return cls.raw(); |
| 79 } | 76 } |
| 80 | 77 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 133 |
| 137 | 134 |
| 138 RawUnresolvedClass* UnresolvedClass::ReadFrom(SnapshotReader* reader, | 135 RawUnresolvedClass* UnresolvedClass::ReadFrom(SnapshotReader* reader, |
| 139 intptr_t object_id, | 136 intptr_t object_id, |
| 140 intptr_t tags, | 137 intptr_t tags, |
| 141 Snapshot::Kind kind, | 138 Snapshot::Kind kind, |
| 142 bool as_reference) { | 139 bool as_reference) { |
| 143 ASSERT(reader != NULL); | 140 ASSERT(reader != NULL); |
| 144 | 141 |
| 145 // Allocate unresolved class object. | 142 // Allocate unresolved class object. |
| 146 UnresolvedClass& unresolved_class = UnresolvedClass::ZoneHandle( | 143 UnresolvedClass& unresolved_class = |
| 147 reader->zone(), UnresolvedClass::New()); | 144 UnresolvedClass::ZoneHandle(reader->zone(), UnresolvedClass::New()); |
| 148 reader->AddBackRef(object_id, &unresolved_class, kIsDeserialized); | 145 reader->AddBackRef(object_id, &unresolved_class, kIsDeserialized); |
| 149 | 146 |
| 150 // Set all non object fields. | 147 // Set all non object fields. |
| 151 unresolved_class.set_token_pos( | 148 unresolved_class.set_token_pos( |
| 152 TokenPosition::SnapshotDecode(reader->Read<int32_t>())); | 149 TokenPosition::SnapshotDecode(reader->Read<int32_t>())); |
| 153 | 150 |
| 154 // Set all the object fields. | 151 // Set all the object fields. |
| 155 READ_OBJECT_FIELDS(unresolved_class, | 152 READ_OBJECT_FIELDS(unresolved_class, unresolved_class.raw()->from(), |
| 156 unresolved_class.raw()->from(), | 153 unresolved_class.raw()->to(), kAsReference); |
| 157 unresolved_class.raw()->to(), | |
| 158 kAsReference); | |
| 159 | 154 |
| 160 return unresolved_class.raw(); | 155 return unresolved_class.raw(); |
| 161 } | 156 } |
| 162 | 157 |
| 163 | 158 |
| 164 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, | 159 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, |
| 165 intptr_t object_id, | 160 intptr_t object_id, |
| 166 Snapshot::Kind kind, | 161 Snapshot::Kind kind, |
| 167 bool as_reference) { | 162 bool as_reference) { |
| 168 ASSERT(writer != NULL); | 163 ASSERT(writer != NULL); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 Snapshot::Kind kind, | 202 Snapshot::Kind kind, |
| 208 bool as_reference) { | 203 bool as_reference) { |
| 209 ASSERT(reader != NULL); | 204 ASSERT(reader != NULL); |
| 210 | 205 |
| 211 // Determine if the type class of this type is in the full snapshot. | 206 // Determine if the type class of this type is in the full snapshot. |
| 212 bool typeclass_is_in_fullsnapshot = reader->Read<bool>(); | 207 bool typeclass_is_in_fullsnapshot = reader->Read<bool>(); |
| 213 | 208 |
| 214 // Allocate type object. | 209 // Allocate type object. |
| 215 Type& type = Type::ZoneHandle(reader->zone(), Type::New()); | 210 Type& type = Type::ZoneHandle(reader->zone(), Type::New()); |
| 216 bool is_canonical = RawObject::IsCanonical(tags); | 211 bool is_canonical = RawObject::IsCanonical(tags); |
| 217 bool defer_canonicalization = is_canonical && | 212 bool defer_canonicalization = |
| 213 is_canonical && |
| 218 ((kind == Snapshot::kMessage) || | 214 ((kind == Snapshot::kMessage) || |
| 219 (!Snapshot::IsFull(kind) && typeclass_is_in_fullsnapshot)); | 215 (!Snapshot::IsFull(kind) && typeclass_is_in_fullsnapshot)); |
| 220 reader->AddBackRef(object_id, &type, kIsDeserialized, defer_canonicalization); | 216 reader->AddBackRef(object_id, &type, kIsDeserialized, defer_canonicalization); |
| 221 | 217 |
| 222 // Set all non object fields. | 218 // Set all non object fields. |
| 223 type.set_token_pos(TokenPosition::SnapshotDecode(reader->Read<int32_t>())); | 219 type.set_token_pos(TokenPosition::SnapshotDecode(reader->Read<int32_t>())); |
| 224 type.set_type_state(reader->Read<int8_t>()); | 220 type.set_type_state(reader->Read<int8_t>()); |
| 225 | 221 |
| 226 // Set all the object fields. | 222 // Set all the object fields. |
| 227 READ_OBJECT_FIELDS(type, type.raw()->from(), type.raw()->to(), kAsReference); | 223 READ_OBJECT_FIELDS(type, type.raw()->from(), type.raw()->to(), kAsReference); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 287 |
| 292 | 288 |
| 293 RawTypeRef* TypeRef::ReadFrom(SnapshotReader* reader, | 289 RawTypeRef* TypeRef::ReadFrom(SnapshotReader* reader, |
| 294 intptr_t object_id, | 290 intptr_t object_id, |
| 295 intptr_t tags, | 291 intptr_t tags, |
| 296 Snapshot::Kind kind, | 292 Snapshot::Kind kind, |
| 297 bool as_reference) { | 293 bool as_reference) { |
| 298 ASSERT(reader != NULL); | 294 ASSERT(reader != NULL); |
| 299 | 295 |
| 300 // Allocate type ref object. | 296 // Allocate type ref object. |
| 301 TypeRef& type_ref = TypeRef::ZoneHandle( | 297 TypeRef& type_ref = TypeRef::ZoneHandle(reader->zone(), TypeRef::New()); |
| 302 reader->zone(), TypeRef::New()); | |
| 303 reader->AddBackRef(object_id, &type_ref, kIsDeserialized); | 298 reader->AddBackRef(object_id, &type_ref, kIsDeserialized); |
| 304 | 299 |
| 305 // Set all the object fields. | 300 // Set all the object fields. |
| 306 READ_OBJECT_FIELDS(type_ref, | 301 READ_OBJECT_FIELDS(type_ref, type_ref.raw()->from(), type_ref.raw()->to(), |
| 307 type_ref.raw()->from(), type_ref.raw()->to(), | |
| 308 kAsReference); | 302 kAsReference); |
| 309 | 303 |
| 310 return type_ref.raw(); | 304 return type_ref.raw(); |
| 311 } | 305 } |
| 312 | 306 |
| 313 | 307 |
| 314 void RawTypeRef::WriteTo(SnapshotWriter* writer, | 308 void RawTypeRef::WriteTo(SnapshotWriter* writer, |
| 315 intptr_t object_id, | 309 intptr_t object_id, |
| 316 Snapshot::Kind kind, | 310 Snapshot::Kind kind, |
| 317 bool as_reference) { | 311 bool as_reference) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 331 | 325 |
| 332 | 326 |
| 333 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader, | 327 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader, |
| 334 intptr_t object_id, | 328 intptr_t object_id, |
| 335 intptr_t tags, | 329 intptr_t tags, |
| 336 Snapshot::Kind kind, | 330 Snapshot::Kind kind, |
| 337 bool as_reference) { | 331 bool as_reference) { |
| 338 ASSERT(reader != NULL); | 332 ASSERT(reader != NULL); |
| 339 | 333 |
| 340 // Allocate type parameter object. | 334 // Allocate type parameter object. |
| 341 TypeParameter& type_parameter = TypeParameter::ZoneHandle( | 335 TypeParameter& type_parameter = |
| 342 reader->zone(), TypeParameter::New()); | 336 TypeParameter::ZoneHandle(reader->zone(), TypeParameter::New()); |
| 343 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized); | 337 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized); |
| 344 | 338 |
| 345 // Set all non object fields. | 339 // Set all non object fields. |
| 346 type_parameter.set_token_pos( | 340 type_parameter.set_token_pos( |
| 347 TokenPosition::SnapshotDecode(reader->Read<int32_t>())); | 341 TokenPosition::SnapshotDecode(reader->Read<int32_t>())); |
| 348 type_parameter.set_index(reader->Read<int16_t>()); | 342 type_parameter.set_index(reader->Read<int16_t>()); |
| 349 type_parameter.set_parent_level(reader->Read<uint8_t>()); | 343 type_parameter.set_parent_level(reader->Read<uint8_t>()); |
| 350 type_parameter.set_type_state(reader->Read<int8_t>()); | 344 type_parameter.set_type_state(reader->Read<int8_t>()); |
| 351 | 345 |
| 352 // Set all the object fields. | 346 // Set all the object fields. |
| 353 READ_OBJECT_FIELDS(type_parameter, | 347 READ_OBJECT_FIELDS(type_parameter, type_parameter.raw()->from(), |
| 354 type_parameter.raw()->from(), type_parameter.raw()->to(), | 348 type_parameter.raw()->to(), kAsReference); |
| 355 kAsReference); | |
| 356 | 349 |
| 357 // Read in the parameterized class. | 350 // Read in the parameterized class. |
| 358 (*reader->ClassHandle()) = | 351 (*reader->ClassHandle()) = |
| 359 Class::RawCast(reader->ReadObjectImpl(kAsReference)); | 352 Class::RawCast(reader->ReadObjectImpl(kAsReference)); |
| 360 type_parameter.set_parameterized_class(*reader->ClassHandle()); | 353 type_parameter.set_parameterized_class(*reader->ClassHandle()); |
| 361 | 354 |
| 362 return type_parameter.raw(); | 355 return type_parameter.raw(); |
| 363 } | 356 } |
| 364 | 357 |
| 365 | 358 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 | 390 |
| 398 | 391 |
| 399 RawBoundedType* BoundedType::ReadFrom(SnapshotReader* reader, | 392 RawBoundedType* BoundedType::ReadFrom(SnapshotReader* reader, |
| 400 intptr_t object_id, | 393 intptr_t object_id, |
| 401 intptr_t tags, | 394 intptr_t tags, |
| 402 Snapshot::Kind kind, | 395 Snapshot::Kind kind, |
| 403 bool as_reference) { | 396 bool as_reference) { |
| 404 ASSERT(reader != NULL); | 397 ASSERT(reader != NULL); |
| 405 | 398 |
| 406 // Allocate bounded type object. | 399 // Allocate bounded type object. |
| 407 BoundedType& bounded_type = BoundedType::ZoneHandle( | 400 BoundedType& bounded_type = |
| 408 reader->zone(), BoundedType::New()); | 401 BoundedType::ZoneHandle(reader->zone(), BoundedType::New()); |
| 409 reader->AddBackRef(object_id, &bounded_type, kIsDeserialized); | 402 reader->AddBackRef(object_id, &bounded_type, kIsDeserialized); |
| 410 | 403 |
| 411 // Set all the object fields. | 404 // Set all the object fields. |
| 412 READ_OBJECT_FIELDS(bounded_type, | 405 READ_OBJECT_FIELDS(bounded_type, bounded_type.raw()->from(), |
| 413 bounded_type.raw()->from(), bounded_type.raw()->to(), | 406 bounded_type.raw()->to(), kAsReference); |
| 414 kAsReference); | |
| 415 | 407 |
| 416 return bounded_type.raw(); | 408 return bounded_type.raw(); |
| 417 } | 409 } |
| 418 | 410 |
| 419 | 411 |
| 420 void RawBoundedType::WriteTo(SnapshotWriter* writer, | 412 void RawBoundedType::WriteTo(SnapshotWriter* writer, |
| 421 intptr_t object_id, | 413 intptr_t object_id, |
| 422 Snapshot::Kind kind, | 414 Snapshot::Kind kind, |
| 423 bool as_reference) { | 415 bool as_reference) { |
| 424 ASSERT(writer != NULL); | 416 ASSERT(writer != NULL); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 bool as_reference) { | 453 bool as_reference) { |
| 462 ASSERT(reader != NULL); | 454 ASSERT(reader != NULL); |
| 463 | 455 |
| 464 // Read the length so that we can determine instance size to allocate. | 456 // Read the length so that we can determine instance size to allocate. |
| 465 intptr_t len = reader->ReadSmiValue(); | 457 intptr_t len = reader->ReadSmiValue(); |
| 466 | 458 |
| 467 TypeArguments& type_arguments = TypeArguments::ZoneHandle( | 459 TypeArguments& type_arguments = TypeArguments::ZoneHandle( |
| 468 reader->zone(), TypeArguments::New(len, HEAP_SPACE(kind))); | 460 reader->zone(), TypeArguments::New(len, HEAP_SPACE(kind))); |
| 469 bool is_canonical = RawObject::IsCanonical(tags); | 461 bool is_canonical = RawObject::IsCanonical(tags); |
| 470 bool defer_canonicalization = is_canonical && (!Snapshot::IsFull(kind)); | 462 bool defer_canonicalization = is_canonical && (!Snapshot::IsFull(kind)); |
| 471 reader->AddBackRef(object_id, | 463 reader->AddBackRef(object_id, &type_arguments, kIsDeserialized, |
| 472 &type_arguments, | |
| 473 kIsDeserialized, | |
| 474 defer_canonicalization); | 464 defer_canonicalization); |
| 475 | 465 |
| 476 // Set the instantiations field, which is only read from a full snapshot. | 466 // Set the instantiations field, which is only read from a full snapshot. |
| 477 type_arguments.set_instantiations(Object::zero_array()); | 467 type_arguments.set_instantiations(Object::zero_array()); |
| 478 | 468 |
| 479 // Now set all the type fields. | 469 // Now set all the type fields. |
| 480 intptr_t offset = type_arguments.TypeAddr(0) - | 470 intptr_t offset = |
| 471 type_arguments.TypeAddr(0) - |
| 481 reinterpret_cast<RawAbstractType**>(type_arguments.raw()->ptr()); | 472 reinterpret_cast<RawAbstractType**>(type_arguments.raw()->ptr()); |
| 482 for (intptr_t i = 0; i < len; i++) { | 473 for (intptr_t i = 0; i < len; i++) { |
| 483 *reader->TypeHandle() ^= | 474 *reader->TypeHandle() ^= |
| 484 reader->ReadObjectImpl(kAsReference, object_id, (i + offset)); | 475 reader->ReadObjectImpl(kAsReference, object_id, (i + offset)); |
| 485 type_arguments.SetTypeAt(i, *reader->TypeHandle()); | 476 type_arguments.SetTypeAt(i, *reader->TypeHandle()); |
| 486 } | 477 } |
| 487 | 478 |
| 488 // Set the canonical bit. | 479 // Set the canonical bit. |
| 489 if (!defer_canonicalization && is_canonical) { | 480 if (!defer_canonicalization && is_canonical) { |
| 490 type_arguments.SetCanonical(); | 481 type_arguments.SetCanonical(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 520 | 511 |
| 521 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader, | 512 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader, |
| 522 intptr_t object_id, | 513 intptr_t object_id, |
| 523 intptr_t tags, | 514 intptr_t tags, |
| 524 Snapshot::Kind kind, | 515 Snapshot::Kind kind, |
| 525 bool as_reference) { | 516 bool as_reference) { |
| 526 ASSERT(reader != NULL); | 517 ASSERT(reader != NULL); |
| 527 ASSERT(kind == Snapshot::kScript); | 518 ASSERT(kind == Snapshot::kScript); |
| 528 | 519 |
| 529 // Allocate function object. | 520 // Allocate function object. |
| 530 PatchClass& cls = PatchClass::ZoneHandle(reader->zone(), | 521 PatchClass& cls = PatchClass::ZoneHandle(reader->zone(), PatchClass::New()); |
| 531 PatchClass::New()); | |
| 532 reader->AddBackRef(object_id, &cls, kIsDeserialized); | 522 reader->AddBackRef(object_id, &cls, kIsDeserialized); |
| 533 | 523 |
| 534 // Set all the object fields. | 524 // Set all the object fields. |
| 535 READ_OBJECT_FIELDS(cls, cls.raw()->from(), cls.raw()->to(), kAsReference); | 525 READ_OBJECT_FIELDS(cls, cls.raw()->from(), cls.raw()->to(), kAsReference); |
| 536 | 526 |
| 537 return cls.raw(); | 527 return cls.raw(); |
| 538 } | 528 } |
| 539 | 529 |
| 540 | 530 |
| 541 void RawPatchClass::WriteTo(SnapshotWriter* writer, | 531 void RawPatchClass::WriteTo(SnapshotWriter* writer, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 570 void RawClosure::WriteTo(SnapshotWriter* writer, | 560 void RawClosure::WriteTo(SnapshotWriter* writer, |
| 571 intptr_t object_id, | 561 intptr_t object_id, |
| 572 Snapshot::Kind kind, | 562 Snapshot::Kind kind, |
| 573 bool as_reference) { | 563 bool as_reference) { |
| 574 ASSERT(writer != NULL); | 564 ASSERT(writer != NULL); |
| 575 ASSERT((kind == Snapshot::kMessage) || (kind == Snapshot::kScript)); | 565 ASSERT((kind == Snapshot::kMessage) || (kind == Snapshot::kScript)); |
| 576 | 566 |
| 577 // Check if closure is serializable, throw an exception otherwise. | 567 // Check if closure is serializable, throw an exception otherwise. |
| 578 RawFunction* func = writer->IsSerializableClosure(this); | 568 RawFunction* func = writer->IsSerializableClosure(this); |
| 579 if (func != Function::null()) { | 569 if (func != Function::null()) { |
| 580 writer->WriteStaticImplicitClosure(object_id, | 570 writer->WriteStaticImplicitClosure(object_id, func, |
| 581 func, | |
| 582 writer->GetObjectTags(this)); | 571 writer->GetObjectTags(this)); |
| 583 return; | 572 return; |
| 584 } | 573 } |
| 585 | 574 |
| 586 UNREACHABLE(); | 575 UNREACHABLE(); |
| 587 } | 576 } |
| 588 | 577 |
| 589 | 578 |
| 590 RawClosureData* ClosureData::ReadFrom(SnapshotReader* reader, | 579 RawClosureData* ClosureData::ReadFrom(SnapshotReader* reader, |
| 591 intptr_t object_id, | 580 intptr_t object_id, |
| 592 intptr_t tags, | 581 intptr_t tags, |
| 593 Snapshot::Kind kind, | 582 Snapshot::Kind kind, |
| 594 bool as_reference) { | 583 bool as_reference) { |
| 595 ASSERT(reader != NULL); | 584 ASSERT(reader != NULL); |
| 596 ASSERT(kind == Snapshot::kScript); | 585 ASSERT(kind == Snapshot::kScript); |
| 597 | 586 |
| 598 // Allocate closure data object. | 587 // Allocate closure data object. |
| 599 ClosureData& data = ClosureData::ZoneHandle(reader->zone(), | 588 ClosureData& data = |
| 600 ClosureData::New()); | 589 ClosureData::ZoneHandle(reader->zone(), ClosureData::New()); |
| 601 reader->AddBackRef(object_id, &data, kIsDeserialized); | 590 reader->AddBackRef(object_id, &data, kIsDeserialized); |
| 602 | 591 |
| 603 // Set all the object fields. | 592 // Set all the object fields. |
| 604 READ_OBJECT_FIELDS(data, | 593 READ_OBJECT_FIELDS(data, data.raw()->from(), data.raw()->to(), |
| 605 data.raw()->from(), data.raw()->to(), | |
| 606 kAsInlinedObject); | 594 kAsInlinedObject); |
| 607 | 595 |
| 608 return data.raw(); | 596 return data.raw(); |
| 609 } | 597 } |
| 610 | 598 |
| 611 | 599 |
| 612 void RawClosureData::WriteTo(SnapshotWriter* writer, | 600 void RawClosureData::WriteTo(SnapshotWriter* writer, |
| 613 intptr_t object_id, | 601 intptr_t object_id, |
| 614 Snapshot::Kind kind, | 602 Snapshot::Kind kind, |
| 615 bool as_reference) { | 603 bool as_reference) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 646 | 634 |
| 647 RawRedirectionData* RedirectionData::ReadFrom(SnapshotReader* reader, | 635 RawRedirectionData* RedirectionData::ReadFrom(SnapshotReader* reader, |
| 648 intptr_t object_id, | 636 intptr_t object_id, |
| 649 intptr_t tags, | 637 intptr_t tags, |
| 650 Snapshot::Kind kind, | 638 Snapshot::Kind kind, |
| 651 bool as_reference) { | 639 bool as_reference) { |
| 652 ASSERT(reader != NULL); | 640 ASSERT(reader != NULL); |
| 653 ASSERT(kind == Snapshot::kScript); | 641 ASSERT(kind == Snapshot::kScript); |
| 654 | 642 |
| 655 // Allocate redirection data object. | 643 // Allocate redirection data object. |
| 656 RedirectionData& data = RedirectionData::ZoneHandle(reader->zone(), | 644 RedirectionData& data = |
| 657 RedirectionData::New()); | 645 RedirectionData::ZoneHandle(reader->zone(), RedirectionData::New()); |
| 658 reader->AddBackRef(object_id, &data, kIsDeserialized); | 646 reader->AddBackRef(object_id, &data, kIsDeserialized); |
| 659 | 647 |
| 660 // Set all the object fields. | 648 // Set all the object fields. |
| 661 READ_OBJECT_FIELDS(data, | 649 READ_OBJECT_FIELDS(data, data.raw()->from(), data.raw()->to(), kAsReference); |
| 662 data.raw()->from(), data.raw()->to(), | |
| 663 kAsReference); | |
| 664 | 650 |
| 665 return data.raw(); | 651 return data.raw(); |
| 666 } | 652 } |
| 667 | 653 |
| 668 | 654 |
| 669 void RawRedirectionData::WriteTo(SnapshotWriter* writer, | 655 void RawRedirectionData::WriteTo(SnapshotWriter* writer, |
| 670 intptr_t object_id, | 656 intptr_t object_id, |
| 671 Snapshot::Kind kind, | 657 Snapshot::Kind kind, |
| 672 bool as_reference) { | 658 bool as_reference) { |
| 673 ASSERT(writer != NULL); | 659 ASSERT(writer != NULL); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 690 intptr_t object_id, | 676 intptr_t object_id, |
| 691 intptr_t tags, | 677 intptr_t tags, |
| 692 Snapshot::Kind kind, | 678 Snapshot::Kind kind, |
| 693 bool as_reference) { | 679 bool as_reference) { |
| 694 ASSERT(reader != NULL); | 680 ASSERT(reader != NULL); |
| 695 ASSERT(kind == Snapshot::kScript); | 681 ASSERT(kind == Snapshot::kScript); |
| 696 | 682 |
| 697 bool is_in_fullsnapshot = reader->Read<bool>(); | 683 bool is_in_fullsnapshot = reader->Read<bool>(); |
| 698 if (!is_in_fullsnapshot) { | 684 if (!is_in_fullsnapshot) { |
| 699 // Allocate function object. | 685 // Allocate function object. |
| 700 Function& func = Function::ZoneHandle(reader->zone(), | 686 Function& func = Function::ZoneHandle(reader->zone(), Function::New()); |
| 701 Function::New()); | |
| 702 reader->AddBackRef(object_id, &func, kIsDeserialized); | 687 reader->AddBackRef(object_id, &func, kIsDeserialized); |
| 703 | 688 |
| 704 // Set all the non object fields. Read the token positions now but | 689 // Set all the non object fields. Read the token positions now but |
| 705 // don't set them until after setting the kind. | 690 // don't set them until after setting the kind. |
| 706 const int32_t token_pos = reader->Read<int32_t>(); | 691 const int32_t token_pos = reader->Read<int32_t>(); |
| 707 const int32_t end_token_pos = reader->Read<uint32_t>(); | 692 const int32_t end_token_pos = reader->Read<uint32_t>(); |
| 708 func.set_num_fixed_parameters(reader->Read<int16_t>()); | 693 func.set_num_fixed_parameters(reader->Read<int16_t>()); |
| 709 func.set_num_optional_parameters(reader->Read<int16_t>()); | 694 func.set_num_optional_parameters(reader->Read<int16_t>()); |
| 710 func.set_kind_tag(reader->Read<uint32_t>()); | 695 func.set_kind_tag(reader->Read<uint32_t>()); |
| 711 func.set_token_pos(TokenPosition::SnapshotDecode(token_pos)); | 696 func.set_token_pos(TokenPosition::SnapshotDecode(token_pos)); |
| 712 func.set_end_token_pos(TokenPosition::SnapshotDecode(end_token_pos)); | 697 func.set_end_token_pos(TokenPosition::SnapshotDecode(end_token_pos)); |
| 713 func.set_usage_counter(reader->Read<int32_t>()); | 698 func.set_usage_counter(reader->Read<int32_t>()); |
| 714 func.set_deoptimization_counter(reader->Read<int8_t>()); | 699 func.set_deoptimization_counter(reader->Read<int8_t>()); |
| 715 func.set_optimized_instruction_count(reader->Read<uint16_t>()); | 700 func.set_optimized_instruction_count(reader->Read<uint16_t>()); |
| 716 func.set_optimized_call_site_count(reader->Read<uint16_t>()); | 701 func.set_optimized_call_site_count(reader->Read<uint16_t>()); |
| 717 func.set_kernel_function(NULL); | 702 func.set_kernel_function(NULL); |
| 718 func.set_was_compiled(false); | 703 func.set_was_compiled(false); |
| 719 | 704 |
| 720 // Set all the object fields. | 705 // Set all the object fields. |
| 721 READ_OBJECT_FIELDS(func, | 706 READ_OBJECT_FIELDS(func, func.raw()->from(), func.raw()->to_snapshot(), |
| 722 func.raw()->from(), func.raw()->to_snapshot(), | |
| 723 kAsReference); | 707 kAsReference); |
| 724 // Initialize all fields that are not part of the snapshot. | 708 // Initialize all fields that are not part of the snapshot. |
| 725 bool is_optimized = func.usage_counter() != 0; | 709 bool is_optimized = func.usage_counter() != 0; |
| 726 if (is_optimized) { | 710 if (is_optimized) { |
| 727 // Read the ic data array as the function is an optimized one. | 711 // Read the ic data array as the function is an optimized one. |
| 728 (*reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsReference); | 712 (*reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsReference); |
| 729 func.set_ic_data_array(*reader->ArrayHandle()); | 713 func.set_ic_data_array(*reader->ArrayHandle()); |
| 730 } else { | 714 } else { |
| 731 func.ClearICDataArray(); | 715 func.ClearICDataArray(); |
| 732 } | 716 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 743 Snapshot::Kind kind, | 727 Snapshot::Kind kind, |
| 744 bool as_reference) { | 728 bool as_reference) { |
| 745 ASSERT(writer != NULL); | 729 ASSERT(writer != NULL); |
| 746 ASSERT(kind == Snapshot::kScript); | 730 ASSERT(kind == Snapshot::kScript); |
| 747 bool is_in_fullsnapshot = false; | 731 bool is_in_fullsnapshot = false; |
| 748 bool owner_is_class = false; | 732 bool owner_is_class = false; |
| 749 if ((kind == Snapshot::kScript) && !Function::IsSignatureFunction(this)) { | 733 if ((kind == Snapshot::kScript) && !Function::IsSignatureFunction(this)) { |
| 750 intptr_t tags = writer->GetObjectTags(ptr()->owner_); | 734 intptr_t tags = writer->GetObjectTags(ptr()->owner_); |
| 751 intptr_t cid = ClassIdTag::decode(tags); | 735 intptr_t cid = ClassIdTag::decode(tags); |
| 752 owner_is_class = (cid == kClassCid); | 736 owner_is_class = (cid == kClassCid); |
| 753 is_in_fullsnapshot = owner_is_class ? | 737 is_in_fullsnapshot = |
| 754 Class::IsInFullSnapshot(reinterpret_cast<RawClass*>(ptr()->owner_)) : | 738 owner_is_class ? Class::IsInFullSnapshot( |
| 755 PatchClass::IsInFullSnapshot( | 739 reinterpret_cast<RawClass*>(ptr()->owner_)) |
| 756 reinterpret_cast<RawPatchClass*>(ptr()->owner_)); | 740 : PatchClass::IsInFullSnapshot( |
| 741 reinterpret_cast<RawPatchClass*>(ptr()->owner_)); |
| 757 } | 742 } |
| 758 | 743 |
| 759 // Write out the serialization header value for this object. | 744 // Write out the serialization header value for this object. |
| 760 writer->WriteInlinedObjectHeader(object_id); | 745 writer->WriteInlinedObjectHeader(object_id); |
| 761 | 746 |
| 762 // Write out the class and tags information. | 747 // Write out the class and tags information. |
| 763 writer->WriteVMIsolateObject(kFunctionCid); | 748 writer->WriteVMIsolateObject(kFunctionCid); |
| 764 writer->WriteTags(writer->GetObjectTags(this)); | 749 writer->WriteTags(writer->GetObjectTags(this)); |
| 765 | 750 |
| 766 // Write out the boolean is_in_fullsnapshot first as this will | 751 // Write out the boolean is_in_fullsnapshot first as this will |
| 767 // help the reader decide how the rest of the information needs | 752 // help the reader decide how the rest of the information needs |
| 768 // to be interpreted. | 753 // to be interpreted. |
| 769 writer->Write<bool>(is_in_fullsnapshot); | 754 writer->Write<bool>(is_in_fullsnapshot); |
| 770 | 755 |
| 771 if (!is_in_fullsnapshot) { | 756 if (!is_in_fullsnapshot) { |
| 772 bool is_optimized = Code::IsOptimized(ptr()->code_); | 757 bool is_optimized = Code::IsOptimized(ptr()->code_); |
| 773 | 758 |
| 774 // Write out all the non object fields. | 759 // Write out all the non object fields. |
| 775 #if !defined(DART_PRECOMPILED_RUNTIME) | 760 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 776 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode()); | 761 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode()); |
| 777 writer->Write<int32_t>(ptr()->end_token_pos_.SnapshotEncode()); | 762 writer->Write<int32_t>(ptr()->end_token_pos_.SnapshotEncode()); |
| 778 #endif | 763 #endif |
| 779 writer->Write<int16_t>(ptr()->num_fixed_parameters_); | 764 writer->Write<int16_t>(ptr()->num_fixed_parameters_); |
| 780 writer->Write<int16_t>(ptr()->num_optional_parameters_); | 765 writer->Write<int16_t>(ptr()->num_optional_parameters_); |
| 781 writer->Write<uint32_t>(ptr()->kind_tag_); | 766 writer->Write<uint32_t>(ptr()->kind_tag_); |
| 782 #if !defined(DART_PRECOMPILED_RUNTIME) | 767 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 783 if (is_optimized) { | 768 if (is_optimized) { |
| 784 writer->Write<int32_t>(FLAG_optimization_counter_threshold); | 769 writer->Write<int32_t>(FLAG_optimization_counter_threshold); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 809 Snapshot::Kind kind, | 794 Snapshot::Kind kind, |
| 810 bool as_reference) { | 795 bool as_reference) { |
| 811 ASSERT(reader != NULL); | 796 ASSERT(reader != NULL); |
| 812 ASSERT(kind == Snapshot::kScript); | 797 ASSERT(kind == Snapshot::kScript); |
| 813 | 798 |
| 814 // Allocate field object. | 799 // Allocate field object. |
| 815 Field& field = Field::ZoneHandle(reader->zone(), Field::New()); | 800 Field& field = Field::ZoneHandle(reader->zone(), Field::New()); |
| 816 reader->AddBackRef(object_id, &field, kIsDeserialized); | 801 reader->AddBackRef(object_id, &field, kIsDeserialized); |
| 817 | 802 |
| 818 // Set all non object fields. | 803 // Set all non object fields. |
| 819 field.set_token_pos( | 804 field.set_token_pos(TokenPosition::SnapshotDecode(reader->Read<int32_t>())); |
| 820 TokenPosition::SnapshotDecode(reader->Read<int32_t>())); | |
| 821 field.set_guarded_cid(reader->Read<int32_t>()); | 805 field.set_guarded_cid(reader->Read<int32_t>()); |
| 822 field.set_is_nullable(reader->Read<int32_t>()); | 806 field.set_is_nullable(reader->Read<int32_t>()); |
| 823 field.set_kind_bits(reader->Read<uint8_t>()); | 807 field.set_kind_bits(reader->Read<uint8_t>()); |
| 824 field.set_kernel_field(NULL); | 808 field.set_kernel_field(NULL); |
| 825 | 809 |
| 826 // Set all the object fields. | 810 // Set all the object fields. |
| 827 READ_OBJECT_FIELDS(field, | 811 READ_OBJECT_FIELDS(field, field.raw()->from(), field.raw()->to_snapshot(kind), |
| 828 field.raw()->from(), | |
| 829 field.raw()->to_snapshot(kind), | |
| 830 kAsReference); | 812 kAsReference); |
| 831 field.StorePointer(&field.raw_ptr()->dependent_code_, Array::null()); | 813 field.StorePointer(&field.raw_ptr()->dependent_code_, Array::null()); |
| 832 | 814 |
| 833 if (!FLAG_use_field_guards) { | 815 if (!FLAG_use_field_guards) { |
| 834 field.set_guarded_cid(kDynamicCid); | 816 field.set_guarded_cid(kDynamicCid); |
| 835 field.set_is_nullable(true); | 817 field.set_is_nullable(true); |
| 836 field.set_guarded_list_length(Field::kNoFixedLength); | 818 field.set_guarded_list_length(Field::kNoFixedLength); |
| 837 field.set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset); | 819 field.set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset); |
| 838 } else { | 820 } else { |
| 839 field.InitializeGuardedListLengthInObjectOffset(); | 821 field.InitializeGuardedListLengthInObjectOffset(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 | 872 |
| 891 RawLiteralToken* LiteralToken::ReadFrom(SnapshotReader* reader, | 873 RawLiteralToken* LiteralToken::ReadFrom(SnapshotReader* reader, |
| 892 intptr_t object_id, | 874 intptr_t object_id, |
| 893 intptr_t tags, | 875 intptr_t tags, |
| 894 Snapshot::Kind kind, | 876 Snapshot::Kind kind, |
| 895 bool as_reference) { | 877 bool as_reference) { |
| 896 ASSERT(reader != NULL); | 878 ASSERT(reader != NULL); |
| 897 ASSERT(kind != Snapshot::kMessage); | 879 ASSERT(kind != Snapshot::kMessage); |
| 898 | 880 |
| 899 // Create the literal token object. | 881 // Create the literal token object. |
| 900 LiteralToken& literal_token = LiteralToken::ZoneHandle(reader->zone(), | 882 LiteralToken& literal_token = |
| 901 LiteralToken::New()); | 883 LiteralToken::ZoneHandle(reader->zone(), LiteralToken::New()); |
| 902 reader->AddBackRef(object_id, &literal_token, kIsDeserialized); | 884 reader->AddBackRef(object_id, &literal_token, kIsDeserialized); |
| 903 | 885 |
| 904 // Read the token attributes. | 886 // Read the token attributes. |
| 905 Token::Kind token_kind = static_cast<Token::Kind>(reader->Read<int32_t>()); | 887 Token::Kind token_kind = static_cast<Token::Kind>(reader->Read<int32_t>()); |
| 906 literal_token.set_kind(token_kind); | 888 literal_token.set_kind(token_kind); |
| 907 | 889 |
| 908 // Set all the object fields. | 890 // Set all the object fields. |
| 909 READ_OBJECT_FIELDS(literal_token, | 891 READ_OBJECT_FIELDS(literal_token, literal_token.raw()->from(), |
| 910 literal_token.raw()->from(), literal_token.raw()->to(), | 892 literal_token.raw()->to(), kAsReference); |
| 911 kAsReference); | |
| 912 | 893 |
| 913 return literal_token.raw(); | 894 return literal_token.raw(); |
| 914 } | 895 } |
| 915 | 896 |
| 916 | 897 |
| 917 void RawLiteralToken::WriteTo(SnapshotWriter* writer, | 898 void RawLiteralToken::WriteTo(SnapshotWriter* writer, |
| 918 intptr_t object_id, | 899 intptr_t object_id, |
| 919 Snapshot::Kind kind, | 900 Snapshot::Kind kind, |
| 920 bool as_reference) { | 901 bool as_reference) { |
| 921 ASSERT(writer != NULL); | 902 ASSERT(writer != NULL); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 942 intptr_t tags, | 923 intptr_t tags, |
| 943 Snapshot::Kind kind, | 924 Snapshot::Kind kind, |
| 944 bool as_reference) { | 925 bool as_reference) { |
| 945 ASSERT(reader != NULL); | 926 ASSERT(reader != NULL); |
| 946 ASSERT(kind == Snapshot::kScript); | 927 ASSERT(kind == Snapshot::kScript); |
| 947 | 928 |
| 948 // Read the length so that we can determine number of tokens to read. | 929 // Read the length so that we can determine number of tokens to read. |
| 949 intptr_t len = reader->ReadSmiValue(); | 930 intptr_t len = reader->ReadSmiValue(); |
| 950 | 931 |
| 951 // Create the token stream object. | 932 // Create the token stream object. |
| 952 TokenStream& token_stream = TokenStream::ZoneHandle(reader->zone(), | 933 TokenStream& token_stream = |
| 953 TokenStream::New(len)); | 934 TokenStream::ZoneHandle(reader->zone(), TokenStream::New(len)); |
| 954 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); | 935 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); |
| 955 | 936 |
| 956 // Read the stream of tokens into the TokenStream object for script | 937 // Read the stream of tokens into the TokenStream object for script |
| 957 // snapshots as we made a copy of token stream. | 938 // snapshots as we made a copy of token stream. |
| 958 if (kind == Snapshot::kScript) { | 939 if (kind == Snapshot::kScript) { |
| 959 NoSafepointScope no_safepoint; | 940 NoSafepointScope no_safepoint; |
| 960 RawExternalTypedData* stream = token_stream.GetStream(); | 941 RawExternalTypedData* stream = token_stream.GetStream(); |
| 961 reader->ReadBytes(stream->ptr()->data_, len); | 942 reader->ReadBytes(stream->ptr()->data_, len); |
| 962 } | 943 } |
| 963 | 944 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 ASSERT(kind == Snapshot::kScript); | 989 ASSERT(kind == Snapshot::kScript); |
| 1009 | 990 |
| 1010 // Allocate script object. | 991 // Allocate script object. |
| 1011 Script& script = Script::ZoneHandle(reader->zone(), Script::New()); | 992 Script& script = Script::ZoneHandle(reader->zone(), Script::New()); |
| 1012 reader->AddBackRef(object_id, &script, kIsDeserialized); | 993 reader->AddBackRef(object_id, &script, kIsDeserialized); |
| 1013 | 994 |
| 1014 script.StoreNonPointer(&script.raw_ptr()->line_offset_, | 995 script.StoreNonPointer(&script.raw_ptr()->line_offset_, |
| 1015 reader->Read<int32_t>()); | 996 reader->Read<int32_t>()); |
| 1016 script.StoreNonPointer(&script.raw_ptr()->col_offset_, | 997 script.StoreNonPointer(&script.raw_ptr()->col_offset_, |
| 1017 reader->Read<int32_t>()); | 998 reader->Read<int32_t>()); |
| 1018 script.StoreNonPointer(&script.raw_ptr()->kind_, | 999 script.StoreNonPointer(&script.raw_ptr()->kind_, reader->Read<int8_t>()); |
| 1019 reader->Read<int8_t>()); | |
| 1020 | 1000 |
| 1021 *reader->StringHandle() ^= String::null(); | 1001 *reader->StringHandle() ^= String::null(); |
| 1022 script.set_source(*reader->StringHandle()); | 1002 script.set_source(*reader->StringHandle()); |
| 1023 *reader->StreamHandle() ^= TokenStream::null(); | 1003 *reader->StreamHandle() ^= TokenStream::null(); |
| 1024 script.set_tokens(*reader->StreamHandle()); | 1004 script.set_tokens(*reader->StreamHandle()); |
| 1025 | 1005 |
| 1026 // Set all the object fields. | 1006 // Set all the object fields. |
| 1027 // TODO(5411462): Need to assert No GC can happen here, even though | 1007 // TODO(5411462): Need to assert No GC can happen here, even though |
| 1028 // allocations may happen. | 1008 // allocations may happen. |
| 1029 intptr_t num_flds = (script.raw()->to_snapshot(kind) - script.raw()->from()); | 1009 intptr_t num_flds = (script.raw()->to_snapshot(kind) - script.raw()->from()); |
| 1030 for (intptr_t i = 0; i <= num_flds; i++) { | 1010 for (intptr_t i = 0; i <= num_flds; i++) { |
| 1031 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | 1011 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 1032 script.StorePointer((script.raw()->from() + i), | 1012 script.StorePointer((script.raw()->from() + i), |
| 1033 reader->PassiveObjectHandle()->raw()); | 1013 reader->PassiveObjectHandle()->raw()); |
| 1034 } | 1014 } |
| 1035 | 1015 |
| 1036 script.set_load_timestamp(FLAG_remove_script_timestamps_for_test | 1016 script.set_load_timestamp( |
| 1037 ? 0 : OS::GetCurrentTimeMillis()); | 1017 FLAG_remove_script_timestamps_for_test ? 0 : OS::GetCurrentTimeMillis()); |
| 1038 | 1018 |
| 1039 return script.raw(); | 1019 return script.raw(); |
| 1040 } | 1020 } |
| 1041 | 1021 |
| 1042 | 1022 |
| 1043 void RawScript::WriteTo(SnapshotWriter* writer, | 1023 void RawScript::WriteTo(SnapshotWriter* writer, |
| 1044 intptr_t object_id, | 1024 intptr_t object_id, |
| 1045 Snapshot::Kind kind, | 1025 Snapshot::Kind kind, |
| 1046 bool as_reference) { | 1026 bool as_reference) { |
| 1047 ASSERT(writer != NULL); | 1027 ASSERT(writer != NULL); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 | 1155 |
| 1176 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader, | 1156 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader, |
| 1177 intptr_t object_id, | 1157 intptr_t object_id, |
| 1178 intptr_t tags, | 1158 intptr_t tags, |
| 1179 Snapshot::Kind kind, | 1159 Snapshot::Kind kind, |
| 1180 bool as_reference) { | 1160 bool as_reference) { |
| 1181 ASSERT(reader != NULL); | 1161 ASSERT(reader != NULL); |
| 1182 ASSERT(kind == Snapshot::kScript); | 1162 ASSERT(kind == Snapshot::kScript); |
| 1183 | 1163 |
| 1184 // Allocate library prefix object. | 1164 // Allocate library prefix object. |
| 1185 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(reader->zone(), | 1165 LibraryPrefix& prefix = |
| 1186 LibraryPrefix::New()); | 1166 LibraryPrefix::ZoneHandle(reader->zone(), LibraryPrefix::New()); |
| 1187 reader->AddBackRef(object_id, &prefix, kIsDeserialized); | 1167 reader->AddBackRef(object_id, &prefix, kIsDeserialized); |
| 1188 | 1168 |
| 1189 // Set all non object fields. | 1169 // Set all non object fields. |
| 1190 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_, | 1170 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_, |
| 1191 reader->Read<int16_t>()); | 1171 reader->Read<int16_t>()); |
| 1192 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_, | 1172 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_, |
| 1193 reader->Read<bool>()); | 1173 reader->Read<bool>()); |
| 1194 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, | 1174 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, |
| 1195 !prefix.raw_ptr()->is_deferred_load_); | 1175 !prefix.raw_ptr()->is_deferred_load_); |
| 1196 | 1176 |
| 1197 // Set all the object fields. | 1177 // Set all the object fields. |
| 1198 READ_OBJECT_FIELDS(prefix, | 1178 READ_OBJECT_FIELDS(prefix, prefix.raw()->from(), |
| 1199 prefix.raw()->from(), | 1179 prefix.raw()->to_snapshot(kind), kAsReference); |
| 1200 prefix.raw()->to_snapshot(kind), | 1180 prefix.StorePointer(&prefix.raw_ptr()->dependent_code_, Array::null()); |
| 1201 kAsReference); | |
| 1202 prefix.StorePointer(&prefix.raw_ptr()->dependent_code_, | |
| 1203 Array::null()); | |
| 1204 | 1181 |
| 1205 return prefix.raw(); | 1182 return prefix.raw(); |
| 1206 } | 1183 } |
| 1207 | 1184 |
| 1208 | 1185 |
| 1209 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, | 1186 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, |
| 1210 intptr_t object_id, | 1187 intptr_t object_id, |
| 1211 Snapshot::Kind kind, | 1188 Snapshot::Kind kind, |
| 1212 bool as_reference) { | 1189 bool as_reference) { |
| 1213 ASSERT(writer != NULL); | 1190 ASSERT(writer != NULL); |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 ICData& result = ICData::ZoneHandle(reader->zone(), ICData::New()); | 1551 ICData& result = ICData::ZoneHandle(reader->zone(), ICData::New()); |
| 1575 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1552 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 1576 | 1553 |
| 1577 NOT_IN_PRECOMPILED(result.set_deopt_id(reader->Read<int32_t>())); | 1554 NOT_IN_PRECOMPILED(result.set_deopt_id(reader->Read<int32_t>())); |
| 1578 result.set_state_bits(reader->Read<uint32_t>()); | 1555 result.set_state_bits(reader->Read<uint32_t>()); |
| 1579 #if defined(TAG_IC_DATA) | 1556 #if defined(TAG_IC_DATA) |
| 1580 result.set_tag(reader->Read<int16_t>()); | 1557 result.set_tag(reader->Read<int16_t>()); |
| 1581 #endif | 1558 #endif |
| 1582 | 1559 |
| 1583 // Set all the object fields. | 1560 // Set all the object fields. |
| 1584 READ_OBJECT_FIELDS(result, | 1561 READ_OBJECT_FIELDS(result, result.raw()->from(), |
| 1585 result.raw()->from(), | 1562 result.raw()->to_snapshot(kind), kAsReference); |
| 1586 result.raw()->to_snapshot(kind), | |
| 1587 kAsReference); | |
| 1588 | 1563 |
| 1589 return result.raw(); | 1564 return result.raw(); |
| 1590 } | 1565 } |
| 1591 | 1566 |
| 1592 | 1567 |
| 1593 void RawICData::WriteTo(SnapshotWriter* writer, | 1568 void RawICData::WriteTo(SnapshotWriter* writer, |
| 1594 intptr_t object_id, | 1569 intptr_t object_id, |
| 1595 Snapshot::Kind kind, | 1570 Snapshot::Kind kind, |
| 1596 bool as_reference) { | 1571 bool as_reference) { |
| 1597 ASSERT(kind == Snapshot::kScript); | 1572 ASSERT(kind == Snapshot::kScript); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1673 | 1648 |
| 1674 | 1649 |
| 1675 RawApiError* ApiError::ReadFrom(SnapshotReader* reader, | 1650 RawApiError* ApiError::ReadFrom(SnapshotReader* reader, |
| 1676 intptr_t object_id, | 1651 intptr_t object_id, |
| 1677 intptr_t tags, | 1652 intptr_t tags, |
| 1678 Snapshot::Kind kind, | 1653 Snapshot::Kind kind, |
| 1679 bool as_reference) { | 1654 bool as_reference) { |
| 1680 ASSERT(reader != NULL); | 1655 ASSERT(reader != NULL); |
| 1681 | 1656 |
| 1682 // Allocate ApiError object. | 1657 // Allocate ApiError object. |
| 1683 ApiError& api_error = | 1658 ApiError& api_error = ApiError::ZoneHandle(reader->zone(), ApiError::New()); |
| 1684 ApiError::ZoneHandle(reader->zone(), ApiError::New()); | |
| 1685 reader->AddBackRef(object_id, &api_error, kIsDeserialized); | 1659 reader->AddBackRef(object_id, &api_error, kIsDeserialized); |
| 1686 | 1660 |
| 1687 // Set all the object fields. | 1661 // Set all the object fields. |
| 1688 READ_OBJECT_FIELDS(api_error, | 1662 READ_OBJECT_FIELDS(api_error, api_error.raw()->from(), api_error.raw()->to(), |
| 1689 api_error.raw()->from(), api_error.raw()->to(), | |
| 1690 kAsReference); | 1663 kAsReference); |
| 1691 | 1664 |
| 1692 return api_error.raw(); | 1665 return api_error.raw(); |
| 1693 } | 1666 } |
| 1694 | 1667 |
| 1695 | 1668 |
| 1696 void RawApiError::WriteTo(SnapshotWriter* writer, | 1669 void RawApiError::WriteTo(SnapshotWriter* writer, |
| 1697 intptr_t object_id, | 1670 intptr_t object_id, |
| 1698 Snapshot::Kind kind, | 1671 Snapshot::Kind kind, |
| 1699 bool as_reference) { | 1672 bool as_reference) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1724 LanguageError::ZoneHandle(reader->zone(), LanguageError::New()); | 1697 LanguageError::ZoneHandle(reader->zone(), LanguageError::New()); |
| 1725 reader->AddBackRef(object_id, &language_error, kIsDeserialized); | 1698 reader->AddBackRef(object_id, &language_error, kIsDeserialized); |
| 1726 | 1699 |
| 1727 // Set all non object fields. | 1700 // Set all non object fields. |
| 1728 language_error.set_token_pos( | 1701 language_error.set_token_pos( |
| 1729 TokenPosition::SnapshotDecode(reader->Read<int32_t>())); | 1702 TokenPosition::SnapshotDecode(reader->Read<int32_t>())); |
| 1730 language_error.set_report_after_token(reader->Read<bool>()); | 1703 language_error.set_report_after_token(reader->Read<bool>()); |
| 1731 language_error.set_kind(reader->Read<uint8_t>()); | 1704 language_error.set_kind(reader->Read<uint8_t>()); |
| 1732 | 1705 |
| 1733 // Set all the object fields. | 1706 // Set all the object fields. |
| 1734 READ_OBJECT_FIELDS(language_error, | 1707 READ_OBJECT_FIELDS(language_error, language_error.raw()->from(), |
| 1735 language_error.raw()->from(), language_error.raw()->to(), | 1708 language_error.raw()->to(), kAsReference); |
| 1736 kAsReference); | |
| 1737 | 1709 |
| 1738 return language_error.raw(); | 1710 return language_error.raw(); |
| 1739 } | 1711 } |
| 1740 | 1712 |
| 1741 | 1713 |
| 1742 void RawLanguageError::WriteTo(SnapshotWriter* writer, | 1714 void RawLanguageError::WriteTo(SnapshotWriter* writer, |
| 1743 intptr_t object_id, | 1715 intptr_t object_id, |
| 1744 Snapshot::Kind kind, | 1716 Snapshot::Kind kind, |
| 1745 bool as_reference) { | 1717 bool as_reference) { |
| 1746 ASSERT(writer != NULL); | 1718 ASSERT(writer != NULL); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1761 SnapshotWriterVisitor visitor(writer, kAsReference); | 1733 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 1762 visitor.VisitPointers(from(), to()); | 1734 visitor.VisitPointers(from(), to()); |
| 1763 } | 1735 } |
| 1764 | 1736 |
| 1765 | 1737 |
| 1766 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader, | 1738 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader, |
| 1767 intptr_t object_id, | 1739 intptr_t object_id, |
| 1768 intptr_t tags, | 1740 intptr_t tags, |
| 1769 Snapshot::Kind kind, | 1741 Snapshot::Kind kind, |
| 1770 bool as_reference) { | 1742 bool as_reference) { |
| 1771 UnhandledException& result = UnhandledException::ZoneHandle( | 1743 UnhandledException& result = |
| 1772 reader->zone(), UnhandledException::New()); | 1744 UnhandledException::ZoneHandle(reader->zone(), UnhandledException::New()); |
| 1773 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1745 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 1774 | 1746 |
| 1775 // Set all the object fields. | 1747 // Set all the object fields. |
| 1776 READ_OBJECT_FIELDS(result, | 1748 READ_OBJECT_FIELDS(result, result.raw()->from(), result.raw()->to(), |
| 1777 result.raw()->from(), result.raw()->to(), | |
| 1778 kAsReference); | 1749 kAsReference); |
| 1779 | 1750 |
| 1780 return result.raw(); | 1751 return result.raw(); |
| 1781 } | 1752 } |
| 1782 | 1753 |
| 1783 | 1754 |
| 1784 void RawUnhandledException::WriteTo(SnapshotWriter* writer, | 1755 void RawUnhandledException::WriteTo(SnapshotWriter* writer, |
| 1785 intptr_t object_id, | 1756 intptr_t object_id, |
| 1786 Snapshot::Kind kind, | 1757 Snapshot::Kind kind, |
| 1787 bool as_reference) { | 1758 bool as_reference) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1818 RawInstance* Instance::ReadFrom(SnapshotReader* reader, | 1789 RawInstance* Instance::ReadFrom(SnapshotReader* reader, |
| 1819 intptr_t object_id, | 1790 intptr_t object_id, |
| 1820 intptr_t tags, | 1791 intptr_t tags, |
| 1821 Snapshot::Kind kind, | 1792 Snapshot::Kind kind, |
| 1822 bool as_reference) { | 1793 bool as_reference) { |
| 1823 ASSERT(reader != NULL); | 1794 ASSERT(reader != NULL); |
| 1824 | 1795 |
| 1825 // Create an Instance object or get canonical one if it is a canonical | 1796 // Create an Instance object or get canonical one if it is a canonical |
| 1826 // constant. | 1797 // constant. |
| 1827 Instance& obj = Instance::ZoneHandle(reader->zone(), Instance::null()); | 1798 Instance& obj = Instance::ZoneHandle(reader->zone(), Instance::null()); |
| 1828 obj ^= Object::Allocate(kInstanceCid, | 1799 obj ^= Object::Allocate(kInstanceCid, Instance::InstanceSize(), |
| 1829 Instance::InstanceSize(), | |
| 1830 HEAP_SPACE(kind)); | 1800 HEAP_SPACE(kind)); |
| 1831 if (RawObject::IsCanonical(tags)) { | 1801 if (RawObject::IsCanonical(tags)) { |
| 1832 obj = obj.CheckAndCanonicalize(reader->thread(), NULL); | 1802 obj = obj.CheckAndCanonicalize(reader->thread(), NULL); |
| 1833 } | 1803 } |
| 1834 reader->AddBackRef(object_id, &obj, kIsDeserialized); | 1804 reader->AddBackRef(object_id, &obj, kIsDeserialized); |
| 1835 | 1805 |
| 1836 return obj.raw(); | 1806 return obj.raw(); |
| 1837 } | 1807 } |
| 1838 | 1808 |
| 1839 | 1809 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1858 Snapshot::Kind kind, | 1828 Snapshot::Kind kind, |
| 1859 bool as_reference) { | 1829 bool as_reference) { |
| 1860 ASSERT(reader != NULL); | 1830 ASSERT(reader != NULL); |
| 1861 | 1831 |
| 1862 // Read the 64 bit value for the object. | 1832 // Read the 64 bit value for the object. |
| 1863 int64_t value = reader->Read<int64_t>(); | 1833 int64_t value = reader->Read<int64_t>(); |
| 1864 | 1834 |
| 1865 // Check if the value could potentially fit in a Smi in our current | 1835 // Check if the value could potentially fit in a Smi in our current |
| 1866 // architecture, if so return the object as a Smi. | 1836 // architecture, if so return the object as a Smi. |
| 1867 if (Smi::IsValid(value)) { | 1837 if (Smi::IsValid(value)) { |
| 1868 Smi& smi = Smi::ZoneHandle(reader->zone(), | 1838 Smi& smi = |
| 1869 Smi::New(static_cast<intptr_t>(value))); | 1839 Smi::ZoneHandle(reader->zone(), Smi::New(static_cast<intptr_t>(value))); |
| 1870 reader->AddBackRef(object_id, &smi, kIsDeserialized); | 1840 reader->AddBackRef(object_id, &smi, kIsDeserialized); |
| 1871 return smi.raw(); | 1841 return smi.raw(); |
| 1872 } | 1842 } |
| 1873 | 1843 |
| 1874 // Create a Mint object or get canonical one if it is a canonical constant. | 1844 // Create a Mint object or get canonical one if it is a canonical constant. |
| 1875 Mint& mint = Mint::ZoneHandle(reader->zone(), Mint::null()); | 1845 Mint& mint = Mint::ZoneHandle(reader->zone(), Mint::null()); |
| 1876 // When reading a script snapshot we need to canonicalize only those object | 1846 // When reading a script snapshot we need to canonicalize only those object |
| 1877 // references that are objects from the core library (loaded from a | 1847 // references that are objects from the core library (loaded from a |
| 1878 // full snapshot). Objects that are only in the script need not be | 1848 // full snapshot). Objects that are only in the script need not be |
| 1879 // canonicalized as they are already canonical. | 1849 // canonicalized as they are already canonical. |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2010 | 1980 |
| 2011 | 1981 |
| 2012 void RawString::WriteTo(SnapshotWriter* writer, | 1982 void RawString::WriteTo(SnapshotWriter* writer, |
| 2013 intptr_t object_id, | 1983 intptr_t object_id, |
| 2014 Snapshot::Kind kind, | 1984 Snapshot::Kind kind, |
| 2015 bool as_reference) { | 1985 bool as_reference) { |
| 2016 UNREACHABLE(); // String is an abstract class. | 1986 UNREACHABLE(); // String is an abstract class. |
| 2017 } | 1987 } |
| 2018 | 1988 |
| 2019 | 1989 |
| 2020 template<typename StringType, typename CharacterType, typename CallbackType> | 1990 template <typename StringType, typename CharacterType, typename CallbackType> |
| 2021 void String::ReadFromImpl(SnapshotReader* reader, | 1991 void String::ReadFromImpl(SnapshotReader* reader, |
| 2022 String* str_obj, | 1992 String* str_obj, |
| 2023 intptr_t len, | 1993 intptr_t len, |
| 2024 intptr_t tags, | 1994 intptr_t tags, |
| 2025 CallbackType new_symbol, | 1995 CallbackType new_symbol, |
| 2026 Snapshot::Kind kind) { | 1996 Snapshot::Kind kind) { |
| 2027 ASSERT(reader != NULL); | 1997 ASSERT(reader != NULL); |
| 2028 if (RawObject::IsCanonical(tags)) { | 1998 if (RawObject::IsCanonical(tags)) { |
| 2029 // Set up canonical string object. | 1999 // Set up canonical string object. |
| 2030 ASSERT(reader != NULL); | 2000 ASSERT(reader != NULL); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2053 RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader, | 2023 RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader, |
| 2054 intptr_t object_id, | 2024 intptr_t object_id, |
| 2055 intptr_t tags, | 2025 intptr_t tags, |
| 2056 Snapshot::Kind kind, | 2026 Snapshot::Kind kind, |
| 2057 bool as_reference) { | 2027 bool as_reference) { |
| 2058 // Read the length so that we can determine instance size to allocate. | 2028 // Read the length so that we can determine instance size to allocate. |
| 2059 ASSERT(reader != NULL); | 2029 ASSERT(reader != NULL); |
| 2060 intptr_t len = reader->ReadSmiValue(); | 2030 intptr_t len = reader->ReadSmiValue(); |
| 2061 String& str_obj = String::ZoneHandle(reader->zone(), String::null()); | 2031 String& str_obj = String::ZoneHandle(reader->zone(), String::null()); |
| 2062 | 2032 |
| 2063 String::ReadFromImpl<OneByteString, uint8_t>( | 2033 String::ReadFromImpl<OneByteString, uint8_t>(reader, &str_obj, len, tags, |
| 2064 reader, &str_obj, len, tags, Symbols::FromLatin1, kind); | 2034 Symbols::FromLatin1, kind); |
| 2065 reader->AddBackRef(object_id, &str_obj, kIsDeserialized); | 2035 reader->AddBackRef(object_id, &str_obj, kIsDeserialized); |
| 2066 return raw(str_obj); | 2036 return raw(str_obj); |
| 2067 } | 2037 } |
| 2068 | 2038 |
| 2069 | 2039 |
| 2070 RawTwoByteString* TwoByteString::ReadFrom(SnapshotReader* reader, | 2040 RawTwoByteString* TwoByteString::ReadFrom(SnapshotReader* reader, |
| 2071 intptr_t object_id, | 2041 intptr_t object_id, |
| 2072 intptr_t tags, | 2042 intptr_t tags, |
| 2073 Snapshot::Kind kind, | 2043 Snapshot::Kind kind, |
| 2074 bool as_reference) { | 2044 bool as_reference) { |
| 2075 // Read the length so that we can determine instance size to allocate. | 2045 // Read the length so that we can determine instance size to allocate. |
| 2076 ASSERT(reader != NULL); | 2046 ASSERT(reader != NULL); |
| 2077 intptr_t len = reader->ReadSmiValue(); | 2047 intptr_t len = reader->ReadSmiValue(); |
| 2078 String& str_obj = String::ZoneHandle(reader->zone(), String::null()); | 2048 String& str_obj = String::ZoneHandle(reader->zone(), String::null()); |
| 2079 | 2049 |
| 2080 String::ReadFromImpl<TwoByteString, uint16_t>( | 2050 String::ReadFromImpl<TwoByteString, uint16_t>(reader, &str_obj, len, tags, |
| 2081 reader, &str_obj, len, tags, Symbols::FromUTF16, kind); | 2051 Symbols::FromUTF16, kind); |
| 2082 reader->AddBackRef(object_id, &str_obj, kIsDeserialized); | 2052 reader->AddBackRef(object_id, &str_obj, kIsDeserialized); |
| 2083 return raw(str_obj); | 2053 return raw(str_obj); |
| 2084 } | 2054 } |
| 2085 | 2055 |
| 2086 | 2056 |
| 2087 template<typename T> | 2057 template <typename T> |
| 2088 static void StringWriteTo(SnapshotWriter* writer, | 2058 static void StringWriteTo(SnapshotWriter* writer, |
| 2089 intptr_t object_id, | 2059 intptr_t object_id, |
| 2090 Snapshot::Kind kind, | 2060 Snapshot::Kind kind, |
| 2091 intptr_t class_id, | 2061 intptr_t class_id, |
| 2092 intptr_t tags, | 2062 intptr_t tags, |
| 2093 RawSmi* length, | 2063 RawSmi* length, |
| 2094 T* data) { | 2064 T* data) { |
| 2095 ASSERT(writer != NULL); | 2065 ASSERT(writer != NULL); |
| 2096 intptr_t len = Smi::Value(length); | 2066 intptr_t len = Smi::Value(length); |
| 2097 | 2067 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2115 } | 2085 } |
| 2116 } | 2086 } |
| 2117 } | 2087 } |
| 2118 } | 2088 } |
| 2119 | 2089 |
| 2120 | 2090 |
| 2121 void RawOneByteString::WriteTo(SnapshotWriter* writer, | 2091 void RawOneByteString::WriteTo(SnapshotWriter* writer, |
| 2122 intptr_t object_id, | 2092 intptr_t object_id, |
| 2123 Snapshot::Kind kind, | 2093 Snapshot::Kind kind, |
| 2124 bool as_reference) { | 2094 bool as_reference) { |
| 2125 StringWriteTo(writer, | 2095 StringWriteTo(writer, object_id, kind, kOneByteStringCid, |
| 2126 object_id, | 2096 writer->GetObjectTags(this), ptr()->length_, ptr()->data()); |
| 2127 kind, | |
| 2128 kOneByteStringCid, | |
| 2129 writer->GetObjectTags(this), | |
| 2130 ptr()->length_, | |
| 2131 ptr()->data()); | |
| 2132 } | 2097 } |
| 2133 | 2098 |
| 2134 | 2099 |
| 2135 void RawTwoByteString::WriteTo(SnapshotWriter* writer, | 2100 void RawTwoByteString::WriteTo(SnapshotWriter* writer, |
| 2136 intptr_t object_id, | 2101 intptr_t object_id, |
| 2137 Snapshot::Kind kind, | 2102 Snapshot::Kind kind, |
| 2138 bool as_reference) { | 2103 bool as_reference) { |
| 2139 StringWriteTo(writer, | 2104 StringWriteTo(writer, object_id, kind, kTwoByteStringCid, |
| 2140 object_id, | 2105 writer->GetObjectTags(this), ptr()->length_, ptr()->data()); |
| 2141 kind, | |
| 2142 kTwoByteStringCid, | |
| 2143 writer->GetObjectTags(this), | |
| 2144 ptr()->length_, | |
| 2145 ptr()->data()); | |
| 2146 } | 2106 } |
| 2147 | 2107 |
| 2148 | 2108 |
| 2149 RawExternalOneByteString* ExternalOneByteString::ReadFrom( | 2109 RawExternalOneByteString* ExternalOneByteString::ReadFrom( |
| 2150 SnapshotReader* reader, | 2110 SnapshotReader* reader, |
| 2151 intptr_t object_id, | 2111 intptr_t object_id, |
| 2152 intptr_t tags, | 2112 intptr_t tags, |
| 2153 Snapshot::Kind kind, | 2113 Snapshot::Kind kind, |
| 2154 bool as_reference) { | 2114 bool as_reference) { |
| 2155 UNREACHABLE(); | 2115 UNREACHABLE(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2166 UNREACHABLE(); | 2126 UNREACHABLE(); |
| 2167 return ExternalTwoByteString::null(); | 2127 return ExternalTwoByteString::null(); |
| 2168 } | 2128 } |
| 2169 | 2129 |
| 2170 | 2130 |
| 2171 void RawExternalOneByteString::WriteTo(SnapshotWriter* writer, | 2131 void RawExternalOneByteString::WriteTo(SnapshotWriter* writer, |
| 2172 intptr_t object_id, | 2132 intptr_t object_id, |
| 2173 Snapshot::Kind kind, | 2133 Snapshot::Kind kind, |
| 2174 bool as_reference) { | 2134 bool as_reference) { |
| 2175 // Serialize as a non-external one byte string. | 2135 // Serialize as a non-external one byte string. |
| 2176 StringWriteTo(writer, | 2136 StringWriteTo(writer, object_id, kind, kOneByteStringCid, |
| 2177 object_id, | 2137 writer->GetObjectTags(this), ptr()->length_, |
| 2178 kind, | |
| 2179 kOneByteStringCid, | |
| 2180 writer->GetObjectTags(this), | |
| 2181 ptr()->length_, | |
| 2182 ptr()->external_data_->data()); | 2138 ptr()->external_data_->data()); |
| 2183 } | 2139 } |
| 2184 | 2140 |
| 2185 | 2141 |
| 2186 void RawExternalTwoByteString::WriteTo(SnapshotWriter* writer, | 2142 void RawExternalTwoByteString::WriteTo(SnapshotWriter* writer, |
| 2187 intptr_t object_id, | 2143 intptr_t object_id, |
| 2188 Snapshot::Kind kind, | 2144 Snapshot::Kind kind, |
| 2189 bool as_reference) { | 2145 bool as_reference) { |
| 2190 // Serialize as a non-external two byte string. | 2146 // Serialize as a non-external two byte string. |
| 2191 StringWriteTo(writer, | 2147 StringWriteTo(writer, object_id, kind, kTwoByteStringCid, |
| 2192 object_id, | 2148 writer->GetObjectTags(this), ptr()->length_, |
| 2193 kind, | |
| 2194 kTwoByteStringCid, | |
| 2195 writer->GetObjectTags(this), | |
| 2196 ptr()->length_, | |
| 2197 ptr()->external_data_->data()); | 2149 ptr()->external_data_->data()); |
| 2198 } | 2150 } |
| 2199 | 2151 |
| 2200 | 2152 |
| 2201 RawBool* Bool::ReadFrom(SnapshotReader* reader, | 2153 RawBool* Bool::ReadFrom(SnapshotReader* reader, |
| 2202 intptr_t object_id, | 2154 intptr_t object_id, |
| 2203 intptr_t tags, | 2155 intptr_t tags, |
| 2204 Snapshot::Kind kind, | 2156 Snapshot::Kind kind, |
| 2205 bool as_reference) { | 2157 bool as_reference) { |
| 2206 UNREACHABLE(); | 2158 UNREACHABLE(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2227 intptr_t len = reader->ReadSmiValue(); | 2179 intptr_t len = reader->ReadSmiValue(); |
| 2228 Array* array = NULL; | 2180 Array* array = NULL; |
| 2229 DeserializeState state; | 2181 DeserializeState state; |
| 2230 if (!as_reference) { | 2182 if (!as_reference) { |
| 2231 array = reinterpret_cast<Array*>(reader->GetBackRef(object_id)); | 2183 array = reinterpret_cast<Array*>(reader->GetBackRef(object_id)); |
| 2232 state = kIsDeserialized; | 2184 state = kIsDeserialized; |
| 2233 } else { | 2185 } else { |
| 2234 state = kIsNotDeserialized; | 2186 state = kIsNotDeserialized; |
| 2235 } | 2187 } |
| 2236 if (array == NULL) { | 2188 if (array == NULL) { |
| 2237 array = &(Array::ZoneHandle(reader->zone(), | 2189 array = |
| 2238 Array::New(len, HEAP_SPACE(kind)))); | 2190 &(Array::ZoneHandle(reader->zone(), Array::New(len, HEAP_SPACE(kind)))); |
| 2239 reader->AddBackRef(object_id, array, state); | 2191 reader->AddBackRef(object_id, array, state); |
| 2240 } | 2192 } |
| 2241 if (!as_reference) { | 2193 if (!as_reference) { |
| 2242 // Read all the individual elements for inlined objects. | 2194 // Read all the individual elements for inlined objects. |
| 2243 ASSERT(!RawObject::IsCanonical(tags)); | 2195 ASSERT(!RawObject::IsCanonical(tags)); |
| 2244 reader->ArrayReadFrom(object_id, *array, len, tags); | 2196 reader->ArrayReadFrom(object_id, *array, len, tags); |
| 2245 } | 2197 } |
| 2246 return array->raw(); | 2198 return array->raw(); |
| 2247 } | 2199 } |
| 2248 | 2200 |
| 2249 | 2201 |
| 2250 RawImmutableArray* ImmutableArray::ReadFrom(SnapshotReader* reader, | 2202 RawImmutableArray* ImmutableArray::ReadFrom(SnapshotReader* reader, |
| 2251 intptr_t object_id, | 2203 intptr_t object_id, |
| 2252 intptr_t tags, | 2204 intptr_t tags, |
| 2253 Snapshot::Kind kind, | 2205 Snapshot::Kind kind, |
| 2254 bool as_reference) { | 2206 bool as_reference) { |
| 2255 ASSERT(reader != NULL); | 2207 ASSERT(reader != NULL); |
| 2256 | 2208 |
| 2257 // Read the length so that we can determine instance size to allocate. | 2209 // Read the length so that we can determine instance size to allocate. |
| 2258 intptr_t len = reader->ReadSmiValue(); | 2210 intptr_t len = reader->ReadSmiValue(); |
| 2259 Array* array = NULL; | 2211 Array* array = NULL; |
| 2260 DeserializeState state; | 2212 DeserializeState state; |
| 2261 if (!as_reference) { | 2213 if (!as_reference) { |
| 2262 array = reinterpret_cast<Array*>(reader->GetBackRef(object_id)); | 2214 array = reinterpret_cast<Array*>(reader->GetBackRef(object_id)); |
| 2263 state = kIsDeserialized; | 2215 state = kIsDeserialized; |
| 2264 } else { | 2216 } else { |
| 2265 state = kIsNotDeserialized; | 2217 state = kIsNotDeserialized; |
| 2266 } | 2218 } |
| 2267 if (array == NULL) { | 2219 if (array == NULL) { |
| 2268 array = &(Array::ZoneHandle( | 2220 array = &(Array::ZoneHandle(reader->zone(), |
| 2269 reader->zone(), | 2221 ImmutableArray::New(len, HEAP_SPACE(kind)))); |
| 2270 ImmutableArray::New(len, HEAP_SPACE(kind)))); | |
| 2271 reader->AddBackRef(object_id, array, state); | 2222 reader->AddBackRef(object_id, array, state); |
| 2272 } | 2223 } |
| 2273 if (!as_reference) { | 2224 if (!as_reference) { |
| 2274 // Read all the individual elements for inlined objects. | 2225 // Read all the individual elements for inlined objects. |
| 2275 reader->ArrayReadFrom(object_id, *array, len, tags); | 2226 reader->ArrayReadFrom(object_id, *array, len, tags); |
| 2276 if (RawObject::IsCanonical(tags)) { | 2227 if (RawObject::IsCanonical(tags)) { |
| 2277 *array ^= array->CheckAndCanonicalize(reader->thread(), NULL); | 2228 *array ^= array->CheckAndCanonicalize(reader->thread(), NULL); |
| 2278 } | 2229 } |
| 2279 } | 2230 } |
| 2280 return raw(*array); | 2231 return raw(*array); |
| 2281 } | 2232 } |
| 2282 | 2233 |
| 2283 | 2234 |
| 2284 void RawArray::WriteTo(SnapshotWriter* writer, | 2235 void RawArray::WriteTo(SnapshotWriter* writer, |
| 2285 intptr_t object_id, | 2236 intptr_t object_id, |
| 2286 Snapshot::Kind kind, | 2237 Snapshot::Kind kind, |
| 2287 bool as_reference) { | 2238 bool as_reference) { |
| 2288 ASSERT(!this->IsCanonical()); | 2239 ASSERT(!this->IsCanonical()); |
| 2289 writer->ArrayWriteTo(object_id, | 2240 writer->ArrayWriteTo(object_id, kArrayCid, writer->GetObjectTags(this), |
| 2290 kArrayCid, | 2241 ptr()->length_, ptr()->type_arguments_, ptr()->data(), |
| 2291 writer->GetObjectTags(this), | |
| 2292 ptr()->length_, | |
| 2293 ptr()->type_arguments_, | |
| 2294 ptr()->data(), | |
| 2295 as_reference); | 2242 as_reference); |
| 2296 } | 2243 } |
| 2297 | 2244 |
| 2298 | 2245 |
| 2299 void RawImmutableArray::WriteTo(SnapshotWriter* writer, | 2246 void RawImmutableArray::WriteTo(SnapshotWriter* writer, |
| 2300 intptr_t object_id, | 2247 intptr_t object_id, |
| 2301 Snapshot::Kind kind, | 2248 Snapshot::Kind kind, |
| 2302 bool as_reference) { | 2249 bool as_reference) { |
| 2303 writer->ArrayWriteTo(object_id, | 2250 writer->ArrayWriteTo(object_id, kImmutableArrayCid, |
| 2304 kImmutableArrayCid, | 2251 writer->GetObjectTags(this), ptr()->length_, |
| 2305 writer->GetObjectTags(this), | 2252 ptr()->type_arguments_, ptr()->data(), as_reference); |
| 2306 ptr()->length_, | |
| 2307 ptr()->type_arguments_, | |
| 2308 ptr()->data(), | |
| 2309 as_reference); | |
| 2310 } | 2253 } |
| 2311 | 2254 |
| 2312 | 2255 |
| 2313 RawGrowableObjectArray* GrowableObjectArray::ReadFrom(SnapshotReader* reader, | 2256 RawGrowableObjectArray* GrowableObjectArray::ReadFrom(SnapshotReader* reader, |
| 2314 intptr_t object_id, | 2257 intptr_t object_id, |
| 2315 intptr_t tags, | 2258 intptr_t tags, |
| 2316 Snapshot::Kind kind, | 2259 Snapshot::Kind kind, |
| 2317 bool as_reference) { | 2260 bool as_reference) { |
| 2318 ASSERT(reader != NULL); | 2261 ASSERT(reader != NULL); |
| 2319 | 2262 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2366 } | 2309 } |
| 2367 | 2310 |
| 2368 | 2311 |
| 2369 RawLinkedHashMap* LinkedHashMap::ReadFrom(SnapshotReader* reader, | 2312 RawLinkedHashMap* LinkedHashMap::ReadFrom(SnapshotReader* reader, |
| 2370 intptr_t object_id, | 2313 intptr_t object_id, |
| 2371 intptr_t tags, | 2314 intptr_t tags, |
| 2372 Snapshot::Kind kind, | 2315 Snapshot::Kind kind, |
| 2373 bool as_reference) { | 2316 bool as_reference) { |
| 2374 ASSERT(reader != NULL); | 2317 ASSERT(reader != NULL); |
| 2375 | 2318 |
| 2376 LinkedHashMap& map = LinkedHashMap::ZoneHandle( | 2319 LinkedHashMap& map = |
| 2377 reader->zone(), LinkedHashMap::null()); | 2320 LinkedHashMap::ZoneHandle(reader->zone(), LinkedHashMap::null()); |
| 2378 if (kind == Snapshot::kScript) { | 2321 if (kind == Snapshot::kScript) { |
| 2379 // The immutable maps that seed map literals are not yet VM-internal, so | 2322 // The immutable maps that seed map literals are not yet VM-internal, so |
| 2380 // we don't reach this. | 2323 // we don't reach this. |
| 2381 UNREACHABLE(); | 2324 UNREACHABLE(); |
| 2382 } else { | 2325 } else { |
| 2383 // Since the map might contain itself as a key or value, allocate first. | 2326 // Since the map might contain itself as a key or value, allocate first. |
| 2384 map = LinkedHashMap::NewUninitialized(HEAP_SPACE(kind)); | 2327 map = LinkedHashMap::NewUninitialized(HEAP_SPACE(kind)); |
| 2385 } | 2328 } |
| 2386 reader->AddBackRef(object_id, &map, kIsDeserialized); | 2329 reader->AddBackRef(object_id, &map, kIsDeserialized); |
| 2387 | 2330 |
| 2388 // Read the type arguments. | 2331 // Read the type arguments. |
| 2389 const intptr_t typeargs_offset = | 2332 const intptr_t typeargs_offset = |
| 2390 GrowableObjectArray::type_arguments_offset() / kWordSize; | 2333 GrowableObjectArray::type_arguments_offset() / kWordSize; |
| 2391 *reader->TypeArgumentsHandle() ^= | 2334 *reader->TypeArgumentsHandle() ^= |
| 2392 reader->ReadObjectImpl(kAsInlinedObject, object_id, typeargs_offset); | 2335 reader->ReadObjectImpl(kAsInlinedObject, object_id, typeargs_offset); |
| 2393 map.SetTypeArguments(*reader->TypeArgumentsHandle()); | 2336 map.SetTypeArguments(*reader->TypeArgumentsHandle()); |
| 2394 | 2337 |
| 2395 // Read the number of key/value pairs. | 2338 // Read the number of key/value pairs. |
| 2396 intptr_t len = reader->ReadSmiValue(); | 2339 intptr_t len = reader->ReadSmiValue(); |
| 2397 intptr_t used_data = (len << 1); | 2340 intptr_t used_data = (len << 1); |
| 2398 map.SetUsedData(used_data); | 2341 map.SetUsedData(used_data); |
| 2399 | 2342 |
| 2400 // Allocate the data array. | 2343 // Allocate the data array. |
| 2401 intptr_t data_size = Utils::Maximum( | 2344 intptr_t data_size = |
| 2402 Utils::RoundUpToPowerOfTwo(used_data), | 2345 Utils::Maximum(Utils::RoundUpToPowerOfTwo(used_data), |
| 2403 static_cast<uintptr_t>(LinkedHashMap::kInitialIndexSize)); | 2346 static_cast<uintptr_t>(LinkedHashMap::kInitialIndexSize)); |
| 2404 Array& data = Array::ZoneHandle(reader->zone(), | 2347 Array& data = Array::ZoneHandle(reader->zone(), |
| 2405 Array::New(data_size, HEAP_SPACE(kind))); | 2348 Array::New(data_size, HEAP_SPACE(kind))); |
| 2406 map.SetData(data); | 2349 map.SetData(data); |
| 2407 map.SetDeletedKeys(0); | 2350 map.SetDeletedKeys(0); |
| 2408 | 2351 |
| 2409 // The index and hashMask is regenerated by the maps themselves on demand. | 2352 // The index and hashMask is regenerated by the maps themselves on demand. |
| 2410 // Thus, the index will probably be allocated in new space (unless it's huge). | 2353 // Thus, the index will probably be allocated in new space (unless it's huge). |
| 2411 // TODO(koda): Eagerly rehash here when no keys have user-defined '==', and | 2354 // TODO(koda): Eagerly rehash here when no keys have user-defined '==', and |
| 2412 // in particular, if/when (const) maps are needed in the VM isolate snapshot. | 2355 // in particular, if/when (const) maps are needed in the VM isolate snapshot. |
| 2413 ASSERT(reader->isolate() != Dart::vm_isolate()); | 2356 ASSERT(reader->isolate() != Dart::vm_isolate()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2480 Snapshot::Kind kind, | 2423 Snapshot::Kind kind, |
| 2481 bool as_reference) { | 2424 bool as_reference) { |
| 2482 ASSERT(reader != NULL); | 2425 ASSERT(reader != NULL); |
| 2483 // Read the values. | 2426 // Read the values. |
| 2484 float value0 = reader->Read<float>(); | 2427 float value0 = reader->Read<float>(); |
| 2485 float value1 = reader->Read<float>(); | 2428 float value1 = reader->Read<float>(); |
| 2486 float value2 = reader->Read<float>(); | 2429 float value2 = reader->Read<float>(); |
| 2487 float value3 = reader->Read<float>(); | 2430 float value3 = reader->Read<float>(); |
| 2488 | 2431 |
| 2489 // Create a Float32x4 object. | 2432 // Create a Float32x4 object. |
| 2490 Float32x4& simd = Float32x4::ZoneHandle(reader->zone(), | 2433 Float32x4& simd = Float32x4::ZoneHandle(reader->zone(), Float32x4::null()); |
| 2491 Float32x4::null()); | |
| 2492 simd = Float32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind)); | 2434 simd = Float32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind)); |
| 2493 reader->AddBackRef(object_id, &simd, kIsDeserialized); | 2435 reader->AddBackRef(object_id, &simd, kIsDeserialized); |
| 2494 return simd.raw(); | 2436 return simd.raw(); |
| 2495 } | 2437 } |
| 2496 | 2438 |
| 2497 | 2439 |
| 2498 void RawFloat32x4::WriteTo(SnapshotWriter* writer, | 2440 void RawFloat32x4::WriteTo(SnapshotWriter* writer, |
| 2499 intptr_t object_id, | 2441 intptr_t object_id, |
| 2500 Snapshot::Kind kind, | 2442 Snapshot::Kind kind, |
| 2501 bool as_reference) { | 2443 bool as_reference) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2561 intptr_t object_id, | 2503 intptr_t object_id, |
| 2562 intptr_t tags, | 2504 intptr_t tags, |
| 2563 Snapshot::Kind kind, | 2505 Snapshot::Kind kind, |
| 2564 bool as_reference) { | 2506 bool as_reference) { |
| 2565 ASSERT(reader != NULL); | 2507 ASSERT(reader != NULL); |
| 2566 // Read the values. | 2508 // Read the values. |
| 2567 double value0 = reader->Read<double>(); | 2509 double value0 = reader->Read<double>(); |
| 2568 double value1 = reader->Read<double>(); | 2510 double value1 = reader->Read<double>(); |
| 2569 | 2511 |
| 2570 // Create a Float64x2 object. | 2512 // Create a Float64x2 object. |
| 2571 Float64x2& simd = Float64x2::ZoneHandle(reader->zone(), | 2513 Float64x2& simd = Float64x2::ZoneHandle(reader->zone(), Float64x2::null()); |
| 2572 Float64x2::null()); | |
| 2573 simd = Float64x2::New(value0, value1, HEAP_SPACE(kind)); | 2514 simd = Float64x2::New(value0, value1, HEAP_SPACE(kind)); |
| 2574 reader->AddBackRef(object_id, &simd, kIsDeserialized); | 2515 reader->AddBackRef(object_id, &simd, kIsDeserialized); |
| 2575 return simd.raw(); | 2516 return simd.raw(); |
| 2576 } | 2517 } |
| 2577 | 2518 |
| 2578 | 2519 |
| 2579 void RawFloat64x2::WriteTo(SnapshotWriter* writer, | 2520 void RawFloat64x2::WriteTo(SnapshotWriter* writer, |
| 2580 intptr_t object_id, | 2521 intptr_t object_id, |
| 2581 Snapshot::Kind kind, | 2522 Snapshot::Kind kind, |
| 2582 bool as_reference) { | 2523 bool as_reference) { |
| 2583 ASSERT(writer != NULL); | 2524 ASSERT(writer != NULL); |
| 2584 | 2525 |
| 2585 // Write out the serialization header value for this object. | 2526 // Write out the serialization header value for this object. |
| 2586 writer->WriteInlinedObjectHeader(object_id); | 2527 writer->WriteInlinedObjectHeader(object_id); |
| 2587 | 2528 |
| 2588 // Write out the class and tags information. | 2529 // Write out the class and tags information. |
| 2589 writer->WriteIndexedObject(kFloat64x2Cid); | 2530 writer->WriteIndexedObject(kFloat64x2Cid); |
| 2590 writer->WriteTags(writer->GetObjectTags(this)); | 2531 writer->WriteTags(writer->GetObjectTags(this)); |
| 2591 | 2532 |
| 2592 // Write out the float values. | 2533 // Write out the float values. |
| 2593 writer->Write<double>(ptr()->value_[0]); | 2534 writer->Write<double>(ptr()->value_[0]); |
| 2594 writer->Write<double>(ptr()->value_[1]); | 2535 writer->Write<double>(ptr()->value_[1]); |
| 2595 } | 2536 } |
| 2596 | 2537 |
| 2597 | 2538 |
| 2598 #define TYPED_DATA_READ(setter, type) \ | 2539 #define TYPED_DATA_READ(setter, type) \ |
| 2599 for (intptr_t i = 0; i < length_in_bytes; i += element_size) { \ | 2540 for (intptr_t i = 0; i < length_in_bytes; i += element_size) { \ |
| 2600 result.Set##setter(i, reader->Read<type>()); \ | 2541 result.Set##setter(i, reader->Read<type>()); \ |
| 2601 } \ | 2542 } |
| 2602 | 2543 |
| 2603 | 2544 |
| 2604 RawTypedData* TypedData::ReadFrom(SnapshotReader* reader, | 2545 RawTypedData* TypedData::ReadFrom(SnapshotReader* reader, |
| 2605 intptr_t object_id, | 2546 intptr_t object_id, |
| 2606 intptr_t tags, | 2547 intptr_t tags, |
| 2607 Snapshot::Kind kind, | 2548 Snapshot::Kind kind, |
| 2608 bool as_reference) { | 2549 bool as_reference) { |
| 2609 ASSERT(reader != NULL); | 2550 ASSERT(reader != NULL); |
| 2610 | 2551 |
| 2611 intptr_t cid = RawObject::ClassIdTag::decode(tags); | 2552 intptr_t cid = RawObject::ClassIdTag::decode(tags); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2670 | 2611 |
| 2671 RawExternalTypedData* ExternalTypedData::ReadFrom(SnapshotReader* reader, | 2612 RawExternalTypedData* ExternalTypedData::ReadFrom(SnapshotReader* reader, |
| 2672 intptr_t object_id, | 2613 intptr_t object_id, |
| 2673 intptr_t tags, | 2614 intptr_t tags, |
| 2674 Snapshot::Kind kind, | 2615 Snapshot::Kind kind, |
| 2675 bool as_reference) { | 2616 bool as_reference) { |
| 2676 ASSERT(!Snapshot::IsFull(kind)); | 2617 ASSERT(!Snapshot::IsFull(kind)); |
| 2677 intptr_t cid = RawObject::ClassIdTag::decode(tags); | 2618 intptr_t cid = RawObject::ClassIdTag::decode(tags); |
| 2678 intptr_t length = reader->ReadSmiValue(); | 2619 intptr_t length = reader->ReadSmiValue(); |
| 2679 uint8_t* data = reinterpret_cast<uint8_t*>(reader->ReadRawPointerValue()); | 2620 uint8_t* data = reinterpret_cast<uint8_t*>(reader->ReadRawPointerValue()); |
| 2680 ExternalTypedData& obj = ExternalTypedData::ZoneHandle( | 2621 ExternalTypedData& obj = |
| 2681 ExternalTypedData::New(cid, data, length)); | 2622 ExternalTypedData::ZoneHandle(ExternalTypedData::New(cid, data, length)); |
| 2682 reader->AddBackRef(object_id, &obj, kIsDeserialized); | 2623 reader->AddBackRef(object_id, &obj, kIsDeserialized); |
| 2683 void* peer = reinterpret_cast<void*>(reader->ReadRawPointerValue()); | 2624 void* peer = reinterpret_cast<void*>(reader->ReadRawPointerValue()); |
| 2684 Dart_WeakPersistentHandleFinalizer callback = | 2625 Dart_WeakPersistentHandleFinalizer callback = |
| 2685 reinterpret_cast<Dart_WeakPersistentHandleFinalizer>( | 2626 reinterpret_cast<Dart_WeakPersistentHandleFinalizer>( |
| 2686 reader->ReadRawPointerValue()); | 2627 reader->ReadRawPointerValue()); |
| 2687 intptr_t external_size = obj.LengthInBytes(); | 2628 intptr_t external_size = obj.LengthInBytes(); |
| 2688 obj.AddFinalizer(peer, callback, external_size); | 2629 obj.AddFinalizer(peer, callback, external_size); |
| 2689 return obj.raw(); | 2630 return obj.raw(); |
| 2690 } | 2631 } |
| 2691 | 2632 |
| 2692 | 2633 |
| 2693 #define TYPED_DATA_WRITE(type) \ | 2634 #define TYPED_DATA_WRITE(type) \ |
| 2694 { \ | 2635 { \ |
| 2695 type* data = reinterpret_cast<type*>(ptr()->data()); \ | 2636 type* data = reinterpret_cast<type*>(ptr()->data()); \ |
| 2696 for (intptr_t i = 0; i < len; i++) { \ | 2637 for (intptr_t i = 0; i < len; i++) { \ |
| 2697 writer->Write(data[i]); \ | 2638 writer->Write(data[i]); \ |
| 2698 } \ | 2639 } \ |
| 2699 } \ | 2640 } |
| 2700 | 2641 |
| 2701 | 2642 |
| 2702 void RawTypedData::WriteTo(SnapshotWriter* writer, | 2643 void RawTypedData::WriteTo(SnapshotWriter* writer, |
| 2703 intptr_t object_id, | 2644 intptr_t object_id, |
| 2704 Snapshot::Kind kind, | 2645 Snapshot::Kind kind, |
| 2705 bool as_reference) { | 2646 bool as_reference) { |
| 2706 ASSERT(writer != NULL); | 2647 ASSERT(writer != NULL); |
| 2707 intptr_t cid = this->GetClassId(); | 2648 intptr_t cid = this->GetClassId(); |
| 2708 intptr_t len = Smi::Value(ptr()->length_); | 2649 intptr_t len = Smi::Value(ptr()->length_); |
| 2709 | 2650 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2755 } | 2696 } |
| 2756 } | 2697 } |
| 2757 | 2698 |
| 2758 | 2699 |
| 2759 #define TYPED_EXT_DATA_WRITE(type) \ | 2700 #define TYPED_EXT_DATA_WRITE(type) \ |
| 2760 { \ | 2701 { \ |
| 2761 type* data = reinterpret_cast<type*>(ptr()->data_); \ | 2702 type* data = reinterpret_cast<type*>(ptr()->data_); \ |
| 2762 for (intptr_t i = 0; i < len; i++) { \ | 2703 for (intptr_t i = 0; i < len; i++) { \ |
| 2763 writer->Write(data[i]); \ | 2704 writer->Write(data[i]); \ |
| 2764 } \ | 2705 } \ |
| 2765 } \ | 2706 } |
| 2766 | 2707 |
| 2767 | 2708 |
| 2768 #define EXT_TYPED_DATA_WRITE(cid, type) \ | 2709 #define EXT_TYPED_DATA_WRITE(cid, type) \ |
| 2769 writer->WriteIndexedObject(cid); \ | 2710 writer->WriteIndexedObject(cid); \ |
| 2770 writer->WriteTags(writer->GetObjectTags(this)); \ | 2711 writer->WriteTags(writer->GetObjectTags(this)); \ |
| 2771 writer->Write<RawObject*>(ptr()->length_); \ | 2712 writer->Write<RawObject*>(ptr()->length_); \ |
| 2772 TYPED_EXT_DATA_WRITE(type) \ | 2713 TYPED_EXT_DATA_WRITE(type) |
| 2773 | 2714 |
| 2774 | 2715 |
| 2775 void RawExternalTypedData::WriteTo(SnapshotWriter* writer, | 2716 void RawExternalTypedData::WriteTo(SnapshotWriter* writer, |
| 2776 intptr_t object_id, | 2717 intptr_t object_id, |
| 2777 Snapshot::Kind kind, | 2718 Snapshot::Kind kind, |
| 2778 bool as_reference) { | 2719 bool as_reference) { |
| 2779 ASSERT(writer != NULL); | 2720 ASSERT(writer != NULL); |
| 2780 intptr_t cid = this->GetClassId(); | 2721 intptr_t cid = this->GetClassId(); |
| 2781 intptr_t len = Smi::Value(ptr()->length_); | 2722 intptr_t len = Smi::Value(ptr()->length_); |
| 2782 | 2723 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2825 #undef EXT_TYPED_DATA_WRITE | 2766 #undef EXT_TYPED_DATA_WRITE |
| 2826 | 2767 |
| 2827 | 2768 |
| 2828 RawCapability* Capability::ReadFrom(SnapshotReader* reader, | 2769 RawCapability* Capability::ReadFrom(SnapshotReader* reader, |
| 2829 intptr_t object_id, | 2770 intptr_t object_id, |
| 2830 intptr_t tags, | 2771 intptr_t tags, |
| 2831 Snapshot::Kind kind, | 2772 Snapshot::Kind kind, |
| 2832 bool as_reference) { | 2773 bool as_reference) { |
| 2833 uint64_t id = reader->Read<uint64_t>(); | 2774 uint64_t id = reader->Read<uint64_t>(); |
| 2834 | 2775 |
| 2835 Capability& result = Capability::ZoneHandle(reader->zone(), | 2776 Capability& result = |
| 2836 Capability::New(id)); | 2777 Capability::ZoneHandle(reader->zone(), Capability::New(id)); |
| 2837 reader->AddBackRef(object_id, &result, kIsDeserialized); | 2778 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 2838 return result.raw(); | 2779 return result.raw(); |
| 2839 } | 2780 } |
| 2840 | 2781 |
| 2841 | 2782 |
| 2842 void RawCapability::WriteTo(SnapshotWriter* writer, | 2783 void RawCapability::WriteTo(SnapshotWriter* writer, |
| 2843 intptr_t object_id, | 2784 intptr_t object_id, |
| 2844 Snapshot::Kind kind, | 2785 Snapshot::Kind kind, |
| 2845 bool as_reference) { | 2786 bool as_reference) { |
| 2846 // Write out the serialization header value for this object. | 2787 // Write out the serialization header value for this object. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2883 intptr_t object_id, | 2824 intptr_t object_id, |
| 2884 intptr_t tags, | 2825 intptr_t tags, |
| 2885 Snapshot::Kind kind, | 2826 Snapshot::Kind kind, |
| 2886 bool as_reference) { | 2827 bool as_reference) { |
| 2887 ASSERT(kind == Snapshot::kMessage); | 2828 ASSERT(kind == Snapshot::kMessage); |
| 2888 | 2829 |
| 2889 uint64_t id = reader->Read<uint64_t>(); | 2830 uint64_t id = reader->Read<uint64_t>(); |
| 2890 uint64_t origin_id = reader->Read<uint64_t>(); | 2831 uint64_t origin_id = reader->Read<uint64_t>(); |
| 2891 | 2832 |
| 2892 SendPort& result = | 2833 SendPort& result = |
| 2893 SendPort::ZoneHandle(reader->zone(), | 2834 SendPort::ZoneHandle(reader->zone(), SendPort::New(id, origin_id)); |
| 2894 SendPort::New(id, origin_id)); | |
| 2895 reader->AddBackRef(object_id, &result, kIsDeserialized); | 2835 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 2896 return result.raw(); | 2836 return result.raw(); |
| 2897 } | 2837 } |
| 2898 | 2838 |
| 2899 | 2839 |
| 2900 void RawSendPort::WriteTo(SnapshotWriter* writer, | 2840 void RawSendPort::WriteTo(SnapshotWriter* writer, |
| 2901 intptr_t object_id, | 2841 intptr_t object_id, |
| 2902 Snapshot::Kind kind, | 2842 Snapshot::Kind kind, |
| 2903 bool as_reference) { | 2843 bool as_reference) { |
| 2904 // Write out the serialization header value for this object. | 2844 // Write out the serialization header value for this object. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2945 RegExp& regex = RegExp::ZoneHandle(reader->zone(), RegExp::New()); | 2885 RegExp& regex = RegExp::ZoneHandle(reader->zone(), RegExp::New()); |
| 2946 reader->AddBackRef(object_id, ®ex, kIsDeserialized); | 2886 reader->AddBackRef(object_id, ®ex, kIsDeserialized); |
| 2947 | 2887 |
| 2948 // Read and Set all the other fields. | 2888 // Read and Set all the other fields. |
| 2949 regex.StoreSmi(®ex.raw_ptr()->num_bracket_expressions_, | 2889 regex.StoreSmi(®ex.raw_ptr()->num_bracket_expressions_, |
| 2950 reader->ReadAsSmi()); | 2890 reader->ReadAsSmi()); |
| 2951 *reader->StringHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); | 2891 *reader->StringHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); |
| 2952 regex.set_pattern(*reader->StringHandle()); | 2892 regex.set_pattern(*reader->StringHandle()); |
| 2953 regex.StoreNonPointer(®ex.raw_ptr()->num_registers_, | 2893 regex.StoreNonPointer(®ex.raw_ptr()->num_registers_, |
| 2954 reader->Read<int32_t>()); | 2894 reader->Read<int32_t>()); |
| 2955 regex.StoreNonPointer(®ex.raw_ptr()->type_flags_, | 2895 regex.StoreNonPointer(®ex.raw_ptr()->type_flags_, reader->Read<int8_t>()); |
| 2956 reader->Read<int8_t>()); | |
| 2957 | 2896 |
| 2958 // TODO(18854): Need to implement a way of recreating the irrexp functions. | 2897 // TODO(18854): Need to implement a way of recreating the irrexp functions. |
| 2959 const Function& no_function = Function::Handle(reader->zone()); | 2898 const Function& no_function = Function::Handle(reader->zone()); |
| 2960 regex.set_function(kOneByteStringCid, no_function); | 2899 regex.set_function(kOneByteStringCid, no_function); |
| 2961 regex.set_function(kTwoByteStringCid, no_function); | 2900 regex.set_function(kTwoByteStringCid, no_function); |
| 2962 regex.set_function(kExternalOneByteStringCid, no_function); | 2901 regex.set_function(kExternalOneByteStringCid, no_function); |
| 2963 regex.set_function(kExternalTwoByteStringCid, no_function); | 2902 regex.set_function(kExternalTwoByteStringCid, no_function); |
| 2964 | 2903 |
| 2965 const TypedData& no_bytecode = TypedData::Handle(reader->zone()); | 2904 const TypedData& no_bytecode = TypedData::Handle(reader->zone()); |
| 2966 regex.set_bytecode(true, no_bytecode); | 2905 regex.set_bytecode(true, no_bytecode); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2992 | 2931 |
| 2993 | 2932 |
| 2994 RawWeakProperty* WeakProperty::ReadFrom(SnapshotReader* reader, | 2933 RawWeakProperty* WeakProperty::ReadFrom(SnapshotReader* reader, |
| 2995 intptr_t object_id, | 2934 intptr_t object_id, |
| 2996 intptr_t tags, | 2935 intptr_t tags, |
| 2997 Snapshot::Kind kind, | 2936 Snapshot::Kind kind, |
| 2998 bool as_reference) { | 2937 bool as_reference) { |
| 2999 ASSERT(reader != NULL); | 2938 ASSERT(reader != NULL); |
| 3000 | 2939 |
| 3001 // Allocate the weak property object. | 2940 // Allocate the weak property object. |
| 3002 WeakProperty& weak_property = WeakProperty::ZoneHandle(reader->zone(), | 2941 WeakProperty& weak_property = |
| 3003 WeakProperty::New()); | 2942 WeakProperty::ZoneHandle(reader->zone(), WeakProperty::New()); |
| 3004 reader->AddBackRef(object_id, &weak_property, kIsDeserialized); | 2943 reader->AddBackRef(object_id, &weak_property, kIsDeserialized); |
| 3005 | 2944 |
| 3006 // Set all the object fields. | 2945 // Set all the object fields. |
| 3007 READ_OBJECT_FIELDS(weak_property, | 2946 READ_OBJECT_FIELDS(weak_property, weak_property.raw()->from(), |
| 3008 weak_property.raw()->from(), weak_property.raw()->to(), | 2947 weak_property.raw()->to(), kAsReference); |
| 3009 kAsReference); | |
| 3010 | 2948 |
| 3011 return weak_property.raw(); | 2949 return weak_property.raw(); |
| 3012 } | 2950 } |
| 3013 | 2951 |
| 3014 | 2952 |
| 3015 void RawWeakProperty::WriteTo(SnapshotWriter* writer, | 2953 void RawWeakProperty::WriteTo(SnapshotWriter* writer, |
| 3016 intptr_t object_id, | 2954 intptr_t object_id, |
| 3017 Snapshot::Kind kind, | 2955 Snapshot::Kind kind, |
| 3018 bool as_reference) { | 2956 bool as_reference) { |
| 3019 ASSERT(writer != NULL); | 2957 ASSERT(writer != NULL); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3074 // We do not allow objects with native fields in an isolate message. | 3012 // We do not allow objects with native fields in an isolate message. |
| 3075 writer->SetWriteException(Exceptions::kArgument, | 3013 writer->SetWriteException(Exceptions::kArgument, |
| 3076 "Illegal argument in isolate message" | 3014 "Illegal argument in isolate message" |
| 3077 " : (object is a UserTag)"); | 3015 " : (object is a UserTag)"); |
| 3078 } else { | 3016 } else { |
| 3079 UNREACHABLE(); | 3017 UNREACHABLE(); |
| 3080 } | 3018 } |
| 3081 } | 3019 } |
| 3082 | 3020 |
| 3083 } // namespace dart | 3021 } // namespace dart |
| OLD | NEW |