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

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

Issue 2161853002: Remove dead full snapshot support from the recursive descent serializer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: . Created 4 years, 5 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
« no previous file with comments | « runtime/vm/snapshot.h ('k') | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 159
160 160
161 intptr_t BaseReader::ReadSmiValue() { 161 intptr_t BaseReader::ReadSmiValue() {
162 return Smi::Value(ReadAsSmi()); 162 return Smi::Value(ReadAsSmi());
163 } 163 }
164 164
165 165
166 SnapshotReader::SnapshotReader( 166 SnapshotReader::SnapshotReader(
167 const uint8_t* buffer, 167 const uint8_t* buffer,
168 intptr_t size, 168 intptr_t size,
169 const uint8_t* instructions_buffer,
170 const uint8_t* data_buffer,
171 Snapshot::Kind kind, 169 Snapshot::Kind kind,
172 ZoneGrowableArray<BackRefNode>* backward_refs, 170 ZoneGrowableArray<BackRefNode>* backward_refs,
173 Thread* thread) 171 Thread* thread)
174 : BaseReader(buffer, size), 172 : BaseReader(buffer, size),
175 instructions_buffer_(instructions_buffer),
176 data_buffer_(data_buffer),
177 kind_(kind), 173 kind_(kind),
178 thread_(thread), 174 thread_(thread),
179 zone_(thread->zone()), 175 zone_(thread->zone()),
180 heap_(isolate()->heap()), 176 heap_(isolate()->heap()),
181 old_space_(thread_->isolate()->heap()->old_space()), 177 old_space_(thread_->isolate()->heap()->old_space()),
182 cls_(Class::Handle(zone_)), 178 cls_(Class::Handle(zone_)),
183 obj_(Object::Handle(zone_)), 179 obj_(Object::Handle(zone_)),
184 pobj_(PassiveObject::Handle(zone_)), 180 pobj_(PassiveObject::Handle(zone_)),
185 array_(Array::Handle(zone_)), 181 array_(Array::Handle(zone_)),
186 field_(Field::Handle(zone_)), 182 field_(Field::Handle(zone_)),
187 str_(String::Handle(zone_)), 183 str_(String::Handle(zone_)),
188 library_(Library::Handle(zone_)), 184 library_(Library::Handle(zone_)),
189 type_(AbstractType::Handle(zone_)), 185 type_(AbstractType::Handle(zone_)),
190 type_arguments_(TypeArguments::Handle(zone_)), 186 type_arguments_(TypeArguments::Handle(zone_)),
191 tokens_(GrowableObjectArray::Handle(zone_)), 187 tokens_(GrowableObjectArray::Handle(zone_)),
192 stream_(TokenStream::Handle(zone_)), 188 stream_(TokenStream::Handle(zone_)),
193 data_(ExternalTypedData::Handle(zone_)), 189 data_(ExternalTypedData::Handle(zone_)),
194 typed_data_(TypedData::Handle(zone_)), 190 typed_data_(TypedData::Handle(zone_)),
195 code_(Code::Handle(zone_)),
196 function_(Function::Handle(zone_)), 191 function_(Function::Handle(zone_)),
197 megamorphic_cache_(MegamorphicCache::Handle(zone_)),
198 error_(UnhandledException::Handle(zone_)), 192 error_(UnhandledException::Handle(zone_)),
199 max_vm_isolate_object_id_( 193 max_vm_isolate_object_id_(
200 (Snapshot::IsFull(kind)) ? 194 (Snapshot::IsFull(kind)) ?
201 Object::vm_isolate_snapshot_object_table().Length() : 0), 195 Object::vm_isolate_snapshot_object_table().Length() : 0),
202 backward_references_(backward_refs), 196 backward_references_(backward_refs) {
203 instructions_reader_(NULL) {
204 if (instructions_buffer != NULL) {
205 instructions_reader_ =
206 new InstructionsReader(instructions_buffer, data_buffer);
207 }
208 } 197 }
209 198
210 199
211 RawObject* SnapshotReader::ReadObject() { 200 RawObject* SnapshotReader::ReadObject() {
212 // Setup for long jump in case there is an exception while reading. 201 // Setup for long jump in case there is an exception while reading.
213 LongJumpScope jump; 202 LongJumpScope jump;
214 if (setjmp(*jump.Set()) == 0) { 203 if (setjmp(*jump.Set()) == 0) {
215 PassiveObject& obj = 204 PassiveObject& obj =
216 PassiveObject::Handle(zone(), ReadObjectImpl(kAsInlinedObject)); 205 PassiveObject::Handle(zone(), ReadObjectImpl(kAsInlinedObject));
217 for (intptr_t i = 0; i < backward_references_->length(); i++) { 206 for (intptr_t i = 0; i < backward_references_->length(); i++) {
218 if (!(*backward_references_)[i].is_deserialized()) { 207 if (!(*backward_references_)[i].is_deserialized()) {
219 ReadObjectImpl(kAsInlinedObject); 208 ReadObjectImpl(kAsInlinedObject);
220 (*backward_references_)[i].set_state(kIsDeserialized); 209 (*backward_references_)[i].set_state(kIsDeserialized);
221 } 210 }
222 } 211 }
223 if (!Snapshot::IsFull(kind())) { 212 ProcessDeferredCanonicalizations();
224 ProcessDeferredCanonicalizations();
225 }
226 return obj.raw(); 213 return obj.raw();
227 } else { 214 } else {
228 // An error occurred while reading, return the error object. 215 // An error occurred while reading, return the error object.
229 const Error& err = Error::Handle(thread()->sticky_error()); 216 const Error& err = Error::Handle(thread()->sticky_error());
230 thread()->clear_sticky_error(); 217 thread()->clear_sticky_error();
231 return err.raw(); 218 return err.raw();
232 } 219 }
233 } 220 }
234 221
235 222
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 if (result == NULL) { 460 if (result == NULL) {
474 result = &(Instance::ZoneHandle(zone(), Instance::null())); 461 result = &(Instance::ZoneHandle(zone(), Instance::null()));
475 AddBackRef(object_id, result, state); 462 AddBackRef(object_id, result, state);
476 cls_ ^= ReadObjectImpl(kAsInlinedObject); 463 cls_ ^= ReadObjectImpl(kAsInlinedObject);
477 ASSERT(!cls_.IsNull()); 464 ASSERT(!cls_.IsNull());
478 // Closure instances are handled by Closure::ReadFrom(). 465 // Closure instances are handled by Closure::ReadFrom().
479 ASSERT(!cls_.IsClosureClass()); 466 ASSERT(!cls_.IsClosureClass());
480 instance_size = cls_.instance_size(); 467 instance_size = cls_.instance_size();
481 ASSERT(instance_size > 0); 468 ASSERT(instance_size > 0);
482 // Allocate the instance and read in all the fields for the object. 469 // Allocate the instance and read in all the fields for the object.
483 if (Snapshot::IsFull(kind_)) { 470 *result ^= Object::Allocate(cls_.id(), instance_size, HEAP_SPACE(kind_));
484 *result ^= AllocateUninitialized(cls_.id(), instance_size);
485 } else {
486 *result ^= Object::Allocate(cls_.id(), instance_size, HEAP_SPACE(kind_));
487 }
488 } else { 471 } else {
489 cls_ ^= ReadObjectImpl(kAsInlinedObject); 472 cls_ ^= ReadObjectImpl(kAsInlinedObject);
490 ASSERT(!cls_.IsNull()); 473 ASSERT(!cls_.IsNull());
491 instance_size = cls_.instance_size(); 474 instance_size = cls_.instance_size();
492 } 475 }
493 if (!as_reference) { 476 if (!as_reference) {
494 // Read all the individual fields for inlined objects. 477 // Read all the individual fields for inlined objects.
495 intptr_t next_field_offset = cls_.next_field_offset(); 478 intptr_t next_field_offset = cls_.next_field_offset();
496 479
497 intptr_t type_argument_field_offset = cls_.type_arguments_field_offset(); 480 intptr_t type_argument_field_offset = cls_.type_arguments_field_offset();
(...skipping 17 matching lines...) Expand all
515 field_ ^= array_.At(offset >> kWordSizeLog2); 498 field_ ^= array_.At(offset >> kWordSizeLog2);
516 ASSERT(!field_.IsNull()); 499 ASSERT(!field_.IsNull());
517 ASSERT(field_.Offset() == offset); 500 ASSERT(field_.Offset() == offset);
518 obj_ = pobj_.raw(); 501 obj_ = pobj_.raw();
519 field_.RecordStore(obj_); 502 field_.RecordStore(obj_);
520 } 503 }
521 // TODO(fschneider): Verify the guarded cid and length for other kinds of 504 // TODO(fschneider): Verify the guarded cid and length for other kinds of
522 // snapshot (kFull, kScript) with asserts. 505 // snapshot (kFull, kScript) with asserts.
523 offset += kWordSize; 506 offset += kWordSize;
524 } 507 }
525 if (Snapshot::IsFull(kind_)) {
526 // We create an uninitialized object in the case of full snapshots, so
527 // we need to initialize any remaining padding area with the Null object.
528 while (offset < instance_size) {
529 result->SetFieldAtOffset(offset, Object::null_object());
530 offset += kWordSize;
531 }
532 }
533 if (RawObject::IsCanonical(tags)) { 508 if (RawObject::IsCanonical(tags)) {
534 if (Snapshot::IsFull(kind_)) { 509 *result = result->CheckAndCanonicalize(thread(), NULL);
535 result->SetCanonical(); 510 ASSERT(!result->IsNull());
536 } else {
537 *result = result->CheckAndCanonicalize(thread(), NULL);
538 ASSERT(!result->IsNull());
539 }
540 } 511 }
541 } 512 }
542 return result->raw(); 513 return result->raw();
543 } 514 }
544 515
545 516
546 void SnapshotReader::AddBackRef(intptr_t id, 517 void SnapshotReader::AddBackRef(intptr_t id,
547 Object* obj, 518 Object* obj,
548 DeserializeState state, 519 DeserializeState state,
549 bool defer_canonicalization) { 520 bool defer_canonicalization) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 // allocate the error message in old space. 645 // allocate the error message in old space.
675 const String& msg = String::Handle(String::New(message_buffer, Heap::kOld)); 646 const String& msg = String::Handle(String::New(message_buffer, Heap::kOld));
676 return ApiError::New(msg, Heap::kOld); 647 return ApiError::New(msg, Heap::kOld);
677 } 648 }
678 free(const_cast<char*>(expected_features)); 649 free(const_cast<char*>(expected_features));
679 Advance(expected_len + 1); 650 Advance(expected_len + 1);
680 return ApiError::null(); 651 return ApiError::null();
681 } 652 }
682 653
683 654
684 #define ALLOC_NEW_OBJECT_WITH_LEN(type, length) \
685 ASSERT(Snapshot::IsFull(kind_)); \
686 ASSERT_NO_SAFEPOINT_SCOPE(); \
687 Raw##type* obj = reinterpret_cast<Raw##type*>( \
688 AllocateUninitialized(k##type##Cid, type::InstanceSize(length))); \
689 obj->StoreSmi(&(obj->ptr()->length_), Smi::New(length)); \
690 return obj; \
691
692
693 RawArray* SnapshotReader::NewArray(intptr_t len) {
694 ALLOC_NEW_OBJECT_WITH_LEN(Array, len);
695 }
696
697
698 RawImmutableArray* SnapshotReader::NewImmutableArray(intptr_t len) {
699 ALLOC_NEW_OBJECT_WITH_LEN(ImmutableArray, len);
700 }
701
702
703 RawOneByteString* SnapshotReader::NewOneByteString(intptr_t len) {
704 ALLOC_NEW_OBJECT_WITH_LEN(OneByteString, len);
705 }
706
707
708 RawTwoByteString* SnapshotReader::NewTwoByteString(intptr_t len) {
709 ALLOC_NEW_OBJECT_WITH_LEN(TwoByteString, len);
710 }
711
712
713 RawTypeArguments* SnapshotReader::NewTypeArguments(intptr_t len) {
714 ALLOC_NEW_OBJECT_WITH_LEN(TypeArguments, len);
715 }
716
717
718 RawObjectPool* SnapshotReader::NewObjectPool(intptr_t len) {
719 ASSERT(Snapshot::IsFull(kind_));
720 ASSERT_NO_SAFEPOINT_SCOPE();
721 RawObjectPool* obj = reinterpret_cast<RawObjectPool*>(
722 AllocateUninitialized(kObjectPoolCid, ObjectPool::InstanceSize(len)));
723 obj->ptr()->length_ = len;
724 return obj;
725 }
726
727
728 RawLocalVarDescriptors* SnapshotReader::NewLocalVarDescriptors(
729 intptr_t num_entries) {
730 ASSERT(Snapshot::IsFull(kind_));
731 ASSERT_NO_SAFEPOINT_SCOPE();
732 RawLocalVarDescriptors* obj = reinterpret_cast<RawLocalVarDescriptors*>(
733 AllocateUninitialized(kLocalVarDescriptorsCid,
734 LocalVarDescriptors::InstanceSize(num_entries)));
735 obj->ptr()->num_entries_ = num_entries;
736 return obj;
737 }
738
739
740 RawExceptionHandlers* SnapshotReader::NewExceptionHandlers(
741 intptr_t num_entries) {
742 ASSERT(Snapshot::IsFull(kind_));
743 ASSERT_NO_SAFEPOINT_SCOPE();
744 RawExceptionHandlers* obj = reinterpret_cast<RawExceptionHandlers*>(
745 AllocateUninitialized(kExceptionHandlersCid,
746 ExceptionHandlers::InstanceSize(num_entries)));
747 obj->ptr()->num_entries_ = num_entries;
748 return obj;
749 }
750
751
752 RawPcDescriptors* SnapshotReader::NewPcDescriptors(intptr_t len) {
753 ASSERT(Snapshot::IsFull(kind_));
754 ASSERT_NO_SAFEPOINT_SCOPE();
755 RawPcDescriptors* obj = reinterpret_cast<RawPcDescriptors*>(
756 AllocateUninitialized(kPcDescriptorsCid,
757 PcDescriptors::InstanceSize(len)));
758 obj->ptr()->length_ = len;
759 return obj;
760 }
761
762
763 RawCodeSourceMap* SnapshotReader::NewCodeSourceMap(intptr_t len) {
764 ASSERT(Snapshot::IsFull(kind_));
765 ASSERT_NO_SAFEPOINT_SCOPE();
766 RawCodeSourceMap* obj = reinterpret_cast<RawCodeSourceMap*>(
767 AllocateUninitialized(kCodeSourceMapCid,
768 CodeSourceMap::InstanceSize(len)));
769 obj->ptr()->length_ = len;
770 return obj;
771 }
772
773
774 RawStackmap* SnapshotReader::NewStackmap(intptr_t len) {
775 ASSERT(Snapshot::IsFull(kind_));
776 ASSERT_NO_SAFEPOINT_SCOPE();
777 RawStackmap* obj = reinterpret_cast<RawStackmap*>(
778 AllocateUninitialized(kStackmapCid, Stackmap::InstanceSize(len)));
779 obj->ptr()->length_ = len;
780 return obj;
781 }
782
783
784 RawContextScope* SnapshotReader::NewContextScope(intptr_t num_variables) {
785 ASSERT(Snapshot::IsFull(kind_));
786 ASSERT_NO_SAFEPOINT_SCOPE();
787 RawContextScope* obj = reinterpret_cast<RawContextScope*>(
788 AllocateUninitialized(kContextScopeCid,
789 ContextScope::InstanceSize(num_variables)));
790 obj->ptr()->num_variables_ = num_variables;
791 return obj;
792 }
793
794
795 RawCode* SnapshotReader::NewCode(intptr_t pointer_offsets_length) {
796 ASSERT(pointer_offsets_length == 0);
797 ASSERT(Snapshot::IsFull(kind_));
798 ASSERT_NO_SAFEPOINT_SCOPE();
799 RawCode* obj = reinterpret_cast<RawCode*>(
800 AllocateUninitialized(kCodeCid, Code::InstanceSize(0)));
801 return obj;
802 }
803
804
805 RawTokenStream* SnapshotReader::NewTokenStream(intptr_t len) {
806 ASSERT(Snapshot::IsFull(kind_));
807 ASSERT_NO_SAFEPOINT_SCOPE();
808 stream_ = reinterpret_cast<RawTokenStream*>(
809 AllocateUninitialized(kTokenStreamCid, TokenStream::InstanceSize()));
810 uint8_t* array = const_cast<uint8_t*>(CurrentBufferAddress());
811 ASSERT(array != NULL);
812 Advance(len);
813 data_ = reinterpret_cast<RawExternalTypedData*>(
814 AllocateUninitialized(kExternalTypedDataUint8ArrayCid,
815 ExternalTypedData::InstanceSize()));
816 data_.SetData(array);
817 data_.SetLength(len);
818 stream_.SetStream(data_);
819 return stream_.raw();
820 }
821
822
823 RawContext* SnapshotReader::NewContext(intptr_t num_variables) {
824 ASSERT(Snapshot::IsFull(kind_));
825 ASSERT_NO_SAFEPOINT_SCOPE();
826 RawContext* obj = reinterpret_cast<RawContext*>(
827 AllocateUninitialized(kContextCid, Context::InstanceSize(num_variables)));
828 obj->ptr()->num_variables_ = num_variables;
829 return obj;
830 }
831
832
833 RawClass* SnapshotReader::NewClass(intptr_t class_id) {
834 ASSERT(Snapshot::IsFull(kind_));
835 ASSERT_NO_SAFEPOINT_SCOPE();
836 if (class_id < kNumPredefinedCids) {
837 ASSERT((class_id >= kInstanceCid) &&
838 (class_id <= kNullCid));
839 return isolate()->class_table()->At(class_id);
840 }
841 RawClass* obj = reinterpret_cast<RawClass*>(
842 AllocateUninitialized(kClassCid, Class::InstanceSize()));
843 Instance fake;
844 obj->ptr()->handle_vtable_ = fake.vtable();
845 cls_ = obj;
846 cls_.set_id(class_id);
847 isolate()->RegisterClassAt(class_id, cls_);
848 return cls_.raw();
849 }
850
851
852 RawInstance* SnapshotReader::NewInstance() {
853 ASSERT(Snapshot::IsFull(kind_));
854 ASSERT_NO_SAFEPOINT_SCOPE();
855 RawInstance* obj = reinterpret_cast<RawInstance*>(
856 AllocateUninitialized(kInstanceCid, Instance::InstanceSize()));
857 return obj;
858 }
859
860
861 RawMint* SnapshotReader::NewMint(int64_t value) {
862 ASSERT(Snapshot::IsFull(kind_));
863 ASSERT_NO_SAFEPOINT_SCOPE();
864 RawMint* obj = reinterpret_cast<RawMint*>(
865 AllocateUninitialized(kMintCid, Mint::InstanceSize()));
866 obj->ptr()->value_ = value;
867 return obj;
868 }
869
870
871 RawDouble* SnapshotReader::NewDouble(double value) {
872 ASSERT(Snapshot::IsFull(kind_));
873 ASSERT_NO_SAFEPOINT_SCOPE();
874 RawDouble* obj = reinterpret_cast<RawDouble*>(
875 AllocateUninitialized(kDoubleCid, Double::InstanceSize()));
876 obj->ptr()->value_ = value;
877 return obj;
878 }
879
880
881 RawTypedData* SnapshotReader::NewTypedData(intptr_t class_id, intptr_t len) {
882 ASSERT(Snapshot::IsFull(kind_));
883 ASSERT_NO_SAFEPOINT_SCOPE();
884 const intptr_t lengthInBytes = len * TypedData::ElementSizeInBytes(class_id);
885 RawTypedData* obj = reinterpret_cast<RawTypedData*>(
886 AllocateUninitialized(class_id, TypedData::InstanceSize(lengthInBytes)));
887 obj->StoreSmi(&(obj->ptr()->length_), Smi::New(len));
888 return obj;
889 }
890
891
892 #define ALLOC_NEW_OBJECT(type) \
893 ASSERT(Snapshot::IsFull(kind_)); \
894 ASSERT_NO_SAFEPOINT_SCOPE(); \
895 return reinterpret_cast<Raw##type*>( \
896 AllocateUninitialized(k##type##Cid, type::InstanceSize())); \
897
898
899 RawBigint* SnapshotReader::NewBigint() {
900 ALLOC_NEW_OBJECT(Bigint);
901 }
902
903
904 RawUnresolvedClass* SnapshotReader::NewUnresolvedClass() {
905 ALLOC_NEW_OBJECT(UnresolvedClass);
906 }
907
908
909 RawType* SnapshotReader::NewType() {
910 ALLOC_NEW_OBJECT(Type);
911 }
912
913
914 RawTypeRef* SnapshotReader::NewTypeRef() {
915 ALLOC_NEW_OBJECT(TypeRef);
916 }
917
918
919 RawTypeParameter* SnapshotReader::NewTypeParameter() {
920 ALLOC_NEW_OBJECT(TypeParameter);
921 }
922
923
924 RawBoundedType* SnapshotReader::NewBoundedType() {
925 ALLOC_NEW_OBJECT(BoundedType);
926 }
927
928
929 RawMixinAppType* SnapshotReader::NewMixinAppType() {
930 ALLOC_NEW_OBJECT(MixinAppType);
931 }
932
933
934 RawPatchClass* SnapshotReader::NewPatchClass() {
935 ALLOC_NEW_OBJECT(PatchClass);
936 }
937
938
939 RawClosure* SnapshotReader::NewClosure() {
940 ALLOC_NEW_OBJECT(Closure);
941 }
942
943
944 RawClosureData* SnapshotReader::NewClosureData() {
945 ALLOC_NEW_OBJECT(ClosureData);
946 }
947
948
949 RawRedirectionData* SnapshotReader::NewRedirectionData() {
950 ALLOC_NEW_OBJECT(RedirectionData);
951 }
952
953
954 RawFunction* SnapshotReader::NewFunction() {
955 ALLOC_NEW_OBJECT(Function);
956 }
957
958
959 RawICData* SnapshotReader::NewICData() {
960 ALLOC_NEW_OBJECT(ICData);
961 }
962
963
964 RawLinkedHashMap* SnapshotReader::NewLinkedHashMap() {
965 ALLOC_NEW_OBJECT(LinkedHashMap);
966 }
967
968
969 RawMegamorphicCache* SnapshotReader::NewMegamorphicCache() {
970 ALLOC_NEW_OBJECT(MegamorphicCache);
971 }
972
973
974 RawSubtypeTestCache* SnapshotReader::NewSubtypeTestCache() {
975 ALLOC_NEW_OBJECT(SubtypeTestCache);
976 }
977
978
979 RawField* SnapshotReader::NewField() {
980 ALLOC_NEW_OBJECT(Field);
981 }
982
983
984 RawLibrary* SnapshotReader::NewLibrary() {
985 ALLOC_NEW_OBJECT(Library);
986 }
987
988
989 RawLibraryPrefix* SnapshotReader::NewLibraryPrefix() {
990 ALLOC_NEW_OBJECT(LibraryPrefix);
991 }
992
993
994 RawNamespace* SnapshotReader::NewNamespace() {
995 ALLOC_NEW_OBJECT(Namespace);
996 }
997
998
999 RawScript* SnapshotReader::NewScript() {
1000 ALLOC_NEW_OBJECT(Script);
1001 }
1002
1003
1004 RawLiteralToken* SnapshotReader::NewLiteralToken() {
1005 ALLOC_NEW_OBJECT(LiteralToken);
1006 }
1007
1008
1009 RawGrowableObjectArray* SnapshotReader::NewGrowableObjectArray() {
1010 ALLOC_NEW_OBJECT(GrowableObjectArray);
1011 }
1012
1013
1014 RawWeakProperty* SnapshotReader::NewWeakProperty() {
1015 ALLOC_NEW_OBJECT(WeakProperty);
1016 }
1017
1018
1019 RawRegExp* SnapshotReader::NewRegExp() {
1020 ALLOC_NEW_OBJECT(RegExp);
1021 }
1022
1023
1024 RawFloat32x4* SnapshotReader::NewFloat32x4(float v0, float v1, float v2,
1025 float v3) {
1026 ASSERT(Snapshot::IsFull(kind_));
1027 ASSERT_NO_SAFEPOINT_SCOPE();
1028 RawFloat32x4* obj = reinterpret_cast<RawFloat32x4*>(
1029 AllocateUninitialized(kFloat32x4Cid, Float32x4::InstanceSize()));
1030 obj->ptr()->value_[0] = v0;
1031 obj->ptr()->value_[1] = v1;
1032 obj->ptr()->value_[2] = v2;
1033 obj->ptr()->value_[3] = v3;
1034 return obj;
1035 }
1036
1037
1038 RawInt32x4* SnapshotReader::NewInt32x4(uint32_t v0, uint32_t v1, uint32_t v2,
1039 uint32_t v3) {
1040 ASSERT(Snapshot::IsFull(kind_));
1041 ASSERT_NO_SAFEPOINT_SCOPE();
1042 RawInt32x4* obj = reinterpret_cast<RawInt32x4*>(
1043 AllocateUninitialized(kInt32x4Cid, Int32x4::InstanceSize()));
1044 obj->ptr()->value_[0] = v0;
1045 obj->ptr()->value_[1] = v1;
1046 obj->ptr()->value_[2] = v2;
1047 obj->ptr()->value_[3] = v3;
1048 return obj;
1049 }
1050
1051
1052 RawFloat64x2* SnapshotReader::NewFloat64x2(double v0, double v1) {
1053 ASSERT(Snapshot::IsFull(kind_));
1054 ASSERT_NO_SAFEPOINT_SCOPE();
1055 RawFloat64x2* obj = reinterpret_cast<RawFloat64x2*>(
1056 AllocateUninitialized(kFloat64x2Cid, Float64x2::InstanceSize()));
1057 obj->ptr()->value_[0] = v0;
1058 obj->ptr()->value_[1] = v1;
1059 return obj;
1060 }
1061
1062
1063 RawApiError* SnapshotReader::NewApiError() {
1064 ALLOC_NEW_OBJECT(ApiError);
1065 }
1066
1067
1068 RawLanguageError* SnapshotReader::NewLanguageError() {
1069 ALLOC_NEW_OBJECT(LanguageError);
1070 }
1071
1072
1073 RawUnhandledException* SnapshotReader::NewUnhandledException() {
1074 ALLOC_NEW_OBJECT(UnhandledException);
1075 }
1076
1077
1078 RawObject* SnapshotReader::NewInteger(int64_t value) { 655 RawObject* SnapshotReader::NewInteger(int64_t value) {
1079 ASSERT((value & kSmiTagMask) == kSmiTag); 656 ASSERT((value & kSmiTagMask) == kSmiTag);
1080 value = value >> kSmiTagShift; 657 value = value >> kSmiTagShift;
1081 if (Smi::IsValid(value)) { 658 if (Smi::IsValid(value)) {
1082 return Smi::New(static_cast<intptr_t>(value)); 659 return Smi::New(static_cast<intptr_t>(value));
1083 } 660 }
1084 if (Snapshot::IsFull(kind_)) {
1085 return NewMint(value);
1086 }
1087 return Mint::NewCanonical(value); 661 return Mint::NewCanonical(value);
1088 } 662 }
1089 663
1090 664
1091 RawStacktrace* SnapshotReader::NewStacktrace() {
1092 ALLOC_NEW_OBJECT(Stacktrace);
1093 }
1094
1095
1096 int32_t InstructionsWriter::GetOffsetFor(RawInstructions* instructions, 665 int32_t InstructionsWriter::GetOffsetFor(RawInstructions* instructions,
1097 RawCode* code) { 666 RawCode* code) {
1098 #if defined(PRODUCT) 667 #if defined(PRODUCT)
1099 // Instructions are only dedup in product mode because it obfuscates profiler 668 // Instructions are only dedup in product mode because it obfuscates profiler
1100 // results. 669 // results.
1101 for (intptr_t i = 0; i < instructions_.length(); i++) { 670 for (intptr_t i = 0; i < instructions_.length(); i++) {
1102 if (instructions_[i].raw_insns_ == instructions) { 671 if (instructions_[i].raw_insns_ == instructions) {
1103 return instructions_[i].offset_; 672 return instructions_[i].offset_;
1104 } 673 }
1105 } 674 }
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 ASSERT(IsSingletonClassId(class_id)); 984 ASSERT(IsSingletonClassId(class_id));
1416 return class_id; 985 return class_id;
1417 } 986 }
1418 ASSERT(SerializedHeaderTag::decode(class_header) == kObjectId); 987 ASSERT(SerializedHeaderTag::decode(class_header) == kObjectId);
1419 intptr_t class_id = SerializedHeaderData::decode(class_header); 988 intptr_t class_id = SerializedHeaderData::decode(class_header);
1420 ASSERT(IsObjectStoreClassId(class_id) || IsSingletonClassId(class_id)); 989 ASSERT(IsObjectStoreClassId(class_id) || IsSingletonClassId(class_id));
1421 return class_id; 990 return class_id;
1422 } 991 }
1423 992
1424 993
1425 RawObject* SnapshotReader::AllocateUninitialized(intptr_t class_id,
1426 intptr_t size) {
1427 ASSERT_NO_SAFEPOINT_SCOPE();
1428 ASSERT(Utils::IsAligned(size, kObjectAlignment));
1429
1430 uword address =
1431 old_space()->TryAllocateDataBumpLocked(size, PageSpace::kForceGrowth);
1432 if (address == 0) {
1433 // Use the preallocated out of memory exception to avoid calling
1434 // into dart code or allocating any code.
1435 // We do a longjmp at this point to unwind out of the entire
1436 // read part and return the error object back.
1437 const UnhandledException& error = UnhandledException::Handle(
1438 object_store()->preallocated_unhandled_exception());
1439 thread()->long_jump_base()->Jump(1, error);
1440 }
1441
1442 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag);
1443 uword tags = 0;
1444 ASSERT(class_id != kIllegalCid);
1445 tags = RawObject::ClassIdTag::update(class_id, tags);
1446 tags = RawObject::SizeTag::update(size, tags);
1447 tags = RawObject::VMHeapObjectTag::update(is_vm_isolate(), tags);
1448 raw_obj->ptr()->tags_ = tags;
1449 return raw_obj;
1450 }
1451
1452
1453 #define READ_VM_SINGLETON_OBJ(id, obj) \ 994 #define READ_VM_SINGLETON_OBJ(id, obj) \
1454 if (object_id == id) { \ 995 if (object_id == id) { \
1455 return obj; \ 996 return obj; \
1456 } \ 997 } \
1457 998
1458 RawObject* SnapshotReader::ReadVMIsolateObject(intptr_t header_value) { 999 RawObject* SnapshotReader::ReadVMIsolateObject(intptr_t header_value) {
1459 intptr_t object_id = GetVMIsolateObjectId(header_value); 1000 intptr_t object_id = GetVMIsolateObjectId(header_value);
1460 1001
1461 // First check if it is one of the singleton objects. 1002 // First check if it is one of the singleton objects.
1462 READ_VM_SINGLETON_OBJ(kNullObject, Object::null()); 1003 READ_VM_SINGLETON_OBJ(kNullObject, Object::null());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 } 1054 }
1514 1055
1515 1056
1516 RawObject* SnapshotReader::ReadIndexedObject(intptr_t object_id, 1057 RawObject* SnapshotReader::ReadIndexedObject(intptr_t object_id,
1517 intptr_t patch_object_id, 1058 intptr_t patch_object_id,
1518 intptr_t patch_offset) { 1059 intptr_t patch_offset) {
1519 intptr_t class_id = ClassIdFromObjectId(object_id); 1060 intptr_t class_id = ClassIdFromObjectId(object_id);
1520 if (IsObjectStoreClassId(class_id)) { 1061 if (IsObjectStoreClassId(class_id)) {
1521 return isolate()->class_table()->At(class_id); // get singleton class. 1062 return isolate()->class_table()->At(class_id); // get singleton class.
1522 } 1063 }
1523 if (!Snapshot::IsFull(kind_)) { 1064 if (IsObjectStoreTypeId(object_id)) {
1524 if (IsObjectStoreTypeId(object_id)) { 1065 return GetType(object_store(), object_id); // return type obj.
1525 return GetType(object_store(), object_id); // return type obj.
1526 }
1527 } 1066 }
1528 ASSERT(object_id >= kMaxPredefinedObjectIds); 1067 ASSERT(object_id >= kMaxPredefinedObjectIds);
1529 intptr_t index = (object_id - kMaxPredefinedObjectIds); 1068 intptr_t index = (object_id - kMaxPredefinedObjectIds);
1530 if (index < max_vm_isolate_object_id_) { 1069 if (index < max_vm_isolate_object_id_) {
1531 return VmIsolateSnapshotObject(index); 1070 return VmIsolateSnapshotObject(index);
1532 } 1071 }
1533 AddPatchRecord(object_id, patch_object_id, patch_offset); 1072 AddPatchRecord(object_id, patch_object_id, patch_offset);
1534 return GetBackRef(object_id)->raw(); 1073 return GetBackRef(object_id)->raw();
1535 } 1074 }
1536 1075
1537 1076
1538 void SnapshotReader::AddPatchRecord(intptr_t object_id, 1077 void SnapshotReader::AddPatchRecord(intptr_t object_id,
1539 intptr_t patch_object_id, 1078 intptr_t patch_object_id,
1540 intptr_t patch_offset) { 1079 intptr_t patch_offset) {
1541 if (patch_object_id != kInvalidPatchIndex && !Snapshot::IsFull(kind())) { 1080 if (patch_object_id != kInvalidPatchIndex) {
1542 ASSERT(object_id >= kMaxPredefinedObjectIds); 1081 ASSERT(object_id >= kMaxPredefinedObjectIds);
1543 intptr_t index = (object_id - kMaxPredefinedObjectIds); 1082 intptr_t index = (object_id - kMaxPredefinedObjectIds);
1544 ASSERT(index >= max_vm_isolate_object_id_); 1083 ASSERT(index >= max_vm_isolate_object_id_);
1545 index -= max_vm_isolate_object_id_; 1084 index -= max_vm_isolate_object_id_;
1546 ASSERT(index < backward_references_->length()); 1085 ASSERT(index < backward_references_->length());
1547 BackRefNode& ref = (*backward_references_)[index]; 1086 BackRefNode& ref = (*backward_references_)[index];
1548 ref.AddPatchRecord(patch_object_id, patch_offset); 1087 ref.AddPatchRecord(patch_object_id, patch_offset);
1549 } 1088 }
1550 } 1089 }
1551 1090
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 result.SetAt(i, *PassiveObjectHandle()); 1155 result.SetAt(i, *PassiveObjectHandle());
1617 } 1156 }
1618 } 1157 }
1619 1158
1620 1159
1621 ScriptSnapshotReader::ScriptSnapshotReader(const uint8_t* buffer, 1160 ScriptSnapshotReader::ScriptSnapshotReader(const uint8_t* buffer,
1622 intptr_t size, 1161 intptr_t size,
1623 Thread* thread) 1162 Thread* thread)
1624 : SnapshotReader(buffer, 1163 : SnapshotReader(buffer,
1625 size, 1164 size,
1626 NULL, /* instructions_buffer */
1627 NULL, /* data_buffer */
1628 Snapshot::kScript, 1165 Snapshot::kScript,
1629 new ZoneGrowableArray<BackRefNode>(kNumInitialReferences), 1166 new ZoneGrowableArray<BackRefNode>(kNumInitialReferences),
1630 thread) { 1167 thread) {
1631 } 1168 }
1632 1169
1633 1170
1634 ScriptSnapshotReader::~ScriptSnapshotReader() { 1171 ScriptSnapshotReader::~ScriptSnapshotReader() {
1635 ResetBackwardReferenceTable(); 1172 ResetBackwardReferenceTable();
1636 } 1173 }
1637 1174
1638 1175
1639 MessageSnapshotReader::MessageSnapshotReader(const uint8_t* buffer, 1176 MessageSnapshotReader::MessageSnapshotReader(const uint8_t* buffer,
1640 intptr_t size, 1177 intptr_t size,
1641 Thread* thread) 1178 Thread* thread)
1642 : SnapshotReader(buffer, 1179 : SnapshotReader(buffer,
1643 size, 1180 size,
1644 NULL, /* instructions_buffer */
1645 NULL, /* data_buffer */
1646 Snapshot::kMessage, 1181 Snapshot::kMessage,
1647 new ZoneGrowableArray<BackRefNode>(kNumInitialReferences), 1182 new ZoneGrowableArray<BackRefNode>(kNumInitialReferences),
1648 thread) { 1183 thread) {
1649 } 1184 }
1650 1185
1651 1186
1652 MessageSnapshotReader::~MessageSnapshotReader() { 1187 MessageSnapshotReader::~MessageSnapshotReader() {
1653 ResetBackwardReferenceTable(); 1188 ResetBackwardReferenceTable();
1654 } 1189 }
1655 1190
1656 1191
1657 SnapshotWriter::SnapshotWriter(Thread* thread, 1192 SnapshotWriter::SnapshotWriter(Thread* thread,
1658 Snapshot::Kind kind, 1193 Snapshot::Kind kind,
1659 uint8_t** buffer, 1194 uint8_t** buffer,
1660 ReAlloc alloc, 1195 ReAlloc alloc,
1661 intptr_t initial_size, 1196 intptr_t initial_size,
1662 ForwardList* forward_list, 1197 ForwardList* forward_list,
1663 InstructionsWriter* instructions_writer, 1198 bool can_send_any_object)
1664 bool can_send_any_object,
1665 bool writing_vm_isolate)
1666 : BaseWriter(buffer, alloc, initial_size), 1199 : BaseWriter(buffer, alloc, initial_size),
1667 thread_(thread), 1200 thread_(thread),
1668 kind_(kind), 1201 kind_(kind),
1669 object_store_(isolate()->object_store()), 1202 object_store_(isolate()->object_store()),
1670 class_table_(isolate()->class_table()), 1203 class_table_(isolate()->class_table()),
1671 forward_list_(forward_list), 1204 forward_list_(forward_list),
1672 instructions_writer_(instructions_writer),
1673 exception_type_(Exceptions::kNone), 1205 exception_type_(Exceptions::kNone),
1674 exception_msg_(NULL), 1206 exception_msg_(NULL),
1675 unmarked_objects_(false), 1207 can_send_any_object_(can_send_any_object) {
1676 can_send_any_object_(can_send_any_object),
1677 writing_vm_isolate_(writing_vm_isolate) {
1678 ASSERT(forward_list_ != NULL); 1208 ASSERT(forward_list_ != NULL);
1679 } 1209 }
1680 1210
1681 1211
1682 void SnapshotWriter::WriteObject(RawObject* rawobj) { 1212 void SnapshotWriter::WriteObject(RawObject* rawobj) {
1683 WriteObjectImpl(rawobj, kAsInlinedObject); 1213 WriteObjectImpl(rawobj, kAsInlinedObject);
1684 WriteForwardedObjects(); 1214 WriteForwardedObjects();
1685 } 1215 }
1686 1216
1687 1217
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 } 1289 }
1760 1290
1761 // Check if it is a singleton ICData array object. 1291 // Check if it is a singleton ICData array object.
1762 for (intptr_t i = 0; i < ICData::kCachedICDataArrayCount; i++) { 1292 for (intptr_t i = 0; i < ICData::kCachedICDataArrayCount; i++) {
1763 if (rawobj == ICData::cached_icdata_arrays_[i]) { 1293 if (rawobj == ICData::cached_icdata_arrays_[i]) {
1764 WriteVMIsolateObject(kCachedICDataArray0 + i); 1294 WriteVMIsolateObject(kCachedICDataArray0 + i);
1765 return true; 1295 return true;
1766 } 1296 }
1767 } 1297 }
1768 1298
1769 if (writing_vm_isolate_) { 1299 // In the case of script snapshots or for messages we do not use
1770 // When we are writing the VM isolate snapshot, write out the object 1300 // the index into the vm isolate snapshot object table, instead we
1771 // itself instead of a VM object id. 1301 // explicitly write the object out.
1772 return false; 1302 intptr_t object_id = forward_list_->FindObject(rawobj);
1773 } 1303 if (object_id != -1) {
1774 1304 WriteIndexedObject(object_id);
1775 if (Snapshot::IsFull(kind())) { 1305 return true;
1776 // Check it is a predefined symbol in the VM isolate.
1777 id = Symbols::LookupPredefinedSymbol(rawobj);
1778 if (id != kInvalidIndex) {
1779 WriteVMIsolateObject(id);
1780 return true;
1781 }
1782
1783 // Check if it is an object from the vm isolate snapshot object table.
1784 id = FindVmSnapshotObject(rawobj);
1785 if (id != kInvalidIndex) {
1786 WriteIndexedObject(id);
1787 return true;
1788 }
1789 } else { 1306 } else {
1790 // In the case of script snapshots or for messages we do not use 1307 switch (id) {
1791 // the index into the vm isolate snapshot object table, instead we 1308 VM_OBJECT_CLASS_LIST(VM_OBJECT_WRITE)
1792 // explicitly write the object out. 1309 case kTypedDataUint32ArrayCid: {
1793 intptr_t object_id = forward_list_->FindObject(rawobj); 1310 object_id = forward_list_->AddObject(zone(), rawobj, kIsSerialized);
1794 if (object_id != -1) { 1311 RawTypedData* raw_obj = reinterpret_cast<RawTypedData*>(rawobj);
1795 WriteIndexedObject(object_id); 1312 raw_obj->WriteTo(this, object_id, kind(), false);
1796 return true; 1313 return true;
1797 } else {
1798 switch (id) {
1799 VM_OBJECT_CLASS_LIST(VM_OBJECT_WRITE)
1800 case kTypedDataUint32ArrayCid: {
1801 object_id = forward_list_->AddObject(zone(), rawobj, kIsSerialized);
1802 RawTypedData* raw_obj = reinterpret_cast<RawTypedData*>(rawobj);
1803 raw_obj->WriteTo(this, object_id, kind(), false);
1804 return true;
1805 }
1806 default:
1807 OS::Print("class id = %" Pd "\n", id);
1808 break;
1809 } 1314 }
1315 default:
1316 OS::Print("class id = %" Pd "\n", id);
1317 break;
1810 } 1318 }
1811 } 1319 }
1812 1320
1813 const Object& obj = Object::Handle(rawobj); 1321 const Object& obj = Object::Handle(rawobj);
1814 FATAL1("Unexpected reference to object in VM isolate: %s\n", obj.ToCString()); 1322 FATAL1("Unexpected reference to object in VM isolate: %s\n", obj.ToCString());
1815 return false; 1323 return false;
1816 } 1324 }
1817 1325
1818 #undef VM_OBJECT_WRITE 1326 #undef VM_OBJECT_WRITE
1819 1327
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 } 1431 }
1924 1432
1925 // Now check if it is an object from the VM isolate. These objects are shared 1433 // Now check if it is an object from the VM isolate. These objects are shared
1926 // by all isolates. 1434 // by all isolates.
1927 if (rawobj->IsVMHeapObject() && HandleVMIsolateObject(rawobj)) { 1435 if (rawobj->IsVMHeapObject() && HandleVMIsolateObject(rawobj)) {
1928 return true; 1436 return true;
1929 } 1437 }
1930 1438
1931 // Check if it is a code object in that case just write a Null object 1439 // Check if it is a code object in that case just write a Null object
1932 // as we do not want code objects in the snapshot. 1440 // as we do not want code objects in the snapshot.
1933 if (cid == kCodeCid && !Snapshot::IncludesCode(kind_)) { 1441 if (cid == kCodeCid) {
1934 WriteVMIsolateObject(kNullObject); 1442 WriteVMIsolateObject(kNullObject);
1935 return true; 1443 return true;
1936 } 1444 }
1937 1445
1938 // Check if classes are not being serialized and it is preinitialized type 1446 // Check if classes are not being serialized and it is preinitialized type
1939 // or a predefined internal VM class in the object store. 1447 // or a predefined internal VM class in the object store.
1940 if (!Snapshot::IsFull(kind_)) { 1448 // Check if it is an internal VM class which is in the object store.
1941 // Check if it is an internal VM class which is in the object store. 1449 if (cid == kClassCid) {
1942 if (cid == kClassCid) { 1450 RawClass* raw_class = reinterpret_cast<RawClass*>(rawobj);
1943 RawClass* raw_class = reinterpret_cast<RawClass*>(rawobj); 1451 intptr_t class_id = raw_class->ptr()->id_;
1944 intptr_t class_id = raw_class->ptr()->id_; 1452 if (IsObjectStoreClassId(class_id)) {
1945 if (IsObjectStoreClassId(class_id)) { 1453 intptr_t object_id = ObjectIdFromClassId(class_id);
1946 intptr_t object_id = ObjectIdFromClassId(class_id); 1454 WriteIndexedObject(object_id);
1947 WriteIndexedObject(object_id);
1948 return true;
1949 }
1950 }
1951
1952 // Now check it is a preinitialized type object.
1953 RawType* raw_type = reinterpret_cast<RawType*>(rawobj);
1954 intptr_t index = GetTypeIndex(object_store(), raw_type);
1955 if (index != kInvalidIndex) {
1956 WriteIndexedObject(index);
1957 return true; 1455 return true;
1958 } 1456 }
1959 } 1457 }
1960 1458
1459 // Now check it is a preinitialized type object.
1460 RawType* raw_type = reinterpret_cast<RawType*>(rawobj);
1461 intptr_t index = GetTypeIndex(object_store(), raw_type);
1462 if (index != kInvalidIndex) {
1463 WriteIndexedObject(index);
1464 return true;
1465 }
1466
1961 return false; 1467 return false;
1962 } 1468 }
1963 1469
1964 1470
1965 void SnapshotWriter::WriteObjectImpl(RawObject* raw, bool as_reference) { 1471 void SnapshotWriter::WriteObjectImpl(RawObject* raw, bool as_reference) {
1966 // First check if object can be written as a simple predefined type. 1472 // First check if object can be written as a simple predefined type.
1967 if (CheckAndWritePredefinedObject(raw)) { 1473 if (CheckAndWritePredefinedObject(raw)) {
1968 return; 1474 return;
1969 } 1475 }
1970 1476
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 1857
2352 1858
2353 ScriptSnapshotWriter::ScriptSnapshotWriter(uint8_t** buffer, 1859 ScriptSnapshotWriter::ScriptSnapshotWriter(uint8_t** buffer,
2354 ReAlloc alloc) 1860 ReAlloc alloc)
2355 : SnapshotWriter(Thread::Current(), 1861 : SnapshotWriter(Thread::Current(),
2356 Snapshot::kScript, 1862 Snapshot::kScript,
2357 buffer, 1863 buffer,
2358 alloc, 1864 alloc,
2359 kInitialSize, 1865 kInitialSize,
2360 &forward_list_, 1866 &forward_list_,
2361 NULL, /* instructions_writer */ 1867 true /* can_send_any_object */),
2362 true, /* can_send_any_object */
2363 false /* writing_vm_isolate */),
2364 forward_list_(thread(), kMaxPredefinedObjectIds) { 1868 forward_list_(thread(), kMaxPredefinedObjectIds) {
2365 ASSERT(buffer != NULL); 1869 ASSERT(buffer != NULL);
2366 ASSERT(alloc != NULL); 1870 ASSERT(alloc != NULL);
2367 } 1871 }
2368 1872
2369 1873
2370 void ScriptSnapshotWriter::WriteScriptSnapshot(const Library& lib) { 1874 void ScriptSnapshotWriter::WriteScriptSnapshot(const Library& lib) {
2371 ASSERT(kind() == Snapshot::kScript); 1875 ASSERT(kind() == Snapshot::kScript);
2372 ASSERT(isolate() != NULL); 1876 ASSERT(isolate() != NULL);
2373 ASSERT(ClassFinalizer::AllClassesFinalized()); 1877 ASSERT(ClassFinalizer::AllClassesFinalized());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2407 1911
2408 MessageWriter::MessageWriter(uint8_t** buffer, 1912 MessageWriter::MessageWriter(uint8_t** buffer,
2409 ReAlloc alloc, 1913 ReAlloc alloc,
2410 bool can_send_any_object) 1914 bool can_send_any_object)
2411 : SnapshotWriter(Thread::Current(), 1915 : SnapshotWriter(Thread::Current(),
2412 Snapshot::kMessage, 1916 Snapshot::kMessage,
2413 buffer, 1917 buffer,
2414 alloc, 1918 alloc,
2415 kInitialSize, 1919 kInitialSize,
2416 &forward_list_, 1920 &forward_list_,
2417 NULL, /* instructions_writer */ 1921 can_send_any_object),
2418 can_send_any_object,
2419 false /* writing_vm_isolate */),
2420 forward_list_(thread(), kMaxPredefinedObjectIds) { 1922 forward_list_(thread(), kMaxPredefinedObjectIds) {
2421 ASSERT(buffer != NULL); 1923 ASSERT(buffer != NULL);
2422 ASSERT(alloc != NULL); 1924 ASSERT(alloc != NULL);
2423 } 1925 }
2424 1926
2425 1927
2426 void MessageWriter::WriteMessage(const Object& obj) { 1928 void MessageWriter::WriteMessage(const Object& obj) {
2427 ASSERT(kind() == Snapshot::kMessage); 1929 ASSERT(kind() == Snapshot::kMessage);
2428 ASSERT(isolate() != NULL); 1930 ASSERT(isolate() != NULL);
2429 1931
2430 // Setup for long jump in case there is an exception while writing 1932 // Setup for long jump in case there is an exception while writing
2431 // the message. 1933 // the message.
2432 LongJumpScope jump; 1934 LongJumpScope jump;
2433 if (setjmp(*jump.Set()) == 0) { 1935 if (setjmp(*jump.Set()) == 0) {
2434 NoSafepointScope no_safepoint; 1936 NoSafepointScope no_safepoint;
2435 WriteObject(obj.raw()); 1937 WriteObject(obj.raw());
2436 } else { 1938 } else {
2437 ThrowException(exception_type(), exception_msg()); 1939 ThrowException(exception_type(), exception_msg());
2438 } 1940 }
2439 } 1941 }
2440 1942
2441 1943
2442 } // namespace dart 1944 } // namespace dart
OLDNEW
« no previous file with comments | « 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