| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/assert.h" | 7 #include "vm/assert.h" |
| 8 #include "vm/bootstrap.h" | 8 #include "vm/bootstrap.h" |
| 9 #include "vm/heap.h" | 9 #include "vm/heap.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 ASSERT((value <= kIntptrMax) && (value >= kIntptrMin)); | 60 ASSERT((value <= kIntptrMax) && (value >= kIntptrMin)); |
| 61 return ReadObjectImpl(value); | 61 return ReadObjectImpl(value); |
| 62 } | 62 } |
| 63 | 63 |
| 64 | 64 |
| 65 RawClass* SnapshotReader::ReadClassId(intptr_t object_id) { | 65 RawClass* SnapshotReader::ReadClassId(intptr_t object_id) { |
| 66 ASSERT(kind_ != Snapshot::kFull); | 66 ASSERT(kind_ != Snapshot::kFull); |
| 67 // Read the class header information and lookup the class. | 67 // Read the class header information and lookup the class. |
| 68 intptr_t class_header = ReadIntptrValue(); | 68 intptr_t class_header = ReadIntptrValue(); |
| 69 ASSERT((class_header & kSmiTagMask) != 0); | 69 ASSERT((class_header & kSmiTagMask) != 0); |
| 70 Class& cls = Class::ZoneHandle(); | 70 Class& cls = Class::ZoneHandle(isolate(), Class::null()); |
| 71 cls ^= LookupInternalClass(class_header); | 71 cls ^= LookupInternalClass(class_header); |
| 72 AddBackwardReference(object_id, &cls); | 72 AddBackwardReference(object_id, &cls); |
| 73 if (cls.IsNull()) { | 73 if (cls.IsNull()) { |
| 74 // Read the library/class information and lookup the class. | 74 // Read the library/class information and lookup the class. |
| 75 String& library_url = String::Handle(); | 75 String& library_url = String::Handle(isolate(), String::null()); |
| 76 library_url ^= ReadObjectImpl(class_header); | 76 library_url ^= ReadObjectImpl(class_header); |
| 77 String& class_name = String::Handle(); | 77 String& class_name = String::Handle(isolate(), String::null()); |
| 78 class_name ^= ReadObject(); | 78 class_name ^= ReadObject(); |
| 79 const Library& library = | 79 const Library& library = |
| 80 Library::Handle(Library::LookupLibrary(library_url)); | 80 Library::Handle(isolate(), Library::LookupLibrary(library_url)); |
| 81 ASSERT(!library.IsNull()); | 81 ASSERT(!library.IsNull()); |
| 82 cls ^= library.LookupClass(class_name); | 82 cls ^= library.LookupClass(class_name); |
| 83 } | 83 } |
| 84 ASSERT(!cls.IsNull()); | 84 ASSERT(!cls.IsNull()); |
| 85 return cls.raw(); | 85 return cls.raw(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 | 88 |
| 89 void SnapshotReader::AddBackwardReference(intptr_t id, Object* obj) { | 89 void SnapshotReader::AddBackwardReference(intptr_t id, Object* obj) { |
| 90 ASSERT((id - kMaxPredefinedObjectIds) == backward_references_.length()); | 90 ASSERT((id - kMaxPredefinedObjectIds) == backward_references_.length()); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 intptr_t index = object_id - kMaxPredefinedObjectIds; | 165 intptr_t index = object_id - kMaxPredefinedObjectIds; |
| 166 ASSERT(index < backward_references_.length()); | 166 ASSERT(index < backward_references_.length()); |
| 167 return backward_references_[index]->raw(); | 167 return backward_references_[index]->raw(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 | 170 |
| 171 RawObject* SnapshotReader::ReadInlinedObject(intptr_t object_id) { | 171 RawObject* SnapshotReader::ReadInlinedObject(intptr_t object_id) { |
| 172 // Read the class header information and lookup the class. | 172 // Read the class header information and lookup the class. |
| 173 intptr_t class_header = ReadIntptrValue(); | 173 intptr_t class_header = ReadIntptrValue(); |
| 174 intptr_t tags = ReadIntptrValue(); | 174 intptr_t tags = ReadIntptrValue(); |
| 175 Class& cls = Class::Handle(); | 175 Class& cls = Class::Handle(isolate(), Class::null()); |
| 176 Object& obj = Object::Handle(); | 176 Object& obj = Object::Handle(isolate(), Object::null()); |
| 177 if (SerializedHeaderData::decode(class_header) == kInstanceId) { | 177 if (SerializedHeaderData::decode(class_header) == kInstanceId) { |
| 178 // Object is regular dart instance. | 178 // Object is regular dart instance. |
| 179 Instance& result = Instance::ZoneHandle(); | 179 Instance& result = Instance::ZoneHandle(isolate(), Instance::null()); |
| 180 AddBackwardReference(object_id, &result); | 180 AddBackwardReference(object_id, &result); |
| 181 | 181 |
| 182 cls ^= ReadObject(); | 182 cls ^= ReadObject(); |
| 183 ASSERT(!cls.IsNull()); | 183 ASSERT(!cls.IsNull()); |
| 184 intptr_t instance_size = cls.instance_size(); | 184 intptr_t instance_size = cls.instance_size(); |
| 185 ASSERT(instance_size > 0); | 185 ASSERT(instance_size > 0); |
| 186 // Allocate the instance and read in all the fields for the object. | 186 // Allocate the instance and read in all the fields for the object. |
| 187 RawObject* raw = Object::Allocate(cls, instance_size, Heap::kNew); | 187 RawObject* raw = Object::Allocate(cls, instance_size, Heap::kNew); |
| 188 result ^= raw; | 188 result ^= raw; |
| 189 intptr_t offset = Object::InstanceSize(); | 189 intptr_t offset = Object::InstanceSize(); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 | 445 |
| 446 | 446 |
| 447 void SnapshotWriterVisitor::VisitPointers(RawObject** first, RawObject** last) { | 447 void SnapshotWriterVisitor::VisitPointers(RawObject** first, RawObject** last) { |
| 448 for (RawObject** current = first; current <= last; current++) { | 448 for (RawObject** current = first; current <= last; current++) { |
| 449 RawObject* raw_obj = *current; | 449 RawObject* raw_obj = *current; |
| 450 writer_->WriteObject(raw_obj); | 450 writer_->WriteObject(raw_obj); |
| 451 } | 451 } |
| 452 } | 452 } |
| 453 | 453 |
| 454 } // namespace dart | 454 } // namespace dart |
| OLD | NEW |