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

Unified Diff: runtime/vm/snapshot.cc

Issue 1279453005: Do not try to patch type objects that are already canonical. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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
« no previous file with comments | « no previous file | 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 b08e704d7b220ad08c1691e7c49f3b2a7c169cbb..0219aa8c257d09757bab1d34799e5234b0292136 100644
--- a/runtime/vm/snapshot.cc
+++ b/runtime/vm/snapshot.cc
@@ -1164,41 +1164,37 @@ void SnapshotReader::ProcessDeferredCanonicalizations() {
BackRefNode& backref = (*backward_references_)[i];
if (backref.defer_canonicalization()) {
Object* objref = backref.reference();
- bool needs_patching = false;
// Object should either be an abstract type or a type argument.
if (objref->IsType()) {
typeobj ^= objref->raw();
newobj = typeobj.Canonicalize();
- if ((newobj.raw() != typeobj.raw()) && !typeobj.IsRecursive()) {
- needs_patching = true;
- } else {
- // Set Canonical bit.
- objref->SetCanonical();
- }
} else {
ASSERT(objref->IsTypeArguments());
typeargs ^= objref->raw();
newobj = typeargs.Canonicalize();
- if ((newobj.raw() != typeargs.raw()) && !typeargs.IsRecursive()) {
- needs_patching = true;
- } else {
- // Set Canonical bit.
- objref->SetCanonical();
- }
}
- if (needs_patching) {
+ if (newobj.raw() != objref->raw()) {
ZoneGrowableArray<intptr_t>* patches = backref.patch_records();
ASSERT(newobj.IsCanonical());
ASSERT(patches != NULL);
+ // First we replace the back ref table with the canonical object.
+ *objref = newobj.raw();
+ // Now we go over all the patch records and patch the canonical object.
for (intptr_t j = 0; j < patches->length(); j+=2) {
NoSafepointScope no_safepoint;
intptr_t patch_object_id = (*patches)[j];
intptr_t patch_offset = (*patches)[j + 1];
Object* target = GetBackRef(patch_object_id);
- RawObject** rawptr =
- reinterpret_cast<RawObject**>(target->raw()->ptr());
- target->StorePointer((rawptr + patch_offset), newobj.raw());
+ // We should not backpatch an object that is canonical.
+ if (!target->IsCanonical()) {
+ RawObject** rawptr =
+ reinterpret_cast<RawObject**>(target->raw()->ptr());
+ target->StorePointer((rawptr + patch_offset), newobj.raw());
+ }
}
+ } else {
+ // Set Canonical bit.
+ objref->SetCanonical();
regis 2015/08/07 22:41:42 Is this necessary? It should get set by the Canoni
siva 2015/08/07 23:30:07 Changed it to an ASSERT.
}
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698