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

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: 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 | « no previous file | 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 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 1157
1158 1158
1159 void SnapshotReader::ProcessDeferredCanonicalizations() { 1159 void SnapshotReader::ProcessDeferredCanonicalizations() {
1160 Type& typeobj = Type::Handle(); 1160 Type& typeobj = Type::Handle();
1161 TypeArguments& typeargs = TypeArguments::Handle(); 1161 TypeArguments& typeargs = TypeArguments::Handle();
1162 Object& newobj = Object::Handle(); 1162 Object& newobj = Object::Handle();
1163 for (intptr_t i = 0; i < backward_references_->length(); i++) { 1163 for (intptr_t i = 0; i < backward_references_->length(); i++) {
1164 BackRefNode& backref = (*backward_references_)[i]; 1164 BackRefNode& backref = (*backward_references_)[i];
1165 if (backref.defer_canonicalization()) { 1165 if (backref.defer_canonicalization()) {
1166 Object* objref = backref.reference(); 1166 Object* objref = backref.reference();
1167 bool needs_patching = false;
1168 // Object should either be an abstract type or a type argument. 1167 // Object should either be an abstract type or a type argument.
1169 if (objref->IsType()) { 1168 if (objref->IsType()) {
1170 typeobj ^= objref->raw(); 1169 typeobj ^= objref->raw();
1171 newobj = typeobj.Canonicalize(); 1170 newobj = typeobj.Canonicalize();
1172 if ((newobj.raw() != typeobj.raw()) && !typeobj.IsRecursive()) {
1173 needs_patching = true;
1174 } else {
1175 // Set Canonical bit.
1176 objref->SetCanonical();
1177 }
1178 } else { 1171 } else {
1179 ASSERT(objref->IsTypeArguments()); 1172 ASSERT(objref->IsTypeArguments());
1180 typeargs ^= objref->raw(); 1173 typeargs ^= objref->raw();
1181 newobj = typeargs.Canonicalize(); 1174 newobj = typeargs.Canonicalize();
1182 if ((newobj.raw() != typeargs.raw()) && !typeargs.IsRecursive()) {
1183 needs_patching = true;
1184 } else {
1185 // Set Canonical bit.
1186 objref->SetCanonical();
1187 }
1188 } 1175 }
1189 if (needs_patching) { 1176 if (newobj.raw() != objref->raw()) {
1190 ZoneGrowableArray<intptr_t>* patches = backref.patch_records(); 1177 ZoneGrowableArray<intptr_t>* patches = backref.patch_records();
1191 ASSERT(newobj.IsCanonical()); 1178 ASSERT(newobj.IsCanonical());
1192 ASSERT(patches != NULL); 1179 ASSERT(patches != NULL);
1180 // First we replace the back ref table with the canonical object.
1181 *objref = newobj.raw();
1182 // Now we go over all the patch records and patch the canonical object.
1193 for (intptr_t j = 0; j < patches->length(); j+=2) { 1183 for (intptr_t j = 0; j < patches->length(); j+=2) {
1194 NoSafepointScope no_safepoint; 1184 NoSafepointScope no_safepoint;
1195 intptr_t patch_object_id = (*patches)[j]; 1185 intptr_t patch_object_id = (*patches)[j];
1196 intptr_t patch_offset = (*patches)[j + 1]; 1186 intptr_t patch_offset = (*patches)[j + 1];
1197 Object* target = GetBackRef(patch_object_id); 1187 Object* target = GetBackRef(patch_object_id);
1198 RawObject** rawptr = 1188 // We should not backpatch an object that is canonical.
1199 reinterpret_cast<RawObject**>(target->raw()->ptr()); 1189 if (!target->IsCanonical()) {
1200 target->StorePointer((rawptr + patch_offset), newobj.raw()); 1190 RawObject** rawptr =
1191 reinterpret_cast<RawObject**>(target->raw()->ptr());
1192 target->StorePointer((rawptr + patch_offset), newobj.raw());
1193 }
1201 } 1194 }
1195 } else {
1196 // Set Canonical bit.
1197 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.
1202 } 1198 }
1203 } 1199 }
1204 } 1200 }
1205 } 1201 }
1206 1202
1207 1203
1208 void SnapshotReader::ArrayReadFrom(intptr_t object_id, 1204 void SnapshotReader::ArrayReadFrom(intptr_t object_id,
1209 const Array& result, 1205 const Array& result,
1210 intptr_t len, 1206 intptr_t len,
1211 intptr_t tags) { 1207 intptr_t tags) {
(...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2406 NoSafepointScope no_safepoint; 2402 NoSafepointScope no_safepoint;
2407 WriteObject(obj.raw()); 2403 WriteObject(obj.raw());
2408 UnmarkAll(); 2404 UnmarkAll();
2409 } else { 2405 } else {
2410 ThrowException(exception_type(), exception_msg()); 2406 ThrowException(exception_type(), exception_msg());
2411 } 2407 }
2412 } 2408 }
2413 2409
2414 2410
2415 } // namespace dart 2411 } // namespace dart
OLDNEW
« 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