OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/clustered_snapshot.h" | 5 #include "vm/clustered_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 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1792 default: | 1792 default: |
1793 UNREACHABLE(); | 1793 UNREACHABLE(); |
1794 } | 1794 } |
1795 } | 1795 } |
1796 } | 1796 } |
1797 } | 1797 } |
1798 }; | 1798 }; |
1799 | 1799 |
1800 | 1800 |
1801 #if !defined(DART_PRECOMPILED_RUNTIME) | 1801 #if !defined(DART_PRECOMPILED_RUNTIME) |
1802 // PcDescriptor, Stackmap, OneByteString, TwoByteString | 1802 // PcDescriptor, StackMap, OneByteString, TwoByteString |
1803 class RODataSerializationCluster : public SerializationCluster { | 1803 class RODataSerializationCluster : public SerializationCluster { |
1804 public: | 1804 public: |
1805 explicit RODataSerializationCluster(intptr_t cid) : cid_(cid) {} | 1805 explicit RODataSerializationCluster(intptr_t cid) : cid_(cid) {} |
1806 virtual ~RODataSerializationCluster() {} | 1806 virtual ~RODataSerializationCluster() {} |
1807 | 1807 |
1808 void Trace(Serializer* s, RawObject* object) { | 1808 void Trace(Serializer* s, RawObject* object) { |
1809 objects_.Add(object); | 1809 objects_.Add(object); |
1810 | 1810 |
1811 // A string's hash must already be computed when we write it because it | 1811 // A string's hash must already be computed when we write it because it |
1812 // will be loaded into read-only memory. | 1812 // will be loaded into read-only memory. |
(...skipping 1949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3762 // No finalizer / external size 0. | 3762 // No finalizer / external size 0. |
3763 } | 3763 } |
3764 } | 3764 } |
3765 | 3765 |
3766 private: | 3766 private: |
3767 const intptr_t cid_; | 3767 const intptr_t cid_; |
3768 }; | 3768 }; |
3769 | 3769 |
3770 | 3770 |
3771 #if !defined(DART_PRECOMPILED_RUNTIME) | 3771 #if !defined(DART_PRECOMPILED_RUNTIME) |
3772 class StacktraceSerializationCluster : public SerializationCluster { | 3772 class StackTraceSerializationCluster : public SerializationCluster { |
3773 public: | 3773 public: |
3774 StacktraceSerializationCluster() {} | 3774 StackTraceSerializationCluster() {} |
3775 virtual ~StacktraceSerializationCluster() {} | 3775 virtual ~StackTraceSerializationCluster() {} |
3776 | 3776 |
3777 void Trace(Serializer* s, RawObject* object) { | 3777 void Trace(Serializer* s, RawObject* object) { |
3778 RawStacktrace* trace = Stacktrace::RawCast(object); | 3778 RawStackTrace* trace = StackTrace::RawCast(object); |
3779 objects_.Add(trace); | 3779 objects_.Add(trace); |
3780 | 3780 |
3781 RawObject** from = trace->from(); | 3781 RawObject** from = trace->from(); |
3782 RawObject** to = trace->to(); | 3782 RawObject** to = trace->to(); |
3783 for (RawObject** p = from; p <= to; p++) { | 3783 for (RawObject** p = from; p <= to; p++) { |
3784 s->Push(*p); | 3784 s->Push(*p); |
3785 } | 3785 } |
3786 } | 3786 } |
3787 | 3787 |
3788 void WriteAlloc(Serializer* s) { | 3788 void WriteAlloc(Serializer* s) { |
3789 s->WriteCid(kStacktraceCid); | 3789 s->WriteCid(kStackTraceCid); |
3790 intptr_t count = objects_.length(); | 3790 intptr_t count = objects_.length(); |
3791 s->Write<int32_t>(count); | 3791 s->Write<int32_t>(count); |
3792 for (intptr_t i = 0; i < count; i++) { | 3792 for (intptr_t i = 0; i < count; i++) { |
3793 RawStacktrace* trace = objects_[i]; | 3793 RawStackTrace* trace = objects_[i]; |
3794 s->AssignRef(trace); | 3794 s->AssignRef(trace); |
3795 } | 3795 } |
3796 } | 3796 } |
3797 | 3797 |
3798 void WriteFill(Serializer* s) { | 3798 void WriteFill(Serializer* s) { |
3799 intptr_t count = objects_.length(); | 3799 intptr_t count = objects_.length(); |
3800 for (intptr_t i = 0; i < count; i++) { | 3800 for (intptr_t i = 0; i < count; i++) { |
3801 RawStacktrace* trace = objects_[i]; | 3801 RawStackTrace* trace = objects_[i]; |
3802 RawObject** from = trace->from(); | 3802 RawObject** from = trace->from(); |
3803 RawObject** to = trace->to(); | 3803 RawObject** to = trace->to(); |
3804 for (RawObject** p = from; p <= to; p++) { | 3804 for (RawObject** p = from; p <= to; p++) { |
3805 s->WriteRef(*p); | 3805 s->WriteRef(*p); |
3806 } | 3806 } |
3807 } | 3807 } |
3808 } | 3808 } |
3809 | 3809 |
3810 private: | 3810 private: |
3811 GrowableArray<RawStacktrace*> objects_; | 3811 GrowableArray<RawStackTrace*> objects_; |
3812 }; | 3812 }; |
3813 #endif // !DART_PRECOMPILED_RUNTIME | 3813 #endif // !DART_PRECOMPILED_RUNTIME |
3814 | 3814 |
3815 | 3815 |
3816 class StacktraceDeserializationCluster : public DeserializationCluster { | 3816 class StackTraceDeserializationCluster : public DeserializationCluster { |
3817 public: | 3817 public: |
3818 StacktraceDeserializationCluster() {} | 3818 StackTraceDeserializationCluster() {} |
3819 virtual ~StacktraceDeserializationCluster() {} | 3819 virtual ~StackTraceDeserializationCluster() {} |
3820 | 3820 |
3821 void ReadAlloc(Deserializer* d) { | 3821 void ReadAlloc(Deserializer* d) { |
3822 start_index_ = d->next_index(); | 3822 start_index_ = d->next_index(); |
3823 PageSpace* old_space = d->heap()->old_space(); | 3823 PageSpace* old_space = d->heap()->old_space(); |
3824 intptr_t count = d->Read<int32_t>(); | 3824 intptr_t count = d->Read<int32_t>(); |
3825 for (intptr_t i = 0; i < count; i++) { | 3825 for (intptr_t i = 0; i < count; i++) { |
3826 d->AssignRef( | 3826 d->AssignRef( |
3827 AllocateUninitialized(old_space, Stacktrace::InstanceSize())); | 3827 AllocateUninitialized(old_space, StackTrace::InstanceSize())); |
3828 } | 3828 } |
3829 stop_index_ = d->next_index(); | 3829 stop_index_ = d->next_index(); |
3830 } | 3830 } |
3831 | 3831 |
3832 void ReadFill(Deserializer* d) { | 3832 void ReadFill(Deserializer* d) { |
3833 bool is_vm_object = d->isolate() == Dart::vm_isolate(); | 3833 bool is_vm_object = d->isolate() == Dart::vm_isolate(); |
3834 | 3834 |
3835 for (intptr_t id = start_index_; id < stop_index_; id++) { | 3835 for (intptr_t id = start_index_; id < stop_index_; id++) { |
3836 RawStacktrace* trace = reinterpret_cast<RawStacktrace*>(d->Ref(id)); | 3836 RawStackTrace* trace = reinterpret_cast<RawStackTrace*>(d->Ref(id)); |
3837 Deserializer::InitializeHeader(trace, kStacktraceCid, | 3837 Deserializer::InitializeHeader(trace, kStackTraceCid, |
3838 Stacktrace::InstanceSize(), is_vm_object); | 3838 StackTrace::InstanceSize(), is_vm_object); |
3839 RawObject** from = trace->from(); | 3839 RawObject** from = trace->from(); |
3840 RawObject** to = trace->to(); | 3840 RawObject** to = trace->to(); |
3841 for (RawObject** p = from; p <= to; p++) { | 3841 for (RawObject** p = from; p <= to; p++) { |
3842 *p = d->ReadRef(); | 3842 *p = d->ReadRef(); |
3843 } | 3843 } |
3844 } | 3844 } |
3845 } | 3845 } |
3846 }; | 3846 }; |
3847 | 3847 |
3848 | 3848 |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4459 case kLibraryCid: | 4459 case kLibraryCid: |
4460 return new (Z) LibrarySerializationCluster(); | 4460 return new (Z) LibrarySerializationCluster(); |
4461 case kNamespaceCid: | 4461 case kNamespaceCid: |
4462 return new (Z) NamespaceSerializationCluster(); | 4462 return new (Z) NamespaceSerializationCluster(); |
4463 case kCodeCid: | 4463 case kCodeCid: |
4464 return new (Z) CodeSerializationCluster(); | 4464 return new (Z) CodeSerializationCluster(); |
4465 case kObjectPoolCid: | 4465 case kObjectPoolCid: |
4466 return new (Z) ObjectPoolSerializationCluster(); | 4466 return new (Z) ObjectPoolSerializationCluster(); |
4467 case kPcDescriptorsCid: | 4467 case kPcDescriptorsCid: |
4468 return new (Z) RODataSerializationCluster(kPcDescriptorsCid); | 4468 return new (Z) RODataSerializationCluster(kPcDescriptorsCid); |
4469 case kStackmapCid: | 4469 case kStackMapCid: |
4470 return new (Z) RODataSerializationCluster(kStackmapCid); | 4470 return new (Z) RODataSerializationCluster(kStackMapCid); |
4471 case kExceptionHandlersCid: | 4471 case kExceptionHandlersCid: |
4472 return new (Z) ExceptionHandlersSerializationCluster(); | 4472 return new (Z) ExceptionHandlersSerializationCluster(); |
4473 case kContextCid: | 4473 case kContextCid: |
4474 return new (Z) ContextSerializationCluster(); | 4474 return new (Z) ContextSerializationCluster(); |
4475 case kContextScopeCid: | 4475 case kContextScopeCid: |
4476 return new (Z) ContextScopeSerializationCluster(); | 4476 return new (Z) ContextScopeSerializationCluster(); |
4477 case kUnlinkedCallCid: | 4477 case kUnlinkedCallCid: |
4478 return new (Z) UnlinkedCallSerializationCluster(); | 4478 return new (Z) UnlinkedCallSerializationCluster(); |
4479 case kICDataCid: | 4479 case kICDataCid: |
4480 return new (Z) ICDataSerializationCluster(); | 4480 return new (Z) ICDataSerializationCluster(); |
(...skipping 18 matching lines...) Expand all Loading... |
4499 case kClosureCid: | 4499 case kClosureCid: |
4500 return new (Z) ClosureSerializationCluster(); | 4500 return new (Z) ClosureSerializationCluster(); |
4501 case kMintCid: | 4501 case kMintCid: |
4502 return new (Z) MintSerializationCluster(); | 4502 return new (Z) MintSerializationCluster(); |
4503 case kBigintCid: | 4503 case kBigintCid: |
4504 return new (Z) BigintSerializationCluster(); | 4504 return new (Z) BigintSerializationCluster(); |
4505 case kDoubleCid: | 4505 case kDoubleCid: |
4506 return new (Z) DoubleSerializationCluster(); | 4506 return new (Z) DoubleSerializationCluster(); |
4507 case kGrowableObjectArrayCid: | 4507 case kGrowableObjectArrayCid: |
4508 return new (Z) GrowableObjectArraySerializationCluster(); | 4508 return new (Z) GrowableObjectArraySerializationCluster(); |
4509 case kStacktraceCid: | 4509 case kStackTraceCid: |
4510 return new (Z) StacktraceSerializationCluster(); | 4510 return new (Z) StackTraceSerializationCluster(); |
4511 case kRegExpCid: | 4511 case kRegExpCid: |
4512 return new (Z) RegExpSerializationCluster(); | 4512 return new (Z) RegExpSerializationCluster(); |
4513 case kWeakPropertyCid: | 4513 case kWeakPropertyCid: |
4514 return new (Z) WeakPropertySerializationCluster(); | 4514 return new (Z) WeakPropertySerializationCluster(); |
4515 case kLinkedHashMapCid: | 4515 case kLinkedHashMapCid: |
4516 return new (Z) LinkedHashMapSerializationCluster(); | 4516 return new (Z) LinkedHashMapSerializationCluster(); |
4517 case kArrayCid: | 4517 case kArrayCid: |
4518 return new (Z) ArraySerializationCluster(kArrayCid); | 4518 return new (Z) ArraySerializationCluster(kArrayCid); |
4519 case kImmutableArrayCid: | 4519 case kImmutableArrayCid: |
4520 return new (Z) ArraySerializationCluster(kImmutableArrayCid); | 4520 return new (Z) ArraySerializationCluster(kImmutableArrayCid); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4812 return new (Z) ScriptDeserializationCluster(); | 4812 return new (Z) ScriptDeserializationCluster(); |
4813 case kLibraryCid: | 4813 case kLibraryCid: |
4814 return new (Z) LibraryDeserializationCluster(); | 4814 return new (Z) LibraryDeserializationCluster(); |
4815 case kNamespaceCid: | 4815 case kNamespaceCid: |
4816 return new (Z) NamespaceDeserializationCluster(); | 4816 return new (Z) NamespaceDeserializationCluster(); |
4817 case kCodeCid: | 4817 case kCodeCid: |
4818 return new (Z) CodeDeserializationCluster(); | 4818 return new (Z) CodeDeserializationCluster(); |
4819 case kObjectPoolCid: | 4819 case kObjectPoolCid: |
4820 return new (Z) ObjectPoolDeserializationCluster(); | 4820 return new (Z) ObjectPoolDeserializationCluster(); |
4821 case kPcDescriptorsCid: | 4821 case kPcDescriptorsCid: |
4822 case kStackmapCid: | 4822 case kStackMapCid: |
4823 return new (Z) RODataDeserializationCluster(); | 4823 return new (Z) RODataDeserializationCluster(); |
4824 case kExceptionHandlersCid: | 4824 case kExceptionHandlersCid: |
4825 return new (Z) ExceptionHandlersDeserializationCluster(); | 4825 return new (Z) ExceptionHandlersDeserializationCluster(); |
4826 case kContextCid: | 4826 case kContextCid: |
4827 return new (Z) ContextDeserializationCluster(); | 4827 return new (Z) ContextDeserializationCluster(); |
4828 case kContextScopeCid: | 4828 case kContextScopeCid: |
4829 return new (Z) ContextScopeDeserializationCluster(); | 4829 return new (Z) ContextScopeDeserializationCluster(); |
4830 case kUnlinkedCallCid: | 4830 case kUnlinkedCallCid: |
4831 return new (Z) UnlinkedCallDeserializationCluster(); | 4831 return new (Z) UnlinkedCallDeserializationCluster(); |
4832 case kICDataCid: | 4832 case kICDataCid: |
(...skipping 19 matching lines...) Expand all Loading... |
4852 case kClosureCid: | 4852 case kClosureCid: |
4853 return new (Z) ClosureDeserializationCluster(); | 4853 return new (Z) ClosureDeserializationCluster(); |
4854 case kMintCid: | 4854 case kMintCid: |
4855 return new (Z) MintDeserializationCluster(); | 4855 return new (Z) MintDeserializationCluster(); |
4856 case kBigintCid: | 4856 case kBigintCid: |
4857 return new (Z) BigintDeserializationCluster(); | 4857 return new (Z) BigintDeserializationCluster(); |
4858 case kDoubleCid: | 4858 case kDoubleCid: |
4859 return new (Z) DoubleDeserializationCluster(); | 4859 return new (Z) DoubleDeserializationCluster(); |
4860 case kGrowableObjectArrayCid: | 4860 case kGrowableObjectArrayCid: |
4861 return new (Z) GrowableObjectArrayDeserializationCluster(); | 4861 return new (Z) GrowableObjectArrayDeserializationCluster(); |
4862 case kStacktraceCid: | 4862 case kStackTraceCid: |
4863 return new (Z) StacktraceDeserializationCluster(); | 4863 return new (Z) StackTraceDeserializationCluster(); |
4864 case kRegExpCid: | 4864 case kRegExpCid: |
4865 return new (Z) RegExpDeserializationCluster(); | 4865 return new (Z) RegExpDeserializationCluster(); |
4866 case kWeakPropertyCid: | 4866 case kWeakPropertyCid: |
4867 return new (Z) WeakPropertyDeserializationCluster(); | 4867 return new (Z) WeakPropertyDeserializationCluster(); |
4868 case kLinkedHashMapCid: | 4868 case kLinkedHashMapCid: |
4869 return new (Z) LinkedHashMapDeserializationCluster(); | 4869 return new (Z) LinkedHashMapDeserializationCluster(); |
4870 case kArrayCid: | 4870 case kArrayCid: |
4871 return new (Z) ArrayDeserializationCluster(kArrayCid); | 4871 return new (Z) ArrayDeserializationCluster(kArrayCid); |
4872 case kImmutableArrayCid: | 4872 case kImmutableArrayCid: |
4873 return new (Z) ArrayDeserializationCluster(kImmutableArrayCid); | 4873 return new (Z) ArrayDeserializationCluster(kImmutableArrayCid); |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5361 | 5361 |
5362 deserializer.ReadVMSnapshot(); | 5362 deserializer.ReadVMSnapshot(); |
5363 | 5363 |
5364 Dart::set_instructions_snapshot_buffer(instructions_buffer_); | 5364 Dart::set_instructions_snapshot_buffer(instructions_buffer_); |
5365 Dart::set_data_snapshot_buffer(data_buffer_); | 5365 Dart::set_data_snapshot_buffer(data_buffer_); |
5366 | 5366 |
5367 return ApiError::null(); | 5367 return ApiError::null(); |
5368 } | 5368 } |
5369 | 5369 |
5370 } // namespace dart | 5370 } // namespace dart |
OLD | NEW |