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

Unified Diff: runtime/vm/snapshot.cc

Issue 10829444: Avoid trusting the length encoded in the Snapshot if there is an (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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/snapshot.h ('k') | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/snapshot.cc
===================================================================
--- runtime/vm/snapshot.cc (revision 11409)
+++ runtime/vm/snapshot.cc (working copy)
@@ -145,9 +145,12 @@
}
-SnapshotReader::SnapshotReader(const Snapshot* snapshot, Isolate* isolate)
- : BaseReader(snapshot->content(), snapshot->length()),
- kind_(snapshot->kind()),
+SnapshotReader::SnapshotReader(const uint8_t* buffer,
+ intptr_t size,
+ Snapshot::Kind kind,
+ Isolate* isolate)
+ : BaseReader(buffer, size),
+ kind_(kind),
isolate_(isolate),
cls_(Class::Handle()),
obj_(Object::Handle()),
@@ -156,7 +159,7 @@
type_(AbstractType::Handle()),
type_arguments_(AbstractTypeArguments::Handle()),
tokens_(Array::Handle()),
- backward_references_((snapshot->kind() == Snapshot::kFull) ?
+ backward_references_((kind == Snapshot::kFull) ?
kNumInitialReferencesInFullSnapshot :
kNumInitialReferences) {
}
@@ -857,13 +860,15 @@
}
-void SnapshotWriter::WriteFullSnapshot() {
- ASSERT(kind_ == Snapshot::kFull);
+void FullSnapshotWriter::WriteFullSnapshot() {
Isolate* isolate = Isolate::Current();
ASSERT(isolate != NULL);
ObjectStore* object_store = isolate->object_store();
ASSERT(object_store != NULL);
+ // Reserve space in the output buffer for a snapshot header.
+ ReserveHeader();
+
// Write out all the objects in the object store of the isolate which
// is the root set for all dart allocated objects at this point.
SnapshotWriterVisitor visitor(this, false);
@@ -872,8 +877,8 @@
// Write out all forwarded objects.
WriteForwardedObjects();
- // Finalize the snapshot buffer.
- FinalizeBuffer();
+ FillHeader(kind());
+ UnmarkAll();
}
@@ -1128,10 +1133,10 @@
ASSERT(kind() == Snapshot::kScript);
// Write out the library object.
+ ReserveHeader();
WriteObject(lib.raw());
-
- // Finalize the snapshot buffer.
- FinalizeBuffer();
+ FillHeader(kind());
+ UnmarkAll();
}
@@ -1146,4 +1151,12 @@
}
}
+
+void MessageWriter::WriteMessage(const Object& obj) {
+ ASSERT(kind() == Snapshot::kMessage);
+ WriteObject(obj.raw());
+ UnmarkAll();
+}
+
+
} // namespace dart
« no previous file with comments | « runtime/vm/snapshot.h ('k') | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698