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

Unified Diff: runtime/vm/snapshot.cc

Issue 1190143003: Fix for issue 23647 (https://github.com/dart-lang/sdk/issues/23647) (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address self review comments Created 5 years, 6 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/snapshot.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 8b77013cc998ca14a8609a3cd25f7cd16b7446d6..8b92f723173b3f9f7f85b8c64390ab7cf505c6ce 100644
--- a/runtime/vm/snapshot.cc
+++ b/runtime/vm/snapshot.cc
@@ -1282,6 +1282,19 @@ void SnapshotWriter::WriteObject(RawObject* rawobj) {
WriteForwardedObjects();
}
+#define VM_OBJECT_CLASS_LIST(V) \
+ V(OneByteString) \
+ V(Mint) \
+ V(Bigint) \
+ V(Double) \
+
+#define VM_OBJECT_WRITE(clazz) \
+ case clazz::kClassId: { \
+ object_id = forward_list_->AddObject(rawobj, kIsSerialized); \
+ Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(rawobj); \
+ raw_obj->WriteTo(this, object_id, kind()); \
+ return; \
+ } \
void SnapshotWriter::HandleVMIsolateObject(RawObject* rawobj) {
// Check if it is a singleton null object.
@@ -1345,22 +1358,48 @@ void SnapshotWriter::HandleVMIsolateObject(RawObject* rawobj) {
}
}
- // Check it is a predefined symbol in the VM isolate.
- id = Symbols::LookupVMSymbol(rawobj);
- if (id != kInvalidIndex) {
- WriteVMIsolateObject(id);
- return;
- }
+ if (kind() == Snapshot::kFull) {
+ // Check it is a predefined symbol in the VM isolate.
+ id = Symbols::LookupVMSymbol(rawobj);
+ if (id != kInvalidIndex) {
+ WriteVMIsolateObject(id);
+ return;
+ }
- // Check if it is an object from the vm isolate snapshot object table.
- id = FindVmSnapshotObject(rawobj);
- if (id != kInvalidIndex) {
- WriteIndexedObject(id);
- return;
+ // Check if it is an object from the vm isolate snapshot object table.
+ id = FindVmSnapshotObject(rawobj);
+ if (id != kInvalidIndex) {
+ WriteIndexedObject(id);
+ return;
+ }
+ } else {
+ // In the case of script snapshots or for messages we do not use
+ // the index into the vm isolate snapshot object table, instead we
+ // explicitly write the object out.
+ intptr_t object_id = forward_list_->FindObject(rawobj);
+ if (object_id != -1) {
rmacnak 2015/06/18 20:34:55 kInvalidIndex
+ WriteIndexedObject(object_id);
+ return;
+ } else {
+ switch (id) {
+ VM_OBJECT_CLASS_LIST(VM_OBJECT_WRITE)
+ case kTypedDataUint32ArrayCid: {
+ object_id = forward_list_->AddObject(rawobj, kIsSerialized);
+ RawTypedData* raw_obj = reinterpret_cast<RawTypedData*>(rawobj);
+ raw_obj->WriteTo(this, object_id, kind());
+ return;
+ }
+ default:
+ OS::Print("class id = %d\n", id);
+ break;
+ }
+ }
}
UNREACHABLE();
}
+#undef VM_OBJECT_WRITE
+
void SnapshotWriter::WriteObjectRef(RawObject* raw) {
// First check if object can be written as a simple predefined type.
@@ -1695,11 +1734,40 @@ intptr_t ForwardList::MarkAndAddObject(RawObject* raw, SerializeState state) {
}
+intptr_t ForwardList::AddObject(RawObject* raw, SerializeState state) {
+ NoSafepointScope no_safepoint;
+ intptr_t object_id = next_object_id();
+ ASSERT(object_id > 0 && object_id <= kMaxObjectId);
+ uword tags = raw->ptr()->tags_;
+ // OS::Print("tags = 0x%x\n", tags);
rmacnak 2015/06/18 20:34:55 slip
+ ASSERT(SerializedHeaderTag::decode(tags) != kObjectId);
+ Node* node = new Node(raw, tags, state);
+ ASSERT(node != NULL);
+ nodes_.Add(node);
+ return object_id;
+}
+
+
+intptr_t ForwardList::FindObject(RawObject* raw) {
+ NoSafepointScope no_safepoint;
+ intptr_t id;
+ for (id = first_object_id(); id < next_object_id(); ++id) {
+ const Node* node = NodeForObjectId(id);
+ if (raw == node->raw()) {
+ return id;
+ }
+ }
+ return kInvalidIndex;
+}
+
+
void ForwardList::UnmarkAll() const {
for (intptr_t id = first_object_id(); id < next_object_id(); ++id) {
const Node* node = NodeForObjectId(id);
RawObject* raw = node->raw();
- raw->ptr()->tags_ = node->tags(); // Restore original tags.
+ if (SerializedHeaderTag::decode(raw->ptr()->tags_) == kObjectId) {
+ raw->ptr()->tags_ = node->tags(); // Restore original tags.
+ }
}
Isolate::Current()->DecrementNoSafepointScopeDepth();
}
« no previous file with comments | « runtime/vm/snapshot.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698