| 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/snapshot.h" | 5 #include "vm/snapshot.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/bootstrap.h" | 8 #include "vm/bootstrap.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 LongJumpScope jump; | 207 LongJumpScope jump; |
| 208 if (setjmp(*jump.Set()) == 0) { | 208 if (setjmp(*jump.Set()) == 0) { |
| 209 PassiveObject& obj = | 209 PassiveObject& obj = |
| 210 PassiveObject::Handle(isolate(), ReadObjectImpl(kAsInlinedObject)); | 210 PassiveObject::Handle(isolate(), ReadObjectImpl(kAsInlinedObject)); |
| 211 for (intptr_t i = 0; i < backward_references_->length(); i++) { | 211 for (intptr_t i = 0; i < backward_references_->length(); i++) { |
| 212 if (!(*backward_references_)[i].is_deserialized()) { | 212 if (!(*backward_references_)[i].is_deserialized()) { |
| 213 ReadObjectImpl(kAsInlinedObject); | 213 ReadObjectImpl(kAsInlinedObject); |
| 214 (*backward_references_)[i].set_state(kIsDeserialized); | 214 (*backward_references_)[i].set_state(kIsDeserialized); |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 ProcessDeferredCanonicalizations(); |
| 217 return obj.raw(); | 218 return obj.raw(); |
| 218 } else { | 219 } else { |
| 219 // An error occurred while reading, return the error object. | 220 // An error occurred while reading, return the error object. |
| 220 const Error& err = Error::Handle(isolate()->object_store()->sticky_error()); | 221 const Error& err = Error::Handle(isolate()->object_store()->sticky_error()); |
| 221 isolate()->object_store()->clear_sticky_error(); | 222 isolate()->object_store()->clear_sticky_error(); |
| 222 return err.raw(); | 223 return err.raw(); |
| 223 } | 224 } |
| 224 } | 225 } |
| 225 | 226 |
| 226 | 227 |
| 227 RawClass* SnapshotReader::ReadClassId(intptr_t object_id) { | 228 RawClass* SnapshotReader::ReadClassId(intptr_t object_id) { |
| 228 ASSERT(kind_ != Snapshot::kFull); | 229 ASSERT(kind_ != Snapshot::kFull); |
| 229 // Read the class header information and lookup the class. | 230 // Read the class header information and lookup the class. |
| 230 intptr_t class_header = Read<int32_t>(); | 231 intptr_t class_header = Read<int32_t>(); |
| 231 ASSERT((class_header & kSmiTagMask) != kSmiTag); | 232 ASSERT((class_header & kSmiTagMask) != kSmiTag); |
| 232 ASSERT(!IsVMIsolateObject(class_header) || | 233 ASSERT(!IsVMIsolateObject(class_header) || |
| 233 !IsSingletonClassId(GetVMIsolateObjectId(class_header))); | 234 !IsSingletonClassId(GetVMIsolateObjectId(class_header))); |
| 234 ASSERT((SerializedHeaderTag::decode(class_header) != kObjectId) || | 235 ASSERT((SerializedHeaderTag::decode(class_header) != kObjectId) || |
| 235 !IsObjectStoreClassId(SerializedHeaderData::decode(class_header))); | 236 !IsObjectStoreClassId(SerializedHeaderData::decode(class_header))); |
| 236 Class& cls = Class::ZoneHandle(zone(), Class::null()); | 237 Class& cls = Class::ZoneHandle(zone(), Class::null()); |
| 237 AddBackRef(object_id, &cls, kIsDeserialized); | 238 AddBackRef(object_id, &cls, kIsDeserialized); |
| 238 // Read the library/class information and lookup the class. | 239 // Read the library/class information and lookup the class. |
| 239 str_ ^= ReadObjectImpl(class_header, kAsInlinedObject); | 240 str_ ^= ReadObjectImpl(class_header, kAsInlinedObject, kInvalidPatchIndex, 0); |
| 240 library_ = Library::LookupLibrary(str_); | 241 library_ = Library::LookupLibrary(str_); |
| 241 if (library_.IsNull() || !library_.Loaded()) { | 242 if (library_.IsNull() || !library_.Loaded()) { |
| 242 SetReadException("Invalid object found in message."); | 243 SetReadException("Invalid object found in message."); |
| 243 } | 244 } |
| 244 str_ ^= ReadObjectImpl(kAsInlinedObject); | 245 str_ ^= ReadObjectImpl(kAsInlinedObject); |
| 245 cls = library_.LookupClass(str_); | 246 cls = library_.LookupClass(str_); |
| 246 if (cls.IsNull()) { | 247 if (cls.IsNull()) { |
| 247 SetReadException("Invalid object found in message."); | 248 SetReadException("Invalid object found in message."); |
| 248 } | 249 } |
| 249 cls.EnsureIsFinalized(isolate()); | 250 cls.EnsureIsFinalized(isolate()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 isolate, UnhandledException::New(Instance::Cast(result), stacktrace)); | 316 isolate, UnhandledException::New(Instance::Cast(result), stacktrace)); |
| 316 isolate->long_jump_base()->Jump(1, error); | 317 isolate->long_jump_base()->Jump(1, error); |
| 317 } | 318 } |
| 318 | 319 |
| 319 | 320 |
| 320 RawObject* SnapshotReader::VmIsolateSnapshotObject(intptr_t index) const { | 321 RawObject* SnapshotReader::VmIsolateSnapshotObject(intptr_t index) const { |
| 321 return Object::vm_isolate_snapshot_object_table().At(index); | 322 return Object::vm_isolate_snapshot_object_table().At(index); |
| 322 } | 323 } |
| 323 | 324 |
| 324 | 325 |
| 325 RawObject* SnapshotReader::ReadObjectImpl(bool as_reference) { | 326 RawObject* SnapshotReader::ReadObjectImpl(bool as_reference, |
| 327 intptr_t patch_object_id, |
| 328 intptr_t patch_offset) { |
| 326 int64_t header_value = Read<int64_t>(); | 329 int64_t header_value = Read<int64_t>(); |
| 327 if ((header_value & kSmiTagMask) == kSmiTag) { | 330 if ((header_value & kSmiTagMask) == kSmiTag) { |
| 328 return NewInteger(header_value); | 331 return NewInteger(header_value); |
| 329 } | 332 } |
| 330 ASSERT((header_value <= kIntptrMax) && (header_value >= kIntptrMin)); | 333 ASSERT((header_value <= kIntptrMax) && (header_value >= kIntptrMin)); |
| 331 return ReadObjectImpl(static_cast<intptr_t>(header_value), as_reference); | 334 return ReadObjectImpl(static_cast<intptr_t>(header_value), |
| 335 as_reference, |
| 336 patch_object_id, |
| 337 patch_offset); |
| 332 } | 338 } |
| 333 | 339 |
| 334 | 340 |
| 335 RawObject* SnapshotReader::ReadObjectImpl(intptr_t header_value, | 341 RawObject* SnapshotReader::ReadObjectImpl(intptr_t header_value, |
| 336 bool as_reference) { | 342 bool as_reference, |
| 343 intptr_t patch_object_id, |
| 344 intptr_t patch_offset) { |
| 337 if (IsVMIsolateObject(header_value)) { | 345 if (IsVMIsolateObject(header_value)) { |
| 338 return ReadVMIsolateObject(header_value); | 346 return ReadVMIsolateObject(header_value); |
| 339 } else { | 347 } else { |
| 340 if (SerializedHeaderTag::decode(header_value) == kObjectId) { | 348 if (SerializedHeaderTag::decode(header_value) == kObjectId) { |
| 341 return ReadIndexedObject(SerializedHeaderData::decode(header_value)); | 349 return ReadIndexedObject(SerializedHeaderData::decode(header_value), |
| 350 patch_object_id, |
| 351 patch_offset); |
| 342 } | 352 } |
| 343 ASSERT(SerializedHeaderTag::decode(header_value) == kInlined); | 353 ASSERT(SerializedHeaderTag::decode(header_value) == kInlined); |
| 344 intptr_t object_id = SerializedHeaderData::decode(header_value); | 354 intptr_t object_id = SerializedHeaderData::decode(header_value); |
| 345 if (object_id == kOmittedObjectId) { | 355 if (object_id == kOmittedObjectId) { |
| 346 object_id = NextAvailableObjectId(); | 356 object_id = NextAvailableObjectId(); |
| 347 } | 357 } |
| 348 | 358 |
| 349 // Read the class header information. | 359 // Read the class header information. |
| 350 intptr_t class_header = Read<int32_t>(); | 360 intptr_t class_header = Read<int32_t>(); |
| 351 intptr_t tags = ReadTags(); | 361 intptr_t tags = ReadTags(); |
| 352 if (as_reference && !RawObject::IsCanonical(tags)) { | 362 if (as_reference && !RawObject::IsCanonical(tags)) { |
| 353 return ReadObjectRef(object_id, class_header, tags); | 363 return ReadObjectRef(object_id, |
| 354 } else { | 364 class_header, |
| 355 return ReadInlinedObject(object_id, class_header, tags); | 365 tags, |
| 366 patch_object_id, |
| 367 patch_offset); |
| 356 } | 368 } |
| 369 return ReadInlinedObject(object_id, |
| 370 class_header, |
| 371 tags, |
| 372 patch_object_id, |
| 373 patch_offset); |
| 357 } | 374 } |
| 358 } | 375 } |
| 359 | 376 |
| 360 | 377 |
| 361 RawObject* SnapshotReader::ReadObjectRef(intptr_t object_id, | 378 RawObject* SnapshotReader::ReadObjectRef(intptr_t object_id, |
| 362 intptr_t class_header, | 379 intptr_t class_header, |
| 363 intptr_t tags) { | 380 intptr_t tags, |
| 381 intptr_t patch_object_id, |
| 382 intptr_t patch_offset) { |
| 364 // Since we are only reading an object reference, If it is an instance kind | 383 // Since we are only reading an object reference, If it is an instance kind |
| 365 // then we only need to figure out the class of the object and allocate an | 384 // then we only need to figure out the class of the object and allocate an |
| 366 // instance of it. The individual fields will be read later. | 385 // instance of it. The individual fields will be read later. |
| 367 intptr_t header_id = SerializedHeaderData::decode(class_header); | 386 intptr_t header_id = SerializedHeaderData::decode(class_header); |
| 368 if (header_id == kInstanceObjectId) { | 387 if (header_id == kInstanceObjectId) { |
| 369 Instance& result = Instance::ZoneHandle(zone(), Instance::null()); | 388 Instance& result = Instance::ZoneHandle(zone(), Instance::null()); |
| 370 AddBackRef(object_id, &result, kIsNotDeserialized); | 389 AddBackRef(object_id, &result, kIsNotDeserialized); |
| 371 | 390 |
| 372 cls_ ^= ReadObjectImpl(kAsInlinedObject); // Read class information. | 391 cls_ ^= ReadObjectImpl(kAsInlinedObject); // Read class information. |
| 373 ASSERT(!cls_.IsNull()); | 392 ASSERT(!cls_.IsNull()); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 } | 463 } |
| 445 if (kind_ == Snapshot::kFull) { | 464 if (kind_ == Snapshot::kFull) { |
| 446 pobj_.SetCreatedFromSnapshot(); | 465 pobj_.SetCreatedFromSnapshot(); |
| 447 } | 466 } |
| 448 return pobj_.raw(); | 467 return pobj_.raw(); |
| 449 } | 468 } |
| 450 | 469 |
| 451 | 470 |
| 452 RawObject* SnapshotReader::ReadInlinedObject(intptr_t object_id, | 471 RawObject* SnapshotReader::ReadInlinedObject(intptr_t object_id, |
| 453 intptr_t class_header, | 472 intptr_t class_header, |
| 454 intptr_t tags) { | 473 intptr_t tags, |
| 474 intptr_t patch_object_id, |
| 475 intptr_t patch_offset) { |
| 455 // Lookup the class based on the class header information. | 476 // Lookup the class based on the class header information. |
| 456 intptr_t header_id = SerializedHeaderData::decode(class_header); | 477 intptr_t header_id = SerializedHeaderData::decode(class_header); |
| 457 if (header_id == kInstanceObjectId) { | 478 if (header_id == kInstanceObjectId) { |
| 458 // Object is regular dart instance. | 479 // Object is regular dart instance. |
| 459 Instance* result = reinterpret_cast<Instance*>(GetBackRef(object_id)); | 480 Instance* result = reinterpret_cast<Instance*>(GetBackRef(object_id)); |
| 460 intptr_t instance_size = 0; | 481 intptr_t instance_size = 0; |
| 461 if (result == NULL) { | 482 if (result == NULL) { |
| 462 result = &(Instance::ZoneHandle(zone(), Instance::null())); | 483 result = &(Instance::ZoneHandle(zone(), Instance::null())); |
| 463 AddBackRef(object_id, result, kIsDeserialized); | 484 AddBackRef(object_id, result, kIsDeserialized); |
| 464 cls_ ^= ReadObjectImpl(kAsInlinedObject); | 485 cls_ ^= ReadObjectImpl(kAsInlinedObject); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 486 bool as_reference = RawObject::IsCanonical(tags) ? false : true; | 507 bool as_reference = RawObject::IsCanonical(tags) ? false : true; |
| 487 intptr_t offset = Instance::NextFieldOffset(); | 508 intptr_t offset = Instance::NextFieldOffset(); |
| 488 intptr_t result_cid = result->GetClassId(); | 509 intptr_t result_cid = result->GetClassId(); |
| 489 while (offset < next_field_offset) { | 510 while (offset < next_field_offset) { |
| 490 pobj_ = ReadObjectImpl(as_reference); | 511 pobj_ = ReadObjectImpl(as_reference); |
| 491 result->SetFieldAtOffset(offset, pobj_); | 512 result->SetFieldAtOffset(offset, pobj_); |
| 492 if ((offset != type_argument_field_offset) && | 513 if ((offset != type_argument_field_offset) && |
| 493 (kind_ == Snapshot::kMessage)) { | 514 (kind_ == Snapshot::kMessage)) { |
| 494 // TODO(fschneider): Consider hoisting these lookups out of the loop. | 515 // TODO(fschneider): Consider hoisting these lookups out of the loop. |
| 495 // This would involve creating a handle, since cls_ can't be reused | 516 // This would involve creating a handle, since cls_ can't be reused |
| 496 // across the call to ReadObjectRef. | 517 // across the call to ReadObjectImpl. |
| 497 cls_ = isolate()->class_table()->At(result_cid); | 518 cls_ = isolate()->class_table()->At(result_cid); |
| 498 array_ = cls_.OffsetToFieldMap(); | 519 array_ = cls_.OffsetToFieldMap(); |
| 499 field_ ^= array_.At(offset >> kWordSizeLog2); | 520 field_ ^= array_.At(offset >> kWordSizeLog2); |
| 500 ASSERT(!field_.IsNull()); | 521 ASSERT(!field_.IsNull()); |
| 501 ASSERT(field_.Offset() == offset); | 522 ASSERT(field_.Offset() == offset); |
| 502 obj_ = pobj_.raw(); | 523 obj_ = pobj_.raw(); |
| 503 field_.RecordStore(obj_); | 524 field_.RecordStore(obj_); |
| 504 } | 525 } |
| 505 // TODO(fschneider): Verify the guarded cid and length for other kinds of | 526 // TODO(fschneider): Verify the guarded cid and length for other kinds of |
| 506 // snapshot (kFull, kScript) with asserts. | 527 // snapshot (kFull, kScript) with asserts. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 tags = RawObject::ClassIdTag::update(class_id, tags); | 572 tags = RawObject::ClassIdTag::update(class_id, tags); |
| 552 pobj_ = ExternalTypedData::ReadFrom(this, object_id, tags, kind_); | 573 pobj_ = ExternalTypedData::ReadFrom(this, object_id, tags, kind_); |
| 553 break; | 574 break; |
| 554 } | 575 } |
| 555 #undef SNAPSHOT_READ | 576 #undef SNAPSHOT_READ |
| 556 default: UNREACHABLE(); break; | 577 default: UNREACHABLE(); break; |
| 557 } | 578 } |
| 558 if (kind_ == Snapshot::kFull) { | 579 if (kind_ == Snapshot::kFull) { |
| 559 pobj_.SetCreatedFromSnapshot(); | 580 pobj_.SetCreatedFromSnapshot(); |
| 560 } | 581 } |
| 582 AddPatchRecord(object_id, patch_object_id, patch_offset); |
| 561 return pobj_.raw(); | 583 return pobj_.raw(); |
| 562 } | 584 } |
| 563 | 585 |
| 564 | 586 |
| 565 void SnapshotReader::AddBackRef(intptr_t id, | 587 void SnapshotReader::AddBackRef(intptr_t id, |
| 566 Object* obj, | 588 Object* obj, |
| 567 DeserializeState state) { | 589 DeserializeState state, |
| 590 bool defer_canonicalization) { |
| 568 intptr_t index = (id - kMaxPredefinedObjectIds); | 591 intptr_t index = (id - kMaxPredefinedObjectIds); |
| 569 ASSERT(index >= max_vm_isolate_object_id_); | 592 ASSERT(index >= max_vm_isolate_object_id_); |
| 570 index -= max_vm_isolate_object_id_; | 593 index -= max_vm_isolate_object_id_; |
| 571 ASSERT(index == backward_references_->length()); | 594 ASSERT(index == backward_references_->length()); |
| 572 BackRefNode node(obj, state); | 595 BackRefNode node(obj, state, defer_canonicalization); |
| 573 backward_references_->Add(node); | 596 backward_references_->Add(node); |
| 574 } | 597 } |
| 575 | 598 |
| 576 | 599 |
| 577 Object* SnapshotReader::GetBackRef(intptr_t id) { | 600 Object* SnapshotReader::GetBackRef(intptr_t id) { |
| 578 ASSERT(id >= kMaxPredefinedObjectIds); | 601 ASSERT(id >= kMaxPredefinedObjectIds); |
| 579 intptr_t index = (id - kMaxPredefinedObjectIds); | 602 intptr_t index = (id - kMaxPredefinedObjectIds); |
| 580 ASSERT(index >= max_vm_isolate_object_id_); | 603 ASSERT(index >= max_vm_isolate_object_id_); |
| 581 index -= max_vm_isolate_object_id_; | 604 index -= max_vm_isolate_object_id_; |
| 582 if (index < backward_references_->length()) { | 605 if (index < backward_references_->length()) { |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 return isolate()->class_table()->At(class_id); // get singleton class. | 1110 return isolate()->class_table()->At(class_id); // get singleton class. |
| 1088 } else { | 1111 } else { |
| 1089 ASSERT(Symbols::IsVMSymbolId(object_id)); | 1112 ASSERT(Symbols::IsVMSymbolId(object_id)); |
| 1090 return Symbols::GetVMSymbol(object_id); // return VM symbol. | 1113 return Symbols::GetVMSymbol(object_id); // return VM symbol. |
| 1091 } | 1114 } |
| 1092 UNREACHABLE(); | 1115 UNREACHABLE(); |
| 1093 return Object::null(); | 1116 return Object::null(); |
| 1094 } | 1117 } |
| 1095 | 1118 |
| 1096 | 1119 |
| 1097 RawObject* SnapshotReader::ReadIndexedObject(intptr_t object_id) { | 1120 RawObject* SnapshotReader::ReadIndexedObject(intptr_t object_id, |
| 1121 intptr_t patch_object_id, |
| 1122 intptr_t patch_offset) { |
| 1098 intptr_t class_id = ClassIdFromObjectId(object_id); | 1123 intptr_t class_id = ClassIdFromObjectId(object_id); |
| 1099 if (IsObjectStoreClassId(class_id)) { | 1124 if (IsObjectStoreClassId(class_id)) { |
| 1100 return isolate()->class_table()->At(class_id); // get singleton class. | 1125 return isolate()->class_table()->At(class_id); // get singleton class. |
| 1101 } | 1126 } |
| 1102 if (kind_ != Snapshot::kFull) { | 1127 if (kind_ != Snapshot::kFull) { |
| 1103 if (IsObjectStoreTypeId(object_id)) { | 1128 if (IsObjectStoreTypeId(object_id)) { |
| 1104 return GetType(object_store(), object_id); // return type obj. | 1129 return GetType(object_store(), object_id); // return type obj. |
| 1105 } | 1130 } |
| 1106 } | 1131 } |
| 1107 ASSERT(object_id >= kMaxPredefinedObjectIds); | 1132 ASSERT(object_id >= kMaxPredefinedObjectIds); |
| 1108 intptr_t index = (object_id - kMaxPredefinedObjectIds); | 1133 intptr_t index = (object_id - kMaxPredefinedObjectIds); |
| 1109 if (index < max_vm_isolate_object_id_) { | 1134 if (index < max_vm_isolate_object_id_) { |
| 1110 return VmIsolateSnapshotObject(index); | 1135 return VmIsolateSnapshotObject(index); |
| 1111 } | 1136 } |
| 1137 AddPatchRecord(object_id, patch_object_id, patch_offset); |
| 1112 return GetBackRef(object_id)->raw(); | 1138 return GetBackRef(object_id)->raw(); |
| 1113 } | 1139 } |
| 1114 | 1140 |
| 1115 | 1141 |
| 1116 void SnapshotReader::ArrayReadFrom(const Array& result, | 1142 void SnapshotReader::AddPatchRecord(intptr_t object_id, |
| 1143 intptr_t patch_object_id, |
| 1144 intptr_t patch_offset) { |
| 1145 if (patch_object_id != kInvalidPatchIndex && kind() != Snapshot::kFull) { |
| 1146 ASSERT(object_id >= kMaxPredefinedObjectIds); |
| 1147 intptr_t index = (object_id - kMaxPredefinedObjectIds); |
| 1148 ASSERT(index >= max_vm_isolate_object_id_); |
| 1149 index -= max_vm_isolate_object_id_; |
| 1150 ASSERT(index < backward_references_->length()); |
| 1151 BackRefNode& ref = (*backward_references_)[index]; |
| 1152 ref.AddPatchRecord(patch_object_id, patch_offset); |
| 1153 } |
| 1154 } |
| 1155 |
| 1156 |
| 1157 void SnapshotReader::ProcessDeferredCanonicalizations() { |
| 1158 AbstractType& typeobj = AbstractType::Handle(); |
| 1159 TypeArguments& typeargs = TypeArguments::Handle(); |
| 1160 Object& newobj = Object::Handle(); |
| 1161 for (intptr_t i = 0; i < backward_references_->length(); i++) { |
| 1162 BackRefNode& backref = (*backward_references_)[i]; |
| 1163 if (backref.defer_canonicalization()) { |
| 1164 Object* objref = backref.reference(); |
| 1165 // Object should either be an abstract type or a type argument. |
| 1166 if (objref->IsAbstractType()) { |
| 1167 typeobj ^= objref->raw(); |
| 1168 typeobj.ClearCanonical(); |
| 1169 newobj = typeobj.Canonicalize(); |
| 1170 } else { |
| 1171 ASSERT(objref->IsTypeArguments()); |
| 1172 typeargs ^= objref->raw(); |
| 1173 typeargs.ClearCanonical(); |
| 1174 newobj = typeargs.Canonicalize(); |
| 1175 } |
| 1176 if (newobj.raw() == objref->raw()) { |
| 1177 // Restore Canonical bit. |
| 1178 objref->SetCanonical(); |
| 1179 } else { |
| 1180 ZoneGrowableArray<intptr_t>* patches = backref.patch_records(); |
| 1181 ASSERT(newobj.IsCanonical()); |
| 1182 ASSERT(patches != NULL); |
| 1183 for (intptr_t j = 0; j < patches->length(); j+=2) { |
| 1184 NoSafepointScope no_safepoint; |
| 1185 intptr_t patch_object_id = (*patches)[j]; |
| 1186 intptr_t patch_offset = (*patches)[j + 1]; |
| 1187 Object* target = GetBackRef(patch_object_id); |
| 1188 RawObject** rawptr = |
| 1189 reinterpret_cast<RawObject**>(target->raw()->ptr()); |
| 1190 target->StorePointer((rawptr + patch_offset), newobj.raw()); |
| 1191 } |
| 1192 } |
| 1193 } |
| 1194 } |
| 1195 } |
| 1196 |
| 1197 |
| 1198 void SnapshotReader::ArrayReadFrom(intptr_t object_id, |
| 1199 const Array& result, |
| 1117 intptr_t len, | 1200 intptr_t len, |
| 1118 intptr_t tags) { | 1201 intptr_t tags) { |
| 1119 // Set the object tags. | 1202 // Set the object tags. |
| 1120 result.set_tags(tags); | 1203 result.set_tags(tags); |
| 1121 | 1204 |
| 1122 // Setup the object fields. | 1205 // Setup the object fields. |
| 1123 *TypeArgumentsHandle() ^= ReadObjectImpl(kAsInlinedObject); | 1206 const intptr_t typeargs_offset = |
| 1207 reinterpret_cast<RawObject**>(&result.raw()->ptr()->type_arguments_) - |
| 1208 reinterpret_cast<RawObject**>(result.raw()->ptr()); |
| 1209 *TypeArgumentsHandle() ^= ReadObjectImpl(kAsInlinedObject, |
| 1210 object_id, |
| 1211 typeargs_offset); |
| 1124 result.SetTypeArguments(*TypeArgumentsHandle()); | 1212 result.SetTypeArguments(*TypeArgumentsHandle()); |
| 1125 | 1213 |
| 1126 bool as_reference = RawObject::IsCanonical(tags) ? false : true; | 1214 bool as_reference = RawObject::IsCanonical(tags) ? false : true; |
| 1127 | 1215 intptr_t offset = result.raw_ptr()->data() - |
| 1216 reinterpret_cast<RawObject**>(result.raw()->ptr()); |
| 1128 for (intptr_t i = 0; i < len; i++) { | 1217 for (intptr_t i = 0; i < len; i++) { |
| 1129 *PassiveObjectHandle() = ReadObjectImpl(as_reference); | 1218 *PassiveObjectHandle() = ReadObjectImpl(as_reference, |
| 1219 object_id, |
| 1220 (i + offset)); |
| 1130 result.SetAt(i, *PassiveObjectHandle()); | 1221 result.SetAt(i, *PassiveObjectHandle()); |
| 1131 } | 1222 } |
| 1132 } | 1223 } |
| 1133 | 1224 |
| 1134 | 1225 |
| 1135 VmIsolateSnapshotReader::VmIsolateSnapshotReader(const uint8_t* buffer, | 1226 VmIsolateSnapshotReader::VmIsolateSnapshotReader(const uint8_t* buffer, |
| 1136 intptr_t size, | 1227 intptr_t size, |
| 1137 Zone* zone) | 1228 Zone* zone) |
| 1138 : SnapshotReader(buffer, | 1229 : SnapshotReader(buffer, |
| 1139 size, | 1230 size, |
| (...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2306 NoSafepointScope no_safepoint; | 2397 NoSafepointScope no_safepoint; |
| 2307 WriteObject(obj.raw()); | 2398 WriteObject(obj.raw()); |
| 2308 UnmarkAll(); | 2399 UnmarkAll(); |
| 2309 } else { | 2400 } else { |
| 2310 ThrowException(exception_type(), exception_msg()); | 2401 ThrowException(exception_type(), exception_msg()); |
| 2311 } | 2402 } |
| 2312 } | 2403 } |
| 2313 | 2404 |
| 2314 | 2405 |
| 2315 } // namespace dart | 2406 } // namespace dart |
| OLD | NEW |