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

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

Issue 1539563003: Remove unused fields in RawField from precompiled snapshot. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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 | « runtime/vm/raw_object.h ('k') | no next file » | 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/native_entry.h" 5 #include "vm/native_entry.h"
6 #include "vm/object.h" 6 #include "vm/object.h"
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 #include "vm/snapshot.h" 8 #include "vm/snapshot.h"
9 #include "vm/stub_code.h" 9 #include "vm/stub_code.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 Snapshot::Kind kind, 789 Snapshot::Kind kind,
790 bool as_reference) { 790 bool as_reference) {
791 ASSERT(reader != NULL); 791 ASSERT(reader != NULL);
792 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 792 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
793 793
794 // Allocate field object. 794 // Allocate field object.
795 Field& field = Field::ZoneHandle(reader->zone(), NEW_OBJECT(Field)); 795 Field& field = Field::ZoneHandle(reader->zone(), NEW_OBJECT(Field));
796 reader->AddBackRef(object_id, &field, kIsDeserialized); 796 reader->AddBackRef(object_id, &field, kIsDeserialized);
797 797
798 // Set all non object fields. 798 // Set all non object fields.
799 field.set_token_pos(reader->Read<int32_t>()); 799 if (reader->snapshot_code()) {
800 field.set_guarded_cid(reader->Read<int32_t>()); 800 field.set_token_pos(0);
801 field.set_is_nullable(reader->Read<int32_t>()); 801 field.set_guarded_cid(kIllegalCid);
802 field.set_is_nullable(kIllegalCid);
803 } else {
804 field.set_token_pos(reader->Read<int32_t>());
805 field.set_guarded_cid(reader->Read<int32_t>());
806 field.set_is_nullable(reader->Read<int32_t>());
807 }
802 field.set_kind_bits(reader->Read<uint8_t>()); 808 field.set_kind_bits(reader->Read<uint8_t>());
803 809
804 // Set all the object fields. 810 // Set all the object fields.
811 RawObject** toobj = reader->snapshot_code()
812 ? field.raw()->to_precompiled_snapshot()
813 : field.raw()->to();
805 READ_OBJECT_FIELDS(field, 814 READ_OBJECT_FIELDS(field,
806 field.raw()->from(), field.raw()->to(), 815 field.raw()->from(), toobj,
807 kAsReference); 816 kAsReference);
808 817
809 field.InitializeGuardedListLengthInObjectOffset(); 818 field.InitializeGuardedListLengthInObjectOffset();
810 819
811 return field.raw(); 820 return field.raw();
812 } 821 }
813 822
814 823
815 void RawField::WriteTo(SnapshotWriter* writer, 824 void RawField::WriteTo(SnapshotWriter* writer,
816 intptr_t object_id, 825 intptr_t object_id,
817 Snapshot::Kind kind, 826 Snapshot::Kind kind,
818 bool as_reference) { 827 bool as_reference) {
819 ASSERT(writer != NULL); 828 ASSERT(writer != NULL);
820 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 829 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
821 830
822 // Write out the serialization header value for this object. 831 // Write out the serialization header value for this object.
823 writer->WriteInlinedObjectHeader(object_id); 832 writer->WriteInlinedObjectHeader(object_id);
824 833
825 // Write out the class and tags information. 834 // Write out the class and tags information.
826 writer->WriteVMIsolateObject(kFieldCid); 835 writer->WriteVMIsolateObject(kFieldCid);
827 writer->WriteTags(writer->GetObjectTags(this)); 836 writer->WriteTags(writer->GetObjectTags(this));
828 837
829 // Write out all the non object fields. 838 // Write out all the non object fields.
830 writer->Write<int32_t>(ptr()->token_pos_); 839 if (!writer->snapshot_code()) {
831 writer->Write<int32_t>(ptr()->guarded_cid_); 840 writer->Write<int32_t>(ptr()->token_pos_);
832 writer->Write<int32_t>(ptr()->is_nullable_); 841 writer->Write<int32_t>(ptr()->guarded_cid_);
842 writer->Write<int32_t>(ptr()->is_nullable_);
843 }
833 writer->Write<uint8_t>(ptr()->kind_bits_); 844 writer->Write<uint8_t>(ptr()->kind_bits_);
834 845
835 // Write out the name. 846 // Write out the name.
836 writer->WriteObjectImpl(ptr()->name_, kAsReference); 847 writer->WriteObjectImpl(ptr()->name_, kAsReference);
837 // Write out the owner. 848 // Write out the owner.
838 writer->WriteObjectImpl(ptr()->owner_, kAsReference); 849 writer->WriteObjectImpl(ptr()->owner_, kAsReference);
839 // Write out the type. 850 // Write out the type.
840 writer->WriteObjectImpl(ptr()->type_, kAsReference); 851 writer->WriteObjectImpl(ptr()->type_, kAsReference);
841 // Write out the initial static value or field offset. 852 // Write out the initial static value or field offset.
842 if (Field::StaticBit::decode(ptr()->kind_bits_)) { 853 if (Field::StaticBit::decode(ptr()->kind_bits_)) {
843 if (writer->snapshot_code()) { 854 if (writer->snapshot_code()) {
844 // For precompiled static fields, the value was already reset and 855 // For precompiled static fields, the value was already reset and
845 // initializer_ now contains a Function. 856 // initializer_ now contains a Function.
846 writer->WriteObjectImpl(ptr()->value_.static_value_, kAsReference); 857 writer->WriteObjectImpl(ptr()->value_.static_value_, kAsReference);
847 } else { 858 } else {
848 // Otherwise, for static fields we write out the initial static value. 859 // Otherwise, for static fields we write out the initial static value.
849 writer->WriteObjectImpl(ptr()->initializer_.saved_value_, kAsReference); 860 writer->WriteObjectImpl(ptr()->initializer_.saved_value_, kAsReference);
850 } 861 }
851 } else { 862 } else {
852 writer->WriteObjectImpl(ptr()->value_.offset_, kAsReference); 863 writer->WriteObjectImpl(ptr()->value_.offset_, kAsReference);
853 } 864 }
854 // Write out the dependent code.
855 writer->WriteObjectImpl(ptr()->dependent_code_, kAsReference);
856 // Write out the initializer function or saved initial value. 865 // Write out the initializer function or saved initial value.
857 if (writer->snapshot_code()) { 866 if (writer->snapshot_code()) {
858 writer->WriteObjectImpl(ptr()->initializer_.precompiled_, kAsReference); 867 writer->WriteObjectImpl(ptr()->initializer_.precompiled_, kAsReference);
859 } else { 868 } else {
860 writer->WriteObjectImpl(ptr()->initializer_.saved_value_, kAsReference); 869 writer->WriteObjectImpl(ptr()->initializer_.saved_value_, kAsReference);
861 } 870 }
862 // Write out the guarded list length. 871 if (!writer->snapshot_code()) {
863 writer->WriteObjectImpl(ptr()->guarded_list_length_, kAsReference); 872 // Write out the dependent code.
873 writer->WriteObjectImpl(ptr()->dependent_code_, kAsReference);
874 // Write out the guarded list length.
875 writer->WriteObjectImpl(ptr()->guarded_list_length_, kAsReference);
876 }
864 } 877 }
865 878
866 879
867 RawLiteralToken* LiteralToken::ReadFrom(SnapshotReader* reader, 880 RawLiteralToken* LiteralToken::ReadFrom(SnapshotReader* reader,
868 intptr_t object_id, 881 intptr_t object_id,
869 intptr_t tags, 882 intptr_t tags,
870 Snapshot::Kind kind, 883 Snapshot::Kind kind,
871 bool as_reference) { 884 bool as_reference) {
872 ASSERT(reader != NULL); 885 ASSERT(reader != NULL);
873 ASSERT(kind != Snapshot::kMessage); 886 ASSERT(kind != Snapshot::kMessage);
(...skipping 2617 matching lines...) Expand 10 before | Expand all | Expand 10 after
3491 // We do not allow objects with native fields in an isolate message. 3504 // We do not allow objects with native fields in an isolate message.
3492 writer->SetWriteException(Exceptions::kArgument, 3505 writer->SetWriteException(Exceptions::kArgument,
3493 "Illegal argument in isolate message" 3506 "Illegal argument in isolate message"
3494 " : (object is a UserTag)"); 3507 " : (object is a UserTag)");
3495 } else { 3508 } else {
3496 UNREACHABLE(); 3509 UNREACHABLE();
3497 } 3510 }
3498 } 3511 }
3499 3512
3500 } // namespace dart 3513 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698