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

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

Issue 1918313003: Split Snapshot::kFull into kCore, kAppWithJIT, and kAppNoJIT. Remove snapshot_code flag. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
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/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 intptr_t size, 175 intptr_t size,
176 const uint8_t* instructions_buffer, 176 const uint8_t* instructions_buffer,
177 const uint8_t* data_buffer, 177 const uint8_t* data_buffer,
178 Snapshot::Kind kind, 178 Snapshot::Kind kind,
179 ZoneGrowableArray<BackRefNode>* backward_refs, 179 ZoneGrowableArray<BackRefNode>* backward_refs,
180 Thread* thread) 180 Thread* thread)
181 : BaseReader(buffer, size), 181 : BaseReader(buffer, size),
182 instructions_buffer_(instructions_buffer), 182 instructions_buffer_(instructions_buffer),
183 data_buffer_(data_buffer), 183 data_buffer_(data_buffer),
184 kind_(kind), 184 kind_(kind),
185 snapshot_code_(instructions_buffer != NULL),
186 thread_(thread), 185 thread_(thread),
187 zone_(thread->zone()), 186 zone_(thread->zone()),
188 heap_(isolate()->heap()), 187 heap_(isolate()->heap()),
189 old_space_(thread_->isolate()->heap()->old_space()), 188 old_space_(thread_->isolate()->heap()->old_space()),
190 cls_(Class::Handle(zone_)), 189 cls_(Class::Handle(zone_)),
191 obj_(Object::Handle(zone_)), 190 obj_(Object::Handle(zone_)),
192 pobj_(PassiveObject::Handle(zone_)), 191 pobj_(PassiveObject::Handle(zone_)),
193 array_(Array::Handle(zone_)), 192 array_(Array::Handle(zone_)),
194 field_(Field::Handle(zone_)), 193 field_(Field::Handle(zone_)),
195 str_(String::Handle(zone_)), 194 str_(String::Handle(zone_)),
196 library_(Library::Handle(zone_)), 195 library_(Library::Handle(zone_)),
197 type_(AbstractType::Handle(zone_)), 196 type_(AbstractType::Handle(zone_)),
198 type_arguments_(TypeArguments::Handle(zone_)), 197 type_arguments_(TypeArguments::Handle(zone_)),
199 tokens_(GrowableObjectArray::Handle(zone_)), 198 tokens_(GrowableObjectArray::Handle(zone_)),
200 stream_(TokenStream::Handle(zone_)), 199 stream_(TokenStream::Handle(zone_)),
201 data_(ExternalTypedData::Handle(zone_)), 200 data_(ExternalTypedData::Handle(zone_)),
202 typed_data_(TypedData::Handle(zone_)), 201 typed_data_(TypedData::Handle(zone_)),
203 code_(Code::Handle(zone_)), 202 code_(Code::Handle(zone_)),
204 function_(Function::Handle(zone_)), 203 function_(Function::Handle(zone_)),
205 megamorphic_cache_(MegamorphicCache::Handle(zone_)), 204 megamorphic_cache_(MegamorphicCache::Handle(zone_)),
206 error_(UnhandledException::Handle(zone_)), 205 error_(UnhandledException::Handle(zone_)),
207 max_vm_isolate_object_id_( 206 max_vm_isolate_object_id_(
208 (kind == Snapshot::kFull) ? 207 (Snapshot::IsFull(kind)) ?
209 Object::vm_isolate_snapshot_object_table().Length() : 0), 208 Object::vm_isolate_snapshot_object_table().Length() : 0),
210 backward_references_(backward_refs), 209 backward_references_(backward_refs),
211 instructions_reader_(NULL) { 210 instructions_reader_(NULL) {
212 if (instructions_buffer != NULL) { 211 if (instructions_buffer != NULL) {
213 instructions_reader_ = 212 instructions_reader_ =
214 new InstructionsReader(instructions_buffer, data_buffer); 213 new InstructionsReader(instructions_buffer, data_buffer);
215 } 214 }
216 } 215 }
217 216
218 217
219 RawObject* SnapshotReader::ReadObject() { 218 RawObject* SnapshotReader::ReadObject() {
220 // Setup for long jump in case there is an exception while reading. 219 // Setup for long jump in case there is an exception while reading.
221 LongJumpScope jump; 220 LongJumpScope jump;
222 if (setjmp(*jump.Set()) == 0) { 221 if (setjmp(*jump.Set()) == 0) {
223 PassiveObject& obj = 222 PassiveObject& obj =
224 PassiveObject::Handle(zone(), ReadObjectImpl(kAsInlinedObject)); 223 PassiveObject::Handle(zone(), ReadObjectImpl(kAsInlinedObject));
225 for (intptr_t i = 0; i < backward_references_->length(); i++) { 224 for (intptr_t i = 0; i < backward_references_->length(); i++) {
226 if (!(*backward_references_)[i].is_deserialized()) { 225 if (!(*backward_references_)[i].is_deserialized()) {
227 ReadObjectImpl(kAsInlinedObject); 226 ReadObjectImpl(kAsInlinedObject);
228 (*backward_references_)[i].set_state(kIsDeserialized); 227 (*backward_references_)[i].set_state(kIsDeserialized);
229 } 228 }
230 } 229 }
231 if (kind() != Snapshot::kFull) { 230 if (!Snapshot::IsFull(kind())) {
232 ProcessDeferredCanonicalizations(); 231 ProcessDeferredCanonicalizations();
233 } 232 }
234 return obj.raw(); 233 return obj.raw();
235 } else { 234 } else {
236 // An error occurred while reading, return the error object. 235 // An error occurred while reading, return the error object.
237 const Error& err = Error::Handle(thread()->sticky_error()); 236 const Error& err = Error::Handle(thread()->sticky_error());
238 thread()->clear_sticky_error(); 237 thread()->clear_sticky_error();
239 return err.raw(); 238 return err.raw();
240 } 239 }
241 } 240 }
242 241
243 242
244 RawClass* SnapshotReader::ReadClassId(intptr_t object_id) { 243 RawClass* SnapshotReader::ReadClassId(intptr_t object_id) {
245 ASSERT(kind_ != Snapshot::kFull); 244 ASSERT(!Snapshot::IsFull(kind_));
246 // Read the class header information and lookup the class. 245 // Read the class header information and lookup the class.
247 intptr_t class_header = Read<int32_t>(); 246 intptr_t class_header = Read<int32_t>();
248 ASSERT((class_header & kSmiTagMask) != kSmiTag); 247 ASSERT((class_header & kSmiTagMask) != kSmiTag);
249 ASSERT(!IsVMIsolateObject(class_header) || 248 ASSERT(!IsVMIsolateObject(class_header) ||
250 !IsSingletonClassId(GetVMIsolateObjectId(class_header))); 249 !IsSingletonClassId(GetVMIsolateObjectId(class_header)));
251 ASSERT((SerializedHeaderTag::decode(class_header) != kObjectId) || 250 ASSERT((SerializedHeaderTag::decode(class_header) != kObjectId) ||
252 !IsObjectStoreClassId(SerializedHeaderData::decode(class_header))); 251 !IsObjectStoreClassId(SerializedHeaderData::decode(class_header)));
253 Class& cls = Class::ZoneHandle(zone(), Class::null()); 252 Class& cls = Class::ZoneHandle(zone(), Class::null());
254 AddBackRef(object_id, &cls, kIsDeserialized); 253 AddBackRef(object_id, &cls, kIsDeserialized);
255 // Read the library/class information and lookup the class. 254 // Read the library/class information and lookup the class.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 299 }
301 if (func.IsNull()) { 300 if (func.IsNull()) {
302 SetReadException("Expected a function name, but found an invalid name."); 301 SetReadException("Expected a function name, but found an invalid name.");
303 } 302 }
304 return func.raw(); 303 return func.raw();
305 } 304 }
306 305
307 306
308 RawObject* SnapshotReader::ReadStaticImplicitClosure(intptr_t object_id, 307 RawObject* SnapshotReader::ReadStaticImplicitClosure(intptr_t object_id,
309 intptr_t class_header) { 308 intptr_t class_header) {
310 ASSERT(kind_ != Snapshot::kFull); 309 ASSERT(!Snapshot::IsFull(kind_));
311 310
312 // First create a function object and associate it with the specified 311 // First create a function object and associate it with the specified
313 // 'object_id'. 312 // 'object_id'.
314 Function& func = Function::Handle(zone(), Function::null()); 313 Function& func = Function::Handle(zone(), Function::null());
315 Instance& obj = Instance::ZoneHandle(zone(), Instance::null()); 314 Instance& obj = Instance::ZoneHandle(zone(), Instance::null());
316 AddBackRef(object_id, &obj, kIsDeserialized); 315 AddBackRef(object_id, &obj, kIsDeserialized);
317 316
318 // Read the library/class/function information and lookup the function. 317 // Read the library/class/function information and lookup the function.
319 str_ ^= ReadObjectImpl(kAsInlinedObject); 318 str_ ^= ReadObjectImpl(kAsInlinedObject);
320 library_ = Library::LookupLibrary(str_); 319 library_ = Library::LookupLibrary(str_);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 if (result == NULL) { 480 if (result == NULL) {
482 result = &(Instance::ZoneHandle(zone(), Instance::null())); 481 result = &(Instance::ZoneHandle(zone(), Instance::null()));
483 AddBackRef(object_id, result, state); 482 AddBackRef(object_id, result, state);
484 cls_ ^= ReadObjectImpl(kAsInlinedObject); 483 cls_ ^= ReadObjectImpl(kAsInlinedObject);
485 ASSERT(!cls_.IsNull()); 484 ASSERT(!cls_.IsNull());
486 // Closure instances are handled by Closure::ReadFrom(). 485 // Closure instances are handled by Closure::ReadFrom().
487 ASSERT(!cls_.IsClosureClass()); 486 ASSERT(!cls_.IsClosureClass());
488 instance_size = cls_.instance_size(); 487 instance_size = cls_.instance_size();
489 ASSERT(instance_size > 0); 488 ASSERT(instance_size > 0);
490 // Allocate the instance and read in all the fields for the object. 489 // Allocate the instance and read in all the fields for the object.
491 if (kind_ == Snapshot::kFull) { 490 if (Snapshot::IsFull(kind_)) {
492 *result ^= AllocateUninitialized(cls_.id(), instance_size); 491 *result ^= AllocateUninitialized(cls_.id(), instance_size);
493 } else { 492 } else {
494 *result ^= Object::Allocate(cls_.id(), instance_size, HEAP_SPACE(kind_)); 493 *result ^= Object::Allocate(cls_.id(), instance_size, HEAP_SPACE(kind_));
495 } 494 }
496 } else { 495 } else {
497 cls_ ^= ReadObjectImpl(kAsInlinedObject); 496 cls_ ^= ReadObjectImpl(kAsInlinedObject);
498 ASSERT(!cls_.IsNull()); 497 ASSERT(!cls_.IsNull());
499 instance_size = cls_.instance_size(); 498 instance_size = cls_.instance_size();
500 } 499 }
501 if (!as_reference) { 500 if (!as_reference) {
(...skipping 21 matching lines...) Expand all
523 field_ ^= array_.At(offset >> kWordSizeLog2); 522 field_ ^= array_.At(offset >> kWordSizeLog2);
524 ASSERT(!field_.IsNull()); 523 ASSERT(!field_.IsNull());
525 ASSERT(field_.Offset() == offset); 524 ASSERT(field_.Offset() == offset);
526 obj_ = pobj_.raw(); 525 obj_ = pobj_.raw();
527 field_.RecordStore(obj_); 526 field_.RecordStore(obj_);
528 } 527 }
529 // TODO(fschneider): Verify the guarded cid and length for other kinds of 528 // TODO(fschneider): Verify the guarded cid and length for other kinds of
530 // snapshot (kFull, kScript) with asserts. 529 // snapshot (kFull, kScript) with asserts.
531 offset += kWordSize; 530 offset += kWordSize;
532 } 531 }
533 if (kind_ == Snapshot::kFull) { 532 if (Snapshot::IsFull(kind_)) {
534 // We create an uninitialized object in the case of full snapshots, so 533 // We create an uninitialized object in the case of full snapshots, so
535 // we need to initialize any remaining padding area with the Null object. 534 // we need to initialize any remaining padding area with the Null object.
536 while (offset < instance_size) { 535 while (offset < instance_size) {
537 result->SetFieldAtOffset(offset, Object::null_object()); 536 result->SetFieldAtOffset(offset, Object::null_object());
538 offset += kWordSize; 537 offset += kWordSize;
539 } 538 }
540 } 539 }
541 if (RawObject::IsCanonical(tags)) { 540 if (RawObject::IsCanonical(tags)) {
542 if (kind_ == Snapshot::kFull) { 541 if (Snapshot::IsFull(kind_)) {
543 result->SetCanonical(); 542 result->SetCanonical();
544 } else { 543 } else {
545 *result = result->CheckAndCanonicalize(thread(), NULL); 544 *result = result->CheckAndCanonicalize(thread(), NULL);
546 ASSERT(!result->IsNull()); 545 ASSERT(!result->IsNull());
547 } 546 }
548 } 547 }
549 } 548 }
550 return result->raw(); 549 return result->raw();
551 } 550 }
552 551
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 ~HeapLocker() { 584 ~HeapLocker() {
586 page_space_->ReleaseDataLock(); 585 page_space_->ReleaseDataLock();
587 } 586 }
588 587
589 private: 588 private:
590 PageSpace* page_space_; 589 PageSpace* page_space_;
591 }; 590 };
592 591
593 592
594 RawApiError* SnapshotReader::ReadFullSnapshot() { 593 RawApiError* SnapshotReader::ReadFullSnapshot() {
595 ASSERT(kind_ == Snapshot::kFull); 594 ASSERT(Snapshot::IsFull(kind_));
596 Thread* thread = Thread::Current(); 595 Thread* thread = Thread::Current();
597 Isolate* isolate = thread->isolate(); 596 Isolate* isolate = thread->isolate();
598 ASSERT(isolate != NULL); 597 ASSERT(isolate != NULL);
599 ObjectStore* object_store = isolate->object_store(); 598 ObjectStore* object_store = isolate->object_store();
600 ASSERT(object_store != NULL); 599 ASSERT(object_store != NULL);
601 600
602 // First read the version string, and check that it matches. 601 // First read the version string, and check that it matches.
603 RawApiError* error = VerifyVersion(); 602 RawApiError* error = VerifyVersion();
604 if (error != ApiError::null()) { 603 if (error != ApiError::null()) {
605 return error; 604 return error;
606 } 605 }
607 606
608 // The version string matches. Read the rest of the snapshot. 607 // The version string matches. Read the rest of the snapshot.
609 608
610 // TODO(asiva): Add a check here to ensure we have the right heap 609 // TODO(asiva): Add a check here to ensure we have the right heap
611 // size for the full snapshot being read. 610 // size for the full snapshot being read.
612 { 611 {
613 NoSafepointScope no_safepoint; 612 NoSafepointScope no_safepoint;
614 HeapLocker hl(thread, old_space()); 613 HeapLocker hl(thread, old_space());
615 614
616 // Read in all the objects stored in the object store. 615 // Read in all the objects stored in the object store.
617 RawObject** toobj = snapshot_code() ? object_store->to() 616 intptr_t num_flds =
618 : object_store->to_snapshot(); 617 (object_store->to_snapshot(kind_) - object_store->from());
619 intptr_t num_flds = (toobj - object_store->from());
620 for (intptr_t i = 0; i <= num_flds; i++) { 618 for (intptr_t i = 0; i <= num_flds; i++) {
621 *(object_store->from() + i) = ReadObjectImpl(kAsInlinedObject); 619 *(object_store->from() + i) = ReadObjectImpl(kAsInlinedObject);
622 } 620 }
623 for (intptr_t i = 0; i < backward_references_->length(); i++) { 621 for (intptr_t i = 0; i < backward_references_->length(); i++) {
624 if (!(*backward_references_)[i].is_deserialized()) { 622 if (!(*backward_references_)[i].is_deserialized()) {
625 ReadObjectImpl(kAsInlinedObject); 623 ReadObjectImpl(kAsInlinedObject);
626 (*backward_references_)[i].set_state(kIsDeserialized); 624 (*backward_references_)[i].set_state(kIsDeserialized);
627 } 625 }
628 } 626 }
629 627
630 if (snapshot_code()) { 628 if (Snapshot::IncludesCode(kind_)) {
631 ICData& ic = ICData::Handle(thread->zone()); 629 ICData& ic = ICData::Handle(thread->zone());
632 Object& funcOrCode = Object::Handle(thread->zone()); 630 Object& funcOrCode = Object::Handle(thread->zone());
633 Code& code = Code::Handle(thread->zone()); 631 Code& code = Code::Handle(thread->zone());
634 Smi& entry_point = Smi::Handle(thread->zone()); 632 Smi& entry_point = Smi::Handle(thread->zone());
635 for (intptr_t i = 0; i < backward_references_->length(); i++) { 633 for (intptr_t i = 0; i < backward_references_->length(); i++) {
636 if ((*backward_references_)[i].reference()->IsICData()) { 634 if ((*backward_references_)[i].reference()->IsICData()) {
637 ic ^= (*backward_references_)[i].reference()->raw(); 635 ic ^= (*backward_references_)[i].reference()->raw();
638 for (intptr_t j = 0; j < ic.NumberOfChecks(); j++) { 636 for (intptr_t j = 0; j < ic.NumberOfChecks(); j++) {
639 funcOrCode = ic.GetTargetOrCodeAt(j); 637 funcOrCode = ic.GetTargetOrCodeAt(j);
640 if (funcOrCode.IsCode()) { 638 if (funcOrCode.IsCode()) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 715
718 const char* version = reinterpret_cast<const char*>(CurrentBufferAddress()); 716 const char* version = reinterpret_cast<const char*>(CurrentBufferAddress());
719 ASSERT(version != NULL); 717 ASSERT(version != NULL);
720 if (strncmp(version, expected_version, version_len)) { 718 if (strncmp(version, expected_version, version_len)) {
721 const intptr_t kMessageBufferSize = 256; 719 const intptr_t kMessageBufferSize = 256;
722 char message_buffer[kMessageBufferSize]; 720 char message_buffer[kMessageBufferSize];
723 char* actual_version = OS::StrNDup(version, version_len); 721 char* actual_version = OS::StrNDup(version, version_len);
724 OS::SNPrint(message_buffer, 722 OS::SNPrint(message_buffer,
725 kMessageBufferSize, 723 kMessageBufferSize,
726 "Wrong %s snapshot version, expected '%s' found '%s'", 724 "Wrong %s snapshot version, expected '%s' found '%s'",
727 (kind_ == Snapshot::kFull) ? "full" : "script", 725 (Snapshot::IsFull(kind_)) ? "full" : "script",
728 Version::SnapshotString(), 726 Version::SnapshotString(),
729 actual_version); 727 actual_version);
730 free(actual_version); 728 free(actual_version);
731 // This can also fail while bringing up the VM isolate, so make sure to 729 // This can also fail while bringing up the VM isolate, so make sure to
732 // allocate the error message in old space. 730 // allocate the error message in old space.
733 const String& msg = String::Handle(String::New(message_buffer, Heap::kOld)); 731 const String& msg = String::Handle(String::New(message_buffer, Heap::kOld));
734 return ApiError::New(msg, Heap::kOld); 732 return ApiError::New(msg, Heap::kOld);
735 } 733 }
736 Advance(version_len); 734 Advance(version_len);
737 return ApiError::null(); 735 return ApiError::null();
738 } 736 }
739 737
740 738
741 #define ALLOC_NEW_OBJECT_WITH_LEN(type, length) \ 739 #define ALLOC_NEW_OBJECT_WITH_LEN(type, length) \
742 ASSERT(kind_ == Snapshot::kFull); \ 740 ASSERT(Snapshot::IsFull(kind_)); \
743 ASSERT_NO_SAFEPOINT_SCOPE(); \ 741 ASSERT_NO_SAFEPOINT_SCOPE(); \
744 Raw##type* obj = reinterpret_cast<Raw##type*>( \ 742 Raw##type* obj = reinterpret_cast<Raw##type*>( \
745 AllocateUninitialized(k##type##Cid, type::InstanceSize(length))); \ 743 AllocateUninitialized(k##type##Cid, type::InstanceSize(length))); \
746 obj->StoreSmi(&(obj->ptr()->length_), Smi::New(length)); \ 744 obj->StoreSmi(&(obj->ptr()->length_), Smi::New(length)); \
747 return obj; \ 745 return obj; \
748 746
749 747
750 RawArray* SnapshotReader::NewArray(intptr_t len) { 748 RawArray* SnapshotReader::NewArray(intptr_t len) {
751 ALLOC_NEW_OBJECT_WITH_LEN(Array, len); 749 ALLOC_NEW_OBJECT_WITH_LEN(Array, len);
752 } 750 }
(...skipping 13 matching lines...) Expand all
766 ALLOC_NEW_OBJECT_WITH_LEN(TwoByteString, len); 764 ALLOC_NEW_OBJECT_WITH_LEN(TwoByteString, len);
767 } 765 }
768 766
769 767
770 RawTypeArguments* SnapshotReader::NewTypeArguments(intptr_t len) { 768 RawTypeArguments* SnapshotReader::NewTypeArguments(intptr_t len) {
771 ALLOC_NEW_OBJECT_WITH_LEN(TypeArguments, len); 769 ALLOC_NEW_OBJECT_WITH_LEN(TypeArguments, len);
772 } 770 }
773 771
774 772
775 RawObjectPool* SnapshotReader::NewObjectPool(intptr_t len) { 773 RawObjectPool* SnapshotReader::NewObjectPool(intptr_t len) {
776 ASSERT(kind_ == Snapshot::kFull); 774 ASSERT(Snapshot::IsFull(kind_));
777 ASSERT_NO_SAFEPOINT_SCOPE(); 775 ASSERT_NO_SAFEPOINT_SCOPE();
778 RawObjectPool* obj = reinterpret_cast<RawObjectPool*>( 776 RawObjectPool* obj = reinterpret_cast<RawObjectPool*>(
779 AllocateUninitialized(kObjectPoolCid, ObjectPool::InstanceSize(len))); 777 AllocateUninitialized(kObjectPoolCid, ObjectPool::InstanceSize(len)));
780 obj->ptr()->length_ = len; 778 obj->ptr()->length_ = len;
781 return obj; 779 return obj;
782 } 780 }
783 781
784 782
785 RawLocalVarDescriptors* SnapshotReader::NewLocalVarDescriptors( 783 RawLocalVarDescriptors* SnapshotReader::NewLocalVarDescriptors(
786 intptr_t num_entries) { 784 intptr_t num_entries) {
787 ASSERT(kind_ == Snapshot::kFull); 785 ASSERT(Snapshot::IsFull(kind_));
788 ASSERT_NO_SAFEPOINT_SCOPE(); 786 ASSERT_NO_SAFEPOINT_SCOPE();
789 RawLocalVarDescriptors* obj = reinterpret_cast<RawLocalVarDescriptors*>( 787 RawLocalVarDescriptors* obj = reinterpret_cast<RawLocalVarDescriptors*>(
790 AllocateUninitialized(kLocalVarDescriptorsCid, 788 AllocateUninitialized(kLocalVarDescriptorsCid,
791 LocalVarDescriptors::InstanceSize(num_entries))); 789 LocalVarDescriptors::InstanceSize(num_entries)));
792 obj->ptr()->num_entries_ = num_entries; 790 obj->ptr()->num_entries_ = num_entries;
793 return obj; 791 return obj;
794 } 792 }
795 793
796 794
797 RawExceptionHandlers* SnapshotReader::NewExceptionHandlers( 795 RawExceptionHandlers* SnapshotReader::NewExceptionHandlers(
798 intptr_t num_entries) { 796 intptr_t num_entries) {
799 ASSERT(kind_ == Snapshot::kFull); 797 ASSERT(Snapshot::IsFull(kind_));
800 ASSERT_NO_SAFEPOINT_SCOPE(); 798 ASSERT_NO_SAFEPOINT_SCOPE();
801 RawExceptionHandlers* obj = reinterpret_cast<RawExceptionHandlers*>( 799 RawExceptionHandlers* obj = reinterpret_cast<RawExceptionHandlers*>(
802 AllocateUninitialized(kExceptionHandlersCid, 800 AllocateUninitialized(kExceptionHandlersCid,
803 ExceptionHandlers::InstanceSize(num_entries))); 801 ExceptionHandlers::InstanceSize(num_entries)));
804 obj->ptr()->num_entries_ = num_entries; 802 obj->ptr()->num_entries_ = num_entries;
805 return obj; 803 return obj;
806 } 804 }
807 805
808 806
809 RawPcDescriptors* SnapshotReader::NewPcDescriptors(intptr_t len) { 807 RawPcDescriptors* SnapshotReader::NewPcDescriptors(intptr_t len) {
810 ASSERT(kind_ == Snapshot::kFull); 808 ASSERT(Snapshot::IsFull(kind_));
811 ASSERT_NO_SAFEPOINT_SCOPE(); 809 ASSERT_NO_SAFEPOINT_SCOPE();
812 RawPcDescriptors* obj = reinterpret_cast<RawPcDescriptors*>( 810 RawPcDescriptors* obj = reinterpret_cast<RawPcDescriptors*>(
813 AllocateUninitialized(kPcDescriptorsCid, 811 AllocateUninitialized(kPcDescriptorsCid,
814 PcDescriptors::InstanceSize(len))); 812 PcDescriptors::InstanceSize(len)));
815 obj->ptr()->length_ = len; 813 obj->ptr()->length_ = len;
816 return obj; 814 return obj;
817 } 815 }
818 816
819 817
820 RawCodeSourceMap* SnapshotReader::NewCodeSourceMap(intptr_t len) { 818 RawCodeSourceMap* SnapshotReader::NewCodeSourceMap(intptr_t len) {
821 ASSERT(kind_ == Snapshot::kFull); 819 ASSERT(Snapshot::IsFull(kind_));
822 ASSERT_NO_SAFEPOINT_SCOPE(); 820 ASSERT_NO_SAFEPOINT_SCOPE();
823 RawCodeSourceMap* obj = reinterpret_cast<RawCodeSourceMap*>( 821 RawCodeSourceMap* obj = reinterpret_cast<RawCodeSourceMap*>(
824 AllocateUninitialized(kCodeSourceMapCid, 822 AllocateUninitialized(kCodeSourceMapCid,
825 CodeSourceMap::InstanceSize(len))); 823 CodeSourceMap::InstanceSize(len)));
826 obj->ptr()->length_ = len; 824 obj->ptr()->length_ = len;
827 return obj; 825 return obj;
828 } 826 }
829 827
830 828
831 RawStackmap* SnapshotReader::NewStackmap(intptr_t len) { 829 RawStackmap* SnapshotReader::NewStackmap(intptr_t len) {
832 ASSERT(kind_ == Snapshot::kFull); 830 ASSERT(Snapshot::IsFull(kind_));
833 ASSERT_NO_SAFEPOINT_SCOPE(); 831 ASSERT_NO_SAFEPOINT_SCOPE();
834 RawStackmap* obj = reinterpret_cast<RawStackmap*>( 832 RawStackmap* obj = reinterpret_cast<RawStackmap*>(
835 AllocateUninitialized(kStackmapCid, Stackmap::InstanceSize(len))); 833 AllocateUninitialized(kStackmapCid, Stackmap::InstanceSize(len)));
836 obj->ptr()->length_ = len; 834 obj->ptr()->length_ = len;
837 return obj; 835 return obj;
838 } 836 }
839 837
840 838
841 RawContextScope* SnapshotReader::NewContextScope(intptr_t num_variables) { 839 RawContextScope* SnapshotReader::NewContextScope(intptr_t num_variables) {
842 ASSERT(kind_ == Snapshot::kFull); 840 ASSERT(Snapshot::IsFull(kind_));
843 ASSERT_NO_SAFEPOINT_SCOPE(); 841 ASSERT_NO_SAFEPOINT_SCOPE();
844 RawContextScope* obj = reinterpret_cast<RawContextScope*>( 842 RawContextScope* obj = reinterpret_cast<RawContextScope*>(
845 AllocateUninitialized(kContextScopeCid, 843 AllocateUninitialized(kContextScopeCid,
846 ContextScope::InstanceSize(num_variables))); 844 ContextScope::InstanceSize(num_variables)));
847 obj->ptr()->num_variables_ = num_variables; 845 obj->ptr()->num_variables_ = num_variables;
848 return obj; 846 return obj;
849 } 847 }
850 848
851 849
852 RawCode* SnapshotReader::NewCode(intptr_t pointer_offsets_length) { 850 RawCode* SnapshotReader::NewCode(intptr_t pointer_offsets_length) {
853 ASSERT(pointer_offsets_length == 0); 851 ASSERT(pointer_offsets_length == 0);
854 ASSERT(kind_ == Snapshot::kFull); 852 ASSERT(Snapshot::IsFull(kind_));
855 ASSERT_NO_SAFEPOINT_SCOPE(); 853 ASSERT_NO_SAFEPOINT_SCOPE();
856 RawCode* obj = reinterpret_cast<RawCode*>( 854 RawCode* obj = reinterpret_cast<RawCode*>(
857 AllocateUninitialized(kCodeCid, Code::InstanceSize(0))); 855 AllocateUninitialized(kCodeCid, Code::InstanceSize(0)));
858 return obj; 856 return obj;
859 } 857 }
860 858
861 859
862 RawTokenStream* SnapshotReader::NewTokenStream(intptr_t len) { 860 RawTokenStream* SnapshotReader::NewTokenStream(intptr_t len) {
863 ASSERT(kind_ == Snapshot::kFull); 861 ASSERT(Snapshot::IsFull(kind_));
864 ASSERT_NO_SAFEPOINT_SCOPE(); 862 ASSERT_NO_SAFEPOINT_SCOPE();
865 stream_ = reinterpret_cast<RawTokenStream*>( 863 stream_ = reinterpret_cast<RawTokenStream*>(
866 AllocateUninitialized(kTokenStreamCid, TokenStream::InstanceSize())); 864 AllocateUninitialized(kTokenStreamCid, TokenStream::InstanceSize()));
867 uint8_t* array = const_cast<uint8_t*>(CurrentBufferAddress()); 865 uint8_t* array = const_cast<uint8_t*>(CurrentBufferAddress());
868 ASSERT(array != NULL); 866 ASSERT(array != NULL);
869 Advance(len); 867 Advance(len);
870 data_ = reinterpret_cast<RawExternalTypedData*>( 868 data_ = reinterpret_cast<RawExternalTypedData*>(
871 AllocateUninitialized(kExternalTypedDataUint8ArrayCid, 869 AllocateUninitialized(kExternalTypedDataUint8ArrayCid,
872 ExternalTypedData::InstanceSize())); 870 ExternalTypedData::InstanceSize()));
873 data_.SetData(array); 871 data_.SetData(array);
874 data_.SetLength(len); 872 data_.SetLength(len);
875 stream_.SetStream(data_); 873 stream_.SetStream(data_);
876 return stream_.raw(); 874 return stream_.raw();
877 } 875 }
878 876
879 877
880 RawContext* SnapshotReader::NewContext(intptr_t num_variables) { 878 RawContext* SnapshotReader::NewContext(intptr_t num_variables) {
881 ASSERT(kind_ == Snapshot::kFull); 879 ASSERT(Snapshot::IsFull(kind_));
882 ASSERT_NO_SAFEPOINT_SCOPE(); 880 ASSERT_NO_SAFEPOINT_SCOPE();
883 RawContext* obj = reinterpret_cast<RawContext*>( 881 RawContext* obj = reinterpret_cast<RawContext*>(
884 AllocateUninitialized(kContextCid, Context::InstanceSize(num_variables))); 882 AllocateUninitialized(kContextCid, Context::InstanceSize(num_variables)));
885 obj->ptr()->num_variables_ = num_variables; 883 obj->ptr()->num_variables_ = num_variables;
886 return obj; 884 return obj;
887 } 885 }
888 886
889 887
890 RawClass* SnapshotReader::NewClass(intptr_t class_id) { 888 RawClass* SnapshotReader::NewClass(intptr_t class_id) {
891 ASSERT(kind_ == Snapshot::kFull); 889 ASSERT(Snapshot::IsFull(kind_));
892 ASSERT_NO_SAFEPOINT_SCOPE(); 890 ASSERT_NO_SAFEPOINT_SCOPE();
893 if (class_id < kNumPredefinedCids) { 891 if (class_id < kNumPredefinedCids) {
894 ASSERT((class_id >= kInstanceCid) && 892 ASSERT((class_id >= kInstanceCid) &&
895 (class_id <= kNullCid)); 893 (class_id <= kNullCid));
896 return isolate()->class_table()->At(class_id); 894 return isolate()->class_table()->At(class_id);
897 } 895 }
898 RawClass* obj = reinterpret_cast<RawClass*>( 896 RawClass* obj = reinterpret_cast<RawClass*>(
899 AllocateUninitialized(kClassCid, Class::InstanceSize())); 897 AllocateUninitialized(kClassCid, Class::InstanceSize()));
900 Instance fake; 898 Instance fake;
901 obj->ptr()->handle_vtable_ = fake.vtable(); 899 obj->ptr()->handle_vtable_ = fake.vtable();
902 cls_ = obj; 900 cls_ = obj;
903 cls_.set_id(class_id); 901 cls_.set_id(class_id);
904 isolate()->RegisterClassAt(class_id, cls_); 902 isolate()->RegisterClassAt(class_id, cls_);
905 return cls_.raw(); 903 return cls_.raw();
906 } 904 }
907 905
908 906
909 RawInstance* SnapshotReader::NewInstance() { 907 RawInstance* SnapshotReader::NewInstance() {
910 ASSERT(kind_ == Snapshot::kFull); 908 ASSERT(Snapshot::IsFull(kind_));
911 ASSERT_NO_SAFEPOINT_SCOPE(); 909 ASSERT_NO_SAFEPOINT_SCOPE();
912 RawInstance* obj = reinterpret_cast<RawInstance*>( 910 RawInstance* obj = reinterpret_cast<RawInstance*>(
913 AllocateUninitialized(kInstanceCid, Instance::InstanceSize())); 911 AllocateUninitialized(kInstanceCid, Instance::InstanceSize()));
914 return obj; 912 return obj;
915 } 913 }
916 914
917 915
918 RawMint* SnapshotReader::NewMint(int64_t value) { 916 RawMint* SnapshotReader::NewMint(int64_t value) {
919 ASSERT(kind_ == Snapshot::kFull); 917 ASSERT(Snapshot::IsFull(kind_));
920 ASSERT_NO_SAFEPOINT_SCOPE(); 918 ASSERT_NO_SAFEPOINT_SCOPE();
921 RawMint* obj = reinterpret_cast<RawMint*>( 919 RawMint* obj = reinterpret_cast<RawMint*>(
922 AllocateUninitialized(kMintCid, Mint::InstanceSize())); 920 AllocateUninitialized(kMintCid, Mint::InstanceSize()));
923 obj->ptr()->value_ = value; 921 obj->ptr()->value_ = value;
924 return obj; 922 return obj;
925 } 923 }
926 924
927 925
928 RawDouble* SnapshotReader::NewDouble(double value) { 926 RawDouble* SnapshotReader::NewDouble(double value) {
929 ASSERT(kind_ == Snapshot::kFull); 927 ASSERT(Snapshot::IsFull(kind_));
930 ASSERT_NO_SAFEPOINT_SCOPE(); 928 ASSERT_NO_SAFEPOINT_SCOPE();
931 RawDouble* obj = reinterpret_cast<RawDouble*>( 929 RawDouble* obj = reinterpret_cast<RawDouble*>(
932 AllocateUninitialized(kDoubleCid, Double::InstanceSize())); 930 AllocateUninitialized(kDoubleCid, Double::InstanceSize()));
933 obj->ptr()->value_ = value; 931 obj->ptr()->value_ = value;
934 return obj; 932 return obj;
935 } 933 }
936 934
937 935
938 RawTypedData* SnapshotReader::NewTypedData(intptr_t class_id, intptr_t len) { 936 RawTypedData* SnapshotReader::NewTypedData(intptr_t class_id, intptr_t len) {
939 ASSERT(kind_ == Snapshot::kFull); 937 ASSERT(Snapshot::IsFull(kind_));
940 ASSERT_NO_SAFEPOINT_SCOPE(); 938 ASSERT_NO_SAFEPOINT_SCOPE();
941 const intptr_t lengthInBytes = len * TypedData::ElementSizeInBytes(class_id); 939 const intptr_t lengthInBytes = len * TypedData::ElementSizeInBytes(class_id);
942 RawTypedData* obj = reinterpret_cast<RawTypedData*>( 940 RawTypedData* obj = reinterpret_cast<RawTypedData*>(
943 AllocateUninitialized(class_id, TypedData::InstanceSize(lengthInBytes))); 941 AllocateUninitialized(class_id, TypedData::InstanceSize(lengthInBytes)));
944 obj->StoreSmi(&(obj->ptr()->length_), Smi::New(len)); 942 obj->StoreSmi(&(obj->ptr()->length_), Smi::New(len));
945 return obj; 943 return obj;
946 } 944 }
947 945
948 946
949 #define ALLOC_NEW_OBJECT(type) \ 947 #define ALLOC_NEW_OBJECT(type) \
950 ASSERT(kind_ == Snapshot::kFull); \ 948 ASSERT(Snapshot::IsFull(kind_)); \
951 ASSERT_NO_SAFEPOINT_SCOPE(); \ 949 ASSERT_NO_SAFEPOINT_SCOPE(); \
952 return reinterpret_cast<Raw##type*>( \ 950 return reinterpret_cast<Raw##type*>( \
953 AllocateUninitialized(k##type##Cid, type::InstanceSize())); \ 951 AllocateUninitialized(k##type##Cid, type::InstanceSize())); \
954 952
955 953
956 RawBigint* SnapshotReader::NewBigint() { 954 RawBigint* SnapshotReader::NewBigint() {
957 ALLOC_NEW_OBJECT(Bigint); 955 ALLOC_NEW_OBJECT(Bigint);
958 } 956 }
959 957
960 958
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 } 1071 }
1074 1072
1075 1073
1076 RawRegExp* SnapshotReader::NewRegExp() { 1074 RawRegExp* SnapshotReader::NewRegExp() {
1077 ALLOC_NEW_OBJECT(RegExp); 1075 ALLOC_NEW_OBJECT(RegExp);
1078 } 1076 }
1079 1077
1080 1078
1081 RawFloat32x4* SnapshotReader::NewFloat32x4(float v0, float v1, float v2, 1079 RawFloat32x4* SnapshotReader::NewFloat32x4(float v0, float v1, float v2,
1082 float v3) { 1080 float v3) {
1083 ASSERT(kind_ == Snapshot::kFull); 1081 ASSERT(Snapshot::IsFull(kind_));
1084 ASSERT_NO_SAFEPOINT_SCOPE(); 1082 ASSERT_NO_SAFEPOINT_SCOPE();
1085 RawFloat32x4* obj = reinterpret_cast<RawFloat32x4*>( 1083 RawFloat32x4* obj = reinterpret_cast<RawFloat32x4*>(
1086 AllocateUninitialized(kFloat32x4Cid, Float32x4::InstanceSize())); 1084 AllocateUninitialized(kFloat32x4Cid, Float32x4::InstanceSize()));
1087 obj->ptr()->value_[0] = v0; 1085 obj->ptr()->value_[0] = v0;
1088 obj->ptr()->value_[1] = v1; 1086 obj->ptr()->value_[1] = v1;
1089 obj->ptr()->value_[2] = v2; 1087 obj->ptr()->value_[2] = v2;
1090 obj->ptr()->value_[3] = v3; 1088 obj->ptr()->value_[3] = v3;
1091 return obj; 1089 return obj;
1092 } 1090 }
1093 1091
1094 1092
1095 RawInt32x4* SnapshotReader::NewInt32x4(uint32_t v0, uint32_t v1, uint32_t v2, 1093 RawInt32x4* SnapshotReader::NewInt32x4(uint32_t v0, uint32_t v1, uint32_t v2,
1096 uint32_t v3) { 1094 uint32_t v3) {
1097 ASSERT(kind_ == Snapshot::kFull); 1095 ASSERT(Snapshot::IsFull(kind_));
1098 ASSERT_NO_SAFEPOINT_SCOPE(); 1096 ASSERT_NO_SAFEPOINT_SCOPE();
1099 RawInt32x4* obj = reinterpret_cast<RawInt32x4*>( 1097 RawInt32x4* obj = reinterpret_cast<RawInt32x4*>(
1100 AllocateUninitialized(kInt32x4Cid, Int32x4::InstanceSize())); 1098 AllocateUninitialized(kInt32x4Cid, Int32x4::InstanceSize()));
1101 obj->ptr()->value_[0] = v0; 1099 obj->ptr()->value_[0] = v0;
1102 obj->ptr()->value_[1] = v1; 1100 obj->ptr()->value_[1] = v1;
1103 obj->ptr()->value_[2] = v2; 1101 obj->ptr()->value_[2] = v2;
1104 obj->ptr()->value_[3] = v3; 1102 obj->ptr()->value_[3] = v3;
1105 return obj; 1103 return obj;
1106 } 1104 }
1107 1105
1108 1106
1109 RawFloat64x2* SnapshotReader::NewFloat64x2(double v0, double v1) { 1107 RawFloat64x2* SnapshotReader::NewFloat64x2(double v0, double v1) {
1110 ASSERT(kind_ == Snapshot::kFull); 1108 ASSERT(Snapshot::IsFull(kind_));
1111 ASSERT_NO_SAFEPOINT_SCOPE(); 1109 ASSERT_NO_SAFEPOINT_SCOPE();
1112 RawFloat64x2* obj = reinterpret_cast<RawFloat64x2*>( 1110 RawFloat64x2* obj = reinterpret_cast<RawFloat64x2*>(
1113 AllocateUninitialized(kFloat64x2Cid, Float64x2::InstanceSize())); 1111 AllocateUninitialized(kFloat64x2Cid, Float64x2::InstanceSize()));
1114 obj->ptr()->value_[0] = v0; 1112 obj->ptr()->value_[0] = v0;
1115 obj->ptr()->value_[1] = v1; 1113 obj->ptr()->value_[1] = v1;
1116 return obj; 1114 return obj;
1117 } 1115 }
1118 1116
1119 1117
1120 RawApiError* SnapshotReader::NewApiError() { 1118 RawApiError* SnapshotReader::NewApiError() {
(...skipping 10 matching lines...) Expand all
1131 ALLOC_NEW_OBJECT(UnhandledException); 1129 ALLOC_NEW_OBJECT(UnhandledException);
1132 } 1130 }
1133 1131
1134 1132
1135 RawObject* SnapshotReader::NewInteger(int64_t value) { 1133 RawObject* SnapshotReader::NewInteger(int64_t value) {
1136 ASSERT((value & kSmiTagMask) == kSmiTag); 1134 ASSERT((value & kSmiTagMask) == kSmiTag);
1137 value = value >> kSmiTagShift; 1135 value = value >> kSmiTagShift;
1138 if (Smi::IsValid(value)) { 1136 if (Smi::IsValid(value)) {
1139 return Smi::New(static_cast<intptr_t>(value)); 1137 return Smi::New(static_cast<intptr_t>(value));
1140 } 1138 }
1141 if (kind_ == Snapshot::kFull) { 1139 if (Snapshot::IsFull(kind_)) {
1142 return NewMint(value); 1140 return NewMint(value);
1143 } 1141 }
1144 return Mint::NewCanonical(value); 1142 return Mint::NewCanonical(value);
1145 } 1143 }
1146 1144
1147 1145
1148 RawStacktrace* SnapshotReader::NewStacktrace() { 1146 RawStacktrace* SnapshotReader::NewStacktrace() {
1149 ALLOC_NEW_OBJECT(Stacktrace); 1147 ALLOC_NEW_OBJECT(Stacktrace);
1150 } 1148 }
1151 1149
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 } 1521 }
1524 1522
1525 1523
1526 RawObject* SnapshotReader::ReadIndexedObject(intptr_t object_id, 1524 RawObject* SnapshotReader::ReadIndexedObject(intptr_t object_id,
1527 intptr_t patch_object_id, 1525 intptr_t patch_object_id,
1528 intptr_t patch_offset) { 1526 intptr_t patch_offset) {
1529 intptr_t class_id = ClassIdFromObjectId(object_id); 1527 intptr_t class_id = ClassIdFromObjectId(object_id);
1530 if (IsObjectStoreClassId(class_id)) { 1528 if (IsObjectStoreClassId(class_id)) {
1531 return isolate()->class_table()->At(class_id); // get singleton class. 1529 return isolate()->class_table()->At(class_id); // get singleton class.
1532 } 1530 }
1533 if (kind_ != Snapshot::kFull) { 1531 if (!Snapshot::IsFull(kind_)) {
1534 if (IsObjectStoreTypeId(object_id)) { 1532 if (IsObjectStoreTypeId(object_id)) {
1535 return GetType(object_store(), object_id); // return type obj. 1533 return GetType(object_store(), object_id); // return type obj.
1536 } 1534 }
1537 } 1535 }
1538 ASSERT(object_id >= kMaxPredefinedObjectIds); 1536 ASSERT(object_id >= kMaxPredefinedObjectIds);
1539 intptr_t index = (object_id - kMaxPredefinedObjectIds); 1537 intptr_t index = (object_id - kMaxPredefinedObjectIds);
1540 if (index < max_vm_isolate_object_id_) { 1538 if (index < max_vm_isolate_object_id_) {
1541 return VmIsolateSnapshotObject(index); 1539 return VmIsolateSnapshotObject(index);
1542 } 1540 }
1543 AddPatchRecord(object_id, patch_object_id, patch_offset); 1541 AddPatchRecord(object_id, patch_object_id, patch_offset);
1544 return GetBackRef(object_id)->raw(); 1542 return GetBackRef(object_id)->raw();
1545 } 1543 }
1546 1544
1547 1545
1548 void SnapshotReader::AddPatchRecord(intptr_t object_id, 1546 void SnapshotReader::AddPatchRecord(intptr_t object_id,
1549 intptr_t patch_object_id, 1547 intptr_t patch_object_id,
1550 intptr_t patch_offset) { 1548 intptr_t patch_offset) {
1551 if (patch_object_id != kInvalidPatchIndex && kind() != Snapshot::kFull) { 1549 if (patch_object_id != kInvalidPatchIndex && !Snapshot::IsFull(kind())) {
1552 ASSERT(object_id >= kMaxPredefinedObjectIds); 1550 ASSERT(object_id >= kMaxPredefinedObjectIds);
1553 intptr_t index = (object_id - kMaxPredefinedObjectIds); 1551 intptr_t index = (object_id - kMaxPredefinedObjectIds);
1554 ASSERT(index >= max_vm_isolate_object_id_); 1552 ASSERT(index >= max_vm_isolate_object_id_);
1555 index -= max_vm_isolate_object_id_; 1553 index -= max_vm_isolate_object_id_;
1556 ASSERT(index < backward_references_->length()); 1554 ASSERT(index < backward_references_->length());
1557 BackRefNode& ref = (*backward_references_)[index]; 1555 BackRefNode& ref = (*backward_references_)[index];
1558 ref.AddPatchRecord(patch_object_id, patch_offset); 1556 ref.AddPatchRecord(patch_object_id, patch_offset);
1559 } 1557 }
1560 } 1558 }
1561 1559
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 for (intptr_t i = 0; i < len; i++) { 1620 for (intptr_t i = 0; i < len; i++) {
1623 *PassiveObjectHandle() = ReadObjectImpl(as_reference, 1621 *PassiveObjectHandle() = ReadObjectImpl(as_reference,
1624 object_id, 1622 object_id,
1625 (i + offset)); 1623 (i + offset));
1626 result.SetAt(i, *PassiveObjectHandle()); 1624 result.SetAt(i, *PassiveObjectHandle());
1627 } 1625 }
1628 } 1626 }
1629 1627
1630 1628
1631 VmIsolateSnapshotReader::VmIsolateSnapshotReader( 1629 VmIsolateSnapshotReader::VmIsolateSnapshotReader(
1630 Snapshot::Kind kind,
1632 const uint8_t* buffer, 1631 const uint8_t* buffer,
1633 intptr_t size, 1632 intptr_t size,
1634 const uint8_t* instructions_buffer, 1633 const uint8_t* instructions_buffer,
1635 const uint8_t* data_buffer, 1634 const uint8_t* data_buffer,
1636 Thread* thread) 1635 Thread* thread)
1637 : SnapshotReader(buffer, 1636 : SnapshotReader(buffer,
1638 size, 1637 size,
1639 instructions_buffer, 1638 instructions_buffer,
1640 data_buffer, 1639 data_buffer,
1641 Snapshot::kFull, 1640 kind,
1642 new ZoneGrowableArray<BackRefNode>( 1641 new ZoneGrowableArray<BackRefNode>(
1643 kNumVmIsolateSnapshotReferences), 1642 kNumVmIsolateSnapshotReferences),
1644 thread) { 1643 thread) {
1644 ASSERT(Snapshot::IsFull(kind));
1645 } 1645 }
1646 1646
1647 1647
1648 VmIsolateSnapshotReader::~VmIsolateSnapshotReader() { 1648 VmIsolateSnapshotReader::~VmIsolateSnapshotReader() {
1649 intptr_t len = GetBackwardReferenceTable()->length(); 1649 intptr_t len = GetBackwardReferenceTable()->length();
1650 Object::InitVmIsolateSnapshotObjectTable(len); 1650 Object::InitVmIsolateSnapshotObjectTable(len);
1651 ZoneGrowableArray<BackRefNode>* backrefs = GetBackwardReferenceTable(); 1651 ZoneGrowableArray<BackRefNode>* backrefs = GetBackwardReferenceTable();
1652 for (intptr_t i = 0; i < len; i++) { 1652 for (intptr_t i = 0; i < len; i++) {
1653 Object::vm_isolate_snapshot_object_table().SetAt( 1653 Object::vm_isolate_snapshot_object_table().SetAt(
1654 i, *(backrefs->At(i).reference())); 1654 i, *(backrefs->At(i).reference()));
1655 } 1655 }
1656 ResetBackwardReferenceTable(); 1656 ResetBackwardReferenceTable();
1657 Dart::set_instructions_snapshot_buffer(instructions_buffer_); 1657 Dart::set_instructions_snapshot_buffer(instructions_buffer_);
1658 Dart::set_data_snapshot_buffer(data_buffer_); 1658 Dart::set_data_snapshot_buffer(data_buffer_);
1659 } 1659 }
1660 1660
1661 1661
1662 RawApiError* VmIsolateSnapshotReader::ReadVmIsolateSnapshot() { 1662 RawApiError* VmIsolateSnapshotReader::ReadVmIsolateSnapshot() {
1663 ASSERT(kind() == Snapshot::kFull); 1663 ASSERT(Snapshot::IsFull(kind()));
1664 Thread* thread = Thread::Current(); 1664 Thread* thread = Thread::Current();
1665 Isolate* isolate = thread->isolate(); 1665 Isolate* isolate = thread->isolate();
1666 ASSERT(isolate != NULL); 1666 ASSERT(isolate != NULL);
1667 ASSERT(isolate == Dart::vm_isolate()); 1667 ASSERT(isolate == Dart::vm_isolate());
1668 ObjectStore* object_store = isolate->object_store(); 1668 ObjectStore* object_store = isolate->object_store();
1669 ASSERT(object_store != NULL); 1669 ASSERT(object_store != NULL);
1670 1670
1671 // First read the version string, and check that it matches. 1671 // First read the version string, and check that it matches.
1672 RawApiError* error = VerifyVersion(); 1672 RawApiError* error = VerifyVersion();
1673 if (error != ApiError::null()) { 1673 if (error != ApiError::null()) {
1674 return error; 1674 return error;
1675 } 1675 }
1676 1676
1677 // The version string matches. Read the rest of the snapshot. 1677 // The version string matches. Read the rest of the snapshot.
1678 1678
1679 { 1679 {
1680 NoSafepointScope no_safepoint; 1680 NoSafepointScope no_safepoint;
1681 HeapLocker hl(thread, old_space()); 1681 HeapLocker hl(thread, old_space());
1682 1682
1683 // Read in the symbol table. 1683 // Read in the symbol table.
1684 object_store->symbol_table_ = reinterpret_cast<RawArray*>(ReadObject()); 1684 object_store->symbol_table_ = reinterpret_cast<RawArray*>(ReadObject());
1685 1685
1686 Symbols::InitOnceFromSnapshot(isolate); 1686 Symbols::InitOnceFromSnapshot(isolate);
1687 1687
1688 // Read in all the script objects and the accompanying token streams 1688 // Read in all the script objects and the accompanying token streams
1689 // for bootstrap libraries so that they are in the VM isolate's read 1689 // for bootstrap libraries so that they are in the VM isolate's read
1690 // only memory. 1690 // only memory.
1691 *(ArrayHandle()) ^= ReadObject(); 1691 *(ArrayHandle()) ^= ReadObject();
1692 1692
1693 if (snapshot_code()) { 1693 if (Snapshot::IncludesCode(kind())) {
1694 StubCode::ReadFrom(this); 1694 StubCode::ReadFrom(this);
1695 } 1695 }
1696 1696
1697 // Validate the class table. 1697 // Validate the class table.
1698 #if defined(DEBUG) 1698 #if defined(DEBUG)
1699 isolate->ValidateClassTable(); 1699 isolate->ValidateClassTable();
1700 #endif 1700 #endif
1701 1701
1702 return ApiError::null(); 1702 return ApiError::null();
1703 } 1703 }
1704 } 1704 }
1705 1705
1706 1706
1707 IsolateSnapshotReader::IsolateSnapshotReader(const uint8_t* buffer, 1707 IsolateSnapshotReader::IsolateSnapshotReader(Snapshot::Kind kind,
1708 const uint8_t* buffer,
1708 intptr_t size, 1709 intptr_t size,
1709 const uint8_t* instructions_buffer, 1710 const uint8_t* instructions_buffer,
1710 const uint8_t* data_buffer, 1711 const uint8_t* data_buffer,
1711 Thread* thread) 1712 Thread* thread)
1712 : SnapshotReader(buffer, 1713 : SnapshotReader(buffer,
1713 size, 1714 size,
1714 instructions_buffer, 1715 instructions_buffer,
1715 data_buffer, 1716 data_buffer,
1716 Snapshot::kFull, 1717 kind,
1717 new ZoneGrowableArray<BackRefNode>( 1718 new ZoneGrowableArray<BackRefNode>(
1718 kNumInitialReferencesInFullSnapshot), 1719 kNumInitialReferencesInFullSnapshot),
1719 thread) { 1720 thread) {
1720 isolate()->set_compilation_allowed(instructions_buffer_ == NULL); 1721 isolate()->set_compilation_allowed(instructions_buffer_ == NULL);
1722 ASSERT(Snapshot::IsFull(kind));
1721 } 1723 }
1722 1724
1723 1725
1724 IsolateSnapshotReader::~IsolateSnapshotReader() { 1726 IsolateSnapshotReader::~IsolateSnapshotReader() {
1725 ResetBackwardReferenceTable(); 1727 ResetBackwardReferenceTable();
1726 } 1728 }
1727 1729
1728 1730
1729 ScriptSnapshotReader::ScriptSnapshotReader(const uint8_t* buffer, 1731 ScriptSnapshotReader::ScriptSnapshotReader(const uint8_t* buffer,
1730 intptr_t size, 1732 intptr_t size,
(...skipping 24 matching lines...) Expand all
1755 new ZoneGrowableArray<BackRefNode>(kNumInitialReferences), 1757 new ZoneGrowableArray<BackRefNode>(kNumInitialReferences),
1756 thread) { 1758 thread) {
1757 } 1759 }
1758 1760
1759 1761
1760 MessageSnapshotReader::~MessageSnapshotReader() { 1762 MessageSnapshotReader::~MessageSnapshotReader() {
1761 ResetBackwardReferenceTable(); 1763 ResetBackwardReferenceTable();
1762 } 1764 }
1763 1765
1764 1766
1765 SnapshotWriter::SnapshotWriter(Snapshot::Kind kind, 1767 SnapshotWriter::SnapshotWriter(Thread* thread,
1766 Thread* thread, 1768 Snapshot::Kind kind,
1767 uint8_t** buffer, 1769 uint8_t** buffer,
1768 ReAlloc alloc, 1770 ReAlloc alloc,
1769 intptr_t initial_size, 1771 intptr_t initial_size,
1770 ForwardList* forward_list, 1772 ForwardList* forward_list,
1771 InstructionsWriter* instructions_writer, 1773 InstructionsWriter* instructions_writer,
1772 bool can_send_any_object, 1774 bool can_send_any_object,
1773 bool snapshot_code,
1774 bool vm_isolate_is_symbolic) 1775 bool vm_isolate_is_symbolic)
1775 : BaseWriter(buffer, alloc, initial_size), 1776 : BaseWriter(buffer, alloc, initial_size),
1777 thread_(thread),
1776 kind_(kind), 1778 kind_(kind),
1777 thread_(thread),
1778 object_store_(isolate()->object_store()), 1779 object_store_(isolate()->object_store()),
1779 class_table_(isolate()->class_table()), 1780 class_table_(isolate()->class_table()),
1780 forward_list_(forward_list), 1781 forward_list_(forward_list),
1781 instructions_writer_(instructions_writer), 1782 instructions_writer_(instructions_writer),
1782 exception_type_(Exceptions::kNone), 1783 exception_type_(Exceptions::kNone),
1783 exception_msg_(NULL), 1784 exception_msg_(NULL),
1784 unmarked_objects_(false), 1785 unmarked_objects_(false),
1785 can_send_any_object_(can_send_any_object), 1786 can_send_any_object_(can_send_any_object),
1786 snapshot_code_(snapshot_code),
1787 vm_isolate_is_symbolic_(vm_isolate_is_symbolic) { 1787 vm_isolate_is_symbolic_(vm_isolate_is_symbolic) {
1788 ASSERT(forward_list_ != NULL); 1788 ASSERT(forward_list_ != NULL);
1789 } 1789 }
1790 1790
1791 1791
1792 void SnapshotWriter::WriteObject(RawObject* rawobj) { 1792 void SnapshotWriter::WriteObject(RawObject* rawobj) {
1793 WriteObjectImpl(rawobj, kAsInlinedObject); 1793 WriteObjectImpl(rawobj, kAsInlinedObject);
1794 WriteForwardedObjects(); 1794 WriteForwardedObjects();
1795 } 1795 }
1796 1796
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 } 1869 }
1870 1870
1871 // Check if it is a singleton ICData array object. 1871 // Check if it is a singleton ICData array object.
1872 for (intptr_t i = 0; i < ICData::kCachedICDataArrayCount; i++) { 1872 for (intptr_t i = 0; i < ICData::kCachedICDataArrayCount; i++) {
1873 if (rawobj == ICData::cached_icdata_arrays_[i]) { 1873 if (rawobj == ICData::cached_icdata_arrays_[i]) {
1874 WriteVMIsolateObject(kCachedICDataArray0 + i); 1874 WriteVMIsolateObject(kCachedICDataArray0 + i);
1875 return true; 1875 return true;
1876 } 1876 }
1877 } 1877 }
1878 1878
1879 if (kind() == Snapshot::kFull) { 1879 if (Snapshot::IsFull(kind())) {
1880 // Check it is a predefined symbol in the VM isolate. 1880 // Check it is a predefined symbol in the VM isolate.
1881 id = Symbols::LookupVMSymbol(rawobj); 1881 id = Symbols::LookupVMSymbol(rawobj);
1882 if (id != kInvalidIndex) { 1882 if (id != kInvalidIndex) {
1883 WriteVMIsolateObject(id); 1883 WriteVMIsolateObject(id);
1884 return true; 1884 return true;
1885 } 1885 }
1886 1886
1887 // Check if it is an object from the vm isolate snapshot object table. 1887 // Check if it is an object from the vm isolate snapshot object table.
1888 id = FindVmSnapshotObject(rawobj); 1888 id = FindVmSnapshotObject(rawobj);
1889 if (id != kInvalidIndex) { 1889 if (id != kInvalidIndex) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 1954
1955 intptr_t count() const { return count_; } 1955 intptr_t count() const { return count_; }
1956 1956
1957 private: 1957 private:
1958 Object& objHandle_; 1958 Object& objHandle_;
1959 intptr_t count_; 1959 intptr_t count_;
1960 const Array* scripts_; 1960 const Array* scripts_;
1961 }; 1961 };
1962 1962
1963 1963
1964 FullSnapshotWriter::FullSnapshotWriter(uint8_t** vm_isolate_snapshot_buffer, 1964 FullSnapshotWriter::FullSnapshotWriter(Snapshot::Kind kind,
1965 uint8_t** vm_isolate_snapshot_buffer,
1965 uint8_t** isolate_snapshot_buffer, 1966 uint8_t** isolate_snapshot_buffer,
1966 ReAlloc alloc, 1967 ReAlloc alloc,
1967 InstructionsWriter* instructions_writer, 1968 InstructionsWriter* instructions_writer,
1968 bool snapshot_code,
1969 bool vm_isolate_is_symbolic) 1969 bool vm_isolate_is_symbolic)
1970 : thread_(Thread::Current()), 1970 : thread_(Thread::Current()),
1971 kind_(kind),
1971 vm_isolate_snapshot_buffer_(vm_isolate_snapshot_buffer), 1972 vm_isolate_snapshot_buffer_(vm_isolate_snapshot_buffer),
1972 isolate_snapshot_buffer_(isolate_snapshot_buffer), 1973 isolate_snapshot_buffer_(isolate_snapshot_buffer),
1973 alloc_(alloc), 1974 alloc_(alloc),
1974 vm_isolate_snapshot_size_(0), 1975 vm_isolate_snapshot_size_(0),
1975 isolate_snapshot_size_(0), 1976 isolate_snapshot_size_(0),
1976 forward_list_(NULL), 1977 forward_list_(NULL),
1977 instructions_writer_(instructions_writer), 1978 instructions_writer_(instructions_writer),
1978 scripts_(Array::Handle(zone())), 1979 scripts_(Array::Handle(zone())),
1979 symbol_table_(Array::Handle(zone())), 1980 symbol_table_(Array::Handle(zone())),
1980 snapshot_code_(snapshot_code),
1981 vm_isolate_is_symbolic_(vm_isolate_is_symbolic) { 1981 vm_isolate_is_symbolic_(vm_isolate_is_symbolic) {
1982 ASSERT(isolate_snapshot_buffer_ != NULL); 1982 ASSERT(isolate_snapshot_buffer_ != NULL);
1983 ASSERT(alloc_ != NULL); 1983 ASSERT(alloc_ != NULL);
1984 ASSERT(isolate() != NULL); 1984 ASSERT(isolate() != NULL);
1985 ASSERT(ClassFinalizer::AllClassesFinalized()); 1985 ASSERT(ClassFinalizer::AllClassesFinalized());
1986 ASSERT(isolate() != NULL); 1986 ASSERT(isolate() != NULL);
1987 ASSERT(heap() != NULL); 1987 ASSERT(heap() != NULL);
1988 ObjectStore* object_store = isolate()->object_store(); 1988 ObjectStore* object_store = isolate()->object_store();
1989 ASSERT(object_store != NULL); 1989 ASSERT(object_store != NULL);
1990 // Ensure the class table is valid. 1990 // Ensure the class table is valid.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 if (!symbol_table_.IsNull()) { 2022 if (!symbol_table_.IsNull()) {
2023 isolate()->object_store()->set_symbol_table(symbol_table_); 2023 isolate()->object_store()->set_symbol_table(symbol_table_);
2024 symbol_table_ = Array::null(); 2024 symbol_table_ = Array::null();
2025 } 2025 }
2026 scripts_ = Array::null(); 2026 scripts_ = Array::null();
2027 } 2027 }
2028 2028
2029 2029
2030 void FullSnapshotWriter::WriteVmIsolateSnapshot() { 2030 void FullSnapshotWriter::WriteVmIsolateSnapshot() {
2031 ASSERT(vm_isolate_snapshot_buffer_ != NULL); 2031 ASSERT(vm_isolate_snapshot_buffer_ != NULL);
2032 SnapshotWriter writer(Snapshot::kFull, 2032 SnapshotWriter writer(thread(),
2033 thread(), 2033 kind_,
2034 vm_isolate_snapshot_buffer_, 2034 vm_isolate_snapshot_buffer_,
2035 alloc_, 2035 alloc_,
2036 kInitialSize, 2036 kInitialSize,
2037 forward_list_, 2037 forward_list_,
2038 instructions_writer_, 2038 instructions_writer_,
2039 true, /* can_send_any_object */ 2039 true, /* can_send_any_object */
2040 snapshot_code_,
2041 vm_isolate_is_symbolic_); 2040 vm_isolate_is_symbolic_);
2042 // Write full snapshot for the VM isolate. 2041 // Write full snapshot for the VM isolate.
2043 // Setup for long jump in case there is an exception while writing 2042 // Setup for long jump in case there is an exception while writing
2044 // the snapshot. 2043 // the snapshot.
2045 LongJumpScope jump; 2044 LongJumpScope jump;
2046 if (setjmp(*jump.Set()) == 0) { 2045 if (setjmp(*jump.Set()) == 0) {
2047 // Reserve space in the output buffer for a snapshot header. 2046 // Reserve space in the output buffer for a snapshot header.
2048 writer.ReserveHeader(); 2047 writer.ReserveHeader();
2049 2048
2050 // Write out the version string. 2049 // Write out the version string.
2051 writer.WriteVersion(); 2050 writer.WriteVersion();
2052 2051
2053 /* 2052 /*
2054 * Now Write out the following 2053 * Now Write out the following
2055 * - the symbol table 2054 * - the symbol table
2056 * - all the scripts and token streams for these scripts 2055 * - all the scripts and token streams for these scripts
2057 * 2056 *
2058 **/ 2057 **/
2059 // Write out the symbol table. 2058 // Write out the symbol table.
2060 writer.WriteObject(symbol_table_.raw()); 2059 writer.WriteObject(symbol_table_.raw());
2061 2060
2062 // Write out all the script objects and the accompanying token streams 2061 // Write out all the script objects and the accompanying token streams
2063 // for the bootstrap libraries so that they are in the VM isolate 2062 // for the bootstrap libraries so that they are in the VM isolate
2064 // read only memory. 2063 // read only memory.
2065 writer.WriteObject(scripts_.raw()); 2064 writer.WriteObject(scripts_.raw());
2066 2065
2067 if (snapshot_code_) { 2066 if (Snapshot::IncludesCode(kind_)) {
2068 ASSERT(!vm_isolate_is_symbolic_); 2067 ASSERT(!vm_isolate_is_symbolic_);
2069 StubCode::WriteTo(&writer); 2068 StubCode::WriteTo(&writer);
2070 } 2069 }
2071 2070
2072 2071
2073 writer.FillHeader(writer.kind()); 2072 writer.FillHeader(writer.kind());
2074 2073
2075 vm_isolate_snapshot_size_ = writer.BytesWritten(); 2074 vm_isolate_snapshot_size_ = writer.BytesWritten();
2076 } else { 2075 } else {
2077 writer.ThrowException(writer.exception_type(), writer.exception_msg()); 2076 writer.ThrowException(writer.exception_type(), writer.exception_msg());
2078 } 2077 }
2079 } 2078 }
2080 2079
2081 2080
2082 void FullSnapshotWriter::WriteIsolateFullSnapshot() { 2081 void FullSnapshotWriter::WriteIsolateFullSnapshot() {
2083 SnapshotWriter writer(Snapshot::kFull, 2082 SnapshotWriter writer(thread(),
2084 thread(), 2083 kind_,
2085 isolate_snapshot_buffer_, 2084 isolate_snapshot_buffer_,
2086 alloc_, 2085 alloc_,
2087 kInitialSize, 2086 kInitialSize,
2088 forward_list_, 2087 forward_list_,
2089 instructions_writer_, 2088 instructions_writer_,
2090 true, /* can_send_any_object */ 2089 true, /* can_send_any_object */
2091 snapshot_code_,
2092 true /* vm_isolate_is_symbolic */); 2090 true /* vm_isolate_is_symbolic */);
2093 ObjectStore* object_store = isolate()->object_store(); 2091 ObjectStore* object_store = isolate()->object_store();
2094 ASSERT(object_store != NULL); 2092 ASSERT(object_store != NULL);
2095 2093
2096 // Write full snapshot for a regular isolate. 2094 // Write full snapshot for a regular isolate.
2097 // Setup for long jump in case there is an exception while writing 2095 // Setup for long jump in case there is an exception while writing
2098 // the snapshot. 2096 // the snapshot.
2099 LongJumpScope jump; 2097 LongJumpScope jump;
2100 if (setjmp(*jump.Set()) == 0) { 2098 if (setjmp(*jump.Set()) == 0) {
2101 // Reserve space in the output buffer for a snapshot header. 2099 // Reserve space in the output buffer for a snapshot header.
2102 writer.ReserveHeader(); 2100 writer.ReserveHeader();
2103 2101
2104 // Write out the version string. 2102 // Write out the version string.
2105 writer.WriteVersion(); 2103 writer.WriteVersion();
2106 2104
2107 // Write out the full snapshot. 2105 // Write out the full snapshot.
2108 2106
2109 // Write out all the objects in the object store of the isolate which 2107 // Write out all the objects in the object store of the isolate which
2110 // is the root set for all dart allocated objects at this point. 2108 // is the root set for all dart allocated objects at this point.
2111 SnapshotWriterVisitor visitor(&writer, false); 2109 SnapshotWriterVisitor visitor(&writer, false);
2112 visitor.VisitPointers(object_store->from(), 2110 visitor.VisitPointers(object_store->from(),
2113 snapshot_code_ ? object_store->to() 2111 object_store->to_snapshot(kind_));
2114 : object_store->to_snapshot());
2115 2112
2116 // Write out all forwarded objects. 2113 // Write out all forwarded objects.
2117 writer.WriteForwardedObjects(); 2114 writer.WriteForwardedObjects();
2118 2115
2119 writer.FillHeader(writer.kind()); 2116 writer.FillHeader(writer.kind());
2120 2117
2121 isolate_snapshot_size_ = writer.BytesWritten(); 2118 isolate_snapshot_size_ = writer.BytesWritten();
2122 } else { 2119 } else {
2123 writer.ThrowException(writer.exception_type(), writer.exception_msg()); 2120 writer.ThrowException(writer.exception_type(), writer.exception_msg());
2124 } 2121 }
2125 } 2122 }
2126 2123
2127 2124
2128 void FullSnapshotWriter::WriteFullSnapshot() { 2125 void FullSnapshotWriter::WriteFullSnapshot() {
2129 if (vm_isolate_snapshot_buffer() != NULL) { 2126 if (vm_isolate_snapshot_buffer() != NULL) {
2130 WriteVmIsolateSnapshot(); 2127 WriteVmIsolateSnapshot();
2131 } 2128 }
2132 WriteIsolateFullSnapshot(); 2129 WriteIsolateFullSnapshot();
2133 if (snapshot_code_) { 2130 if (Snapshot::IncludesCode(kind_)) {
2134 instructions_writer_->Write(); 2131 instructions_writer_->Write();
2135 2132
2136 OS::Print("VMIsolate(CodeSize): %" Pd "\n", VmIsolateSnapshotSize()); 2133 OS::Print("VMIsolate(CodeSize): %" Pd "\n", VmIsolateSnapshotSize());
2137 OS::Print("Isolate(CodeSize): %" Pd "\n", IsolateSnapshotSize()); 2134 OS::Print("Isolate(CodeSize): %" Pd "\n", IsolateSnapshotSize());
2138 OS::Print("Instructions(CodeSize): %" Pd "\n", 2135 OS::Print("Instructions(CodeSize): %" Pd "\n",
2139 instructions_writer_->binary_size()); 2136 instructions_writer_->binary_size());
2140 intptr_t total = VmIsolateSnapshotSize() + 2137 intptr_t total = VmIsolateSnapshotSize() +
2141 IsolateSnapshotSize() + 2138 IsolateSnapshotSize() +
2142 instructions_writer_->binary_size(); 2139 instructions_writer_->binary_size();
2143 OS::Print("Total(CodeSize): %" Pd "\n", total); 2140 OS::Print("Total(CodeSize): %" Pd "\n", total);
2144 } 2141 }
2145 } 2142 }
2146 2143
2147 2144
2148 PrecompiledSnapshotWriter::PrecompiledSnapshotWriter( 2145 PrecompiledSnapshotWriter::PrecompiledSnapshotWriter(
2149 uint8_t** vm_isolate_snapshot_buffer, 2146 uint8_t** vm_isolate_snapshot_buffer,
2150 uint8_t** isolate_snapshot_buffer, 2147 uint8_t** isolate_snapshot_buffer,
2151 ReAlloc alloc, 2148 ReAlloc alloc,
2152 InstructionsWriter* instructions_writer) 2149 InstructionsWriter* instructions_writer)
2153 : FullSnapshotWriter(vm_isolate_snapshot_buffer, 2150 : FullSnapshotWriter(Snapshot::kAppNoJIT,
2151 vm_isolate_snapshot_buffer,
2154 isolate_snapshot_buffer, 2152 isolate_snapshot_buffer,
2155 alloc, 2153 alloc,
2156 instructions_writer, 2154 instructions_writer,
2157 true, /* snapshot_code */
2158 false /* vm_isolate_is_symbolic */) { 2155 false /* vm_isolate_is_symbolic */) {
2159 } 2156 }
2160 2157
2161 2158
2162 PrecompiledSnapshotWriter::~PrecompiledSnapshotWriter() {} 2159 PrecompiledSnapshotWriter::~PrecompiledSnapshotWriter() {}
2163 2160
2164 2161
2165 ForwardList::ForwardList(Thread* thread, intptr_t first_object_id) 2162 ForwardList::ForwardList(Thread* thread, intptr_t first_object_id)
2166 : thread_(thread), 2163 : thread_(thread),
2167 first_object_id_(first_object_id), 2164 first_object_id_(first_object_id),
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2233 } 2230 }
2234 2231
2235 // Now check if it is an object from the VM isolate. These objects are shared 2232 // Now check if it is an object from the VM isolate. These objects are shared
2236 // by all isolates. 2233 // by all isolates.
2237 if (rawobj->IsVMHeapObject() && HandleVMIsolateObject(rawobj)) { 2234 if (rawobj->IsVMHeapObject() && HandleVMIsolateObject(rawobj)) {
2238 return true; 2235 return true;
2239 } 2236 }
2240 2237
2241 // Check if it is a code object in that case just write a Null object 2238 // Check if it is a code object in that case just write a Null object
2242 // as we do not want code objects in the snapshot. 2239 // as we do not want code objects in the snapshot.
2243 if (cid == kCodeCid && !snapshot_code()) { 2240 if (cid == kCodeCid && !Snapshot::IncludesCode(kind_)) {
2244 WriteVMIsolateObject(kNullObject); 2241 WriteVMIsolateObject(kNullObject);
2245 return true; 2242 return true;
2246 } 2243 }
2247 2244
2248 // Check if classes are not being serialized and it is preinitialized type 2245 // Check if classes are not being serialized and it is preinitialized type
2249 // or a predefined internal VM class in the object store. 2246 // or a predefined internal VM class in the object store.
2250 if (kind_ != Snapshot::kFull) { 2247 if (!Snapshot::IsFull(kind_)) {
2251 // Check if it is an internal VM class which is in the object store. 2248 // Check if it is an internal VM class which is in the object store.
2252 if (cid == kClassCid) { 2249 if (cid == kClassCid) {
2253 RawClass* raw_class = reinterpret_cast<RawClass*>(rawobj); 2250 RawClass* raw_class = reinterpret_cast<RawClass*>(rawobj);
2254 intptr_t class_id = raw_class->ptr()->id_; 2251 intptr_t class_id = raw_class->ptr()->id_;
2255 if (IsObjectStoreClassId(class_id)) { 2252 if (IsObjectStoreClassId(class_id)) {
2256 intptr_t object_id = ObjectIdFromClassId(class_id); 2253 intptr_t object_id = ObjectIdFromClassId(class_id);
2257 WriteIndexedObject(object_id); 2254 WriteIndexedObject(object_id);
2258 return true; 2255 return true;
2259 } 2256 }
2260 } 2257 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 2392
2396 // Mark object as serialized. 2393 // Mark object as serialized.
2397 NodeForObjectId(id)->set_state(kIsSerialized); 2394 NodeForObjectId(id)->set_state(kIsSerialized);
2398 } 2395 }
2399 } 2396 }
2400 first_unprocessed_object_id_ = next_object_id(); 2397 first_unprocessed_object_id_ = next_object_id();
2401 } 2398 }
2402 2399
2403 2400
2404 void SnapshotWriter::WriteClassId(RawClass* cls) { 2401 void SnapshotWriter::WriteClassId(RawClass* cls) {
2405 ASSERT(kind_ != Snapshot::kFull); 2402 ASSERT(!Snapshot::IsFull(kind_));
2406 int class_id = cls->ptr()->id_; 2403 int class_id = cls->ptr()->id_;
2407 ASSERT(!IsSingletonClassId(class_id) && !IsObjectStoreClassId(class_id)); 2404 ASSERT(!IsSingletonClassId(class_id) && !IsObjectStoreClassId(class_id));
2408 2405
2409 // Write out the library url and class name. 2406 // Write out the library url and class name.
2410 RawLibrary* library = cls->ptr()->library_; 2407 RawLibrary* library = cls->ptr()->library_;
2411 ASSERT(library != Library::null()); 2408 ASSERT(library != Library::null());
2412 WriteObjectImpl(library->ptr()->url_, kAsInlinedObject); 2409 WriteObjectImpl(library->ptr()->url_, kAsInlinedObject);
2413 WriteObjectImpl(cls->ptr()->name_, kAsInlinedObject); 2410 WriteObjectImpl(cls->ptr()->name_, kAsInlinedObject);
2414 } 2411 }
2415 2412
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
2655 2652
2656 intptr_t SnapshotWriter::FirstObjectId() { 2653 intptr_t SnapshotWriter::FirstObjectId() {
2657 intptr_t max_vm_isolate_object_id = 2654 intptr_t max_vm_isolate_object_id =
2658 Object::vm_isolate_snapshot_object_table().Length(); 2655 Object::vm_isolate_snapshot_object_table().Length();
2659 return kMaxPredefinedObjectIds + max_vm_isolate_object_id; 2656 return kMaxPredefinedObjectIds + max_vm_isolate_object_id;
2660 } 2657 }
2661 2658
2662 2659
2663 ScriptSnapshotWriter::ScriptSnapshotWriter(uint8_t** buffer, 2660 ScriptSnapshotWriter::ScriptSnapshotWriter(uint8_t** buffer,
2664 ReAlloc alloc) 2661 ReAlloc alloc)
2665 : SnapshotWriter(Snapshot::kScript, 2662 : SnapshotWriter(Thread::Current(),
2666 Thread::Current(), 2663 Snapshot::kScript,
2667 buffer, 2664 buffer,
2668 alloc, 2665 alloc,
2669 kInitialSize, 2666 kInitialSize,
2670 &forward_list_, 2667 &forward_list_,
2671 NULL, /* instructions_writer */ 2668 NULL, /* instructions_writer */
2672 true, /* can_send_any_object */ 2669 true, /* can_send_any_object */
2673 false, /* snapshot_code */
2674 true /* vm_isolate_is_symbolic */), 2670 true /* vm_isolate_is_symbolic */),
2675 forward_list_(thread(), kMaxPredefinedObjectIds) { 2671 forward_list_(thread(), kMaxPredefinedObjectIds) {
2676 ASSERT(buffer != NULL); 2672 ASSERT(buffer != NULL);
2677 ASSERT(alloc != NULL); 2673 ASSERT(alloc != NULL);
2678 } 2674 }
2679 2675
2680 2676
2681 void ScriptSnapshotWriter::WriteScriptSnapshot(const Library& lib) { 2677 void ScriptSnapshotWriter::WriteScriptSnapshot(const Library& lib) {
2682 ASSERT(kind() == Snapshot::kScript); 2678 ASSERT(kind() == Snapshot::kScript);
2683 ASSERT(isolate() != NULL); 2679 ASSERT(isolate() != NULL);
(...skipping 28 matching lines...) Expand all
2712 for (RawObject** current = first; current <= last; current++) { 2708 for (RawObject** current = first; current <= last; current++) {
2713 RawObject* raw_obj = *current; 2709 RawObject* raw_obj = *current;
2714 writer_->WriteObjectImpl(raw_obj, as_references_); 2710 writer_->WriteObjectImpl(raw_obj, as_references_);
2715 } 2711 }
2716 } 2712 }
2717 2713
2718 2714
2719 MessageWriter::MessageWriter(uint8_t** buffer, 2715 MessageWriter::MessageWriter(uint8_t** buffer,
2720 ReAlloc alloc, 2716 ReAlloc alloc,
2721 bool can_send_any_object) 2717 bool can_send_any_object)
2722 : SnapshotWriter(Snapshot::kMessage, 2718 : SnapshotWriter(Thread::Current(),
2723 Thread::Current(), 2719 Snapshot::kMessage,
2724 buffer, 2720 buffer,
2725 alloc, 2721 alloc,
2726 kInitialSize, 2722 kInitialSize,
2727 &forward_list_, 2723 &forward_list_,
2728 NULL, /* instructions_writer */ 2724 NULL, /* instructions_writer */
2729 can_send_any_object, 2725 can_send_any_object,
2730 false, /* snapshot_code */
2731 true /* vm_isolate_is_symbolic */), 2726 true /* vm_isolate_is_symbolic */),
2732 forward_list_(thread(), kMaxPredefinedObjectIds) { 2727 forward_list_(thread(), kMaxPredefinedObjectIds) {
2733 ASSERT(buffer != NULL); 2728 ASSERT(buffer != NULL);
2734 ASSERT(alloc != NULL); 2729 ASSERT(alloc != NULL);
2735 } 2730 }
2736 2731
2737 2732
2738 void MessageWriter::WriteMessage(const Object& obj) { 2733 void MessageWriter::WriteMessage(const Object& obj) {
2739 ASSERT(kind() == Snapshot::kMessage); 2734 ASSERT(kind() == Snapshot::kMessage);
2740 ASSERT(isolate() != NULL); 2735 ASSERT(isolate() != NULL);
2741 2736
2742 // Setup for long jump in case there is an exception while writing 2737 // Setup for long jump in case there is an exception while writing
2743 // the message. 2738 // the message.
2744 LongJumpScope jump; 2739 LongJumpScope jump;
2745 if (setjmp(*jump.Set()) == 0) { 2740 if (setjmp(*jump.Set()) == 0) {
2746 NoSafepointScope no_safepoint; 2741 NoSafepointScope no_safepoint;
2747 WriteObject(obj.raw()); 2742 WriteObject(obj.raw());
2748 } else { 2743 } else {
2749 ThrowException(exception_type(), exception_msg()); 2744 ThrowException(exception_type(), exception_msg());
2750 } 2745 }
2751 } 2746 }
2752 2747
2753 2748
2754 } // namespace dart 2749 } // namespace dart
OLDNEW
« runtime/vm/snapshot.h ('K') | « runtime/vm/snapshot.h ('k') | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698