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

Side by Side Diff: runtime/vm/snapshot.cc

Issue 187133004: When reading a full snapshot use the class id from the snapshot instead of generating a new one. Th… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 for (intptr_t i = 0; i <= num_flds; i++) { 373 for (intptr_t i = 0; i <= num_flds; i++) {
374 *(object_store->from() + i) = ReadObjectImpl(); 374 *(object_store->from() + i) = ReadObjectImpl();
375 } 375 }
376 for (intptr_t i = 0; i < backward_references_.length(); i++) { 376 for (intptr_t i = 0; i < backward_references_.length(); i++) {
377 if (!backward_references_[i]->is_deserialized()) { 377 if (!backward_references_[i]->is_deserialized()) {
378 ReadObjectImpl(); 378 ReadObjectImpl();
379 backward_references_[i]->set_state(kIsDeserialized); 379 backward_references_[i]->set_state(kIsDeserialized);
380 } 380 }
381 } 381 }
382 382
383 // Validate the class table.
384 #if defined(DEBUG)
385 isolate->ValidateClassTable();
386 #endif
387
383 // Setup native resolver for bootstrap impl. 388 // Setup native resolver for bootstrap impl.
384 Bootstrap::SetupNativeResolver(); 389 Bootstrap::SetupNativeResolver();
385 } 390 }
386 391
387 392
388 #define ALLOC_NEW_OBJECT_WITH_LEN(type, class_obj, length) \ 393 #define ALLOC_NEW_OBJECT_WITH_LEN(type, class_obj, length) \
389 ASSERT(kind_ == Snapshot::kFull); \ 394 ASSERT(kind_ == Snapshot::kFull); \
390 ASSERT(isolate()->no_gc_scope_depth() != 0); \ 395 ASSERT(isolate()->no_gc_scope_depth() != 0); \
391 cls_ = class_obj; \ 396 cls_ = class_obj; \
392 Raw##type* obj = reinterpret_cast<Raw##type*>( \ 397 Raw##type* obj = reinterpret_cast<Raw##type*>( \
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 ASSERT((class_id >= kInstanceCid) && 470 ASSERT((class_id >= kInstanceCid) &&
466 (class_id <= kNullCid)); 471 (class_id <= kNullCid));
467 return isolate()->class_table()->At(class_id); 472 return isolate()->class_table()->At(class_id);
468 } 473 }
469 cls_ = Object::class_class(); 474 cls_ = Object::class_class();
470 RawClass* obj = reinterpret_cast<RawClass*>( 475 RawClass* obj = reinterpret_cast<RawClass*>(
471 AllocateUninitialized(cls_, Class::InstanceSize())); 476 AllocateUninitialized(cls_, Class::InstanceSize()));
472 Instance fake; 477 Instance fake;
473 obj->ptr()->handle_vtable_ = fake.vtable(); 478 obj->ptr()->handle_vtable_ = fake.vtable();
474 cls_ = obj; 479 cls_ = obj;
475 cls_.set_id(kIllegalCid); 480 cls_.set_id(class_id);
476 isolate()->RegisterClass(cls_); 481 isolate()->RegisterClassAt(class_id, cls_);
477 return cls_.raw(); 482 return cls_.raw();
478 } 483 }
479 484
480 485
481 RawInstance* SnapshotReader::NewInstance() { 486 RawInstance* SnapshotReader::NewInstance() {
482 ASSERT(kind_ == Snapshot::kFull); 487 ASSERT(kind_ == Snapshot::kFull);
483 ASSERT(isolate()->no_gc_scope_depth() != 0); 488 ASSERT(isolate()->no_gc_scope_depth() != 0);
484 cls_ = object_store()->object_class(); 489 cls_ = object_store()->object_class();
485 RawInstance* obj = reinterpret_cast<RawInstance*>( 490 RawInstance* obj = reinterpret_cast<RawInstance*>(
486 AllocateUninitialized(cls_, Instance::InstanceSize())); 491 AllocateUninitialized(cls_, Instance::InstanceSize()));
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 } 1119 }
1115 1120
1116 1121
1117 void FullSnapshotWriter::WriteFullSnapshot() { 1122 void FullSnapshotWriter::WriteFullSnapshot() {
1118 Isolate* isolate = Isolate::Current(); 1123 Isolate* isolate = Isolate::Current();
1119 ASSERT(isolate != NULL); 1124 ASSERT(isolate != NULL);
1120 ObjectStore* object_store = isolate->object_store(); 1125 ObjectStore* object_store = isolate->object_store();
1121 ASSERT(object_store != NULL); 1126 ASSERT(object_store != NULL);
1122 ASSERT(ClassFinalizer::AllClassesFinalized()); 1127 ASSERT(ClassFinalizer::AllClassesFinalized());
1123 1128
1129 // Ensure the class table is valid.
1130 #if defined(DEBUG)
1131 isolate->ValidateClassTable();
1132 #endif
1133
1134
1124 // Setup for long jump in case there is an exception while writing 1135 // Setup for long jump in case there is an exception while writing
1125 // the snapshot. 1136 // the snapshot.
1126 LongJumpScope jump; 1137 LongJumpScope jump;
1127 if (setjmp(*jump.Set()) == 0) { 1138 if (setjmp(*jump.Set()) == 0) {
1128 NoGCScope no_gc; 1139 NoGCScope no_gc;
1129 1140
1130 // Reserve space in the output buffer for a snapshot header. 1141 // Reserve space in the output buffer for a snapshot header.
1131 ReserveHeader(); 1142 ReserveHeader();
1132 1143
1133 // Write out all the objects in the object store of the isolate which 1144 // Write out all the objects in the object store of the isolate which
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 NoGCScope no_gc; 1560 NoGCScope no_gc;
1550 WriteObject(obj.raw()); 1561 WriteObject(obj.raw());
1551 UnmarkAll(); 1562 UnmarkAll();
1552 } else { 1563 } else {
1553 ThrowException(exception_type(), exception_msg()); 1564 ThrowException(exception_type(), exception_msg());
1554 } 1565 }
1555 } 1566 }
1556 1567
1557 1568
1558 } // namespace dart 1569 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698