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

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
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/snapshot.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) 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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 func.set_optimized_instruction_count(reader->Read<uint16_t>()); 647 func.set_optimized_instruction_count(reader->Read<uint16_t>());
648 func.set_optimized_call_site_count(reader->Read<uint16_t>()); 648 func.set_optimized_call_site_count(reader->Read<uint16_t>());
649 649
650 // Set all the object fields. 650 // Set all the object fields.
651 bool is_optimized = func.usage_counter() != 0; 651 bool is_optimized = func.usage_counter() != 0;
652 RawObject** toobj = reader->snapshot_code() ? func.raw()->to() : 652 RawObject** toobj = reader->snapshot_code() ? func.raw()->to() :
653 (is_optimized ? func.raw()->to_optimized_snapshot() : 653 (is_optimized ? func.raw()->to_optimized_snapshot() :
654 func.raw()->to_snapshot()); 654 func.raw()->to_snapshot());
655 READ_OBJECT_FIELDS(func, 655 READ_OBJECT_FIELDS(func,
656 func.raw()->from(), toobj, 656 func.raw()->from(), toobj,
657 kAsReference); 657 kAsInlinedObject);
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 if (!is_optimized) { 660 if (!is_optimized) {
661 func.ClearICDataArray(); 661 func.ClearICDataArray();
662 } 662 }
663 func.ClearCode(); 663 func.ClearCode();
664 } else { 664 } else {
665 // TODO(rmacnak): Fix entry_point_. 665 // Fix entry point.
666 (*reader->CodeHandle()) = func.CurrentCode();
667 uword new_entry = (*reader->CodeHandle()).EntryPoint();
668 ASSERT(Dart::vm_isolate()->heap()->CodeContains(new_entry));
669 func.StoreNonPointer(&func.raw_ptr()->entry_point_, new_entry);
666 } 670 }
667 return func.raw(); 671 return func.raw();
668 } else { 672 } else {
669 return reader->ReadFunctionId(object_id); 673 return reader->ReadFunctionId(object_id);
670 } 674 }
671 } 675 }
672 676
673 677
674 void RawFunction::WriteTo(SnapshotWriter* writer, 678 void RawFunction::WriteTo(SnapshotWriter* writer,
675 intptr_t object_id, 679 intptr_t object_id,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 writer->Write<int16_t>(ptr()->num_optional_parameters_); 719 writer->Write<int16_t>(ptr()->num_optional_parameters_);
716 writer->Write<int16_t>(ptr()->deoptimization_counter_); 720 writer->Write<int16_t>(ptr()->deoptimization_counter_);
717 writer->Write<uint32_t>(ptr()->kind_tag_); 721 writer->Write<uint32_t>(ptr()->kind_tag_);
718 writer->Write<uint16_t>(ptr()->optimized_instruction_count_); 722 writer->Write<uint16_t>(ptr()->optimized_instruction_count_);
719 writer->Write<uint16_t>(ptr()->optimized_call_site_count_); 723 writer->Write<uint16_t>(ptr()->optimized_call_site_count_);
720 724
721 // Write out all the object pointer fields. 725 // Write out all the object pointer fields.
722 RawObject** toobj = 726 RawObject** toobj =
723 writer->snapshot_code() ? to() : 727 writer->snapshot_code() ? to() :
724 (is_optimized ? to_optimized_snapshot() : to_snapshot()); 728 (is_optimized ? to_optimized_snapshot() : to_snapshot());
725 SnapshotWriterVisitor visitor(writer); 729 SnapshotWriterVisitor visitor(writer, kAsInlinedObject);
726 visitor.VisitPointers(from(), toobj); 730 visitor.VisitPointers(from(), toobj);
727 } else { 731 } else {
728 writer->WriteFunctionId(this, owner_is_class); 732 writer->WriteFunctionId(this, owner_is_class);
729 } 733 }
730 } 734 }
731 735
732 736
733 RawField* Field::ReadFrom(SnapshotReader* reader, 737 RawField* Field::ReadFrom(SnapshotReader* reader,
734 intptr_t object_id, 738 intptr_t object_id,
735 intptr_t tags, 739 intptr_t tags,
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 1195
1192 result.set_compile_timestamp(reader->Read<int64_t>()); 1196 result.set_compile_timestamp(reader->Read<int64_t>());
1193 result.set_state_bits(reader->Read<int32_t>()); 1197 result.set_state_bits(reader->Read<int32_t>());
1194 result.set_entry_patch_pc_offset(reader->Read<int32_t>()); 1198 result.set_entry_patch_pc_offset(reader->Read<int32_t>());
1195 result.set_patch_code_pc_offset(reader->Read<int32_t>()); 1199 result.set_patch_code_pc_offset(reader->Read<int32_t>());
1196 result.set_lazy_deopt_pc_offset(reader->Read<int32_t>()); 1200 result.set_lazy_deopt_pc_offset(reader->Read<int32_t>());
1197 1201
1198 // Set all the object fields. 1202 // Set all the object fields.
1199 READ_OBJECT_FIELDS(result, 1203 READ_OBJECT_FIELDS(result,
1200 result.raw()->from(), result.raw()->to(), 1204 result.raw()->from(), result.raw()->to(),
1201 kAsReference); 1205 kAsInlinedObject);
1202 1206
1203 // TODO(rmacnak): Fix entry_point_. 1207 // Fix entry point.
1208 uword new_entry = result.EntryPoint();
1209 ASSERT(Dart::vm_isolate()->heap()->CodeContains(new_entry));
1210 result.StoreNonPointer(&result.raw_ptr()->entry_point_, new_entry);
1204 1211
1205 return result.raw(); 1212 return result.raw();
1206 } 1213 }
1207 1214
1208 1215
1209 void RawCode::WriteTo(SnapshotWriter* writer, 1216 void RawCode::WriteTo(SnapshotWriter* writer,
1210 intptr_t object_id, 1217 intptr_t object_id,
1211 Snapshot::Kind kind) { 1218 Snapshot::Kind kind) {
1212 ASSERT(writer->snapshot_code()); 1219 ASSERT(writer->snapshot_code());
1213 ASSERT(kind == Snapshot::kFull); 1220 ASSERT(kind == Snapshot::kFull);
(...skipping 13 matching lines...) Expand all
1227 writer->WriteTags(writer->GetObjectTags(this)); 1234 writer->WriteTags(writer->GetObjectTags(this));
1228 1235
1229 // Write out all the non object fields. 1236 // Write out all the non object fields.
1230 writer->Write<int64_t>(ptr()->compile_timestamp_); 1237 writer->Write<int64_t>(ptr()->compile_timestamp_);
1231 writer->Write<int32_t>(ptr()->state_bits_); 1238 writer->Write<int32_t>(ptr()->state_bits_);
1232 writer->Write<int32_t>(ptr()->entry_patch_pc_offset_); 1239 writer->Write<int32_t>(ptr()->entry_patch_pc_offset_);
1233 writer->Write<int32_t>(ptr()->patch_code_pc_offset_); 1240 writer->Write<int32_t>(ptr()->patch_code_pc_offset_);
1234 writer->Write<int32_t>(ptr()->lazy_deopt_pc_offset_); 1241 writer->Write<int32_t>(ptr()->lazy_deopt_pc_offset_);
1235 1242
1236 // Write out all the object pointer fields. 1243 // Write out all the object pointer fields.
1237 SnapshotWriterVisitor visitor(writer); 1244 SnapshotWriterVisitor visitor(writer, kAsInlinedObject);
1238 visitor.VisitPointers(from(), to()); 1245 visitor.VisitPointers(from(), to());
1239 1246
1240 writer->SetInstructionsCode(ptr()->instructions_, this); 1247 writer->SetInstructionsCode(ptr()->instructions_, this);
1241 } 1248 }
1242 1249
1243 1250
1244 RawInstructions* Instructions::ReadFrom(SnapshotReader* reader, 1251 RawInstructions* Instructions::ReadFrom(SnapshotReader* reader,
1245 intptr_t object_id, 1252 intptr_t object_id,
1246 intptr_t tags, 1253 intptr_t tags,
1247 Snapshot::Kind kind) { 1254 Snapshot::Kind kind) {
1248 ASSERT(reader->snapshot_code()); 1255 ASSERT(reader->snapshot_code());
1249 ASSERT(kind == Snapshot::kFull); 1256 ASSERT(kind == Snapshot::kFull);
1250 1257
1251 intptr_t full_tags = static_cast<uword>(reader->Read<intptr_t>()); 1258 intptr_t full_tags = static_cast<uword>(reader->Read<intptr_t>());
1252 intptr_t offset = reader->Read<int32_t>(); 1259 intptr_t offset = reader->Read<int32_t>();
1253 Instructions& result = 1260 Instructions& result =
1254 Instructions::ZoneHandle(reader->zone(), 1261 Instructions::ZoneHandle(reader->zone(),
1255 reader->GetInstructionsAt(offset, full_tags)); 1262 reader->GetInstructionsAt(offset, full_tags));
1256 reader->AddBackRef(object_id, &result, kIsDeserialized); 1263 reader->AddBackRef(object_id, &result, kIsDeserialized);
1257 1264
1258 {
1259 // TODO(rmacnak): Drop after calling convention change.
1260 Code::CheckedHandle(reader->ReadObjectImpl(kAsReference));
1261 ObjectPool::CheckedHandle(reader->ReadObjectImpl(kAsReference));
1262 }
1263
1264 return result.raw(); 1265 return result.raw();
1265 } 1266 }
1266 1267
1267 1268
1268 void RawInstructions::WriteTo(SnapshotWriter* writer, 1269 void RawInstructions::WriteTo(SnapshotWriter* writer,
1269 intptr_t object_id, 1270 intptr_t object_id,
1270 Snapshot::Kind kind) { 1271 Snapshot::Kind kind) {
1271 ASSERT(writer->snapshot_code()); 1272 ASSERT(writer->snapshot_code());
1272 ASSERT(kind == Snapshot::kFull); 1273 ASSERT(kind == Snapshot::kFull);
1273 1274
1274 { 1275 writer->WriteInlinedObjectHeader(object_id);
1275 // TODO(rmacnak): Drop after calling convention change. 1276 writer->WriteVMIsolateObject(kInstructionsCid);
1276 writer->WriteInlinedObjectHeader(object_id); 1277 writer->WriteTags(writer->GetObjectTags(this));
1277 writer->WriteVMIsolateObject(kInstructionsCid);
1278 writer->WriteTags(writer->GetObjectTags(this));
1279 }
1280 1278
1281 writer->Write<intptr_t>(writer->GetObjectTags(this)); // For sanity check. 1279 // Instructions will be written pre-marked and in the VM heap. Write out
1280 // the tags we expect to find when reading the snapshot for a sanity check
1281 // that our offsets/alignment didn't get out of sync.
1282 uword written_tags = writer->GetObjectTags(this);
1283 written_tags = RawObject::VMHeapObjectTag::update(true, written_tags);
1284 written_tags = RawObject::MarkBit::update(true, written_tags);
1285 writer->Write<intptr_t>(written_tags);
1282 1286
1283 // Temporarily restore the object header for writing to the text section.
1284 // TODO(asiva): Don't mutate object headers during serialization.
1285 uword object_tags = writer->GetObjectTags(this);
1286 uword snapshot_tags = ptr()->tags_;
1287 ptr()->tags_ = object_tags;
1288 writer->Write<int32_t>(writer->GetInstructionsId(this)); 1287 writer->Write<int32_t>(writer->GetInstructionsId(this));
1289 ptr()->tags_ = snapshot_tags;
1290 1288
1291 { 1289 {
1292 // TODO(rmacnak): Drop after calling convention change. 1290 // TODO(rmacnak): Drop after calling convention change.
1293 writer->WriteObjectImpl(ptr()->code_, kAsReference); 1291 writer->WriteObjectImpl(ptr()->code_, kAsReference);
1294 writer->WriteObjectImpl(ptr()->object_pool_, kAsReference); 1292 writer->WriteObjectImpl(ptr()->object_pool_, kAsReference);
1295 } 1293 }
1296 } 1294 }
1297 1295
1298 1296
1299 RawObjectPool* ObjectPool::ReadFrom(SnapshotReader* reader, 1297 RawObjectPool* ObjectPool::ReadFrom(SnapshotReader* reader,
(...skipping 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after
3301 // We do not allow objects with native fields in an isolate message. 3299 // We do not allow objects with native fields in an isolate message.
3302 writer->SetWriteException(Exceptions::kArgument, 3300 writer->SetWriteException(Exceptions::kArgument,
3303 "Illegal argument in isolate message" 3301 "Illegal argument in isolate message"
3304 " : (object is a UserTag)"); 3302 " : (object is a UserTag)");
3305 } else { 3303 } else {
3306 UNREACHABLE(); 3304 UNREACHABLE();
3307 } 3305 }
3308 } 3306 }
3309 3307
3310 } // namespace dart 3308 } // namespace dart
OLDNEW
« no previous file with comments | « 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