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

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

Issue 1336763002: Last snapshot bits to get working precompiled hello_world on x64. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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/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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 func.set_deoptimization_counter(reader->Read<int16_t>()); 646 func.set_deoptimization_counter(reader->Read<int16_t>());
647 func.set_kind_tag(reader->Read<uint32_t>()); 647 func.set_kind_tag(reader->Read<uint32_t>());
648 func.set_optimized_instruction_count(reader->Read<uint16_t>()); 648 func.set_optimized_instruction_count(reader->Read<uint16_t>());
649 func.set_optimized_call_site_count(reader->Read<uint16_t>()); 649 func.set_optimized_call_site_count(reader->Read<uint16_t>());
650 650
651 // Set all the object fields. 651 // Set all the object fields.
652 READ_OBJECT_FIELDS(func, 652 READ_OBJECT_FIELDS(func,
653 func.raw()->from(), 653 func.raw()->from(),
654 reader->snapshot_code() ? func.raw()->to() 654 reader->snapshot_code() ? func.raw()->to()
655 : func.raw()->to_snapshot(), 655 : func.raw()->to_snapshot(),
656 kAsReference); 656 kAsInlinedObject);
657 657
658 if (!reader->snapshot_code()) { 658 if (!reader->snapshot_code()) {
659 // Initialize all fields that are not part of the snapshot. 659 // Initialize all fields that are not part of the snapshot.
660 func.ClearICDataArray(); 660 func.ClearICDataArray();
661 func.ClearCode(); 661 func.ClearCode();
662 } else { 662 } else {
663 // TODO(rmacnak): Fix entry_point_. 663 // Fix entry point.
664 (*reader->CodeHandle()) = func.CurrentCode();
665 uword new_entry = (*reader->CodeHandle()).EntryPoint();
666 ASSERT(Dart::vm_isolate()->heap()->CodeContains(new_entry));
667 func.StoreNonPointer(&func.raw_ptr()->entry_point_, new_entry);
664 } 668 }
665 return func.raw(); 669 return func.raw();
666 } 670 }
667 671
668 672
669 void RawFunction::WriteTo(SnapshotWriter* writer, 673 void RawFunction::WriteTo(SnapshotWriter* writer,
670 intptr_t object_id, 674 intptr_t object_id,
671 Snapshot::Kind kind) { 675 Snapshot::Kind kind) {
672 ASSERT(writer != NULL); 676 ASSERT(writer != NULL);
673 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 677 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
(...skipping 14 matching lines...) Expand all
688 writer->Write<int32_t>(0); 692 writer->Write<int32_t>(0);
689 } 693 }
690 writer->Write<int16_t>(ptr()->num_fixed_parameters_); 694 writer->Write<int16_t>(ptr()->num_fixed_parameters_);
691 writer->Write<int16_t>(ptr()->num_optional_parameters_); 695 writer->Write<int16_t>(ptr()->num_optional_parameters_);
692 writer->Write<int16_t>(ptr()->deoptimization_counter_); 696 writer->Write<int16_t>(ptr()->deoptimization_counter_);
693 writer->Write<uint32_t>(ptr()->kind_tag_); 697 writer->Write<uint32_t>(ptr()->kind_tag_);
694 writer->Write<uint16_t>(ptr()->optimized_instruction_count_); 698 writer->Write<uint16_t>(ptr()->optimized_instruction_count_);
695 writer->Write<uint16_t>(ptr()->optimized_call_site_count_); 699 writer->Write<uint16_t>(ptr()->optimized_call_site_count_);
696 700
697 // Write out all the object pointer fields. 701 // Write out all the object pointer fields.
698 SnapshotWriterVisitor visitor(writer); 702 SnapshotWriterVisitor visitor(writer, kAsInlinedObject);
699 visitor.VisitPointers(from(), writer->snapshot_code() ? to() 703 visitor.VisitPointers(from(), writer->snapshot_code() ? to()
700 : to_snapshot()); 704 : to_snapshot());
701 } 705 }
702 706
703 707
704 RawField* Field::ReadFrom(SnapshotReader* reader, 708 RawField* Field::ReadFrom(SnapshotReader* reader,
705 intptr_t object_id, 709 intptr_t object_id,
706 intptr_t tags, 710 intptr_t tags,
707 Snapshot::Kind kind) { 711 Snapshot::Kind kind) {
708 ASSERT(reader != NULL); 712 ASSERT(reader != NULL);
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 1156
1153 result.set_compile_timestamp(reader->Read<int64_t>()); 1157 result.set_compile_timestamp(reader->Read<int64_t>());
1154 result.set_state_bits(reader->Read<int32_t>()); 1158 result.set_state_bits(reader->Read<int32_t>());
1155 result.set_entry_patch_pc_offset(reader->Read<int32_t>()); 1159 result.set_entry_patch_pc_offset(reader->Read<int32_t>());
1156 result.set_patch_code_pc_offset(reader->Read<int32_t>()); 1160 result.set_patch_code_pc_offset(reader->Read<int32_t>());
1157 result.set_lazy_deopt_pc_offset(reader->Read<int32_t>()); 1161 result.set_lazy_deopt_pc_offset(reader->Read<int32_t>());
1158 1162
1159 // Set all the object fields. 1163 // Set all the object fields.
1160 READ_OBJECT_FIELDS(result, 1164 READ_OBJECT_FIELDS(result,
1161 result.raw()->from(), result.raw()->to(), 1165 result.raw()->from(), result.raw()->to(),
1162 kAsReference); 1166 kAsInlinedObject);
1163 1167
1164 // TODO(rmacnak): Fix entry_point_. 1168 // Fix entry point.
1169 uword new_entry = result.EntryPoint();
1170 ASSERT(Dart::vm_isolate()->heap()->CodeContains(new_entry));
1171 result.StoreNonPointer(&result.raw_ptr()->entry_point_, new_entry);
1165 1172
1166 return result.raw(); 1173 return result.raw();
1167 } 1174 }
1168 1175
1169 1176
1170 void RawCode::WriteTo(SnapshotWriter* writer, 1177 void RawCode::WriteTo(SnapshotWriter* writer,
1171 intptr_t object_id, 1178 intptr_t object_id,
1172 Snapshot::Kind kind) { 1179 Snapshot::Kind kind) {
1173 ASSERT(writer->snapshot_code()); 1180 ASSERT(writer->snapshot_code());
1174 ASSERT(kind == Snapshot::kFull); 1181 ASSERT(kind == Snapshot::kFull);
(...skipping 13 matching lines...) Expand all
1188 writer->WriteTags(writer->GetObjectTags(this)); 1195 writer->WriteTags(writer->GetObjectTags(this));
1189 1196
1190 // Write out all the non object fields. 1197 // Write out all the non object fields.
1191 writer->Write<int64_t>(ptr()->compile_timestamp_); 1198 writer->Write<int64_t>(ptr()->compile_timestamp_);
1192 writer->Write<int32_t>(ptr()->state_bits_); 1199 writer->Write<int32_t>(ptr()->state_bits_);
1193 writer->Write<int32_t>(ptr()->entry_patch_pc_offset_); 1200 writer->Write<int32_t>(ptr()->entry_patch_pc_offset_);
1194 writer->Write<int32_t>(ptr()->patch_code_pc_offset_); 1201 writer->Write<int32_t>(ptr()->patch_code_pc_offset_);
1195 writer->Write<int32_t>(ptr()->lazy_deopt_pc_offset_); 1202 writer->Write<int32_t>(ptr()->lazy_deopt_pc_offset_);
1196 1203
1197 // Write out all the object pointer fields. 1204 // Write out all the object pointer fields.
1198 SnapshotWriterVisitor visitor(writer); 1205 SnapshotWriterVisitor visitor(writer, kAsInlinedObject);
1199 visitor.VisitPointers(from(), to()); 1206 visitor.VisitPointers(from(), to());
1200 1207
1201 writer->SetInstructionsCode(ptr()->instructions_, this); 1208 writer->SetInstructionsCode(ptr()->instructions_, this);
1202 } 1209 }
1203 1210
1204 1211
1205 RawInstructions* Instructions::ReadFrom(SnapshotReader* reader, 1212 RawInstructions* Instructions::ReadFrom(SnapshotReader* reader,
1206 intptr_t object_id, 1213 intptr_t object_id,
1207 intptr_t tags, 1214 intptr_t tags,
1208 Snapshot::Kind kind) { 1215 Snapshot::Kind kind) {
1209 ASSERT(reader->snapshot_code()); 1216 ASSERT(reader->snapshot_code());
1210 ASSERT(kind == Snapshot::kFull); 1217 ASSERT(kind == Snapshot::kFull);
1211 1218
1212 intptr_t full_tags = static_cast<uword>(reader->Read<intptr_t>()); 1219 intptr_t full_tags = static_cast<uword>(reader->Read<intptr_t>());
1213 intptr_t offset = reader->Read<int32_t>(); 1220 intptr_t offset = reader->Read<int32_t>();
1214 Instructions& result = 1221 Instructions& result =
1215 Instructions::ZoneHandle(reader->zone(), 1222 Instructions::ZoneHandle(reader->zone(),
1216 reader->GetInstructionsAt(offset, full_tags)); 1223 reader->GetInstructionsAt(offset, full_tags));
1217 reader->AddBackRef(object_id, &result, kIsDeserialized); 1224 reader->AddBackRef(object_id, &result, kIsDeserialized);
1218 1225
1219 {
1220 // TODO(rmacnak): Drop after calling convention change.
1221 Code::CheckedHandle(reader->ReadObjectImpl(kAsReference));
1222 ObjectPool::CheckedHandle(reader->ReadObjectImpl(kAsReference));
1223 }
1224
1225 return result.raw(); 1226 return result.raw();
1226 } 1227 }
1227 1228
1228 1229
1229 void RawInstructions::WriteTo(SnapshotWriter* writer, 1230 void RawInstructions::WriteTo(SnapshotWriter* writer,
1230 intptr_t object_id, 1231 intptr_t object_id,
1231 Snapshot::Kind kind) { 1232 Snapshot::Kind kind) {
1232 ASSERT(writer->snapshot_code()); 1233 ASSERT(writer->snapshot_code());
1233 ASSERT(kind == Snapshot::kFull); 1234 ASSERT(kind == Snapshot::kFull);
1234 1235
1235 { 1236 writer->WriteInlinedObjectHeader(object_id);
1236 // TODO(rmacnak): Drop after calling convention change. 1237 writer->WriteVMIsolateObject(kInstructionsCid);
1237 writer->WriteInlinedObjectHeader(object_id); 1238 writer->WriteTags(writer->GetObjectTags(this));
1238 writer->WriteVMIsolateObject(kInstructionsCid);
1239 writer->WriteTags(writer->GetObjectTags(this));
1240 }
1241
1242 writer->Write<intptr_t>(writer->GetObjectTags(this)); // For sanity check.
1243 1239
1244 // Temporarily restore the object header for writing to the text section. 1240 // Temporarily restore the object header for writing to the text section.
1245 // TODO(asiva): Don't mutate object headers during serialization. 1241 // TODO(asiva): Don't mutate object headers during serialization.
siva 2015/09/15 23:22:01 Is this temporary restore of tags stuff necessary
rmacnak 2015/09/16 01:34:45 Dropped.
1246 uword object_tags = writer->GetObjectTags(this); 1242 uword object_tags = writer->GetObjectTags(this);
1247 uword snapshot_tags = ptr()->tags_; 1243 uword snapshot_tags = ptr()->tags_;
1248 ptr()->tags_ = object_tags; 1244 ptr()->tags_ = object_tags;
1245
1246 // Instructions with be written pre-marked and in the VM heap. Write out
1247 // the tags we expect to find when reading the snapshot for a sanity check
1248 // that our offsets/alignment didn't get out of sync.
1249 uword written_tags = object_tags;
1250 written_tags = RawObject::VMHeapObjectTag::update(true, written_tags);
1251 written_tags = RawObject::MarkBit::update(true, written_tags);
1252 writer->Write<intptr_t>(written_tags);
1253
1249 writer->Write<int32_t>(writer->GetInstructionsId(this)); 1254 writer->Write<int32_t>(writer->GetInstructionsId(this));
1255
1250 ptr()->tags_ = snapshot_tags; 1256 ptr()->tags_ = snapshot_tags;
1251 1257
1252 { 1258 {
1253 // TODO(rmacnak): Drop after calling convention change. 1259 // TODO(rmacnak): Drop after calling convention change.
1254 writer->WriteObjectImpl(ptr()->code_, kAsReference); 1260 writer->WriteObjectImpl(ptr()->code_, kAsReference);
1255 writer->WriteObjectImpl(ptr()->object_pool_, kAsReference); 1261 writer->WriteObjectImpl(ptr()->object_pool_, kAsReference);
1256 } 1262 }
1257 } 1263 }
1258 1264
1259 1265
(...skipping 2004 matching lines...) Expand 10 before | Expand all | Expand 10 after
3264 // We do not allow objects with native fields in an isolate message. 3270 // We do not allow objects with native fields in an isolate message.
3265 writer->SetWriteException(Exceptions::kArgument, 3271 writer->SetWriteException(Exceptions::kArgument,
3266 "Illegal argument in isolate message" 3272 "Illegal argument in isolate message"
3267 " : (object is a UserTag)"); 3273 " : (object is a UserTag)");
3268 } else { 3274 } else {
3269 UNREACHABLE(); 3275 UNREACHABLE();
3270 } 3276 }
3271 } 3277 }
3272 3278
3273 } // namespace dart 3279 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698