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

Unified Diff: runtime/vm/raw_object_snapshot.cc

Issue 1584443002: VM: Precompiled rodata snapshot. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: compute string hash if necessary Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/raw_object_snapshot.cc
diff --git a/runtime/vm/raw_object_snapshot.cc b/runtime/vm/raw_object_snapshot.cc
index 1a617bacaf32013d55ff7e5bf5a5f43760b43420..cfa19c47beed844fcba28efd133cf85644cbe87a 100644
--- a/runtime/vm/raw_object_snapshot.cc
+++ b/runtime/vm/raw_object_snapshot.cc
@@ -1477,7 +1477,11 @@ RawInstructions* Instructions::ReadFrom(SnapshotReader* reader,
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(),
@@ -1499,6 +1503,7 @@ void RawInstructions::WriteTo(SnapshotWriter* writer,
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.
@@ -1506,6 +1511,7 @@ void RawInstructions::WriteTo(SnapshotWriter* writer,
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));
}
@@ -1643,19 +1649,11 @@ RawPcDescriptors* PcDescriptors::ReadFrom(SnapshotReader* reader,
ASSERT(reader->snapshot_code());
ASSERT(kind == Snapshot::kFull);
- const int32_t length = reader->Read<int32_t>();
- PcDescriptors& result =
- PcDescriptors::ZoneHandle(reader->zone(),
- NEW_OBJECT_WITH_LEN(PcDescriptors, length));
+ intptr_t offset = reader->Read<int32_t>();
+ PcDescriptors& result = PcDescriptors::ZoneHandle(reader->zone());
+ result ^= reader->GetObjectAt(offset);
reader->AddBackRef(object_id, &result, kIsDeserialized);
- if (result.Length() > 0) {
- NoSafepointScope no_safepoint;
- intptr_t len = result.Length();
- uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data());
- reader->ReadBytes(data, len);
- }
-
return result.raw();
}
@@ -1671,12 +1669,8 @@ void RawPcDescriptors::WriteTo(SnapshotWriter* writer,
writer->WriteInlinedObjectHeader(object_id);
writer->WriteIndexedObject(kPcDescriptorsCid);
writer->WriteTags(writer->GetObjectTags(this));
- writer->Write<int32_t>(ptr()->length_);
- if (ptr()->length_ > 0) {
- intptr_t len = ptr()->length_;
- uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data());
- writer->WriteBytes(data, len);
- }
+
+ writer->Write<int32_t>(writer->GetObjectId(this));
}
@@ -1733,22 +1727,11 @@ RawStackmap* Stackmap::ReadFrom(SnapshotReader* reader,
ASSERT(reader->snapshot_code());
ASSERT(kind == Snapshot::kFull);
- const int32_t length = reader->Read<int32_t>();
- Stackmap& result =
- Stackmap::ZoneHandle(reader->zone(),
- reader->NewStackmap(length));
+ intptr_t offset = reader->Read<int32_t>();
+ Stackmap& result = Stackmap::ZoneHandle(reader->zone());
+ result ^= reader->GetObjectAt(offset);
reader->AddBackRef(object_id, &result, kIsDeserialized);
- result.SetRegisterBitCount(reader->Read<int32_t>());
- result.SetPcOffset(reader->Read<uint32_t>());
-
- if (length > 0) {
- NoSafepointScope no_safepoint;
- intptr_t len = (result.Length() + 7) / 8;
- uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data());
- reader->ReadBytes(data, len);
- }
-
return result.raw();
}
@@ -1765,14 +1748,7 @@ void RawStackmap::WriteTo(SnapshotWriter* writer,
writer->WriteIndexedObject(kStackmapCid);
writer->WriteTags(writer->GetObjectTags(this));
- writer->Write<int32_t>(ptr()->length_);
- writer->Write<int32_t>(ptr()->register_bit_count_);
- writer->Write<uint32_t>(ptr()->pc_offset_);
- if (ptr()->length_ > 0) {
- intptr_t len = (ptr()->length_ + 7) / 8;
- uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data());
- writer->WriteBytes(data, len);
- }
+ writer->Write<int32_t>(writer->GetObjectId(this));
}
@@ -2572,6 +2548,14 @@ RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader,
intptr_t tags,
Snapshot::Kind kind,
bool as_reference) {
+ if (reader->snapshot_code()) {
+ ASSERT(kind == Snapshot::kFull);
+ intptr_t offset = reader->Read<int32_t>();
+ String& result = String::ZoneHandle(reader->zone());
+ result ^= reader->GetObjectAt(offset);
+ reader->AddBackRef(object_id, &result, kIsDeserialized);
+ return raw(result);
+ }
// Read the length so that we can determine instance size to allocate.
ASSERT(reader != NULL);
intptr_t len = reader->ReadSmiValue();
@@ -2679,6 +2663,22 @@ void RawOneByteString::WriteTo(SnapshotWriter* writer,
intptr_t object_id,
Snapshot::Kind kind,
bool as_reference) {
+ if (writer->snapshot_code()) {
+ ASSERT(writer->snapshot_code());
+ ASSERT(kind == Snapshot::kFull);
+ // Assert that hash is computed.
+ if (ptr()->hash_ == NULL) {
+ ptr()->hash_ = Smi::New(String::Hash(ptr()->data(),
+ Smi::Value(ptr()->length_)));
+ }
+ ASSERT(ptr()->hash_ != NULL);
+ // Write out the serialization header value for this object.
+ writer->WriteInlinedObjectHeader(object_id);
+ writer->WriteIndexedObject(kOneByteStringCid);
+ writer->WriteTags(writer->GetObjectTags(this));
+ writer->Write<int32_t>(writer->GetObjectId(this));
+ return;
+ }
StringWriteTo(writer,
object_id,
kind,
« 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