| 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/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 9 #include "vm/bootstrap.h" | 9 #include "vm/bootstrap.h" |
| 10 #include "vm/exceptions.h" | 10 #include "vm/exceptions.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 AllocateUninitialized(cls_, Class::InstanceSize())); | 225 AllocateUninitialized(cls_, Class::InstanceSize())); |
| 226 if (object_kind == kInstance) { | 226 if (object_kind == kInstance) { |
| 227 Instance fake; | 227 Instance fake; |
| 228 obj->ptr()->handle_vtable_ = fake.vtable(); | 228 obj->ptr()->handle_vtable_ = fake.vtable(); |
| 229 } else { | 229 } else { |
| 230 Closure fake; | 230 Closure fake; |
| 231 obj->ptr()->handle_vtable_ = fake.vtable(); | 231 obj->ptr()->handle_vtable_ = fake.vtable(); |
| 232 } | 232 } |
| 233 cls_ = obj; | 233 cls_ = obj; |
| 234 cls_.set_instance_kind(object_kind); | 234 cls_.set_instance_kind(object_kind); |
| 235 cls_.set_index(kIllegalObjectKind); | 235 cls_.set_id(kIllegalObjectKind); |
| 236 isolate()->class_table()->Register(cls_); | 236 isolate()->class_table()->Register(cls_); |
| 237 return cls_.raw(); | 237 return cls_.raw(); |
| 238 } | 238 } |
| 239 return Class::GetClass(object_kind); | 239 return Class::GetClass(object_kind); |
| 240 } | 240 } |
| 241 | 241 |
| 242 | 242 |
| 243 RawMint* SnapshotReader::NewMint(int64_t value) { | 243 RawMint* SnapshotReader::NewMint(int64_t value) { |
| 244 ASSERT(kind_ == Snapshot::kFull); | 244 ASSERT(kind_ == Snapshot::kFull); |
| 245 ASSERT(isolate()->no_gc_scope_depth() != 0); | 245 ASSERT(isolate()->no_gc_scope_depth() != 0); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 // Use the preallocated out of memory exception to avoid calling | 363 // Use the preallocated out of memory exception to avoid calling |
| 364 // into dart code or allocating any code. | 364 // into dart code or allocating any code. |
| 365 const Instance& exception = | 365 const Instance& exception = |
| 366 Instance::Handle(object_store()->out_of_memory()); | 366 Instance::Handle(object_store()->out_of_memory()); |
| 367 Exceptions::Throw(exception); | 367 Exceptions::Throw(exception); |
| 368 UNREACHABLE(); | 368 UNREACHABLE(); |
| 369 } | 369 } |
| 370 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); | 370 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); |
| 371 raw_obj->ptr()->class_ = cls.raw(); | 371 raw_obj->ptr()->class_ = cls.raw(); |
| 372 uword tags = 0; | 372 uword tags = 0; |
| 373 intptr_t index = cls.index(); | 373 intptr_t index = cls.id(); |
| 374 ASSERT(index != kIllegalObjectKind); | 374 ASSERT(index != kIllegalObjectKind); |
| 375 tags = RawObject::ClassTag::update(index, tags); | 375 tags = RawObject::ClassIdTag::update(index, tags); |
| 376 tags = RawObject::SizeTag::update(size, tags); | 376 tags = RawObject::SizeTag::update(size, tags); |
| 377 raw_obj->ptr()->tags_ = tags; | 377 raw_obj->ptr()->tags_ = tags; |
| 378 return raw_obj; | 378 return raw_obj; |
| 379 } | 379 } |
| 380 | 380 |
| 381 | 381 |
| 382 RawObject* SnapshotReader::ReadObjectImpl(intptr_t header) { | 382 RawObject* SnapshotReader::ReadObjectImpl(intptr_t header) { |
| 383 SerializedHeaderType header_type = SerializedHeaderTag::decode(header); | 383 SerializedHeaderType header_type = SerializedHeaderTag::decode(header); |
| 384 intptr_t header_value = SerializedHeaderData::decode(header); | 384 intptr_t header_value = SerializedHeaderData::decode(header); |
| 385 | 385 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 } | 520 } |
| 521 | 521 |
| 522 // Check if it is a singleton boolean false value. | 522 // Check if it is a singleton boolean false value. |
| 523 if (rawobj == object_store()->false_value()) { | 523 if (rawobj == object_store()->false_value()) { |
| 524 WriteIndexedObject(ObjectStore::kFalseValue); | 524 WriteIndexedObject(ObjectStore::kFalseValue); |
| 525 return; | 525 return; |
| 526 } | 526 } |
| 527 | 527 |
| 528 // Check if it is a code object in that case just write a Null object | 528 // Check if it is a code object in that case just write a Null object |
| 529 // as we do not want code objects in the snapshot. | 529 // as we do not want code objects in the snapshot. |
| 530 if (RawObject::ClassTag::decode(GetObjectTags(rawobj)) == kCode) { | 530 if (RawObject::ClassIdTag::decode(GetObjectTags(rawobj)) == kCode) { |
| 531 WriteIndexedObject(Object::kNullObject); | 531 WriteIndexedObject(Object::kNullObject); |
| 532 return; | 532 return; |
| 533 } | 533 } |
| 534 | 534 |
| 535 // Check if classes are not being serialized and it is preinitialized type. | 535 // Check if classes are not being serialized and it is preinitialized type. |
| 536 if (kind_ != Snapshot::kFull) { | 536 if (kind_ != Snapshot::kFull) { |
| 537 RawType* raw_type = reinterpret_cast<RawType*>(rawobj); | 537 RawType* raw_type = reinterpret_cast<RawType*>(rawobj); |
| 538 index = object_store()->GetTypeIndex(raw_type); | 538 index = object_store()->GetTypeIndex(raw_type); |
| 539 if (index != ObjectStore::kInvalidIndex) { | 539 if (index != ObjectStore::kInvalidIndex) { |
| 540 WriteIndexedObject(index); | 540 WriteIndexedObject(index); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 uword tags = raw->ptr()->tags_; | 605 uword tags = raw->ptr()->tags_; |
| 606 | 606 |
| 607 // Check if object has already been serialized, in that | 607 // Check if object has already been serialized, in that |
| 608 // case just write the object id out. | 608 // case just write the object id out. |
| 609 if (SerializedHeaderTag::decode(tags) == kObjectId) { | 609 if (SerializedHeaderTag::decode(tags) == kObjectId) { |
| 610 intptr_t id = SerializedHeaderData::decode(tags); | 610 intptr_t id = SerializedHeaderData::decode(tags); |
| 611 WriteIndexedObject(id); | 611 WriteIndexedObject(id); |
| 612 return; | 612 return; |
| 613 } | 613 } |
| 614 | 614 |
| 615 RawClass* cls = class_table_->At(RawObject::ClassTag::decode(tags)); | 615 RawClass* cls = class_table_->At(RawObject::ClassIdTag::decode(tags)); |
| 616 | 616 |
| 617 // Object is being serialized, add it to the forward ref list and mark | 617 // Object is being serialized, add it to the forward ref list and mark |
| 618 // it so that future references to this object in the snapshot will use | 618 // it so that future references to this object in the snapshot will use |
| 619 // an object id, instead of trying to serialize it again. | 619 // an object id, instead of trying to serialize it again. |
| 620 intptr_t object_id = MarkObject(raw, cls); | 620 intptr_t object_id = MarkObject(raw, cls); |
| 621 | 621 |
| 622 ObjectKind kind = cls->ptr()->instance_kind_; | 622 ObjectKind kind = cls->ptr()->instance_kind_; |
| 623 if (kind == Instance::kInstanceKind) { | 623 if (kind == Instance::kInstanceKind) { |
| 624 // Object is regular dart instance. | 624 // Object is regular dart instance. |
| 625 // TODO(5411462): figure out what we need to do if an object with native | 625 // TODO(5411462): figure out what we need to do if an object with native |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 | 697 |
| 698 | 698 |
| 699 void SnapshotWriterVisitor::VisitPointers(RawObject** first, RawObject** last) { | 699 void SnapshotWriterVisitor::VisitPointers(RawObject** first, RawObject** last) { |
| 700 for (RawObject** current = first; current <= last; current++) { | 700 for (RawObject** current = first; current <= last; current++) { |
| 701 RawObject* raw_obj = *current; | 701 RawObject* raw_obj = *current; |
| 702 writer_->WriteObject(raw_obj); | 702 writer_->WriteObject(raw_obj); |
| 703 } | 703 } |
| 704 } | 704 } |
| 705 | 705 |
| 706 } // namespace dart | 706 } // namespace dart |
| OLD | NEW |