Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: vm/snapshot.cc

Issue 9965042: - Add a class index to the classes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 cls_ = obj;
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 // Use the preallocated out of memory exception to avoid calling 359 // Use the preallocated out of memory exception to avoid calling
357 // into dart code or allocating any code. 360 // into dart code or allocating any code.
358 const Instance& exception = 361 const Instance& exception =
359 Instance::Handle(object_store()->out_of_memory()); 362 Instance::Handle(object_store()->out_of_memory());
360 Exceptions::Throw(exception); 363 Exceptions::Throw(exception);
361 UNREACHABLE(); 364 UNREACHABLE();
362 } 365 }
363 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); 366 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag);
364 raw_obj->ptr()->class_ = cls.raw(); 367 raw_obj->ptr()->class_ = cls.raw();
365 uword tags = 0; 368 uword tags = 0;
369 intptr_t index = cls.index();
370 ASSERT(index != kIllegalObjectKind);
371 tags = RawObject::ClassTag::update(index, tags);
366 tags = RawObject::SizeTag::update(size, tags); 372 tags = RawObject::SizeTag::update(size, tags);
367 raw_obj->ptr()->tags_ = tags; 373 raw_obj->ptr()->tags_ = tags;
368 return raw_obj; 374 return raw_obj;
369 } 375 }
370 376
371 377
372 RawObject* SnapshotReader::ReadObjectImpl(intptr_t header) { 378 RawObject* SnapshotReader::ReadObjectImpl(intptr_t header) {
373 SerializedHeaderType header_type = SerializedHeaderTag::decode(header); 379 SerializedHeaderType header_type = SerializedHeaderTag::decode(header);
374 intptr_t header_value = SerializedHeaderData::decode(header); 380 intptr_t header_value = SerializedHeaderData::decode(header);
375 381
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 679
674 680
675 void SnapshotWriterVisitor::VisitPointers(RawObject** first, RawObject** last) { 681 void SnapshotWriterVisitor::VisitPointers(RawObject** first, RawObject** last) {
676 for (RawObject** current = first; current <= last; current++) { 682 for (RawObject** current = first; current <= last; current++) {
677 RawObject* raw_obj = *current; 683 RawObject* raw_obj = *current;
678 writer_->WriteObject(raw_obj); 684 writer_->WriteObject(raw_obj);
679 } 685 }
680 } 686 }
681 687
682 } // namespace dart 688 } // namespace dart
OLDNEW
« vm/raw_object.cc ('K') | « vm/raw_object.cc ('k') | vm/stub_code_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698