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

Unified Diff: runtime/vm/raw_object_snapshot.cc

Issue 1323813004: Changes to prepare for allowing script snapshots to be taken after running the main application (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code-review-comments Created 5 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
Index: runtime/vm/raw_object_snapshot.cc
diff --git a/runtime/vm/raw_object_snapshot.cc b/runtime/vm/raw_object_snapshot.cc
index da3c3a646719b30974de152695bc6150a87bc1f3..00cddc02d0a89b8ded2d0e4785c5b139aaf1278e 100644
--- a/runtime/vm/raw_object_snapshot.cc
+++ b/runtime/vm/raw_object_snapshot.cc
@@ -604,7 +604,17 @@ void RawClosureData::WriteTo(SnapshotWriter* writer,
writer->WriteTags(writer->GetObjectTags(this));
// Context scope.
- // We don't write the context scope in the snapshot.
+ if (ptr()->context_scope_ == Object::empty_context_scope().raw()) {
+ writer->WriteVMIsolateObject(kEmptyContextScopeObject);
+ } else {
+ if (ptr()->context_scope_->ptr()->is_implicit_) {
+ writer->WriteObjectImpl(ptr()->context_scope_, kAsInlinedObject);
+ } else {
+ // We don't write non implicit context scopes in the snapshot.
+ writer->WriteVMIsolateObject(kNullObject);
+ }
+ }
+
writer->WriteObjectImpl(Object::null(), kAsInlinedObject);
// Parent function.
@@ -615,7 +625,7 @@ void RawClosureData::WriteTo(SnapshotWriter* writer,
// Static closure/Closure allocation stub.
// We don't write the closure or allocation stub in the snapshot.
- writer->WriteObjectImpl(Object::null(), kAsInlinedObject);
+ writer->WriteVMIsolateObject(kNullObject);
}
@@ -1619,6 +1629,27 @@ RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
intptr_t tags,
Snapshot::Kind kind) {
+ ASSERT(reader != NULL);
+
+ // Allocate context object.
+ bool is_implicit = reader->Read<bool>();
+ if (is_implicit) {
+ ContextScope& context_scope =
+ ContextScope::ZoneHandle(ContextScope::New(1, true));
+ reader->AddBackRef(object_id, &context_scope, kIsDeserialized);
+
+ *reader->TypeHandle() ^= reader->ReadObjectImpl(kAsInlinedObject);
+
+ // Create a descriptor for 'this' variable.
+ context_scope.SetTokenIndexAt(0, 0);
+ context_scope.SetNameAt(0, Symbols::This());
+ context_scope.SetIsFinalAt(0, true);
+ context_scope.SetIsConstAt(0, false);
+ context_scope.SetTypeAt(0, *reader->TypeHandle());
+ context_scope.SetContextIndexAt(0, 0);
+ context_scope.SetContextLevelAt(0, 0);
+ return context_scope.raw();
+ }
UNREACHABLE();
return NULL;
}
@@ -1627,6 +1658,27 @@ RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader,
void RawContextScope::WriteTo(SnapshotWriter* writer,
intptr_t object_id,
Snapshot::Kind kind) {
+ ASSERT(writer != NULL);
+
+ if (ptr()->is_implicit_) {
+ ASSERT(ptr()->num_variables_ == 1);
+ const VariableDesc* var = ptr()->VariableDescAddr(0);
+
+ // Write out the serialization header value for this object.
+ writer->WriteInlinedObjectHeader(object_id);
+
+ // Write out the class and tags information.
+ writer->WriteVMIsolateObject(kContextScopeCid);
+ writer->WriteTags(writer->GetObjectTags(this));
+
+ // Write out is_implicit flag for the context scope.
+ writer->Write<bool>(true);
+
+ // Write out the type of 'this' the variable.
+ writer->WriteObjectImpl(var->type, kAsInlinedObject);
+
+ return;
+ }
UNREACHABLE();
}
« runtime/vm/raw_object.h ('K') | « runtime/vm/raw_object.h ('k') | runtime/vm/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698