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

Unified Diff: runtime/vm/raw_object_snapshot.cc

Issue 998763002: While creating snapshots do not write out fields of an empty context and while reading do not creat… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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/object.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/raw_object_snapshot.cc
===================================================================
--- runtime/vm/raw_object_snapshot.cc (revision 44383)
+++ runtime/vm/raw_object_snapshot.cc (working copy)
@@ -1366,23 +1366,26 @@
// Allocate context object.
int32_t num_vars = reader->Read<int32_t>();
- Context& context = Context::ZoneHandle(
- reader->isolate(), NEW_OBJECT_WITH_LEN(Context, num_vars));
+ Context& context = Context::ZoneHandle(reader->isolate());
reader->AddBackRef(object_id, &context, kIsDeserialized);
+ if (num_vars == 0) {
+ context ^= reader->object_store()->empty_context();
+ } else {
+ context ^= NEW_OBJECT_WITH_LEN(Context, num_vars);
- // Set the object tags.
- context.set_tags(tags);
+ // Set the object tags.
+ context.set_tags(tags);
- // Set all the object fields.
- // TODO(5411462): Need to assert No GC can happen here, even though
- // allocations may happen.
- intptr_t num_flds = (context.raw()->to(num_vars) - context.raw()->from());
- for (intptr_t i = 0; i <= num_flds; i++) {
- (*reader->PassiveObjectHandle()) = reader->ReadObjectRef();
- context.StorePointer((context.raw()->from() + i),
- reader->PassiveObjectHandle()->raw());
+ // Set all the object fields.
+ // TODO(5411462): Need to assert No GC can happen here, even though
+ // allocations may happen.
+ intptr_t num_flds = (context.raw()->to(num_vars) - context.raw()->from());
+ for (intptr_t i = 0; i <= num_flds; i++) {
+ (*reader->PassiveObjectHandle()) = reader->ReadObjectRef();
+ context.StorePointer((context.raw()->from() + i),
+ reader->PassiveObjectHandle()->raw());
+ }
}
-
return context.raw();
}
@@ -1400,11 +1403,13 @@
writer->WriteTags(writer->GetObjectTags(this));
// Write out num of variables in the context.
- writer->Write<int32_t>(ptr()->num_variables_);
-
- // Write out all the object pointer fields.
- SnapshotWriterVisitor visitor(writer);
- visitor.VisitPointers(from(), to(ptr()->num_variables_));
+ int32_t num_variables = ptr()->num_variables_;
+ writer->Write<int32_t>(num_variables);
+ if (num_variables != 0) {
+ // Write out all the object pointer fields.
+ SnapshotWriterVisitor visitor(writer);
+ visitor.VisitPointers(from(), to(num_variables));
+ }
}
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698