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

Unified Diff: runtime/vm/snapshot.cc

Issue 10450014: Request for comments on overall approach. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix scavenger and freelist handling Created 8 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
Index: runtime/vm/snapshot.cc
diff --git a/runtime/vm/snapshot.cc b/runtime/vm/snapshot.cc
index f9f37749579c7e56d9b2bd3c2dfa4b6a0879a2c9..9fb17ff37e92f5da3be96b787871781250fed85c 100644
--- a/runtime/vm/snapshot.cc
+++ b/runtime/vm/snapshot.cc
@@ -364,7 +364,6 @@ RawObject* SnapshotReader::AllocateUninitialized(const Class& cls,
UNREACHABLE();
}
RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag);
- raw_obj->ptr()->class_ = cls.raw();
uword tags = 0;
intptr_t index = cls.index();
ASSERT(index != kIllegalObjectKind);
@@ -523,7 +522,7 @@ void SnapshotWriter::WriteObject(RawObject* rawobj) {
// Check if it is a code object in that case just write a Null object
// as we do not want code objects in the snapshot.
- if (rawobj->ptr()->class_ == Object::code_class()) {
+ if (RawObject::GetClass(GetObjectTags(rawobj)) == Object::code_class()) {
WriteIndexedObject(Object::kNullObject);
return;
}
@@ -547,7 +546,7 @@ void SnapshotWriter::UnmarkAll() {
NoGCScope no_gc;
for (intptr_t i = 0; i < forward_list_.length(); i++) {
RawObject* raw = forward_list_[i]->raw();
- raw->ptr()->class_ = forward_list_[i]->cls(); // Restore original class.
+ raw->ptr()->tags_ = forward_list_[i]->tags(); // Restore original class.
}
}
@@ -569,6 +568,17 @@ void SnapshotWriter::WriteFullSnapshot() {
}
+uword SnapshotWriter::GetObjectTags(RawObject* raw) {
+ uword tags = raw->ptr()->tags_;
+ if (SerializedHeaderTag::decode(tags) == kObjectId) {
+ intptr_t id = SerializedHeaderData::decode(tags);
+ return forward_list_[id - kMaxPredefinedObjectIds]->tags();
+ } else {
+ return tags;
+ }
+}
+
+
intptr_t SnapshotWriter::MarkObject(RawObject* raw, RawClass* cls) {
NoGCScope no_gc;
intptr_t object_id = forward_list_.length() + kMaxPredefinedObjectIds;
@@ -576,8 +586,9 @@ intptr_t SnapshotWriter::MarkObject(RawObject* raw, RawClass* cls) {
uword value = 0;
value = SerializedHeaderTag::update(kObjectId, value);
value = SerializedHeaderData::update(object_id, value);
- raw->ptr()->class_ = reinterpret_cast<RawClass*>(value);
- ForwardObjectNode* node = new ForwardObjectNode(raw, cls);
+ uword tags = raw->ptr()->tags_;
+ raw->ptr()->tags_ = value;
+ ForwardObjectNode* node = new ForwardObjectNode(raw, tags);
ASSERT(node != NULL);
forward_list_.Add(node);
return object_id;
@@ -586,16 +597,18 @@ intptr_t SnapshotWriter::MarkObject(RawObject* raw, RawClass* cls) {
void SnapshotWriter::WriteInlinedObject(RawObject* raw) {
NoGCScope no_gc;
- RawClass* cls = raw->ptr()->class_;
+ uword tags = raw->ptr()->tags_;
// Check if object has already been serialized, in that
// case just write the object id out.
- if (SerializedHeaderTag::decode(reinterpret_cast<uword>(cls)) == kObjectId) {
- intptr_t id = SerializedHeaderData::decode(reinterpret_cast<intptr_t>(cls));
+ if (SerializedHeaderTag::decode(tags) == kObjectId) {
+ intptr_t id = SerializedHeaderData::decode(tags);
WriteIndexedObject(id);
return;
}
+ RawClass* cls = raw->GetClass();
+
// Object is being serialized, add it to the forward ref list and mark
// it so that future references to this object in the snapshot will use
// an object id, instead of trying to serialize it again.
@@ -617,7 +630,7 @@ void SnapshotWriter::WriteInlinedObject(RawObject* raw) {
WriteIntptrValue(SerializedHeaderData::encode(kInstanceId));
// Write out the tags.
- WriteIntptrValue(raw->ptr()->tags_);
+ WriteIntptrValue(tags);
// Write out the class information for this object.
WriteObject(cls);

Powered by Google App Engine
This is Rietveld 408576698