Index: runtime/vm/snapshot.cc |
diff --git a/runtime/vm/snapshot.cc b/runtime/vm/snapshot.cc |
index 515d5a560cf43df207f5c528d7733229d7ebf6e4..c7086a419da76d7e3e5ff32a68ab812d7dcd731f 100644 |
--- a/runtime/vm/snapshot.cc |
+++ b/runtime/vm/snapshot.cc |
@@ -2226,15 +2226,25 @@ void SnapshotWriter::WriteObjectImpl(RawObject* raw, bool as_reference) { |
return; |
} |
- if (as_reference && !raw->IsCanonical()) { |
- WriteObjectRef(raw); |
- } else { |
+ // Objects are usually writen as references to avoid deep recursion, but in |
+ // some places we know we are dealing with leaf or shallow objects and write |
+ // them inline. |
+ // Code and Instructions are written inline so that Functions and Code |
+ // can patch their entry points in their ReadFrom's. TODO(rmacnak): Remove the |
+ // special case for Code and Instructions and patch entries after the whole |
+ // graph has been loaded. |
+ if (!as_reference || |
+ raw->IsCanonical() || |
+ raw->IsCode() || |
+ raw->IsInstructions()) { |
// Object is being serialized, add it to the forward ref list and mark |
// it so that future references to this object in the snapshot will use |
// an object id, instead of trying to serialize it again. |
forward_list_->MarkAndAddObject(raw, kIsSerialized); |
WriteInlinedObject(raw); |
+ } else { |
+ WriteObjectRef(raw); |
} |
} |