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

Unified Diff: runtime/vm/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: sync 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/snapshot.cc
diff --git a/runtime/vm/snapshot.cc b/runtime/vm/snapshot.cc
index 85099cca5c331ac19b8e367b8c48f82a4de8efe0..c4aeeef76f4c656e28bf7491db7432a17d133002 100644
--- a/runtime/vm/snapshot.cc
+++ b/runtime/vm/snapshot.cc
@@ -198,6 +198,8 @@ SnapshotReader::SnapshotReader(
data_(ExternalTypedData::Handle(zone_)),
typed_data_(TypedData::Handle(zone_)),
code_(Code::Handle(zone_)),
+ function_(Function::Handle(zone_)),
+ megamorphic_cache_(MegamorphicCache::Handle(zone_)),
error_(UnhandledException::Handle(zone_)),
max_vm_isolate_object_id_(
(kind == Snapshot::kFull) ?
@@ -664,6 +666,9 @@ RawApiError* SnapshotReader::ReadFullSnapshot() {
for (intptr_t i = 0; i <= num_flds; i++) {
*(object_store->from() + i) = ReadObjectImpl(kAsInlinedObject);
}
+ if (snapshot_code_) {
+ isolate->megamorphic_cache_table()->ReadFrom(this);
+ }
for (intptr_t i = 0; i < backward_references_->length(); i++) {
if (!(*backward_references_)[i].is_deserialized()) {
ReadObjectImpl(kAsInlinedObject);
@@ -1171,9 +1176,18 @@ void InstructionsWriter::WriteAssembly() {
stream_.Print(".text\n");
stream_.Print(".globl _kInstructionsSnapshot\n");
- stream_.Print(".balign %" Pd ", 0\n", OS::PreferredCodeAlignment());
+ stream_.Print(".balign %" Pd ", 0\n", OS::kMaxPreferredCodeAlignment);
stream_.Print("_kInstructionsSnapshot:\n");
+ // This head also provides the gap to make the instructions snapshot
+ // look like a HeapPage.
+ intptr_t instructions_length = next_offset_;
+ stream_.Print(".quad 0x%0.16" Px64 "\n", instructions_length);
+ intptr_t header_quads = HeaderSize() / sizeof(uint64_t);
+ for (intptr_t i = 1; i < header_quads; i++) {
+ stream_.Print(".quad 0\n");
+ }
+
Object& owner = Object::Handle(Z);
String& str = String::Handle(Z);
@@ -1186,6 +1200,21 @@ void InstructionsWriter::WriteAssembly() {
{
// 1. Write from the header to the entry point.
NoSafepointScope no_safepoint;
+
+ bool was_marked = insns.raw()->IsMarked();
+ bool was_vmheap = insns.raw()->IsVMHeapObject();
+
+ if (!was_marked) {
+ insns.raw()->SetMarkBit();
+ }
+ if (!was_vmheap) {
+ insns.raw()->SetVMHeapObject();
+ }
+
+ // Write Instructions with the mark and VM heap bits set.
+ ASSERT(insns.raw()->IsMarked());
+ ASSERT(insns.raw()->IsVMHeapObject());
+
uword beginning = reinterpret_cast<uword>(insns.raw()) - kHeapObjectTag;
uword entry = beginning + Instructions::HeaderSize();
@@ -1197,6 +1226,13 @@ void InstructionsWriter::WriteAssembly() {
cursor++) {
stream_.Print(".quad 0x%0.16" Px64 "\n", *cursor);
}
+
+ if (!was_vmheap) {
+ insns.raw()->ClearVMHeapObject();
+ }
+ if (!was_marked) {
+ insns.raw()->ClearMarkBit();
+ }
siva 2015/09/14 21:29:34 This style of setting and unsetting the mark bit a
rmacnak 2015/09/15 20:07:45 Done.
}
// 2. Write a label at the entry point.
@@ -1253,9 +1289,9 @@ RawInstructions* InstructionsReader::GetInstructionsAt(int32_t offset,
actual_tags);
}
- // TODO(rmacnak): The above contains stale pointers to a Code and an
- // ObjectPool. Return the actual result after calling convention change.
- return Instructions::null();
+ ASSERT(result->IsMarked());
+
+ return result;
}
@@ -1996,6 +2032,10 @@ void FullSnapshotWriter::WriteIsolateFullSnapshot() {
SnapshotWriterVisitor visitor(&writer, false);
object_store->VisitObjectPointers(&visitor);
+ if (snapshot_code_) {
+ isolate_->megamorphic_cache_table()->WriteTo(&writer);
+ }
+
// Write out all forwarded objects.
writer.WriteForwardedObjects();

Powered by Google App Engine
This is Rietveld 408576698