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

Unified Diff: runtime/vm/raw_object_snapshot.cc

Issue 10832199: Add a weak property type to the virtual machine. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address final review comments 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/raw_object.cc ('k') | runtime/vm/scavenger.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/raw_object_snapshot.cc
diff --git a/runtime/vm/raw_object_snapshot.cc b/runtime/vm/raw_object_snapshot.cc
index 855391edecb1b6acb0767e48b204fc6bf11256fb..f43db8204a5ddb9324141b1164354c3df717805f 100644
--- a/runtime/vm/raw_object_snapshot.cc
+++ b/runtime/vm/raw_object_snapshot.cc
@@ -2051,4 +2051,44 @@ void RawJSRegExp::WriteTo(SnapshotWriter* writer,
}
+RawWeakProperty* WeakProperty::ReadFrom(SnapshotReader* reader,
+ intptr_t object_id,
+ intptr_t tags,
+ Snapshot::Kind kind) {
+ ASSERT(reader != NULL);
+
+ // Allocate the weak property object.
+ WeakProperty& weak_property = WeakProperty::ZoneHandle(
+ reader->isolate(),
+ WeakProperty::New((kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew));
+ reader->AddBackRef(object_id, &weak_property, kIsDeserialized);
+
+ // Set the object tags.
+ weak_property.set_tags(tags);
+
+ // Set all the object fields.
+ weak_property.raw_ptr()->key_ = reader->ReadObjectRef();
+ weak_property.raw_ptr()->value_ = reader->ReadObjectRef();
+
+ return weak_property.raw();
+}
+
+
+void RawWeakProperty::WriteTo(SnapshotWriter* writer,
+ intptr_t object_id,
+ Snapshot::Kind kind) {
+ ASSERT(writer != NULL);
+
+ // Write out the serialization header value for this object.
+ writer->WriteInlinedObjectHeader(object_id);
+
+ // Write out the class and tags information.
+ writer->WriteIndexedObject(kWeakPropertyCid);
+ writer->WriteIntptrValue(writer->GetObjectTags(this));
+
+ // Write out all the other fields.
+ writer->Write<RawObject*>(ptr()->key_);
+ writer->Write<RawObject*>(ptr()->value_);
+}
+
} // namespace dart
« no previous file with comments | « runtime/vm/raw_object.cc ('k') | runtime/vm/scavenger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698