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

Side by Side Diff: runtime/vm/snapshot.cc

Issue 1276753002: 1. Fix the type arguments recursion problem that gets introduced when canonicalization of type argu… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address-code-review 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') | runtime/vm/snapshot_test.cc » ('j') | 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 LongJumpScope jump; 207 LongJumpScope jump;
208 if (setjmp(*jump.Set()) == 0) { 208 if (setjmp(*jump.Set()) == 0) {
209 PassiveObject& obj = 209 PassiveObject& obj =
210 PassiveObject::Handle(isolate(), ReadObjectImpl(kAsInlinedObject)); 210 PassiveObject::Handle(isolate(), ReadObjectImpl(kAsInlinedObject));
211 for (intptr_t i = 0; i < backward_references_->length(); i++) { 211 for (intptr_t i = 0; i < backward_references_->length(); i++) {
212 if (!(*backward_references_)[i].is_deserialized()) { 212 if (!(*backward_references_)[i].is_deserialized()) {
213 ReadObjectImpl(kAsInlinedObject); 213 ReadObjectImpl(kAsInlinedObject);
214 (*backward_references_)[i].set_state(kIsDeserialized); 214 (*backward_references_)[i].set_state(kIsDeserialized);
215 } 215 }
216 } 216 }
217 ProcessDeferredCanonicalizations(); 217 if (kind() != Snapshot::kFull) {
218 ProcessDeferredCanonicalizations();
219 }
218 return obj.raw(); 220 return obj.raw();
219 } else { 221 } else {
220 // An error occurred while reading, return the error object. 222 // An error occurred while reading, return the error object.
221 const Error& err = Error::Handle(isolate()->object_store()->sticky_error()); 223 const Error& err = Error::Handle(isolate()->object_store()->sticky_error());
222 isolate()->object_store()->clear_sticky_error(); 224 isolate()->object_store()->clear_sticky_error();
223 return err.raw(); 225 return err.raw();
224 } 226 }
225 } 227 }
226 228
227 229
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 ASSERT(index >= max_vm_isolate_object_id_); 1150 ASSERT(index >= max_vm_isolate_object_id_);
1149 index -= max_vm_isolate_object_id_; 1151 index -= max_vm_isolate_object_id_;
1150 ASSERT(index < backward_references_->length()); 1152 ASSERT(index < backward_references_->length());
1151 BackRefNode& ref = (*backward_references_)[index]; 1153 BackRefNode& ref = (*backward_references_)[index];
1152 ref.AddPatchRecord(patch_object_id, patch_offset); 1154 ref.AddPatchRecord(patch_object_id, patch_offset);
1153 } 1155 }
1154 } 1156 }
1155 1157
1156 1158
1157 void SnapshotReader::ProcessDeferredCanonicalizations() { 1159 void SnapshotReader::ProcessDeferredCanonicalizations() {
1158 AbstractType& typeobj = AbstractType::Handle(); 1160 Type& typeobj = Type::Handle();
1159 TypeArguments& typeargs = TypeArguments::Handle(); 1161 TypeArguments& typeargs = TypeArguments::Handle();
1160 Object& newobj = Object::Handle(); 1162 Object& newobj = Object::Handle();
1161 for (intptr_t i = 0; i < backward_references_->length(); i++) { 1163 for (intptr_t i = 0; i < backward_references_->length(); i++) {
1162 BackRefNode& backref = (*backward_references_)[i]; 1164 BackRefNode& backref = (*backward_references_)[i];
1163 if (backref.defer_canonicalization()) { 1165 if (backref.defer_canonicalization()) {
1164 Object* objref = backref.reference(); 1166 Object* objref = backref.reference();
1167 bool needs_patching = false;
1165 // Object should either be an abstract type or a type argument. 1168 // Object should either be an abstract type or a type argument.
1166 if (objref->IsAbstractType()) { 1169 if (objref->IsType()) {
1167 typeobj ^= objref->raw(); 1170 typeobj ^= objref->raw();
1168 typeobj.ClearCanonical();
1169 newobj = typeobj.Canonicalize(); 1171 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 }
1170 } else { 1178 } else {
1171 ASSERT(objref->IsTypeArguments()); 1179 ASSERT(objref->IsTypeArguments());
1172 typeargs ^= objref->raw(); 1180 typeargs ^= objref->raw();
1173 typeargs.ClearCanonical();
1174 newobj = typeargs.Canonicalize(); 1181 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 }
1175 } 1188 }
1176 if (newobj.raw() == objref->raw()) { 1189 if (needs_patching) {
1177 // Restore Canonical bit.
1178 objref->SetCanonical();
1179 } else {
1180 ZoneGrowableArray<intptr_t>* patches = backref.patch_records(); 1190 ZoneGrowableArray<intptr_t>* patches = backref.patch_records();
1181 ASSERT(newobj.IsCanonical()); 1191 ASSERT(newobj.IsCanonical());
1182 ASSERT(patches != NULL); 1192 ASSERT(patches != NULL);
1183 for (intptr_t j = 0; j < patches->length(); j+=2) { 1193 for (intptr_t j = 0; j < patches->length(); j+=2) {
1184 NoSafepointScope no_safepoint; 1194 NoSafepointScope no_safepoint;
1185 intptr_t patch_object_id = (*patches)[j]; 1195 intptr_t patch_object_id = (*patches)[j];
1186 intptr_t patch_offset = (*patches)[j + 1]; 1196 intptr_t patch_offset = (*patches)[j + 1];
1187 Object* target = GetBackRef(patch_object_id); 1197 Object* target = GetBackRef(patch_object_id);
1188 RawObject** rawptr = 1198 RawObject** rawptr =
1189 reinterpret_cast<RawObject**>(target->raw()->ptr()); 1199 reinterpret_cast<RawObject**>(target->raw()->ptr());
1190 target->StorePointer((rawptr + patch_offset), newobj.raw()); 1200 target->StorePointer((rawptr + patch_offset), newobj.raw());
1191 } 1201 }
1192 } 1202 }
1193 } 1203 }
1194 } 1204 }
1195 } 1205 }
1196 1206
1197 1207
1198 void SnapshotReader::ArrayReadFrom(intptr_t object_id, 1208 void SnapshotReader::ArrayReadFrom(intptr_t object_id,
1199 const Array& result, 1209 const Array& result,
1200 intptr_t len, 1210 intptr_t len,
1201 intptr_t tags) { 1211 intptr_t tags) {
1202 // Set the object tags. 1212 // Set the object tags.
1203 result.set_tags(tags); 1213 result.set_tags(tags);
1204 1214
1205 // Setup the object fields. 1215 // Setup the object fields.
1206 const intptr_t typeargs_offset = 1216 const intptr_t typeargs_offset =
1207 reinterpret_cast<RawObject**>(&result.raw()->ptr()->type_arguments_) - 1217 GrowableObjectArray::type_arguments_offset() / kWordSize;
1208 reinterpret_cast<RawObject**>(result.raw()->ptr());
1209 *TypeArgumentsHandle() ^= ReadObjectImpl(kAsInlinedObject, 1218 *TypeArgumentsHandle() ^= ReadObjectImpl(kAsInlinedObject,
1210 object_id, 1219 object_id,
1211 typeargs_offset); 1220 typeargs_offset);
1212 result.SetTypeArguments(*TypeArgumentsHandle()); 1221 result.SetTypeArguments(*TypeArgumentsHandle());
1213 1222
1214 bool as_reference = RawObject::IsCanonical(tags) ? false : true; 1223 bool as_reference = RawObject::IsCanonical(tags) ? false : true;
1215 intptr_t offset = result.raw_ptr()->data() - 1224 intptr_t offset = result.raw_ptr()->data() -
1216 reinterpret_cast<RawObject**>(result.raw()->ptr()); 1225 reinterpret_cast<RawObject**>(result.raw()->ptr());
1217 for (intptr_t i = 0; i < len; i++) { 1226 for (intptr_t i = 0; i < len; i++) {
1218 *PassiveObjectHandle() = ReadObjectImpl(as_reference, 1227 *PassiveObjectHandle() = ReadObjectImpl(as_reference,
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after
2397 NoSafepointScope no_safepoint; 2406 NoSafepointScope no_safepoint;
2398 WriteObject(obj.raw()); 2407 WriteObject(obj.raw());
2399 UnmarkAll(); 2408 UnmarkAll();
2400 } else { 2409 } else {
2401 ThrowException(exception_type(), exception_msg()); 2410 ThrowException(exception_type(), exception_msg());
2402 } 2411 }
2403 } 2412 }
2404 2413
2405 2414
2406 } // namespace dart 2415 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object_snapshot.cc ('k') | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698