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

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

Issue 2591823002: Introduce a SignatureData class so that signature functions can store both their (Closed)
Patch Set: address comments Created 4 years 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 | « no previous file | runtime/vm/object.h » ('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) 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 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 } 771 }
772 data->ptr()->parent_function_ = static_cast<RawFunction*>(d->ReadRef()); 772 data->ptr()->parent_function_ = static_cast<RawFunction*>(d->ReadRef());
773 data->ptr()->signature_type_ = static_cast<RawType*>(d->ReadRef()); 773 data->ptr()->signature_type_ = static_cast<RawType*>(d->ReadRef());
774 data->ptr()->closure_ = static_cast<RawInstance*>(d->ReadRef()); 774 data->ptr()->closure_ = static_cast<RawInstance*>(d->ReadRef());
775 } 775 }
776 } 776 }
777 }; 777 };
778 778
779 779
780 #if !defined(DART_PRECOMPILED_RUNTIME) 780 #if !defined(DART_PRECOMPILED_RUNTIME)
781 class SignatureDataSerializationCluster : public SerializationCluster {
782 public:
783 SignatureDataSerializationCluster() {}
784 virtual ~SignatureDataSerializationCluster() {}
785
786 void Trace(Serializer* s, RawObject* object) {
787 RawSignatureData* data = SignatureData::RawCast(object);
788 objects_.Add(data);
789
790 RawObject** from = data->from();
791 RawObject** to = data->to();
792 for (RawObject** p = from; p <= to; p++) {
793 s->Push(*p);
794 }
795 }
796
797 void WriteAlloc(Serializer* s) {
798 s->WriteCid(kSignatureDataCid);
799 intptr_t count = objects_.length();
800 s->Write<int32_t>(count);
801 for (intptr_t i = 0; i < count; i++) {
802 RawSignatureData* data = objects_[i];
803 s->AssignRef(data);
804 }
805 }
806
807 void WriteFill(Serializer* s) {
808 intptr_t count = objects_.length();
809 for (intptr_t i = 0; i < count; i++) {
810 RawSignatureData* data = objects_[i];
811 RawObject** from = data->from();
812 RawObject** to = data->to();
813 for (RawObject** p = from; p <= to; p++) {
814 s->WriteRef(*p);
815 }
816 }
817 }
818
819 private:
820 GrowableArray<RawSignatureData*> objects_;
821 };
822 #endif // !DART_PRECOMPILED_RUNTIME
823
824
825 class SignatureDataDeserializationCluster : public DeserializationCluster {
826 public:
827 SignatureDataDeserializationCluster() {}
828 virtual ~SignatureDataDeserializationCluster() {}
829
830 void ReadAlloc(Deserializer* d) {
831 start_index_ = d->next_index();
832 PageSpace* old_space = d->heap()->old_space();
833 intptr_t count = d->Read<int32_t>();
834 for (intptr_t i = 0; i < count; i++) {
835 d->AssignRef(
836 AllocateUninitialized(old_space, SignatureData::InstanceSize()));
837 }
838 stop_index_ = d->next_index();
839 }
840
841 void ReadFill(Deserializer* d) {
842 bool is_vm_object = d->isolate() == Dart::vm_isolate();
843
844 for (intptr_t id = start_index_; id < stop_index_; id++) {
845 RawSignatureData* data = reinterpret_cast<RawSignatureData*>(d->Ref(id));
846 Deserializer::InitializeHeader(
847 data, kSignatureDataCid, SignatureData::InstanceSize(), is_vm_object);
848 RawObject** from = data->from();
849 RawObject** to = data->to();
850 for (RawObject** p = from; p <= to; p++) {
851 *p = d->ReadRef();
852 }
853 }
854 }
855 };
856
857
858 #if !defined(DART_PRECOMPILED_RUNTIME)
781 class RedirectionDataSerializationCluster : public SerializationCluster { 859 class RedirectionDataSerializationCluster : public SerializationCluster {
782 public: 860 public:
783 RedirectionDataSerializationCluster() {} 861 RedirectionDataSerializationCluster() {}
784 virtual ~RedirectionDataSerializationCluster() {} 862 virtual ~RedirectionDataSerializationCluster() {}
785 863
786 void Trace(Serializer* s, RawObject* object) { 864 void Trace(Serializer* s, RawObject* object) {
787 RawRedirectionData* data = RedirectionData::RawCast(object); 865 RawRedirectionData* data = RedirectionData::RawCast(object);
788 objects_.Add(data); 866 objects_.Add(data);
789 867
790 RawObject** from = data->from(); 868 RawObject** from = data->from();
(...skipping 3648 matching lines...) Expand 10 before | Expand all | Expand 10 after
4439 case kUnresolvedClassCid: 4517 case kUnresolvedClassCid:
4440 return new (Z) UnresolvedClassSerializationCluster(); 4518 return new (Z) UnresolvedClassSerializationCluster();
4441 case kTypeArgumentsCid: 4519 case kTypeArgumentsCid:
4442 return new (Z) TypeArgumentsSerializationCluster(); 4520 return new (Z) TypeArgumentsSerializationCluster();
4443 case kPatchClassCid: 4521 case kPatchClassCid:
4444 return new (Z) PatchClassSerializationCluster(); 4522 return new (Z) PatchClassSerializationCluster();
4445 case kFunctionCid: 4523 case kFunctionCid:
4446 return new (Z) FunctionSerializationCluster(); 4524 return new (Z) FunctionSerializationCluster();
4447 case kClosureDataCid: 4525 case kClosureDataCid:
4448 return new (Z) ClosureDataSerializationCluster(); 4526 return new (Z) ClosureDataSerializationCluster();
4527 case kSignatureDataCid:
4528 return new (Z) SignatureDataSerializationCluster();
4449 case kRedirectionDataCid: 4529 case kRedirectionDataCid:
4450 return new (Z) RedirectionDataSerializationCluster(); 4530 return new (Z) RedirectionDataSerializationCluster();
4451 case kFieldCid: 4531 case kFieldCid:
4452 return new (Z) FieldSerializationCluster(); 4532 return new (Z) FieldSerializationCluster();
4453 case kLiteralTokenCid: 4533 case kLiteralTokenCid:
4454 return new (Z) LiteralTokenSerializationCluster(); 4534 return new (Z) LiteralTokenSerializationCluster();
4455 case kTokenStreamCid: 4535 case kTokenStreamCid:
4456 return new (Z) TokenStreamSerializationCluster(); 4536 return new (Z) TokenStreamSerializationCluster();
4457 case kScriptCid: 4537 case kScriptCid:
4458 return new (Z) ScriptSerializationCluster(); 4538 return new (Z) ScriptSerializationCluster();
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
4803 case kUnresolvedClassCid: 4883 case kUnresolvedClassCid:
4804 return new (Z) UnresolvedClassDeserializationCluster(); 4884 return new (Z) UnresolvedClassDeserializationCluster();
4805 case kTypeArgumentsCid: 4885 case kTypeArgumentsCid:
4806 return new (Z) TypeArgumentsDeserializationCluster(); 4886 return new (Z) TypeArgumentsDeserializationCluster();
4807 case kPatchClassCid: 4887 case kPatchClassCid:
4808 return new (Z) PatchClassDeserializationCluster(); 4888 return new (Z) PatchClassDeserializationCluster();
4809 case kFunctionCid: 4889 case kFunctionCid:
4810 return new (Z) FunctionDeserializationCluster(); 4890 return new (Z) FunctionDeserializationCluster();
4811 case kClosureDataCid: 4891 case kClosureDataCid:
4812 return new (Z) ClosureDataDeserializationCluster(); 4892 return new (Z) ClosureDataDeserializationCluster();
4893 case kSignatureDataCid:
4894 return new (Z) SignatureDataDeserializationCluster();
4813 case kRedirectionDataCid: 4895 case kRedirectionDataCid:
4814 return new (Z) RedirectionDataDeserializationCluster(); 4896 return new (Z) RedirectionDataDeserializationCluster();
4815 case kFieldCid: 4897 case kFieldCid:
4816 return new (Z) FieldDeserializationCluster(); 4898 return new (Z) FieldDeserializationCluster();
4817 case kLiteralTokenCid: 4899 case kLiteralTokenCid:
4818 return new (Z) LiteralTokenDeserializationCluster(); 4900 return new (Z) LiteralTokenDeserializationCluster();
4819 case kTokenStreamCid: 4901 case kTokenStreamCid:
4820 return new (Z) TokenStreamDeserializationCluster(); 4902 return new (Z) TokenStreamDeserializationCluster();
4821 case kScriptCid: 4903 case kScriptCid:
4822 return new (Z) ScriptDeserializationCluster(); 4904 return new (Z) ScriptDeserializationCluster();
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
5383 5465
5384 deserializer.ReadVMSnapshot(); 5466 deserializer.ReadVMSnapshot();
5385 5467
5386 Dart::set_instructions_snapshot_buffer(instructions_buffer_); 5468 Dart::set_instructions_snapshot_buffer(instructions_buffer_);
5387 Dart::set_data_snapshot_buffer(data_buffer_); 5469 Dart::set_data_snapshot_buffer(data_buffer_);
5388 5470
5389 return ApiError::null(); 5471 return ApiError::null();
5390 } 5472 }
5391 5473
5392 } // namespace dart 5474 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698