| 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/bigint_operations.h" | 5 #include "vm/bigint_operations.h" |
| 6 #include "vm/object.h" | 6 #include "vm/object.h" |
| 7 #include "vm/object_store.h" | 7 #include "vm/object_store.h" |
| 8 #include "vm/snapshot.h" | 8 #include "vm/snapshot.h" |
| 9 #include "vm/symbols.h" | 9 #include "vm/symbols.h" |
| 10 #include "vm/visitor.h" | 10 #include "vm/visitor.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 RawType* Type::ReadFrom(SnapshotReader* reader, | 188 RawType* Type::ReadFrom(SnapshotReader* reader, |
| 189 intptr_t object_id, | 189 intptr_t object_id, |
| 190 intptr_t tags, | 190 intptr_t tags, |
| 191 Snapshot::Kind kind) { | 191 Snapshot::Kind kind) { |
| 192 ASSERT(reader != NULL); | 192 ASSERT(reader != NULL); |
| 193 | 193 |
| 194 // Allocate type object. | 194 // Allocate type object. |
| 195 Type& type = Type::ZoneHandle(reader->isolate(), NEW_OBJECT(Type)); | 195 Type& type = Type::ZoneHandle(reader->isolate(), NEW_OBJECT(Type)); |
| 196 reader->AddBackRef(object_id, &type, kIsDeserialized); | 196 reader->AddBackRef(object_id, &type, kIsDeserialized); |
| 197 | 197 |
| 198 // Set the object tags. | |
| 199 type.set_tags(tags); | |
| 200 | |
| 201 // Set all non object fields. | 198 // Set all non object fields. |
| 202 type.set_token_pos(reader->ReadIntptrValue()); | 199 type.set_token_pos(reader->ReadIntptrValue()); |
| 203 type.set_type_state(reader->Read<int8_t>()); | 200 type.set_type_state(reader->Read<int8_t>()); |
| 204 | 201 |
| 205 // Set all the object fields. | 202 // Set all the object fields. |
| 206 // TODO(5411462): Need to assert No GC can happen here, even though | 203 // TODO(5411462): Need to assert No GC can happen here, even though |
| 207 // allocations may happen. | 204 // allocations may happen. |
| 208 intptr_t num_flds = (type.raw()->to() - type.raw()->from()); | 205 intptr_t num_flds = (type.raw()->to() - type.raw()->from()); |
| 209 for (intptr_t i = 0; i <= num_flds; i++) { | 206 for (intptr_t i = 0; i <= num_flds; i++) { |
| 210 type.StorePointer((type.raw()->from() + i), reader->ReadObjectRef()); | 207 type.StorePointer((type.raw()->from() + i), reader->ReadObjectRef()); |
| 211 } | 208 } |
| 212 | 209 |
| 213 // If object needs to be a canonical object, Canonicalize it. | 210 // If object needs to be a canonical object, Canonicalize it. |
| 214 if ((kind != Snapshot::kFull) && type.IsCanonical()) { | 211 if ((kind != Snapshot::kFull) && RawObject::IsCanonical(tags)) { |
| 215 type ^= type.Canonicalize(); | 212 type ^= type.Canonicalize(); |
| 216 } | 213 } |
| 214 |
| 215 // Set the object tags (This is done after 'Canonicalize', which |
| 216 // does not canonicalize a type already marked as canonical). |
| 217 type.set_tags(tags); |
| 218 |
| 217 return type.raw(); | 219 return type.raw(); |
| 218 } | 220 } |
| 219 | 221 |
| 220 | 222 |
| 221 void RawType::WriteTo(SnapshotWriter* writer, | 223 void RawType::WriteTo(SnapshotWriter* writer, |
| 222 intptr_t object_id, | 224 intptr_t object_id, |
| 223 Snapshot::Kind kind) { | 225 Snapshot::Kind kind) { |
| 224 ASSERT(writer != NULL); | 226 ASSERT(writer != NULL); |
| 225 | 227 |
| 226 // Write out the serialization header value for this object. | 228 // Write out the serialization header value for this object. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 TypeArguments& type_arguments = TypeArguments::ZoneHandle( | 327 TypeArguments& type_arguments = TypeArguments::ZoneHandle( |
| 326 reader->isolate(), NEW_OBJECT_WITH_LEN_SPACE(TypeArguments, len, kind)); | 328 reader->isolate(), NEW_OBJECT_WITH_LEN_SPACE(TypeArguments, len, kind)); |
| 327 reader->AddBackRef(object_id, &type_arguments, kIsDeserialized); | 329 reader->AddBackRef(object_id, &type_arguments, kIsDeserialized); |
| 328 | 330 |
| 329 // Now set all the object fields. | 331 // Now set all the object fields. |
| 330 for (intptr_t i = 0; i < len; i++) { | 332 for (intptr_t i = 0; i < len; i++) { |
| 331 *reader->TypeHandle() ^= reader->ReadObjectImpl(); | 333 *reader->TypeHandle() ^= reader->ReadObjectImpl(); |
| 332 type_arguments.SetTypeAt(i, *reader->TypeHandle()); | 334 type_arguments.SetTypeAt(i, *reader->TypeHandle()); |
| 333 } | 335 } |
| 334 | 336 |
| 337 // If object needs to be a canonical object, Canonicalize it. |
| 338 if ((kind != Snapshot::kFull) && RawObject::IsCanonical(tags)) { |
| 339 type_arguments ^= type_arguments.Canonicalize(); |
| 340 } |
| 341 |
| 335 // Set the object tags (This is done after setting the object fields | 342 // Set the object tags (This is done after setting the object fields |
| 336 // because 'SetTypeAt' has an assertion to check if the object is not | 343 // because 'SetTypeAt' has an assertion to check if the object is not |
| 337 // already canonical). | 344 // already canonical. Also, this is done after 'Canonicalize', which |
| 345 // does not canonicalize a type already marked as canonical). |
| 338 type_arguments.set_tags(tags); | 346 type_arguments.set_tags(tags); |
| 339 | 347 |
| 340 // If object needs to be a canonical object, Canonicalize it. | |
| 341 if ((kind != Snapshot::kFull) && type_arguments.IsCanonical()) { | |
| 342 type_arguments ^= type_arguments.Canonicalize(); | |
| 343 } | |
| 344 return type_arguments.raw(); | 348 return type_arguments.raw(); |
| 345 } | 349 } |
| 346 | 350 |
| 347 | 351 |
| 348 void RawTypeArguments::WriteTo(SnapshotWriter* writer, | 352 void RawTypeArguments::WriteTo(SnapshotWriter* writer, |
| 349 intptr_t object_id, | 353 intptr_t object_id, |
| 350 Snapshot::Kind kind) { | 354 Snapshot::Kind kind) { |
| 351 ASSERT(writer != NULL); | 355 ASSERT(writer != NULL); |
| 352 | 356 |
| 353 // Write out the serialization header value for this object. | 357 // Write out the serialization header value for this object. |
| (...skipping 1970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2324 // Write out the class and tags information. | 2328 // Write out the class and tags information. |
| 2325 writer->WriteIndexedObject(kWeakPropertyCid); | 2329 writer->WriteIndexedObject(kWeakPropertyCid); |
| 2326 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 2330 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 2327 | 2331 |
| 2328 // Write out all the other fields. | 2332 // Write out all the other fields. |
| 2329 writer->Write<RawObject*>(ptr()->key_); | 2333 writer->Write<RawObject*>(ptr()->key_); |
| 2330 writer->Write<RawObject*>(ptr()->value_); | 2334 writer->Write<RawObject*>(ptr()->value_); |
| 2331 } | 2335 } |
| 2332 | 2336 |
| 2333 } // namespace dart | 2337 } // namespace dart |
| OLD | NEW |