Chromium Code Reviews| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 | 212 |
| 213 | 213 |
| 214 RawClass* SnapshotReader::NewClass(int value) { | 214 RawClass* SnapshotReader::NewClass(int value) { |
| 215 ASSERT(kind_ == Snapshot::kFull); | 215 ASSERT(kind_ == Snapshot::kFull); |
| 216 ASSERT(isolate()->no_gc_scope_depth() != 0); | 216 ASSERT(isolate()->no_gc_scope_depth() != 0); |
| 217 ObjectKind object_kind = static_cast<ObjectKind>(value); | 217 ObjectKind object_kind = static_cast<ObjectKind>(value); |
| 218 if ((object_kind == kInstance || object_kind == kClosure)) { | 218 if ((object_kind == kInstance || object_kind == kClosure)) { |
| 219 cls_ = Object::class_class(); | 219 cls_ = Object::class_class(); |
| 220 RawClass* obj = reinterpret_cast<RawClass*>( | 220 RawClass* obj = reinterpret_cast<RawClass*>( |
| 221 AllocateUninitialized(cls_, Class::InstanceSize())); | 221 AllocateUninitialized(cls_, Class::InstanceSize())); |
| 222 obj->ptr()->instance_kind_ = object_kind; | |
| 223 if (object_kind == kInstance) { | 222 if (object_kind == kInstance) { |
| 224 Instance fake; | 223 Instance fake; |
| 225 obj->ptr()->handle_vtable_ = fake.vtable(); | 224 obj->ptr()->handle_vtable_ = fake.vtable(); |
| 226 } else { | 225 } else { |
| 227 Closure fake; | 226 Closure fake; |
| 228 obj->ptr()->handle_vtable_ = fake.vtable(); | 227 obj->ptr()->handle_vtable_ = fake.vtable(); |
| 229 } | 228 } |
| 230 return obj; | 229 const Class& cls = Class::Handle(obj); |
|
siva
2012/04/02 18:29:21
cls_ = obj;
That way we avoid the creation of a
Ivan Posva
2012/04/29 21:08:25
Done.
| |
| 230 cls.set_instance_kind(object_kind); | |
| 231 cls.set_index(kIllegalObjectKind); | |
| 232 isolate()->class_table()->Register(cls); | |
| 233 return cls.raw(); | |
| 231 } | 234 } |
| 232 return Class::GetClass(object_kind); | 235 return Class::GetClass(object_kind); |
| 233 } | 236 } |
| 234 | 237 |
| 235 | 238 |
| 236 RawMint* SnapshotReader::NewMint(int64_t value) { | 239 RawMint* SnapshotReader::NewMint(int64_t value) { |
| 237 ASSERT(kind_ == Snapshot::kFull); | 240 ASSERT(kind_ == Snapshot::kFull); |
| 238 ASSERT(isolate()->no_gc_scope_depth() != 0); | 241 ASSERT(isolate()->no_gc_scope_depth() != 0); |
| 239 cls_ = object_store()->mint_class(); | 242 cls_ = object_store()->mint_class(); |
| 240 RawMint* obj = reinterpret_cast<RawMint*>( | 243 RawMint* obj = reinterpret_cast<RawMint*>( |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 // Use the preallocated out of memory exception to avoid calling | 357 // Use the preallocated out of memory exception to avoid calling |
| 355 // into dart code or allocating any code. | 358 // into dart code or allocating any code. |
| 356 const Instance& exception = | 359 const Instance& exception = |
| 357 Instance::Handle(object_store()->out_of_memory()); | 360 Instance::Handle(object_store()->out_of_memory()); |
| 358 Exceptions::Throw(exception); | 361 Exceptions::Throw(exception); |
| 359 UNREACHABLE(); | 362 UNREACHABLE(); |
| 360 } | 363 } |
| 361 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); | 364 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); |
| 362 raw_obj->ptr()->class_ = cls.raw(); | 365 raw_obj->ptr()->class_ = cls.raw(); |
| 363 uword tags = 0; | 366 uword tags = 0; |
| 367 intptr_t index = cls.index(); | |
| 368 ASSERT(index != kIllegalObjectKind); | |
| 369 tags = RawObject::ClassTag::update(index, tags); | |
| 364 tags = RawObject::SizeTag::update(size, tags); | 370 tags = RawObject::SizeTag::update(size, tags); |
| 365 raw_obj->ptr()->tags_ = tags; | 371 raw_obj->ptr()->tags_ = tags; |
| 366 return raw_obj; | 372 return raw_obj; |
| 367 } | 373 } |
| 368 | 374 |
| 369 | 375 |
| 370 RawObject* SnapshotReader::ReadObjectImpl(intptr_t header) { | 376 RawObject* SnapshotReader::ReadObjectImpl(intptr_t header) { |
| 371 SerializedHeaderType header_type = SerializedHeaderTag::decode(header); | 377 SerializedHeaderType header_type = SerializedHeaderTag::decode(header); |
| 372 intptr_t header_value = SerializedHeaderData::decode(header); | 378 intptr_t header_value = SerializedHeaderData::decode(header); |
| 373 | 379 |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 671 | 677 |
| 672 | 678 |
| 673 void SnapshotWriterVisitor::VisitPointers(RawObject** first, RawObject** last) { | 679 void SnapshotWriterVisitor::VisitPointers(RawObject** first, RawObject** last) { |
| 674 for (RawObject** current = first; current <= last; current++) { | 680 for (RawObject** current = first; current <= last; current++) { |
| 675 RawObject* raw_obj = *current; | 681 RawObject* raw_obj = *current; |
| 676 writer_->WriteObject(raw_obj); | 682 writer_->WriteObject(raw_obj); |
| 677 } | 683 } |
| 678 } | 684 } |
| 679 | 685 |
| 680 } // namespace dart | 686 } // namespace dart |
| OLD | NEW |