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

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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 1166
1163 result.set_compile_timestamp(reader->Read<int64_t>()); 1167 result.set_compile_timestamp(reader->Read<int64_t>());
1164 result.set_state_bits(reader->Read<int32_t>()); 1168 result.set_state_bits(reader->Read<int32_t>());
1165 result.set_entry_patch_pc_offset(reader->Read<int32_t>()); 1169 result.set_entry_patch_pc_offset(reader->Read<int32_t>());
1166 result.set_patch_code_pc_offset(reader->Read<int32_t>()); 1170 result.set_patch_code_pc_offset(reader->Read<int32_t>());
1167 result.set_lazy_deopt_pc_offset(reader->Read<int32_t>()); 1171 result.set_lazy_deopt_pc_offset(reader->Read<int32_t>());
1168 1172
1169 // Set all the object fields. 1173 // Set all the object fields.
1170 READ_OBJECT_FIELDS(result, 1174 READ_OBJECT_FIELDS(result,
1171 result.raw()->from(), result.raw()->to(), 1175 result.raw()->from(), result.raw()->to(),
1172 kAsReference); 1176 kAsInlinedObject);
1173 1177
1174 // TODO(rmacnak): Fix entry_point_. 1178 // Fix entry point.
1179 uword new_entry = result.EntryPoint();
1180 ASSERT(Dart::vm_isolate()->heap()->CodeContains(new_entry));
1181 result.StoreNonPointer(&result.raw_ptr()->entry_point_, new_entry);
1175 1182
1176 return result.raw(); 1183 return result.raw();
1177 } 1184 }
1178 1185
1179 1186
1180 void RawCode::WriteTo(SnapshotWriter* writer, 1187 void RawCode::WriteTo(SnapshotWriter* writer,
1181 intptr_t object_id, 1188 intptr_t object_id,
1182 Snapshot::Kind kind) { 1189 Snapshot::Kind kind) {
1183 ASSERT(writer->snapshot_code()); 1190 ASSERT(writer->snapshot_code());
1184 ASSERT(kind == Snapshot::kFull); 1191 ASSERT(kind == Snapshot::kFull);
(...skipping 13 matching lines...) Expand all
1198 writer->WriteTags(writer->GetObjectTags(this)); 1205 writer->WriteTags(writer->GetObjectTags(this));
1199 1206
1200 // Write out all the non object fields. 1207 // Write out all the non object fields.
1201 writer->Write<int64_t>(ptr()->compile_timestamp_); 1208 writer->Write<int64_t>(ptr()->compile_timestamp_);
1202 writer->Write<int32_t>(ptr()->state_bits_); 1209 writer->Write<int32_t>(ptr()->state_bits_);
1203 writer->Write<int32_t>(ptr()->entry_patch_pc_offset_); 1210 writer->Write<int32_t>(ptr()->entry_patch_pc_offset_);
1204 writer->Write<int32_t>(ptr()->patch_code_pc_offset_); 1211 writer->Write<int32_t>(ptr()->patch_code_pc_offset_);
1205 writer->Write<int32_t>(ptr()->lazy_deopt_pc_offset_); 1212 writer->Write<int32_t>(ptr()->lazy_deopt_pc_offset_);
1206 1213
1207 // Write out all the object pointer fields. 1214 // Write out all the object pointer fields.
1208 SnapshotWriterVisitor visitor(writer); 1215 SnapshotWriterVisitor visitor(writer, kAsInlinedObject);
1209 visitor.VisitPointers(from(), to()); 1216 visitor.VisitPointers(from(), to());
1210 1217
1211 writer->SetInstructionsCode(ptr()->instructions_, this); 1218 writer->SetInstructionsCode(ptr()->instructions_, this);
1212 } 1219 }
1213 1220
1214 1221
1215 RawInstructions* Instructions::ReadFrom(SnapshotReader* reader, 1222 RawInstructions* Instructions::ReadFrom(SnapshotReader* reader,
1216 intptr_t object_id, 1223 intptr_t object_id,
1217 intptr_t tags, 1224 intptr_t tags,
1218 Snapshot::Kind kind) { 1225 Snapshot::Kind kind) {
1219 ASSERT(reader->snapshot_code()); 1226 ASSERT(reader->snapshot_code());
1220 ASSERT(kind == Snapshot::kFull); 1227 ASSERT(kind == Snapshot::kFull);
1221 1228
1222 intptr_t full_tags = static_cast<uword>(reader->Read<intptr_t>()); 1229 intptr_t full_tags = static_cast<uword>(reader->Read<intptr_t>());
1223 intptr_t offset = reader->Read<int32_t>(); 1230 intptr_t offset = reader->Read<int32_t>();
1224 Instructions& result = 1231 Instructions& result =
1225 Instructions::ZoneHandle(reader->zone(), 1232 Instructions::ZoneHandle(reader->zone(),
1226 reader->GetInstructionsAt(offset, full_tags)); 1233 reader->GetInstructionsAt(offset, full_tags));
1227 reader->AddBackRef(object_id, &result, kIsDeserialized); 1234 reader->AddBackRef(object_id, &result, kIsDeserialized);
1228 1235
1229 {
1230 // TODO(rmacnak): Drop after calling convention change.
1231 Code::CheckedHandle(reader->ReadObjectImpl(kAsReference));
1232 ObjectPool::CheckedHandle(reader->ReadObjectImpl(kAsReference));
1233 }
1234
1235 return result.raw(); 1236 return result.raw();
1236 } 1237 }
1237 1238
1238 1239
1239 void RawInstructions::WriteTo(SnapshotWriter* writer, 1240 void RawInstructions::WriteTo(SnapshotWriter* writer,
1240 intptr_t object_id, 1241 intptr_t object_id,
1241 Snapshot::Kind kind) { 1242 Snapshot::Kind kind) {
1242 ASSERT(writer->snapshot_code()); 1243 ASSERT(writer->snapshot_code());
1243 ASSERT(kind == Snapshot::kFull); 1244 ASSERT(kind == Snapshot::kFull);
1244 1245
1245 { 1246 writer->WriteInlinedObjectHeader(object_id);
1246 // TODO(rmacnak): Drop after calling convention change. 1247 writer->WriteVMIsolateObject(kInstructionsCid);
1247 writer->WriteInlinedObjectHeader(object_id); 1248 writer->WriteTags(writer->GetObjectTags(this));
1248 writer->WriteVMIsolateObject(kInstructionsCid);
1249 writer->WriteTags(writer->GetObjectTags(this));
1250 }
1251 1249
1252 writer->Write<intptr_t>(writer->GetObjectTags(this)); // For sanity check. 1250 // Instructions will be written pre-marked and in the VM heap. Write out
1251 // the tags we expect to find when reading the snapshot for a sanity check
1252 // that our offsets/alignment didn't get out of sync.
1253 uword written_tags = writer->GetObjectTags(this);
1254 written_tags = RawObject::VMHeapObjectTag::update(true, written_tags);
1255 written_tags = RawObject::MarkBit::update(true, written_tags);
1256 writer->Write<intptr_t>(written_tags);
1253 1257
1254 // Temporarily restore the object header for writing to the text section.
1255 // TODO(asiva): Don't mutate object headers during serialization.
1256 uword object_tags = writer->GetObjectTags(this);
1257 uword snapshot_tags = ptr()->tags_;
1258 ptr()->tags_ = object_tags;
1259 writer->Write<int32_t>(writer->GetInstructionsId(this)); 1258 writer->Write<int32_t>(writer->GetInstructionsId(this));
1260 ptr()->tags_ = snapshot_tags;
1261 1259
1262 { 1260 {
1263 // TODO(rmacnak): Drop after calling convention change. 1261 // TODO(rmacnak): Drop after calling convention change.
1264 writer->WriteObjectImpl(ptr()->code_, kAsReference); 1262 writer->WriteObjectImpl(ptr()->code_, kAsReference);
1265 writer->WriteObjectImpl(ptr()->object_pool_, kAsReference); 1263 writer->WriteObjectImpl(ptr()->object_pool_, kAsReference);
1266 } 1264 }
1267 } 1265 }
1268 1266
1269 1267
1270 RawObjectPool* ObjectPool::ReadFrom(SnapshotReader* reader, 1268 RawObjectPool* ObjectPool::ReadFrom(SnapshotReader* reader,
(...skipping 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after
3274 // We do not allow objects with native fields in an isolate message. 3272 // We do not allow objects with native fields in an isolate message.
3275 writer->SetWriteException(Exceptions::kArgument, 3273 writer->SetWriteException(Exceptions::kArgument,
3276 "Illegal argument in isolate message" 3274 "Illegal argument in isolate message"
3277 " : (object is a UserTag)"); 3275 " : (object is a UserTag)");
3278 } else { 3276 } else {
3279 UNREACHABLE(); 3277 UNREACHABLE();
3280 } 3278 }
3281 } 3279 }
3282 3280
3283 } // namespace dart 3281 } // namespace dart
OLDNEW
« runtime/vm/pages.cc ('K') | « runtime/vm/raw_object.h ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698