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

Side by Side 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: code-review-comments 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/raw_object_snapshot.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/snapshot.h" 5 #include "vm/snapshot.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 1161
1162 1162
1163 void SnapshotReader::ProcessDeferredCanonicalizations() { 1163 void SnapshotReader::ProcessDeferredCanonicalizations() {
1164 Type& typeobj = Type::Handle(); 1164 Type& typeobj = Type::Handle();
1165 TypeArguments& typeargs = TypeArguments::Handle(); 1165 TypeArguments& typeargs = TypeArguments::Handle();
1166 Object& newobj = Object::Handle(); 1166 Object& newobj = Object::Handle();
1167 for (intptr_t i = 0; i < backward_references_->length(); i++) { 1167 for (intptr_t i = 0; i < backward_references_->length(); i++) {
1168 BackRefNode& backref = (*backward_references_)[i]; 1168 BackRefNode& backref = (*backward_references_)[i];
1169 if (backref.defer_canonicalization()) { 1169 if (backref.defer_canonicalization()) {
1170 Object* objref = backref.reference(); 1170 Object* objref = backref.reference();
1171 bool needs_patching = false;
1172 // Object should either be an abstract type or a type argument. 1171 // Object should either be an abstract type or a type argument.
1173 if (objref->IsType()) { 1172 if (objref->IsType()) {
1174 typeobj ^= objref->raw(); 1173 typeobj ^= objref->raw();
1175 newobj = typeobj.Canonicalize(); 1174 newobj = typeobj.Canonicalize();
1176 if ((newobj.raw() != typeobj.raw()) && !typeobj.IsRecursive()) {
1177 needs_patching = true;
1178 } else {
1179 // Set Canonical bit.
1180 objref->SetCanonical();
1181 }
1182 } else { 1175 } else {
1183 ASSERT(objref->IsTypeArguments()); 1176 ASSERT(objref->IsTypeArguments());
1184 typeargs ^= objref->raw(); 1177 typeargs ^= objref->raw();
1185 newobj = typeargs.Canonicalize(); 1178 newobj = typeargs.Canonicalize();
1186 if ((newobj.raw() != typeargs.raw()) && !typeargs.IsRecursive()) {
1187 needs_patching = true;
1188 } else {
1189 // Set Canonical bit.
1190 objref->SetCanonical();
1191 }
1192 } 1179 }
1193 if (needs_patching) { 1180 if (newobj.raw() != objref->raw()) {
1194 ZoneGrowableArray<intptr_t>* patches = backref.patch_records(); 1181 ZoneGrowableArray<intptr_t>* patches = backref.patch_records();
1195 ASSERT(newobj.IsCanonical()); 1182 ASSERT(newobj.IsCanonical());
1196 ASSERT(patches != NULL); 1183 ASSERT(patches != NULL);
1184 // First we replace the back ref table with the canonical object.
1185 *objref = newobj.raw();
1186 // Now we go over all the patch records and patch the canonical object.
1197 for (intptr_t j = 0; j < patches->length(); j+=2) { 1187 for (intptr_t j = 0; j < patches->length(); j+=2) {
1198 NoSafepointScope no_safepoint; 1188 NoSafepointScope no_safepoint;
1199 intptr_t patch_object_id = (*patches)[j]; 1189 intptr_t patch_object_id = (*patches)[j];
1200 intptr_t patch_offset = (*patches)[j + 1]; 1190 intptr_t patch_offset = (*patches)[j + 1];
1201 Object* target = GetBackRef(patch_object_id); 1191 Object* target = GetBackRef(patch_object_id);
1202 RawObject** rawptr = 1192 // We should not backpatch an object that is canonical.
1203 reinterpret_cast<RawObject**>(target->raw()->ptr()); 1193 if (!target->IsCanonical()) {
1204 target->StorePointer((rawptr + patch_offset), newobj.raw()); 1194 RawObject** rawptr =
1195 reinterpret_cast<RawObject**>(target->raw()->ptr());
1196 target->StorePointer((rawptr + patch_offset), newobj.raw());
1197 }
1205 } 1198 }
1199 } else {
1200 ASSERT(objref->IsCanonical());
1206 } 1201 }
1207 } 1202 }
1208 } 1203 }
1209 } 1204 }
1210 1205
1211 1206
1212 void SnapshotReader::ArrayReadFrom(intptr_t object_id, 1207 void SnapshotReader::ArrayReadFrom(intptr_t object_id,
1213 const Array& result, 1208 const Array& result,
1214 intptr_t len, 1209 intptr_t len,
1215 intptr_t tags) { 1210 intptr_t tags) {
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2402 NoSafepointScope no_safepoint; 2397 NoSafepointScope no_safepoint;
2403 WriteObject(obj.raw()); 2398 WriteObject(obj.raw());
2404 UnmarkAll(); 2399 UnmarkAll();
2405 } else { 2400 } else {
2406 ThrowException(exception_type(), exception_msg()); 2401 ThrowException(exception_type(), exception_msg());
2407 } 2402 }
2408 } 2403 }
2409 2404
2410 2405
2411 } // namespace dart 2406 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object_snapshot.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698