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

Unified Diff: runtime/vm/snapshot.cc

Issue 1151113002: Move bootstrap scripts and token streams to the VM isolate so that they become read only objects. T… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: self review Created 5 years, 7 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
« runtime/vm/object.cc ('K') | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/snapshot.cc
diff --git a/runtime/vm/snapshot.cc b/runtime/vm/snapshot.cc
index 8f3d2a6d2841eb72c8c0d47b40e210f300b246f7..ff91ba03e773639841b68776af4900f802bce5f0 100644
--- a/runtime/vm/snapshot.cc
+++ b/runtime/vm/snapshot.cc
@@ -1184,6 +1184,13 @@ RawApiError* VmIsolateSnapshotReader::ReadVmIsolateSnapshot() {
// Read in the symbol table.
object_store->symbol_table_ = reinterpret_cast<RawArray*>(ReadObject());
+ Symbols::InitOnceFromSnapshot(isolate);
+
+ // Read in all the script objects and the accompanying token streams
+ // for bootstrap libraries so that they are in the VM isolate's read
+ // only memory.
+ *(ArrayHandle()) ^= ReadObject();
+
// Validate the class table.
#if defined(DEBUG)
isolate->ValidateClassTable();
@@ -1466,6 +1473,41 @@ FullSnapshotWriter::FullSnapshotWriter(uint8_t** vm_isolate_snapshot_buffer,
}
+// An object visitor which will serialize all . This is used to
hausner 2015/05/21 20:37:13 missing word after "serialize all"? Lower case S i
siva 2015/05/22 18:09:27 Done.
+// Serialize all the script objects into the VM isolate heap.
+class ScriptVisitor : public ObjectVisitor {
+ public:
+ explicit ScriptVisitor(Isolate* isolate) :
+ ObjectVisitor(isolate),
+ objHandle_(Object::Handle(isolate)),
+ count_(0),
+ scripts_(NULL) {}
+
+ ScriptVisitor(Isolate* isolate, const Array* scripts) :
+ ObjectVisitor(isolate),
+ objHandle_(Object::Handle(isolate)),
+ count_(0),
+ scripts_(scripts) {}
+
+ void VisitObject(RawObject* obj) {
+ if (obj->IsScript()) {
+ if (scripts_ != NULL) {
+ objHandle_ = obj;
+ scripts_->SetAt(count_, objHandle_);
+ }
+ count_ += 1;
+ }
+ }
+
+ intptr_t count() const { return count_; }
+
+ private:
+ Object& objHandle_;
+ intptr_t count_;
+ const Array* scripts_;
+};
+
+
void FullSnapshotWriter::WriteVmIsolateSnapshot() {
ASSERT(vm_isolate_snapshot_buffer_ != NULL);
SnapshotWriter writer(Snapshot::kFull,
@@ -1485,7 +1527,18 @@ void FullSnapshotWriter::WriteVmIsolateSnapshot() {
isolate->ValidateClassTable();
#endif
- // Write full snapshot for a regular isolate.
+ // Collect all the script objects and their accompanying token stream objects
+ // into an array so that we can write it out as part of the VM isolate
+ // snapshot. We first count the number of script objects, allocate an array
+ // and then fill it up with the script objects.
+ ScriptVisitor scripts_counter(isolate);
+ isolate->heap()->old_space()->VisitObjects(&scripts_counter);
+ intptr_t count = scripts_counter.count();
+ const Array& scripts = Array::Handle(isolate, Array::New(count, Heap::kOld));
+ ScriptVisitor script_visitor(isolate, &scripts);
+ isolate->heap()->old_space()->VisitObjects(&script_visitor);
+
+ // Write full snapshot for the VM isolate.
// Setup for long jump in case there is an exception while writing
// the snapshot.
LongJumpScope jump;
@@ -1505,6 +1558,14 @@ void FullSnapshotWriter::WriteVmIsolateSnapshot() {
// snapshot of a regular dart isolate.
writer.WriteObject(object_store->symbol_table());
+ // Write out all the script objects and the accompanying token streams
+ // for the bootstrap libraries so that they are in the VM isolate
+ // read only memory.
+ writer.WriteObject(scripts.raw());
+
+ // Write out all forwarded objects.
+ writer.WriteForwardedObjects();
+
writer.FillHeader(writer.kind());
}
vm_isolate_snapshot_size_ = writer.BytesWritten();
« runtime/vm/object.cc ('K') | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698