Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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(); |
|
regis
2015/08/06 16:36:08
Ideally, in the case of a resursive type, Canonica
siva
2015/08/06 17:28:44
I was thinking of another approach wherein we alwa
regis
2015/08/06 18:24:35
We still have to make sure type tests succeed. Yes
| |
| 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()); |
| (...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2397 NoSafepointScope no_safepoint; | 2407 NoSafepointScope no_safepoint; |
| 2398 WriteObject(obj.raw()); | 2408 WriteObject(obj.raw()); |
| 2399 UnmarkAll(); | 2409 UnmarkAll(); |
| 2400 } else { | 2410 } else { |
| 2401 ThrowException(exception_type(), exception_msg()); | 2411 ThrowException(exception_type(), exception_msg()); |
| 2402 } | 2412 } |
| 2403 } | 2413 } |
| 2404 | 2414 |
| 2405 | 2415 |
| 2406 } // namespace dart | 2416 } // namespace dart |
| OLD | NEW |