| Index: runtime/vm/raw_object_snapshot.cc
|
| diff --git a/runtime/vm/raw_object_snapshot.cc b/runtime/vm/raw_object_snapshot.cc
|
| index 194317f1ed6e52fd1ce29df2617368f7ee50f933..a76a7e10f6b9fc9bfa35d6e3d0d5c76598439f1c 100644
|
| --- a/runtime/vm/raw_object_snapshot.cc
|
| +++ b/runtime/vm/raw_object_snapshot.cc
|
| @@ -1339,6 +1339,19 @@ void RawNamespace::WriteTo(SnapshotWriter* writer,
|
| }
|
|
|
|
|
| +#if defined(DEBUG)
|
| +static uword Checksum(uword entry, intptr_t size) {
|
| + uword sum = 0;
|
| + uword* start = reinterpret_cast<uword*>(entry);
|
| + uword* end = reinterpret_cast<uword*>(entry + size);
|
| + for (uword* cursor = start; cursor < end; cursor++) {
|
| + sum ^= *cursor;
|
| + }
|
| + return sum;
|
| +}
|
| +#endif
|
| +
|
| +
|
| RawCode* Code::ReadFrom(SnapshotReader* reader,
|
| intptr_t object_id,
|
| intptr_t tags,
|
| @@ -1354,20 +1367,66 @@ RawCode* Code::ReadFrom(SnapshotReader* reader,
|
| result.set_state_bits(reader->Read<int32_t>());
|
| result.set_lazy_deopt_pc_offset(-1);
|
|
|
| - // Set all the object fields.
|
| - READ_OBJECT_FIELDS(result,
|
| - result.raw()->from(), result.raw()->to_snapshot(),
|
| - kAsReference);
|
| - for (RawObject** ptr = result.raw()->to();
|
| - ptr > result.raw()->to_snapshot();
|
| - ptr--) {
|
| - result.StorePointer(ptr, Object::null());
|
| - }
|
| + int32_t text_offset = reader->Read<int32_t>();
|
| + int32_t instructions_size = reader->Read<int32_t>();
|
| + uword entry_point = reader->GetInstructionsAt(text_offset);
|
|
|
| - // Fix entry point.
|
| - uword new_entry = result.EntryPoint();
|
| - ASSERT(Dart::vm_isolate()->heap()->CodeContains(new_entry));
|
| - result.StoreNonPointer(&result.raw_ptr()->entry_point_, new_entry);
|
| +#if defined(DEBUG)
|
| + uword expected_check = reader->Read<uword>();
|
| + uword actual_check = Checksum(entry_point, instructions_size);
|
| + ASSERT(expected_check == actual_check);
|
| +#endif
|
| +
|
| + result.StoreNonPointer(&result.raw_ptr()->entry_point_, entry_point);
|
| +
|
| + result.StorePointer(reinterpret_cast<RawSmi*const*>(
|
| + &result.raw_ptr()->instructions_),
|
| + Smi::New(instructions_size));
|
| +
|
| + (*reader->PassiveObjectHandle()) ^= reader->ReadObjectImpl(kAsReference);
|
| + result.StorePointer(reinterpret_cast<RawObject*const*>(
|
| + &result.raw_ptr()->object_pool_),
|
| + reader->PassiveObjectHandle()->raw());
|
| +
|
| + (*reader->PassiveObjectHandle()) ^= reader->ReadObjectImpl(kAsReference);
|
| + result.StorePointer(&result.raw_ptr()->owner_,
|
| + reader->PassiveObjectHandle()->raw());
|
| +
|
| + (*reader->PassiveObjectHandle()) ^= reader->ReadObjectImpl(kAsReference);
|
| + result.StorePointer(reinterpret_cast<RawObject*const*>(
|
| + &result.raw_ptr()->exception_handlers_),
|
| + reader->PassiveObjectHandle()->raw());
|
| +
|
| + (*reader->PassiveObjectHandle()) ^= reader->ReadObjectImpl(kAsReference);
|
| + result.StorePointer(reinterpret_cast<RawObject*const*>(
|
| + &result.raw_ptr()->pc_descriptors_),
|
| + reader->PassiveObjectHandle()->raw());
|
| +
|
| + (*reader->PassiveObjectHandle()) ^= reader->ReadObjectImpl(kAsReference);
|
| + result.StorePointer(reinterpret_cast<RawObject*const*>(
|
| + &result.raw_ptr()->code_source_map_),
|
| + reader->PassiveObjectHandle()->raw());
|
| +
|
| + (*reader->PassiveObjectHandle()) ^= reader->ReadObjectImpl(kAsReference);
|
| + result.StorePointer(reinterpret_cast<RawObject*const*>(
|
| + &result.raw_ptr()->stackmaps_),
|
| + reader->PassiveObjectHandle()->raw());
|
| +
|
| + result.StorePointer(&result.raw_ptr()->deopt_info_array_,
|
| + Array::null());
|
| + result.StorePointer(&result.raw_ptr()->static_calls_target_table_,
|
| + Array::null());
|
| + result.StorePointer(&result.raw_ptr()->var_descriptors_,
|
| + LocalVarDescriptors::null());
|
| + result.StorePointer(&result.raw_ptr()->inlined_metadata_,
|
| + Array::null());
|
| + result.StorePointer(&result.raw_ptr()->comments_,
|
| + Array::null());
|
| + result.StorePointer(&result.raw_ptr()->return_address_metadata_,
|
| + Object::null());
|
| +
|
| + ASSERT(result.Size() == instructions_size);
|
| + ASSERT(result.EntryPoint() == entry_point);
|
|
|
| return result.raw();
|
| }
|
| @@ -1397,11 +1456,23 @@ void RawCode::WriteTo(SnapshotWriter* writer,
|
| // Write out all the non object fields.
|
| writer->Write<int32_t>(ptr()->state_bits_);
|
|
|
| - // Write out all the object pointer fields.
|
| - SnapshotWriterVisitor visitor(writer, kAsReference);
|
| - visitor.VisitPointers(from(), to_snapshot());
|
| + RawInstructions* instr = ptr()->instructions_;
|
| + intptr_t size = instr->ptr()->size_;
|
| + int32_t text_offset = writer->GetInstructionsId(instr, this);
|
| + writer->Write<int32_t>(text_offset);
|
| + writer->Write<int32_t>(size);
|
| +#if defined(DEBUG)
|
| + uword entry = ptr()->entry_point_;
|
| + uword check = Checksum(entry, size);
|
| + writer->Write<uword>(check);
|
| +#endif
|
|
|
| - writer->SetInstructionsCode(ptr()->instructions_, this);
|
| + writer->WriteObjectImpl(ptr()->object_pool_, kAsReference);
|
| + writer->WriteObjectImpl(ptr()->owner_, kAsReference);
|
| + writer->WriteObjectImpl(ptr()->exception_handlers_, kAsReference);
|
| + writer->WriteObjectImpl(ptr()->pc_descriptors_, kAsReference);
|
| + writer->WriteObjectImpl(ptr()->code_source_map_, kAsReference);
|
| + writer->WriteObjectImpl(ptr()->stackmaps_, kAsReference);
|
| }
|
|
|
|
|
| @@ -1410,21 +1481,8 @@ RawInstructions* Instructions::ReadFrom(SnapshotReader* reader,
|
| intptr_t tags,
|
| Snapshot::Kind kind,
|
| bool as_reference) {
|
| - ASSERT(reader->snapshot_code());
|
| - ASSERT(kind == Snapshot::kFull);
|
| -
|
| -#ifdef DEBUG
|
| - intptr_t full_tags = static_cast<uword>(reader->Read<intptr_t>());
|
| -#else
|
| - intptr_t full_tags = 0; // unused in release mode
|
| -#endif
|
| - intptr_t offset = reader->Read<int32_t>();
|
| - Instructions& result =
|
| - Instructions::ZoneHandle(reader->zone(),
|
| - reader->GetInstructionsAt(offset, full_tags));
|
| - reader->AddBackRef(object_id, &result, kIsDeserialized);
|
| -
|
| - return result.raw();
|
| + UNREACHABLE();
|
| + return Instructions::null();
|
| }
|
|
|
|
|
| @@ -1432,24 +1490,7 @@ void RawInstructions::WriteTo(SnapshotWriter* writer,
|
| intptr_t object_id,
|
| Snapshot::Kind kind,
|
| bool as_reference) {
|
| - ASSERT(writer->snapshot_code());
|
| - ASSERT(kind == Snapshot::kFull);
|
| -
|
| - writer->WriteInlinedObjectHeader(object_id);
|
| - writer->WriteVMIsolateObject(kInstructionsCid);
|
| - writer->WriteTags(writer->GetObjectTags(this));
|
| -
|
| -#ifdef DEBUG
|
| - // Instructions will be written pre-marked and in the VM heap. Write out
|
| - // the tags we expect to find when reading the snapshot for a sanity check
|
| - // that our offsets/alignment didn't get out of sync.
|
| - uword written_tags = writer->GetObjectTags(this);
|
| - written_tags = RawObject::VMHeapObjectTag::update(true, written_tags);
|
| - written_tags = RawObject::MarkBit::update(true, written_tags);
|
| - writer->Write<intptr_t>(written_tags);
|
| -#endif
|
| -
|
| - writer->Write<int32_t>(writer->GetInstructionsId(this));
|
| + UNREACHABLE();
|
| }
|
|
|
|
|
|
|