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/object.h" | 5 #include "vm/object.h" |
6 #include "vm/object_store.h" | 6 #include "vm/object_store.h" |
7 #include "vm/snapshot.h" | 7 #include "vm/snapshot.h" |
8 #include "vm/stub_code.h" | 8 #include "vm/stub_code.h" |
9 #include "vm/symbols.h" | 9 #include "vm/symbols.h" |
10 #include "vm/visitor.h" | 10 #include "vm/visitor.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #define OFFSET_OF_FROM(obj) \ | 24 #define OFFSET_OF_FROM(obj) \ |
25 obj.raw()->from() - reinterpret_cast<RawObject**>(obj.raw()->ptr()) | 25 obj.raw()->from() - reinterpret_cast<RawObject**>(obj.raw()->ptr()) |
26 | 26 |
27 RawClass* Class::ReadFrom(SnapshotReader* reader, | 27 RawClass* Class::ReadFrom(SnapshotReader* reader, |
28 intptr_t object_id, | 28 intptr_t object_id, |
29 intptr_t tags, | 29 intptr_t tags, |
30 Snapshot::Kind kind) { | 30 Snapshot::Kind kind) { |
31 ASSERT(reader != NULL); | 31 ASSERT(reader != NULL); |
32 | 32 |
33 Class& cls = Class::ZoneHandle(reader->zone(), Class::null()); | 33 Class& cls = Class::ZoneHandle(reader->zone(), Class::null()); |
| 34 bool is_in_fullsnapshot = reader->Read<bool>(); |
34 if ((kind == Snapshot::kFull) || | 35 if ((kind == Snapshot::kFull) || |
35 (kind == Snapshot::kScript && !RawObject::IsCreatedFromSnapshot(tags))) { | 36 (kind == Snapshot::kScript && !is_in_fullsnapshot)) { |
36 // Read in the base information. | 37 // Read in the base information. |
37 classid_t class_id = reader->ReadClassIDValue(); | 38 classid_t class_id = reader->ReadClassIDValue(); |
38 | 39 |
39 // Allocate class object of specified kind. | 40 // Allocate class object of specified kind. |
40 if (kind == Snapshot::kFull) { | 41 if (kind == Snapshot::kFull) { |
41 cls = reader->NewClass(class_id); | 42 cls = reader->NewClass(class_id); |
42 } else { | 43 } else { |
43 if (class_id < kNumPredefinedCids) { | 44 if (class_id < kNumPredefinedCids) { |
44 ASSERT((class_id >= kInstanceCid) && (class_id <= kMirrorReferenceCid)); | 45 ASSERT((class_id >= kInstanceCid) && (class_id <= kMirrorReferenceCid)); |
45 cls = reader->isolate()->class_table()->At(class_id); | 46 cls = reader->isolate()->class_table()->At(class_id); |
46 } else { | 47 } else { |
47 cls = New<Instance>(kIllegalCid); | 48 cls = New<Instance>(kIllegalCid); |
48 } | 49 } |
49 } | 50 } |
50 reader->AddBackRef(object_id, &cls, kIsDeserialized); | 51 reader->AddBackRef(object_id, &cls, kIsDeserialized); |
51 | 52 |
52 // Set the object tags. | |
53 cls.set_tags(tags); | |
54 | |
55 // Set all non object fields. | 53 // Set all non object fields. |
56 if (!RawObject::IsInternalVMdefinedClassId(class_id)) { | 54 if (!RawObject::IsInternalVMdefinedClassId(class_id)) { |
57 // Instance size of a VM defined class is already set up. | 55 // Instance size of a VM defined class is already set up. |
58 cls.set_instance_size_in_words(reader->Read<int32_t>()); | 56 cls.set_instance_size_in_words(reader->Read<int32_t>()); |
59 cls.set_next_field_offset_in_words(reader->Read<int32_t>()); | 57 cls.set_next_field_offset_in_words(reader->Read<int32_t>()); |
60 } | 58 } |
61 cls.set_type_arguments_field_offset_in_words(reader->Read<int32_t>()); | 59 cls.set_type_arguments_field_offset_in_words(reader->Read<int32_t>()); |
62 cls.set_num_type_arguments(reader->Read<int16_t>()); | 60 cls.set_num_type_arguments(reader->Read<int16_t>()); |
63 cls.set_num_own_type_arguments(reader->Read<int16_t>()); | 61 cls.set_num_own_type_arguments(reader->Read<int16_t>()); |
64 cls.set_num_native_fields(reader->Read<uint16_t>()); | 62 cls.set_num_native_fields(reader->Read<uint16_t>()); |
65 cls.set_token_pos(reader->Read<int32_t>()); | 63 cls.set_token_pos(reader->Read<int32_t>()); |
66 cls.set_state_bits(reader->Read<uint16_t>()); | 64 cls.set_state_bits(reader->Read<uint16_t>()); |
67 | 65 |
68 // Set all the object fields. | 66 // Set all the object fields. |
69 // TODO(5411462): Need to assert No GC can happen here, even though | 67 // TODO(5411462): Need to assert No GC can happen here, even though |
70 // allocations may happen. | 68 // allocations may happen. |
71 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); | 69 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); |
72 intptr_t from_offset = OFFSET_OF_FROM(cls); | 70 intptr_t from_offset = OFFSET_OF_FROM(cls); |
73 for (intptr_t i = 0; i <= num_flds; i++) { | 71 for (intptr_t i = 0; i <= num_flds; i++) { |
74 (*reader->PassiveObjectHandle()) = | 72 (*reader->PassiveObjectHandle()) = |
75 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); | 73 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); |
76 cls.StorePointer((cls.raw()->from() + i), | 74 cls.StorePointer((cls.raw()->from() + i), |
77 reader->PassiveObjectHandle()->raw()); | 75 reader->PassiveObjectHandle()->raw()); |
78 } | 76 } |
| 77 ASSERT(!cls.IsInFullSnapshot() || (kind == Snapshot::kFull)); |
79 } else { | 78 } else { |
80 cls ^= reader->ReadClassId(object_id); | 79 cls ^= reader->ReadClassId(object_id); |
| 80 ASSERT((kind == Snapshot::kMessage) || cls.IsInFullSnapshot()); |
81 } | 81 } |
82 return cls.raw(); | 82 return cls.raw(); |
83 } | 83 } |
84 | 84 |
85 | 85 |
86 void RawClass::WriteTo(SnapshotWriter* writer, | 86 void RawClass::WriteTo(SnapshotWriter* writer, |
87 intptr_t object_id, | 87 intptr_t object_id, |
88 Snapshot::Kind kind) { | 88 Snapshot::Kind kind) { |
89 ASSERT(writer != NULL); | 89 ASSERT(writer != NULL); |
| 90 bool is_in_fullsnapshot = Class::IsInFullSnapshot(this); |
90 | 91 |
91 // Write out the serialization header value for this object. | 92 // Write out the serialization header value for this object. |
92 writer->WriteInlinedObjectHeader(object_id); | 93 writer->WriteInlinedObjectHeader(object_id); |
93 | 94 |
| 95 // Write out the class and tags information. |
| 96 writer->WriteVMIsolateObject(kClassCid); |
| 97 writer->WriteTags(writer->GetObjectTags(this)); |
| 98 |
| 99 // Write out the boolean is_in_fullsnapshot first as this will |
| 100 // help the reader decide how the rest of the information needs |
| 101 // to be interpreted. |
| 102 writer->Write<bool>(is_in_fullsnapshot); |
| 103 |
94 if ((kind == Snapshot::kFull) || | 104 if ((kind == Snapshot::kFull) || |
95 (kind == Snapshot::kScript && | 105 (kind == Snapshot::kScript && !is_in_fullsnapshot)) { |
96 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this)))) { | |
97 // Write out the class and tags information. | |
98 writer->WriteVMIsolateObject(kClassCid); | |
99 writer->WriteTags(writer->GetObjectTags(this)); | |
100 | |
101 // Write out all the non object pointer fields. | 106 // Write out all the non object pointer fields. |
102 // NOTE: cpp_vtable_ is not written. | 107 // NOTE: cpp_vtable_ is not written. |
103 classid_t class_id = ptr()->id_; | 108 classid_t class_id = ptr()->id_; |
104 writer->Write<classid_t>(class_id); | 109 writer->Write<classid_t>(class_id); |
105 if (!RawObject::IsInternalVMdefinedClassId(class_id)) { | 110 if (!RawObject::IsInternalVMdefinedClassId(class_id)) { |
106 // We don't write the instance size of VM defined classes as they | 111 // We don't write the instance size of VM defined classes as they |
107 // are already setup during initialization as part of pre populating | 112 // are already setup during initialization as part of pre populating |
108 // the class table. | 113 // the class table. |
109 writer->Write<int32_t>(ptr()->instance_size_in_words_); | 114 writer->Write<int32_t>(ptr()->instance_size_in_words_); |
110 writer->Write<int32_t>(ptr()->next_field_offset_in_words_); | 115 writer->Write<int32_t>(ptr()->next_field_offset_in_words_); |
(...skipping 26 matching lines...) Expand all Loading... |
137 intptr_t object_id, | 142 intptr_t object_id, |
138 intptr_t tags, | 143 intptr_t tags, |
139 Snapshot::Kind kind) { | 144 Snapshot::Kind kind) { |
140 ASSERT(reader != NULL); | 145 ASSERT(reader != NULL); |
141 | 146 |
142 // Allocate unresolved class object. | 147 // Allocate unresolved class object. |
143 UnresolvedClass& unresolved_class = UnresolvedClass::ZoneHandle( | 148 UnresolvedClass& unresolved_class = UnresolvedClass::ZoneHandle( |
144 reader->zone(), NEW_OBJECT(UnresolvedClass)); | 149 reader->zone(), NEW_OBJECT(UnresolvedClass)); |
145 reader->AddBackRef(object_id, &unresolved_class, kIsDeserialized); | 150 reader->AddBackRef(object_id, &unresolved_class, kIsDeserialized); |
146 | 151 |
147 // Set the object tags. | |
148 unresolved_class.set_tags(tags); | |
149 | |
150 // Set all non object fields. | 152 // Set all non object fields. |
151 unresolved_class.set_token_pos(reader->Read<int32_t>()); | 153 unresolved_class.set_token_pos(reader->Read<int32_t>()); |
152 | 154 |
153 // Set all the object fields. | 155 // Set all the object fields. |
154 // TODO(5411462): Need to assert No GC can happen here, even though | 156 // TODO(5411462): Need to assert No GC can happen here, even though |
155 // allocations may happen. | 157 // allocations may happen. |
156 intptr_t num_flds = (unresolved_class.raw()->to() - | 158 intptr_t num_flds = (unresolved_class.raw()->to() - |
157 unresolved_class.raw()->from()); | 159 unresolved_class.raw()->from()); |
158 for (intptr_t i = 0; i <= num_flds; i++) { | 160 for (intptr_t i = 0; i <= num_flds; i++) { |
159 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | 161 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 // allocations may happen. | 224 // allocations may happen. |
223 intptr_t num_flds = (type.raw()->to() - type.raw()->from()); | 225 intptr_t num_flds = (type.raw()->to() - type.raw()->from()); |
224 intptr_t from_offset = OFFSET_OF_FROM(type); | 226 intptr_t from_offset = OFFSET_OF_FROM(type); |
225 for (intptr_t i = 0; i <= num_flds; i++) { | 227 for (intptr_t i = 0; i <= num_flds; i++) { |
226 (*reader->PassiveObjectHandle()) = | 228 (*reader->PassiveObjectHandle()) = |
227 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); | 229 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); |
228 type.StorePointer((type.raw()->from() + i), | 230 type.StorePointer((type.raw()->from() + i), |
229 reader->PassiveObjectHandle()->raw()); | 231 reader->PassiveObjectHandle()->raw()); |
230 } | 232 } |
231 | 233 |
232 // Set the object tags. | 234 // Set the canonical bit. |
233 type.set_tags(tags); | 235 if (!defer_canonicalization && RawObject::IsCanonical(tags)) { |
234 if (defer_canonicalization) { | 236 type.SetCanonical(); |
235 // We are deferring canonicalization so mark object as not canonical. | |
236 type.ClearCanonical(); | |
237 } | 237 } |
238 | 238 |
239 return type.raw(); | 239 return type.raw(); |
240 } | 240 } |
241 | 241 |
242 | 242 |
243 void RawType::WriteTo(SnapshotWriter* writer, | 243 void RawType::WriteTo(SnapshotWriter* writer, |
244 intptr_t object_id, | 244 intptr_t object_id, |
245 Snapshot::Kind kind) { | 245 Snapshot::Kind kind) { |
246 ASSERT(writer != NULL); | 246 ASSERT(writer != NULL); |
247 | 247 |
248 // Only resolved and finalized types should be written to a snapshot. | 248 // Only resolved and finalized types should be written to a snapshot. |
249 ASSERT((ptr()->type_state_ == RawType::kFinalizedInstantiated) || | 249 ASSERT((ptr()->type_state_ == RawType::kFinalizedInstantiated) || |
250 (ptr()->type_state_ == RawType::kFinalizedUninstantiated)); | 250 (ptr()->type_state_ == RawType::kFinalizedUninstantiated)); |
| 251 ASSERT(ptr()->type_class_ != Object::null()); |
251 | 252 |
252 // Write out the serialization header value for this object. | 253 // Write out the serialization header value for this object. |
253 writer->WriteInlinedObjectHeader(object_id); | 254 writer->WriteInlinedObjectHeader(object_id); |
254 | 255 |
255 // Write out the class and tags information. | 256 // Write out the class and tags information. |
256 writer->WriteIndexedObject(kTypeCid); | 257 writer->WriteIndexedObject(kTypeCid); |
257 writer->WriteTags(writer->GetObjectTags(this)); | 258 writer->WriteTags(writer->GetObjectTags(this)); |
258 | 259 |
259 // Write out all the non object pointer fields. | 260 // Write out all the non object pointer fields. |
260 writer->Write<int32_t>(ptr()->token_pos_); | 261 writer->Write<int32_t>(ptr()->token_pos_); |
261 writer->Write<int8_t>(ptr()->type_state_); | 262 writer->Write<int8_t>(ptr()->type_state_); |
262 | 263 |
263 // Write out all the object pointer fields. Since we will be canonicalizing | 264 // Write out all the object pointer fields. Since we will be canonicalizing |
264 // the type object when reading it back we should write out all the fields | 265 // the type object when reading it back we should write out all the fields |
265 // inline and not as references. | 266 // inline and not as references. |
| 267 ASSERT(ptr()->type_class_ != Object::null()); |
266 SnapshotWriterVisitor visitor(writer); | 268 SnapshotWriterVisitor visitor(writer); |
267 visitor.VisitPointers(from(), to()); | 269 visitor.VisitPointers(from(), to()); |
268 } | 270 } |
269 | 271 |
270 | 272 |
271 RawTypeRef* TypeRef::ReadFrom(SnapshotReader* reader, | 273 RawTypeRef* TypeRef::ReadFrom(SnapshotReader* reader, |
272 intptr_t object_id, | 274 intptr_t object_id, |
273 intptr_t tags, | 275 intptr_t tags, |
274 Snapshot::Kind kind) { | 276 Snapshot::Kind kind) { |
275 ASSERT(reader != NULL); | 277 ASSERT(reader != NULL); |
276 | 278 |
277 // Allocate type ref object. | 279 // Allocate type ref object. |
278 TypeRef& type_ref = TypeRef::ZoneHandle( | 280 TypeRef& type_ref = TypeRef::ZoneHandle( |
279 reader->zone(), NEW_OBJECT(TypeRef)); | 281 reader->zone(), NEW_OBJECT(TypeRef)); |
280 reader->AddBackRef(object_id, &type_ref, kIsDeserialized); | 282 reader->AddBackRef(object_id, &type_ref, kIsDeserialized); |
281 | 283 |
282 // Set the object tags. | |
283 type_ref.set_tags(tags); | |
284 | |
285 // Set all the object fields. | 284 // Set all the object fields. |
286 // TODO(5411462): Need to assert No GC can happen here, even though | 285 // TODO(5411462): Need to assert No GC can happen here, even though |
287 // allocations may happen. | 286 // allocations may happen. |
288 intptr_t num_flds = (type_ref.raw()->to() - type_ref.raw()->from()); | 287 intptr_t num_flds = (type_ref.raw()->to() - type_ref.raw()->from()); |
289 intptr_t from_offset = OFFSET_OF_FROM(type_ref); | 288 intptr_t from_offset = OFFSET_OF_FROM(type_ref); |
290 for (intptr_t i = 0; i <= num_flds; i++) { | 289 for (intptr_t i = 0; i <= num_flds; i++) { |
291 (*reader->PassiveObjectHandle()) = | 290 (*reader->PassiveObjectHandle()) = |
292 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); | 291 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); |
293 type_ref.StorePointer((type_ref.raw()->from() + i), | 292 type_ref.StorePointer((type_ref.raw()->from() + i), |
294 reader->PassiveObjectHandle()->raw()); | 293 reader->PassiveObjectHandle()->raw()); |
(...skipping 25 matching lines...) Expand all Loading... |
320 intptr_t object_id, | 319 intptr_t object_id, |
321 intptr_t tags, | 320 intptr_t tags, |
322 Snapshot::Kind kind) { | 321 Snapshot::Kind kind) { |
323 ASSERT(reader != NULL); | 322 ASSERT(reader != NULL); |
324 | 323 |
325 // Allocate type parameter object. | 324 // Allocate type parameter object. |
326 TypeParameter& type_parameter = TypeParameter::ZoneHandle( | 325 TypeParameter& type_parameter = TypeParameter::ZoneHandle( |
327 reader->zone(), NEW_OBJECT(TypeParameter)); | 326 reader->zone(), NEW_OBJECT(TypeParameter)); |
328 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized); | 327 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized); |
329 | 328 |
330 // Set the object tags. | |
331 type_parameter.set_tags(tags); | |
332 | |
333 // Set all non object fields. | 329 // Set all non object fields. |
334 type_parameter.set_token_pos(reader->Read<int32_t>()); | 330 type_parameter.set_token_pos(reader->Read<int32_t>()); |
335 type_parameter.set_index(reader->Read<int16_t>()); | 331 type_parameter.set_index(reader->Read<int16_t>()); |
336 type_parameter.set_type_state(reader->Read<int8_t>()); | 332 type_parameter.set_type_state(reader->Read<int8_t>()); |
337 | 333 |
338 // Set all the object fields. | 334 // Set all the object fields. |
339 // TODO(5411462): Need to assert No GC can happen here, even though | 335 // TODO(5411462): Need to assert No GC can happen here, even though |
340 // allocations may happen. | 336 // allocations may happen. |
341 intptr_t num_flds = (type_parameter.raw()->to() - | 337 intptr_t num_flds = (type_parameter.raw()->to() - |
342 type_parameter.raw()->from()); | 338 type_parameter.raw()->from()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 intptr_t object_id, | 378 intptr_t object_id, |
383 intptr_t tags, | 379 intptr_t tags, |
384 Snapshot::Kind kind) { | 380 Snapshot::Kind kind) { |
385 ASSERT(reader != NULL); | 381 ASSERT(reader != NULL); |
386 | 382 |
387 // Allocate bounded type object. | 383 // Allocate bounded type object. |
388 BoundedType& bounded_type = BoundedType::ZoneHandle( | 384 BoundedType& bounded_type = BoundedType::ZoneHandle( |
389 reader->zone(), NEW_OBJECT(BoundedType)); | 385 reader->zone(), NEW_OBJECT(BoundedType)); |
390 reader->AddBackRef(object_id, &bounded_type, kIsDeserialized); | 386 reader->AddBackRef(object_id, &bounded_type, kIsDeserialized); |
391 | 387 |
392 // Set the object tags. | |
393 bounded_type.set_tags(tags); | |
394 | |
395 // Set all the object fields. | 388 // Set all the object fields. |
396 // TODO(5411462): Need to assert No GC can happen here, even though | 389 // TODO(5411462): Need to assert No GC can happen here, even though |
397 // allocations may happen. | 390 // allocations may happen. |
398 intptr_t num_flds = (bounded_type.raw()->to() - | 391 intptr_t num_flds = (bounded_type.raw()->to() - |
399 bounded_type.raw()->from()); | 392 bounded_type.raw()->from()); |
400 intptr_t from_offset = OFFSET_OF_FROM(bounded_type); | 393 intptr_t from_offset = OFFSET_OF_FROM(bounded_type); |
401 for (intptr_t i = 0; i <= num_flds; i++) { | 394 for (intptr_t i = 0; i <= num_flds; i++) { |
402 (*reader->PassiveObjectHandle()) = | 395 (*reader->PassiveObjectHandle()) = |
403 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); | 396 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); |
404 bounded_type.StorePointer((bounded_type.raw()->from() + i), | 397 bounded_type.StorePointer((bounded_type.raw()->from() + i), |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 | 464 |
472 // Now set all the type fields. | 465 // Now set all the type fields. |
473 intptr_t offset = type_arguments.TypeAddr(0) - | 466 intptr_t offset = type_arguments.TypeAddr(0) - |
474 reinterpret_cast<RawAbstractType**>(type_arguments.raw()->ptr()); | 467 reinterpret_cast<RawAbstractType**>(type_arguments.raw()->ptr()); |
475 for (intptr_t i = 0; i < len; i++) { | 468 for (intptr_t i = 0; i < len; i++) { |
476 *reader->TypeHandle() ^= | 469 *reader->TypeHandle() ^= |
477 reader->ReadObjectImpl(kAsReference, object_id, (i + offset)); | 470 reader->ReadObjectImpl(kAsReference, object_id, (i + offset)); |
478 type_arguments.SetTypeAt(i, *reader->TypeHandle()); | 471 type_arguments.SetTypeAt(i, *reader->TypeHandle()); |
479 } | 472 } |
480 | 473 |
481 // Set the object tags . | 474 // Set the canonical bit. |
482 type_arguments.set_tags(tags); | 475 if (!defer_canonicalization && RawObject::IsCanonical(tags)) { |
483 if (defer_canonicalization) { | 476 type_arguments.SetCanonical(); |
484 // We are deferring canonicalization so mark object as not canonical. | |
485 type_arguments.ClearCanonical(); | |
486 } | 477 } |
487 | 478 |
488 return type_arguments.raw(); | 479 return type_arguments.raw(); |
489 } | 480 } |
490 | 481 |
491 | 482 |
492 void RawTypeArguments::WriteTo(SnapshotWriter* writer, | 483 void RawTypeArguments::WriteTo(SnapshotWriter* writer, |
493 intptr_t object_id, | 484 intptr_t object_id, |
494 Snapshot::Kind kind) { | 485 Snapshot::Kind kind) { |
495 ASSERT(writer != NULL); | 486 ASSERT(writer != NULL); |
(...skipping 19 matching lines...) Expand all Loading... |
515 writer->WriteObjectImpl(ptr()->types()[i], kAsReference); | 506 writer->WriteObjectImpl(ptr()->types()[i], kAsReference); |
516 } | 507 } |
517 } | 508 } |
518 | 509 |
519 | 510 |
520 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader, | 511 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader, |
521 intptr_t object_id, | 512 intptr_t object_id, |
522 intptr_t tags, | 513 intptr_t tags, |
523 Snapshot::Kind kind) { | 514 Snapshot::Kind kind) { |
524 ASSERT(reader != NULL); | 515 ASSERT(reader != NULL); |
525 ASSERT(((kind == Snapshot::kScript) && | |
526 !RawObject::IsCreatedFromSnapshot(tags)) || | |
527 (kind == Snapshot::kFull)); | |
528 | 516 |
529 // Allocate function object. | 517 // Allocate function object. |
530 PatchClass& cls = PatchClass::ZoneHandle(reader->zone(), | 518 PatchClass& cls = PatchClass::ZoneHandle(reader->zone(), |
531 NEW_OBJECT(PatchClass)); | 519 NEW_OBJECT(PatchClass)); |
532 reader->AddBackRef(object_id, &cls, kIsDeserialized); | 520 reader->AddBackRef(object_id, &cls, kIsDeserialized); |
533 | 521 |
534 // Set the object tags. | |
535 cls.set_tags(tags); | |
536 | |
537 // Set all the object fields. | 522 // Set all the object fields. |
538 // TODO(5411462): Need to assert No GC can happen here, even though | 523 // TODO(5411462): Need to assert No GC can happen here, even though |
539 // allocations may happen. | 524 // allocations may happen. |
540 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); | 525 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); |
541 for (intptr_t i = 0; i <= num_flds; i++) { | 526 for (intptr_t i = 0; i <= num_flds; i++) { |
542 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | 527 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
543 cls.StorePointer((cls.raw()->from() + i), | 528 cls.StorePointer((cls.raw()->from() + i), |
544 reader->PassiveObjectHandle()->raw()); | 529 reader->PassiveObjectHandle()->raw()); |
545 } | 530 } |
| 531 ASSERT(((kind == Snapshot::kScript) && |
| 532 !Class::IsInFullSnapshot(cls.source_class())) || |
| 533 (kind == Snapshot::kFull)); |
546 | 534 |
547 return cls.raw(); | 535 return cls.raw(); |
548 } | 536 } |
549 | 537 |
550 | 538 |
551 void RawPatchClass::WriteTo(SnapshotWriter* writer, | 539 void RawPatchClass::WriteTo(SnapshotWriter* writer, |
552 intptr_t object_id, | 540 intptr_t object_id, |
553 Snapshot::Kind kind) { | 541 Snapshot::Kind kind) { |
554 ASSERT(writer != NULL); | 542 ASSERT(writer != NULL); |
555 ASSERT(((kind == Snapshot::kScript) && | 543 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
556 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || | |
557 (kind == Snapshot::kFull)); | |
558 | 544 |
559 // Write out the serialization header value for this object. | 545 // Write out the serialization header value for this object. |
560 writer->WriteInlinedObjectHeader(object_id); | 546 writer->WriteInlinedObjectHeader(object_id); |
561 | 547 |
562 // Write out the class and tags information. | 548 // Write out the class and tags information. |
563 writer->WriteVMIsolateObject(kPatchClassCid); | 549 writer->WriteVMIsolateObject(kPatchClassCid); |
564 writer->WriteTags(writer->GetObjectTags(this)); | 550 writer->WriteTags(writer->GetObjectTags(this)); |
565 // Write out all the object pointer fields. | 551 // Write out all the object pointer fields. |
566 SnapshotWriterVisitor visitor(writer); | 552 SnapshotWriterVisitor visitor(writer); |
567 visitor.VisitPointers(from(), to()); | 553 visitor.VisitPointers(from(), to()); |
568 } | 554 } |
569 | 555 |
570 | 556 |
571 RawClosureData* ClosureData::ReadFrom(SnapshotReader* reader, | 557 RawClosureData* ClosureData::ReadFrom(SnapshotReader* reader, |
572 intptr_t object_id, | 558 intptr_t object_id, |
573 intptr_t tags, | 559 intptr_t tags, |
574 Snapshot::Kind kind) { | 560 Snapshot::Kind kind) { |
575 ASSERT(reader != NULL); | 561 ASSERT(reader != NULL); |
576 ASSERT(((kind == Snapshot::kScript) && | 562 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
577 !RawObject::IsCreatedFromSnapshot(tags)) || | |
578 (kind == Snapshot::kFull)); | |
579 | 563 |
580 // Allocate closure data object. | 564 // Allocate closure data object. |
581 ClosureData& data = ClosureData::ZoneHandle( | 565 ClosureData& data = ClosureData::ZoneHandle( |
582 reader->zone(), NEW_OBJECT(ClosureData)); | 566 reader->zone(), NEW_OBJECT(ClosureData)); |
583 reader->AddBackRef(object_id, &data, kIsDeserialized); | 567 reader->AddBackRef(object_id, &data, kIsDeserialized); |
584 | 568 |
585 // Set the object tags. | |
586 data.set_tags(tags); | |
587 | |
588 // Set all the object fields. | 569 // Set all the object fields. |
589 // TODO(5411462): Need to assert No GC can happen here, even though | 570 // TODO(5411462): Need to assert No GC can happen here, even though |
590 // allocations may happen. | 571 // allocations may happen. |
591 intptr_t num_flds = (data.raw()->to() - data.raw()->from()); | 572 intptr_t num_flds = (data.raw()->to() - data.raw()->from()); |
592 for (intptr_t i = 0; i <= num_flds; i++) { | 573 for (intptr_t i = 0; i <= num_flds; i++) { |
593 *(data.raw()->from() + i) = reader->ReadObjectImpl(kAsReference); | 574 *(data.raw()->from() + i) = reader->ReadObjectImpl(kAsReference); |
594 } | 575 } |
595 | 576 |
596 return data.raw(); | 577 return data.raw(); |
597 } | 578 } |
598 | 579 |
599 | 580 |
600 void RawClosureData::WriteTo(SnapshotWriter* writer, | 581 void RawClosureData::WriteTo(SnapshotWriter* writer, |
601 intptr_t object_id, | 582 intptr_t object_id, |
602 Snapshot::Kind kind) { | 583 Snapshot::Kind kind) { |
603 ASSERT(writer != NULL); | 584 ASSERT(writer != NULL); |
604 ASSERT(((kind == Snapshot::kScript) && | 585 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
605 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || | |
606 (kind == Snapshot::kFull)); | |
607 | 586 |
608 // Write out the serialization header value for this object. | 587 // Write out the serialization header value for this object. |
609 writer->WriteInlinedObjectHeader(object_id); | 588 writer->WriteInlinedObjectHeader(object_id); |
610 | 589 |
611 // Write out the class and tags information. | 590 // Write out the class and tags information. |
612 writer->WriteVMIsolateObject(kClosureDataCid); | 591 writer->WriteVMIsolateObject(kClosureDataCid); |
613 writer->WriteTags(writer->GetObjectTags(this)); | 592 writer->WriteTags(writer->GetObjectTags(this)); |
614 | 593 |
615 // Context scope. | 594 // Context scope. |
616 // We don't write the context scope in the snapshot. | 595 // We don't write the context scope in the snapshot. |
617 writer->WriteObjectImpl(Object::null(), kAsInlinedObject); | 596 writer->WriteObjectImpl(Object::null(), kAsInlinedObject); |
618 | 597 |
619 // Parent function. | 598 // Parent function. |
620 writer->WriteObjectImpl(ptr()->parent_function_, kAsInlinedObject); | 599 writer->WriteObjectImpl(ptr()->parent_function_, kAsInlinedObject); |
621 | 600 |
622 // Signature class. | 601 // Signature class. |
623 writer->WriteObjectImpl(ptr()->signature_class_, kAsInlinedObject); | 602 writer->WriteObjectImpl(ptr()->signature_class_, kAsInlinedObject); |
624 | 603 |
625 // Static closure/Closure allocation stub. | 604 // Static closure/Closure allocation stub. |
626 // We don't write the closure or allocation stub in the snapshot. | 605 // We don't write the closure or allocation stub in the snapshot. |
627 writer->WriteObjectImpl(Object::null(), kAsInlinedObject); | 606 writer->WriteObjectImpl(Object::null(), kAsInlinedObject); |
628 } | 607 } |
629 | 608 |
630 | 609 |
631 RawRedirectionData* RedirectionData::ReadFrom(SnapshotReader* reader, | 610 RawRedirectionData* RedirectionData::ReadFrom(SnapshotReader* reader, |
632 intptr_t object_id, | 611 intptr_t object_id, |
633 intptr_t tags, | 612 intptr_t tags, |
634 Snapshot::Kind kind) { | 613 Snapshot::Kind kind) { |
635 ASSERT(reader != NULL); | 614 ASSERT(reader != NULL); |
636 ASSERT(((kind == Snapshot::kScript) && | 615 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
637 !RawObject::IsCreatedFromSnapshot(tags)) || | |
638 (kind == Snapshot::kFull)); | |
639 | 616 |
640 // Allocate redirection data object. | 617 // Allocate redirection data object. |
641 RedirectionData& data = RedirectionData::ZoneHandle( | 618 RedirectionData& data = RedirectionData::ZoneHandle( |
642 reader->zone(), NEW_OBJECT(RedirectionData)); | 619 reader->zone(), NEW_OBJECT(RedirectionData)); |
643 reader->AddBackRef(object_id, &data, kIsDeserialized); | 620 reader->AddBackRef(object_id, &data, kIsDeserialized); |
644 | 621 |
645 // Set the object tags. | |
646 data.set_tags(tags); | |
647 | |
648 // Set all the object fields. | 622 // Set all the object fields. |
649 // TODO(5411462): Need to assert No GC can happen here, even though | 623 // TODO(5411462): Need to assert No GC can happen here, even though |
650 // allocations may happen. | 624 // allocations may happen. |
651 intptr_t num_flds = (data.raw()->to() - data.raw()->from()); | 625 intptr_t num_flds = (data.raw()->to() - data.raw()->from()); |
652 intptr_t from_offset = OFFSET_OF_FROM(data); | 626 intptr_t from_offset = OFFSET_OF_FROM(data); |
653 for (intptr_t i = 0; i <= num_flds; i++) { | 627 for (intptr_t i = 0; i <= num_flds; i++) { |
654 (*reader->PassiveObjectHandle()) = | 628 (*reader->PassiveObjectHandle()) = |
655 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); | 629 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); |
656 data.StorePointer((data.raw()->from() + i), | 630 data.StorePointer((data.raw()->from() + i), |
657 reader->PassiveObjectHandle()->raw()); | 631 reader->PassiveObjectHandle()->raw()); |
658 } | 632 } |
659 | 633 |
660 return data.raw(); | 634 return data.raw(); |
661 } | 635 } |
662 | 636 |
663 | 637 |
664 void RawRedirectionData::WriteTo(SnapshotWriter* writer, | 638 void RawRedirectionData::WriteTo(SnapshotWriter* writer, |
665 intptr_t object_id, | 639 intptr_t object_id, |
666 Snapshot::Kind kind) { | 640 Snapshot::Kind kind) { |
667 ASSERT(writer != NULL); | 641 ASSERT(writer != NULL); |
668 ASSERT(((kind == Snapshot::kScript) && | 642 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
669 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || | |
670 (kind == Snapshot::kFull)); | |
671 | 643 |
672 // Write out the serialization header value for this object. | 644 // Write out the serialization header value for this object. |
673 writer->WriteInlinedObjectHeader(object_id); | 645 writer->WriteInlinedObjectHeader(object_id); |
674 | 646 |
675 // Write out the class and tags information. | 647 // Write out the class and tags information. |
676 writer->WriteVMIsolateObject(kRedirectionDataCid); | 648 writer->WriteVMIsolateObject(kRedirectionDataCid); |
677 writer->WriteTags(writer->GetObjectTags(this)); | 649 writer->WriteTags(writer->GetObjectTags(this)); |
678 | 650 |
679 // Write out all the object pointer fields. | 651 // Write out all the object pointer fields. |
680 SnapshotWriterVisitor visitor(writer); | 652 SnapshotWriterVisitor visitor(writer); |
681 visitor.VisitPointers(from(), to()); | 653 visitor.VisitPointers(from(), to()); |
682 } | 654 } |
683 | 655 |
684 | 656 |
685 RawFunction* Function::ReadFrom(SnapshotReader* reader, | 657 RawFunction* Function::ReadFrom(SnapshotReader* reader, |
686 intptr_t object_id, | 658 intptr_t object_id, |
687 intptr_t tags, | 659 intptr_t tags, |
688 Snapshot::Kind kind) { | 660 Snapshot::Kind kind) { |
689 ASSERT(reader != NULL); | 661 ASSERT(reader != NULL); |
690 ASSERT(((kind == Snapshot::kScript) && | 662 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
691 !RawObject::IsCreatedFromSnapshot(tags)) || | |
692 (kind == Snapshot::kFull)); | |
693 | 663 |
694 // Allocate function object. | 664 // Allocate function object. |
695 Function& func = Function::ZoneHandle( | 665 Function& func = Function::ZoneHandle( |
696 reader->zone(), NEW_OBJECT(Function)); | 666 reader->zone(), NEW_OBJECT(Function)); |
697 reader->AddBackRef(object_id, &func, kIsDeserialized); | 667 reader->AddBackRef(object_id, &func, kIsDeserialized); |
698 | 668 |
699 // Set the object tags. | |
700 func.set_tags(tags); | |
701 | |
702 // Set all the non object fields. | 669 // Set all the non object fields. |
703 func.set_token_pos(reader->Read<int32_t>()); | 670 func.set_token_pos(reader->Read<int32_t>()); |
704 func.set_end_token_pos(reader->Read<int32_t>()); | 671 func.set_end_token_pos(reader->Read<int32_t>()); |
705 func.set_usage_counter(reader->Read<int32_t>()); | 672 func.set_usage_counter(reader->Read<int32_t>()); |
706 func.set_num_fixed_parameters(reader->Read<int16_t>()); | 673 func.set_num_fixed_parameters(reader->Read<int16_t>()); |
707 func.set_num_optional_parameters(reader->Read<int16_t>()); | 674 func.set_num_optional_parameters(reader->Read<int16_t>()); |
708 func.set_deoptimization_counter(reader->Read<int16_t>()); | 675 func.set_deoptimization_counter(reader->Read<int16_t>()); |
709 func.set_regexp_cid(reader->ReadClassIDValue()); | 676 func.set_regexp_cid(reader->ReadClassIDValue()); |
710 func.set_kind_tag(reader->Read<uint32_t>()); | 677 func.set_kind_tag(reader->Read<uint32_t>()); |
711 func.set_optimized_instruction_count(reader->Read<uint16_t>()); | 678 func.set_optimized_instruction_count(reader->Read<uint16_t>()); |
(...skipping 15 matching lines...) Expand all Loading... |
727 func.ClearICDataArray(); | 694 func.ClearICDataArray(); |
728 func.ClearCode(); | 695 func.ClearCode(); |
729 return func.raw(); | 696 return func.raw(); |
730 } | 697 } |
731 | 698 |
732 | 699 |
733 void RawFunction::WriteTo(SnapshotWriter* writer, | 700 void RawFunction::WriteTo(SnapshotWriter* writer, |
734 intptr_t object_id, | 701 intptr_t object_id, |
735 Snapshot::Kind kind) { | 702 Snapshot::Kind kind) { |
736 ASSERT(writer != NULL); | 703 ASSERT(writer != NULL); |
737 ASSERT(((kind == Snapshot::kScript) && | 704 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
738 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || | |
739 (kind == Snapshot::kFull)); | |
740 | 705 |
741 // Write out the serialization header value for this object. | 706 // Write out the serialization header value for this object. |
742 writer->WriteInlinedObjectHeader(object_id); | 707 writer->WriteInlinedObjectHeader(object_id); |
743 | 708 |
744 // Write out the class and tags information. | 709 // Write out the class and tags information. |
745 writer->WriteVMIsolateObject(kFunctionCid); | 710 writer->WriteVMIsolateObject(kFunctionCid); |
746 writer->WriteTags(writer->GetObjectTags(this)); | 711 writer->WriteTags(writer->GetObjectTags(this)); |
747 | 712 |
748 // Write out all the non object fields. | 713 // Write out all the non object fields. |
749 writer->Write<int32_t>(ptr()->token_pos_); | 714 writer->Write<int32_t>(ptr()->token_pos_); |
(...skipping 11 matching lines...) Expand all Loading... |
761 SnapshotWriterVisitor visitor(writer); | 726 SnapshotWriterVisitor visitor(writer); |
762 visitor.VisitPointers(from(), to_snapshot()); | 727 visitor.VisitPointers(from(), to_snapshot()); |
763 } | 728 } |
764 | 729 |
765 | 730 |
766 RawField* Field::ReadFrom(SnapshotReader* reader, | 731 RawField* Field::ReadFrom(SnapshotReader* reader, |
767 intptr_t object_id, | 732 intptr_t object_id, |
768 intptr_t tags, | 733 intptr_t tags, |
769 Snapshot::Kind kind) { | 734 Snapshot::Kind kind) { |
770 ASSERT(reader != NULL); | 735 ASSERT(reader != NULL); |
771 ASSERT(((kind == Snapshot::kScript) && | 736 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
772 !RawObject::IsCreatedFromSnapshot(tags)) || | |
773 (kind == Snapshot::kFull)); | |
774 | 737 |
775 // Allocate field object. | 738 // Allocate field object. |
776 Field& field = Field::ZoneHandle(reader->zone(), NEW_OBJECT(Field)); | 739 Field& field = Field::ZoneHandle(reader->zone(), NEW_OBJECT(Field)); |
777 reader->AddBackRef(object_id, &field, kIsDeserialized); | 740 reader->AddBackRef(object_id, &field, kIsDeserialized); |
778 | 741 |
779 // Set the object tags. | |
780 field.set_tags(tags); | |
781 | |
782 // Set all non object fields. | 742 // Set all non object fields. |
783 field.set_token_pos(reader->Read<int32_t>()); | 743 field.set_token_pos(reader->Read<int32_t>()); |
784 field.set_guarded_cid(reader->Read<int32_t>()); | 744 field.set_guarded_cid(reader->Read<int32_t>()); |
785 field.set_is_nullable(reader->Read<int32_t>()); | 745 field.set_is_nullable(reader->Read<int32_t>()); |
786 field.set_kind_bits(reader->Read<uint8_t>()); | 746 field.set_kind_bits(reader->Read<uint8_t>()); |
787 | 747 |
788 // Set all the object fields. | 748 // Set all the object fields. |
789 // TODO(5411462): Need to assert No GC can happen here, even though | 749 // TODO(5411462): Need to assert No GC can happen here, even though |
790 // allocations may happen. | 750 // allocations may happen. |
791 intptr_t num_flds = (field.raw()->to() - field.raw()->from()); | 751 intptr_t num_flds = (field.raw()->to() - field.raw()->from()); |
792 intptr_t from_offset = OFFSET_OF_FROM(field); | 752 intptr_t from_offset = OFFSET_OF_FROM(field); |
793 for (intptr_t i = 0; i <= num_flds; i++) { | 753 for (intptr_t i = 0; i <= num_flds; i++) { |
794 (*reader->PassiveObjectHandle()) = | 754 (*reader->PassiveObjectHandle()) = |
795 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); | 755 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); |
796 field.StorePointer((field.raw()->from() + i), | 756 field.StorePointer((field.raw()->from() + i), |
797 reader->PassiveObjectHandle()->raw()); | 757 reader->PassiveObjectHandle()->raw()); |
798 } | 758 } |
799 | 759 |
800 field.InitializeGuardedListLengthInObjectOffset(); | 760 field.InitializeGuardedListLengthInObjectOffset(); |
801 | 761 |
802 return field.raw(); | 762 return field.raw(); |
803 } | 763 } |
804 | 764 |
805 | 765 |
806 void RawField::WriteTo(SnapshotWriter* writer, | 766 void RawField::WriteTo(SnapshotWriter* writer, |
807 intptr_t object_id, | 767 intptr_t object_id, |
808 Snapshot::Kind kind) { | 768 Snapshot::Kind kind) { |
809 ASSERT(writer != NULL); | 769 ASSERT(writer != NULL); |
810 ASSERT(((kind == Snapshot::kScript) && | 770 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
811 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || | |
812 (kind == Snapshot::kFull)); | |
813 | 771 |
814 // Write out the serialization header value for this object. | 772 // Write out the serialization header value for this object. |
815 writer->WriteInlinedObjectHeader(object_id); | 773 writer->WriteInlinedObjectHeader(object_id); |
816 | 774 |
817 // Write out the class and tags information. | 775 // Write out the class and tags information. |
818 writer->WriteVMIsolateObject(kFieldCid); | 776 writer->WriteVMIsolateObject(kFieldCid); |
819 writer->WriteTags(writer->GetObjectTags(this)); | 777 writer->WriteTags(writer->GetObjectTags(this)); |
820 | 778 |
821 // Write out all the non object fields. | 779 // Write out all the non object fields. |
822 writer->Write<int32_t>(ptr()->token_pos_); | 780 writer->Write<int32_t>(ptr()->token_pos_); |
(...skipping 12 matching lines...) Expand all Loading... |
835 intptr_t tags, | 793 intptr_t tags, |
836 Snapshot::Kind kind) { | 794 Snapshot::Kind kind) { |
837 ASSERT(reader != NULL); | 795 ASSERT(reader != NULL); |
838 ASSERT(kind != Snapshot::kMessage); | 796 ASSERT(kind != Snapshot::kMessage); |
839 | 797 |
840 // Create the literal token object. | 798 // Create the literal token object. |
841 LiteralToken& literal_token = LiteralToken::ZoneHandle( | 799 LiteralToken& literal_token = LiteralToken::ZoneHandle( |
842 reader->zone(), NEW_OBJECT(LiteralToken)); | 800 reader->zone(), NEW_OBJECT(LiteralToken)); |
843 reader->AddBackRef(object_id, &literal_token, kIsDeserialized); | 801 reader->AddBackRef(object_id, &literal_token, kIsDeserialized); |
844 | 802 |
845 // Set the object tags. | |
846 literal_token.set_tags(tags); | |
847 | |
848 // Read the token attributes. | 803 // Read the token attributes. |
849 Token::Kind token_kind = static_cast<Token::Kind>(reader->Read<int32_t>()); | 804 Token::Kind token_kind = static_cast<Token::Kind>(reader->Read<int32_t>()); |
850 literal_token.set_kind(token_kind); | 805 literal_token.set_kind(token_kind); |
851 | 806 |
852 // Set all the object fields. | 807 // Set all the object fields. |
853 // TODO(5411462): Need to assert No GC can happen here, even though | 808 // TODO(5411462): Need to assert No GC can happen here, even though |
854 // allocations may happen. | 809 // allocations may happen. |
855 intptr_t num_flds = (literal_token.raw()->to() - literal_token.raw()->from()); | 810 intptr_t num_flds = (literal_token.raw()->to() - literal_token.raw()->from()); |
856 for (intptr_t i = 0; i <= num_flds; i++) { | 811 for (intptr_t i = 0; i <= num_flds; i++) { |
857 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | 812 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
(...skipping 25 matching lines...) Expand all Loading... |
883 SnapshotWriterVisitor visitor(writer); | 838 SnapshotWriterVisitor visitor(writer); |
884 visitor.VisitPointers(from(), to()); | 839 visitor.VisitPointers(from(), to()); |
885 } | 840 } |
886 | 841 |
887 | 842 |
888 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, | 843 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, |
889 intptr_t object_id, | 844 intptr_t object_id, |
890 intptr_t tags, | 845 intptr_t tags, |
891 Snapshot::Kind kind) { | 846 Snapshot::Kind kind) { |
892 ASSERT(reader != NULL); | 847 ASSERT(reader != NULL); |
893 ASSERT(((kind == Snapshot::kScript) && | 848 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
894 !RawObject::IsCreatedFromSnapshot(tags)) || | |
895 (kind == Snapshot::kFull)); | |
896 | 849 |
897 // Read the length so that we can determine number of tokens to read. | 850 // Read the length so that we can determine number of tokens to read. |
898 intptr_t len = reader->ReadSmiValue(); | 851 intptr_t len = reader->ReadSmiValue(); |
899 | 852 |
900 // Create the token stream object. | 853 // Create the token stream object. |
901 TokenStream& token_stream = TokenStream::ZoneHandle( | 854 TokenStream& token_stream = TokenStream::ZoneHandle( |
902 reader->zone(), NEW_OBJECT_WITH_LEN(TokenStream, len)); | 855 reader->zone(), NEW_OBJECT_WITH_LEN(TokenStream, len)); |
903 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); | 856 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); |
904 | 857 |
905 // Set the object tags. | |
906 token_stream.set_tags(tags); | |
907 | |
908 // Read the stream of tokens into the TokenStream object for script | 858 // Read the stream of tokens into the TokenStream object for script |
909 // snapshots as we made a copy of token stream. | 859 // snapshots as we made a copy of token stream. |
910 if (kind == Snapshot::kScript) { | 860 if (kind == Snapshot::kScript) { |
911 NoSafepointScope no_safepoint; | 861 NoSafepointScope no_safepoint; |
912 RawExternalTypedData* stream = token_stream.GetStream(); | 862 RawExternalTypedData* stream = token_stream.GetStream(); |
913 reader->ReadBytes(stream->ptr()->data_, len); | 863 reader->ReadBytes(stream->ptr()->data_, len); |
914 } | 864 } |
915 | 865 |
916 // Read in the literal/identifier token array. | 866 // Read in the literal/identifier token array. |
917 *(reader->TokensHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); | 867 *(reader->TokensHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); |
918 token_stream.SetTokenObjects(*(reader->TokensHandle())); | 868 token_stream.SetTokenObjects(*(reader->TokensHandle())); |
919 // Read in the private key in use by the token stream. | 869 // Read in the private key in use by the token stream. |
920 *(reader->StringHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); | 870 *(reader->StringHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); |
921 token_stream.SetPrivateKey(*(reader->StringHandle())); | 871 token_stream.SetPrivateKey(*(reader->StringHandle())); |
922 | 872 |
923 return token_stream.raw(); | 873 return token_stream.raw(); |
924 } | 874 } |
925 | 875 |
926 | 876 |
927 void RawTokenStream::WriteTo(SnapshotWriter* writer, | 877 void RawTokenStream::WriteTo(SnapshotWriter* writer, |
928 intptr_t object_id, | 878 intptr_t object_id, |
929 Snapshot::Kind kind) { | 879 Snapshot::Kind kind) { |
930 ASSERT(writer != NULL); | 880 ASSERT(writer != NULL); |
931 ASSERT(((kind == Snapshot::kScript) && | 881 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
932 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || | |
933 (kind == Snapshot::kFull)); | |
934 | 882 |
935 // Write out the serialization header value for this object. | 883 // Write out the serialization header value for this object. |
936 writer->WriteInlinedObjectHeader(object_id); | 884 writer->WriteInlinedObjectHeader(object_id); |
937 | 885 |
938 // Write out the class and tags information. | 886 // Write out the class and tags information. |
939 writer->WriteVMIsolateObject(kTokenStreamCid); | 887 writer->WriteVMIsolateObject(kTokenStreamCid); |
940 writer->WriteTags(writer->GetObjectTags(this)); | 888 writer->WriteTags(writer->GetObjectTags(this)); |
941 | 889 |
942 // Write out the length field and the token stream. | 890 // Write out the length field and the token stream. |
943 RawExternalTypedData* stream = ptr()->stream_; | 891 RawExternalTypedData* stream = ptr()->stream_; |
944 intptr_t len = Smi::Value(stream->ptr()->length_); | 892 intptr_t len = Smi::Value(stream->ptr()->length_); |
945 writer->Write<RawObject*>(stream->ptr()->length_); | 893 writer->Write<RawObject*>(stream->ptr()->length_); |
946 writer->WriteBytes(stream->ptr()->data_, len); | 894 writer->WriteBytes(stream->ptr()->data_, len); |
947 | 895 |
948 // Write out the literal/identifier token array. | 896 // Write out the literal/identifier token array. |
949 writer->WriteObjectImpl(ptr()->token_objects_, kAsInlinedObject); | 897 writer->WriteObjectImpl(ptr()->token_objects_, kAsInlinedObject); |
950 // Write out the private key in use by the token stream. | 898 // Write out the private key in use by the token stream. |
951 writer->WriteObjectImpl(ptr()->private_key_, kAsInlinedObject); | 899 writer->WriteObjectImpl(ptr()->private_key_, kAsInlinedObject); |
952 } | 900 } |
953 | 901 |
954 | 902 |
955 RawScript* Script::ReadFrom(SnapshotReader* reader, | 903 RawScript* Script::ReadFrom(SnapshotReader* reader, |
956 intptr_t object_id, | 904 intptr_t object_id, |
957 intptr_t tags, | 905 intptr_t tags, |
958 Snapshot::Kind kind) { | 906 Snapshot::Kind kind) { |
959 ASSERT(reader != NULL); | 907 ASSERT(reader != NULL); |
960 ASSERT(((kind == Snapshot::kScript) && | 908 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
961 !RawObject::IsCreatedFromSnapshot(tags)) || | |
962 (kind == Snapshot::kFull)); | |
963 | 909 |
964 // Allocate script object. | 910 // Allocate script object. |
965 Script& script = Script::ZoneHandle(reader->zone(), NEW_OBJECT(Script)); | 911 Script& script = Script::ZoneHandle(reader->zone(), NEW_OBJECT(Script)); |
966 reader->AddBackRef(object_id, &script, kIsDeserialized); | 912 reader->AddBackRef(object_id, &script, kIsDeserialized); |
967 | 913 |
968 // Set the object tags. | |
969 script.set_tags(tags); | |
970 | |
971 script.StoreNonPointer(&script.raw_ptr()->line_offset_, | 914 script.StoreNonPointer(&script.raw_ptr()->line_offset_, |
972 reader->Read<int32_t>()); | 915 reader->Read<int32_t>()); |
973 script.StoreNonPointer(&script.raw_ptr()->col_offset_, | 916 script.StoreNonPointer(&script.raw_ptr()->col_offset_, |
974 reader->Read<int32_t>()); | 917 reader->Read<int32_t>()); |
975 script.StoreNonPointer(&script.raw_ptr()->kind_, | 918 script.StoreNonPointer(&script.raw_ptr()->kind_, |
976 reader->Read<int8_t>()); | 919 reader->Read<int8_t>()); |
977 | 920 |
978 // Set all the object fields. | 921 // Set all the object fields. |
979 // TODO(5411462): Need to assert No GC can happen here, even though | 922 // TODO(5411462): Need to assert No GC can happen here, even though |
980 // allocations may happen. | 923 // allocations may happen. |
981 intptr_t num_flds = (script.raw()->to_snapshot() - script.raw()->from()); | 924 intptr_t num_flds = (script.raw()->to_snapshot() - script.raw()->from()); |
982 for (intptr_t i = 0; i <= num_flds; i++) { | 925 for (intptr_t i = 0; i <= num_flds; i++) { |
983 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | 926 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
984 script.StorePointer((script.raw()->from() + i), | 927 script.StorePointer((script.raw()->from() + i), |
985 reader->PassiveObjectHandle()->raw()); | 928 reader->PassiveObjectHandle()->raw()); |
986 } | 929 } |
987 // Script wasn't allocated with nulls? | 930 // Script wasn't allocated with nulls? |
988 *reader->StringHandle() ^= String::null(); | 931 *reader->StringHandle() ^= String::null(); |
989 script.set_source(*reader->StringHandle()); | 932 script.set_source(*reader->StringHandle()); |
990 | 933 |
991 return script.raw(); | 934 return script.raw(); |
992 } | 935 } |
993 | 936 |
994 | 937 |
995 void RawScript::WriteTo(SnapshotWriter* writer, | 938 void RawScript::WriteTo(SnapshotWriter* writer, |
996 intptr_t object_id, | 939 intptr_t object_id, |
997 Snapshot::Kind kind) { | 940 Snapshot::Kind kind) { |
998 ASSERT(writer != NULL); | 941 ASSERT(writer != NULL); |
999 ASSERT(tokens_ != TokenStream::null()); | 942 ASSERT(tokens_ != TokenStream::null()); |
1000 ASSERT(((kind == Snapshot::kScript) && | 943 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
1001 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || | |
1002 (kind == Snapshot::kFull)); | |
1003 | 944 |
1004 // Write out the serialization header value for this object. | 945 // Write out the serialization header value for this object. |
1005 writer->WriteInlinedObjectHeader(object_id); | 946 writer->WriteInlinedObjectHeader(object_id); |
1006 | 947 |
1007 // Write out the class and tags information. | 948 // Write out the class and tags information. |
1008 writer->WriteVMIsolateObject(kScriptCid); | 949 writer->WriteVMIsolateObject(kScriptCid); |
1009 writer->WriteTags(writer->GetObjectTags(this)); | 950 writer->WriteTags(writer->GetObjectTags(this)); |
1010 | 951 |
1011 // Write out all the non object fields. | 952 // Write out all the non object fields. |
1012 writer->Write<int32_t>(ptr()->line_offset_); | 953 writer->Write<int32_t>(ptr()->line_offset_); |
1013 writer->Write<int32_t>(ptr()->col_offset_); | 954 writer->Write<int32_t>(ptr()->col_offset_); |
1014 writer->Write<int8_t>(ptr()->kind_); | 955 writer->Write<int8_t>(ptr()->kind_); |
1015 | 956 |
1016 // Write out all the object pointer fields. | 957 // Write out all the object pointer fields. |
1017 SnapshotWriterVisitor visitor(writer); | 958 SnapshotWriterVisitor visitor(writer); |
1018 visitor.VisitPointers(from(), to_snapshot()); | 959 visitor.VisitPointers(from(), to_snapshot()); |
1019 } | 960 } |
1020 | 961 |
1021 | 962 |
1022 RawLibrary* Library::ReadFrom(SnapshotReader* reader, | 963 RawLibrary* Library::ReadFrom(SnapshotReader* reader, |
1023 intptr_t object_id, | 964 intptr_t object_id, |
1024 intptr_t tags, | 965 intptr_t tags, |
1025 Snapshot::Kind kind) { | 966 Snapshot::Kind kind) { |
1026 ASSERT(reader != NULL); | 967 ASSERT(reader != NULL); |
1027 ASSERT(kind != Snapshot::kMessage); | 968 ASSERT(kind != Snapshot::kMessage); |
1028 | 969 |
1029 Library& library = Library::ZoneHandle(reader->zone(), Library::null()); | 970 Library& library = Library::ZoneHandle(reader->zone(), Library::null()); |
1030 reader->AddBackRef(object_id, &library, kIsDeserialized); | 971 reader->AddBackRef(object_id, &library, kIsDeserialized); |
1031 | 972 |
1032 if ((kind == Snapshot::kScript) && RawObject::IsCreatedFromSnapshot(tags)) { | 973 bool is_in_fullsnapshot = reader->Read<bool>(); |
1033 ASSERT(kind != Snapshot::kFull); | 974 if ((kind == Snapshot::kScript) && is_in_fullsnapshot) { |
1034 // Lookup the object as it should already exist in the heap. | 975 // Lookup the object as it should already exist in the heap. |
1035 *reader->StringHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); | 976 *reader->StringHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); |
1036 library = Library::LookupLibrary(*reader->StringHandle()); | 977 library = Library::LookupLibrary(*reader->StringHandle()); |
| 978 ASSERT(library.is_in_fullsnapshot()); |
1037 } else { | 979 } else { |
1038 // Allocate library object. | 980 // Allocate library object. |
1039 library = NEW_OBJECT(Library); | 981 library = NEW_OBJECT(Library); |
1040 | 982 |
1041 // Set the object tags. | |
1042 library.set_tags(tags); | |
1043 | |
1044 // Set all non object fields. | 983 // Set all non object fields. |
1045 library.StoreNonPointer(&library.raw_ptr()->index_, | 984 library.StoreNonPointer(&library.raw_ptr()->index_, |
1046 reader->ReadClassIDValue()); | 985 reader->ReadClassIDValue()); |
1047 library.StoreNonPointer(&library.raw_ptr()->num_anonymous_, | 986 library.StoreNonPointer(&library.raw_ptr()->num_anonymous_, |
1048 reader->ReadClassIDValue()); | 987 reader->ReadClassIDValue()); |
1049 library.StoreNonPointer(&library.raw_ptr()->num_imports_, | 988 library.StoreNonPointer(&library.raw_ptr()->num_imports_, |
1050 reader->Read<uint16_t>()); | 989 reader->Read<uint16_t>()); |
1051 library.StoreNonPointer(&library.raw_ptr()->load_state_, | 990 library.StoreNonPointer(&library.raw_ptr()->load_state_, |
1052 reader->Read<int8_t>()); | 991 reader->Read<int8_t>()); |
1053 library.StoreNonPointer(&library.raw_ptr()->corelib_imported_, | 992 library.StoreNonPointer(&library.raw_ptr()->corelib_imported_, |
1054 reader->Read<bool>()); | 993 reader->Read<bool>()); |
1055 library.StoreNonPointer(&library.raw_ptr()->is_dart_scheme_, | 994 library.StoreNonPointer(&library.raw_ptr()->is_dart_scheme_, |
1056 reader->Read<bool>()); | 995 reader->Read<bool>()); |
1057 library.StoreNonPointer(&library.raw_ptr()->debuggable_, | 996 library.StoreNonPointer(&library.raw_ptr()->debuggable_, |
1058 reader->Read<bool>()); | 997 reader->Read<bool>()); |
| 998 if (kind == Snapshot::kFull) { |
| 999 is_in_fullsnapshot = true; |
| 1000 } |
| 1001 library.StoreNonPointer(&library.raw_ptr()->is_in_fullsnapshot_, |
| 1002 is_in_fullsnapshot); |
1059 // The native resolver and symbolizer are not serialized. | 1003 // The native resolver and symbolizer are not serialized. |
1060 library.set_native_entry_resolver(NULL); | 1004 library.set_native_entry_resolver(NULL); |
1061 library.set_native_entry_symbol_resolver(NULL); | 1005 library.set_native_entry_symbol_resolver(NULL); |
1062 // The cache of loaded scripts is not serialized. | 1006 // The cache of loaded scripts is not serialized. |
1063 library.StorePointer(&library.raw_ptr()->loaded_scripts_, Array::null()); | 1007 library.StorePointer(&library.raw_ptr()->loaded_scripts_, Array::null()); |
1064 | 1008 |
1065 // Set all the object fields. | 1009 // Set all the object fields. |
1066 // TODO(5411462): Need to assert No GC can happen here, even though | 1010 // TODO(5411462): Need to assert No GC can happen here, even though |
1067 // allocations may happen. | 1011 // allocations may happen. |
1068 intptr_t num_flds = (library.raw()->to() - library.raw()->from()); | 1012 intptr_t num_flds = (library.raw()->to() - library.raw()->from()); |
(...skipping 16 matching lines...) Expand all Loading... |
1085 ASSERT(writer != NULL); | 1029 ASSERT(writer != NULL); |
1086 ASSERT(kind != Snapshot::kMessage); | 1030 ASSERT(kind != Snapshot::kMessage); |
1087 | 1031 |
1088 // Write out the serialization header value for this object. | 1032 // Write out the serialization header value for this object. |
1089 writer->WriteInlinedObjectHeader(object_id); | 1033 writer->WriteInlinedObjectHeader(object_id); |
1090 | 1034 |
1091 // Write out the class and tags information. | 1035 // Write out the class and tags information. |
1092 writer->WriteVMIsolateObject(kLibraryCid); | 1036 writer->WriteVMIsolateObject(kLibraryCid); |
1093 writer->WriteTags(writer->GetObjectTags(this)); | 1037 writer->WriteTags(writer->GetObjectTags(this)); |
1094 | 1038 |
1095 if ((kind == Snapshot::kScript) && | 1039 // Write out the boolean is_in_fullsnapshot_ first as this will |
1096 RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) { | 1040 // help the reader decide how the rest of the information needs |
1097 ASSERT(kind != Snapshot::kFull); | 1041 // to be interpreted. |
| 1042 writer->Write<bool>(ptr()->is_in_fullsnapshot_); |
| 1043 |
| 1044 if ((kind == Snapshot::kScript) && ptr()->is_in_fullsnapshot_) { |
1098 // Write out library URL so that it can be looked up when reading. | 1045 // Write out library URL so that it can be looked up when reading. |
1099 writer->WriteObjectImpl(ptr()->url_, kAsInlinedObject); | 1046 writer->WriteObjectImpl(ptr()->url_, kAsInlinedObject); |
1100 } else { | 1047 } else { |
| 1048 ASSERT((kind == Snapshot::kFull) || !ptr()->is_in_fullsnapshot_); |
1101 // Write out all non object fields. | 1049 // Write out all non object fields. |
1102 writer->WriteClassIDValue(ptr()->index_); | 1050 writer->WriteClassIDValue(ptr()->index_); |
1103 writer->WriteClassIDValue(ptr()->num_anonymous_); | 1051 writer->WriteClassIDValue(ptr()->num_anonymous_); |
1104 writer->Write<uint16_t>(ptr()->num_imports_); | 1052 writer->Write<uint16_t>(ptr()->num_imports_); |
1105 writer->Write<int8_t>(ptr()->load_state_); | 1053 writer->Write<int8_t>(ptr()->load_state_); |
1106 writer->Write<bool>(ptr()->corelib_imported_); | 1054 writer->Write<bool>(ptr()->corelib_imported_); |
1107 writer->Write<bool>(ptr()->is_dart_scheme_); | 1055 writer->Write<bool>(ptr()->is_dart_scheme_); |
1108 writer->Write<bool>(ptr()->debuggable_); | 1056 writer->Write<bool>(ptr()->debuggable_); |
1109 // We do not serialize the native resolver or symbolizer. These need to be | 1057 // We do not serialize the native resolver or symbolizer. These need to be |
1110 // explicitly set after deserialization. | 1058 // explicitly set after deserialization. |
1111 // We do not write the loaded_scripts_ cache to the snapshot. It gets | 1059 // We do not write the loaded_scripts_ cache to the snapshot. It gets |
1112 // set to NULL when reading the library from the snapshot, and will | 1060 // set to NULL when reading the library from the snapshot, and will |
1113 // be rebuilt lazily. | 1061 // be rebuilt lazily. |
1114 | 1062 |
1115 // Write out all the object pointer fields. | 1063 // Write out all the object pointer fields. |
1116 SnapshotWriterVisitor visitor(writer); | 1064 SnapshotWriterVisitor visitor(writer); |
1117 visitor.VisitPointers(from(), to()); | 1065 visitor.VisitPointers(from(), to()); |
1118 } | 1066 } |
1119 } | 1067 } |
1120 | 1068 |
1121 | 1069 |
1122 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader, | 1070 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader, |
1123 intptr_t object_id, | 1071 intptr_t object_id, |
1124 intptr_t tags, | 1072 intptr_t tags, |
1125 Snapshot::Kind kind) { | 1073 Snapshot::Kind kind) { |
1126 ASSERT(reader != NULL); | 1074 ASSERT(reader != NULL); |
1127 ASSERT(((kind == Snapshot::kScript) && | 1075 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
1128 !RawObject::IsCreatedFromSnapshot(tags)) || | |
1129 (kind == Snapshot::kFull)); | |
1130 | 1076 |
1131 // Allocate library prefix object. | 1077 // Allocate library prefix object. |
1132 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle( | 1078 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle( |
1133 reader->zone(), NEW_OBJECT(LibraryPrefix)); | 1079 reader->zone(), NEW_OBJECT(LibraryPrefix)); |
1134 reader->AddBackRef(object_id, &prefix, kIsDeserialized); | 1080 reader->AddBackRef(object_id, &prefix, kIsDeserialized); |
1135 | 1081 |
1136 // Set the object tags. | |
1137 prefix.set_tags(tags); | |
1138 | |
1139 // Set all non object fields. | 1082 // Set all non object fields. |
1140 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_, | 1083 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_, |
1141 reader->Read<int16_t>()); | 1084 reader->Read<int16_t>()); |
1142 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_, | 1085 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_, |
1143 reader->Read<bool>()); | 1086 reader->Read<bool>()); |
1144 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>()); | 1087 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>()); |
1145 | 1088 |
1146 // Set all the object fields. | 1089 // Set all the object fields. |
1147 // TODO(5411462): Need to assert No GC can happen here, even though | 1090 // TODO(5411462): Need to assert No GC can happen here, even though |
1148 // allocations may happen. | 1091 // allocations may happen. |
1149 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from()); | 1092 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from()); |
1150 for (intptr_t i = 0; i <= num_flds; i++) { | 1093 for (intptr_t i = 0; i <= num_flds; i++) { |
1151 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | 1094 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
1152 prefix.StorePointer((prefix.raw()->from() + i), | 1095 prefix.StorePointer((prefix.raw()->from() + i), |
1153 reader->PassiveObjectHandle()->raw()); | 1096 reader->PassiveObjectHandle()->raw()); |
1154 } | 1097 } |
1155 | 1098 |
1156 return prefix.raw(); | 1099 return prefix.raw(); |
1157 } | 1100 } |
1158 | 1101 |
1159 | 1102 |
1160 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, | 1103 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, |
1161 intptr_t object_id, | 1104 intptr_t object_id, |
1162 Snapshot::Kind kind) { | 1105 Snapshot::Kind kind) { |
1163 ASSERT(writer != NULL); | 1106 ASSERT(writer != NULL); |
1164 ASSERT(((kind == Snapshot::kScript) && | 1107 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
1165 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || | |
1166 (kind == Snapshot::kFull)); | |
1167 | 1108 |
1168 // Write out the serialization header value for this object. | 1109 // Write out the serialization header value for this object. |
1169 writer->WriteInlinedObjectHeader(object_id); | 1110 writer->WriteInlinedObjectHeader(object_id); |
1170 | 1111 |
1171 // Write out the class and tags information. | 1112 // Write out the class and tags information. |
1172 writer->WriteIndexedObject(kLibraryPrefixCid); | 1113 writer->WriteIndexedObject(kLibraryPrefixCid); |
1173 writer->WriteTags(writer->GetObjectTags(this)); | 1114 writer->WriteTags(writer->GetObjectTags(this)); |
1174 | 1115 |
1175 // Write out all non object fields. | 1116 // Write out all non object fields. |
1176 writer->Write<int16_t>(ptr()->num_imports_); | 1117 writer->Write<int16_t>(ptr()->num_imports_); |
1177 writer->Write<bool>(ptr()->is_deferred_load_); | 1118 writer->Write<bool>(ptr()->is_deferred_load_); |
1178 writer->Write<bool>(ptr()->is_loaded_); | 1119 writer->Write<bool>(ptr()->is_loaded_); |
1179 | 1120 |
1180 // Write out all the object pointer fields. | 1121 // Write out all the object pointer fields. |
1181 SnapshotWriterVisitor visitor(writer); | 1122 SnapshotWriterVisitor visitor(writer); |
1182 visitor.VisitPointers(from(), to()); | 1123 visitor.VisitPointers(from(), to()); |
1183 } | 1124 } |
1184 | 1125 |
1185 | 1126 |
1186 RawNamespace* Namespace::ReadFrom(SnapshotReader* reader, | 1127 RawNamespace* Namespace::ReadFrom(SnapshotReader* reader, |
1187 intptr_t object_id, | 1128 intptr_t object_id, |
1188 intptr_t tags, | 1129 intptr_t tags, |
1189 Snapshot::Kind kind) { | 1130 Snapshot::Kind kind) { |
1190 ASSERT(reader != NULL); | 1131 ASSERT(reader != NULL); |
1191 ASSERT(((kind == Snapshot::kScript) && | 1132 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
1192 !RawObject::IsCreatedFromSnapshot(tags)) || | |
1193 (kind == Snapshot::kFull)); | |
1194 | 1133 |
1195 // Allocate Namespace object. | 1134 // Allocate Namespace object. |
1196 Namespace& ns = Namespace::ZoneHandle( | 1135 Namespace& ns = Namespace::ZoneHandle( |
1197 reader->zone(), NEW_OBJECT(Namespace)); | 1136 reader->zone(), NEW_OBJECT(Namespace)); |
1198 reader->AddBackRef(object_id, &ns, kIsDeserialized); | 1137 reader->AddBackRef(object_id, &ns, kIsDeserialized); |
1199 | 1138 |
1200 // Set the object tags. | |
1201 ns.set_tags(tags); | |
1202 | |
1203 // Set all the object fields. | 1139 // Set all the object fields. |
1204 // TODO(5411462): Need to assert No GC can happen here, even though | 1140 // TODO(5411462): Need to assert No GC can happen here, even though |
1205 // allocations may happen. | 1141 // allocations may happen. |
1206 intptr_t num_flds = (ns.raw()->to() - ns.raw()->from()); | 1142 intptr_t num_flds = (ns.raw()->to() - ns.raw()->from()); |
1207 for (intptr_t i = 0; i <= num_flds; i++) { | 1143 for (intptr_t i = 0; i <= num_flds; i++) { |
1208 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | 1144 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
1209 ns.StorePointer((ns.raw()->from() + i), | 1145 ns.StorePointer((ns.raw()->from() + i), |
1210 reader->PassiveObjectHandle()->raw()); | 1146 reader->PassiveObjectHandle()->raw()); |
1211 } | 1147 } |
1212 | 1148 |
1213 return ns.raw(); | 1149 return ns.raw(); |
1214 } | 1150 } |
1215 | 1151 |
1216 | 1152 |
1217 void RawNamespace::WriteTo(SnapshotWriter* writer, | 1153 void RawNamespace::WriteTo(SnapshotWriter* writer, |
1218 intptr_t object_id, | 1154 intptr_t object_id, |
1219 Snapshot::Kind kind) { | 1155 Snapshot::Kind kind) { |
1220 ASSERT(writer != NULL); | 1156 ASSERT(writer != NULL); |
1221 ASSERT(((kind == Snapshot::kScript) && | 1157 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
1222 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || | |
1223 (kind == Snapshot::kFull)); | |
1224 | 1158 |
1225 // Write out the serialization header value for this object. | 1159 // Write out the serialization header value for this object. |
1226 writer->WriteInlinedObjectHeader(object_id); | 1160 writer->WriteInlinedObjectHeader(object_id); |
1227 | 1161 |
1228 // Write out the class and tags information. | 1162 // Write out the class and tags information. |
1229 writer->WriteVMIsolateObject(kNamespaceCid); | 1163 writer->WriteVMIsolateObject(kNamespaceCid); |
1230 writer->WriteTags(writer->GetObjectTags(this)); | 1164 writer->WriteTags(writer->GetObjectTags(this)); |
1231 | 1165 |
1232 // Write out all the object pointer fields. | 1166 // Write out all the object pointer fields. |
1233 SnapshotWriterVisitor visitor(writer); | 1167 SnapshotWriterVisitor visitor(writer); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 intptr_t object_id, | 1223 intptr_t object_id, |
1290 intptr_t tags, | 1224 intptr_t tags, |
1291 Snapshot::Kind kind) { | 1225 Snapshot::Kind kind) { |
1292 ASSERT(reader->allow_code()); | 1226 ASSERT(reader->allow_code()); |
1293 | 1227 |
1294 const int32_t length = reader->Read<int32_t>(); | 1228 const int32_t length = reader->Read<int32_t>(); |
1295 PcDescriptors& result = PcDescriptors::ZoneHandle(reader->zone(), | 1229 PcDescriptors& result = PcDescriptors::ZoneHandle(reader->zone(), |
1296 PcDescriptors::New(length)); | 1230 PcDescriptors::New(length)); |
1297 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1231 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1298 | 1232 |
1299 // Set the object tags. | |
1300 result.set_tags(tags); | |
1301 | |
1302 if (result.Length() > 0) { | 1233 if (result.Length() > 0) { |
1303 NoSafepointScope no_safepoint; | 1234 NoSafepointScope no_safepoint; |
1304 intptr_t len = result.Length(); | 1235 intptr_t len = result.Length(); |
1305 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data()); | 1236 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data()); |
1306 reader->ReadBytes(data, len); | 1237 reader->ReadBytes(data, len); |
1307 } | 1238 } |
1308 | 1239 |
1309 return result.raw(); | 1240 return result.raw(); |
1310 } | 1241 } |
1311 | 1242 |
(...skipping 24 matching lines...) Expand all Loading... |
1336 | 1267 |
1337 const int32_t length = reader->Read<int32_t>(); | 1268 const int32_t length = reader->Read<int32_t>(); |
1338 const int32_t register_bit_count = reader->Read<int32_t>(); | 1269 const int32_t register_bit_count = reader->Read<int32_t>(); |
1339 const uword pc_offset = reader->Read<uint32_t>(); | 1270 const uword pc_offset = reader->Read<uint32_t>(); |
1340 | 1271 |
1341 Stackmap& result = | 1272 Stackmap& result = |
1342 Stackmap::ZoneHandle(reader->zone(), | 1273 Stackmap::ZoneHandle(reader->zone(), |
1343 Stackmap::New(length, register_bit_count, pc_offset)); | 1274 Stackmap::New(length, register_bit_count, pc_offset)); |
1344 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1275 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1345 | 1276 |
1346 // Set the object tags. | |
1347 result.set_tags(tags); | |
1348 | |
1349 if (result.Length() > 0) { | 1277 if (result.Length() > 0) { |
1350 NoSafepointScope no_safepoint; | 1278 NoSafepointScope no_safepoint; |
1351 intptr_t len = (result.Length() + 7) / 8; | 1279 intptr_t len = (result.Length() + 7) / 8; |
1352 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data()); | 1280 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data()); |
1353 reader->ReadBytes(data, len); | 1281 reader->ReadBytes(data, len); |
1354 } | 1282 } |
1355 | 1283 |
1356 return result.raw(); | 1284 return result.raw(); |
1357 } | 1285 } |
1358 | 1286 |
(...skipping 24 matching lines...) Expand all Loading... |
1383 Snapshot::Kind kind) { | 1311 Snapshot::Kind kind) { |
1384 ASSERT(reader->allow_code()); | 1312 ASSERT(reader->allow_code()); |
1385 | 1313 |
1386 const int32_t num_entries = reader->Read<int32_t>(); | 1314 const int32_t num_entries = reader->Read<int32_t>(); |
1387 | 1315 |
1388 LocalVarDescriptors& result = | 1316 LocalVarDescriptors& result = |
1389 LocalVarDescriptors::ZoneHandle(reader->zone(), | 1317 LocalVarDescriptors::ZoneHandle(reader->zone(), |
1390 LocalVarDescriptors::New(num_entries)); | 1318 LocalVarDescriptors::New(num_entries)); |
1391 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1319 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1392 | 1320 |
1393 // Set the object tags. | |
1394 result.set_tags(tags); | |
1395 | |
1396 for (intptr_t i = 0; i < num_entries; i++) { | 1321 for (intptr_t i = 0; i < num_entries; i++) { |
1397 (*reader->StringHandle()) ^= reader->ReadObjectImpl(kAsReference); | 1322 (*reader->StringHandle()) ^= reader->ReadObjectImpl(kAsReference); |
1398 result.StorePointer(result.raw()->nameAddrAt(i), | 1323 result.StorePointer(result.raw()->nameAddrAt(i), |
1399 reader->StringHandle()->raw()); | 1324 reader->StringHandle()->raw()); |
1400 } | 1325 } |
1401 | 1326 |
1402 if (num_entries > 0) { | 1327 if (num_entries > 0) { |
1403 NoSafepointScope no_safepoint; | 1328 NoSafepointScope no_safepoint; |
1404 intptr_t len = num_entries * sizeof(RawLocalVarDescriptors::VarInfo); | 1329 intptr_t len = num_entries * sizeof(RawLocalVarDescriptors::VarInfo); |
1405 uint8_t* data = result.UnsafeMutableNonPointer( | 1330 uint8_t* data = result.UnsafeMutableNonPointer( |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1439 ASSERT(reader->allow_code()); | 1364 ASSERT(reader->allow_code()); |
1440 | 1365 |
1441 // handled_types_data. | 1366 // handled_types_data. |
1442 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); | 1367 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); |
1443 | 1368 |
1444 ExceptionHandlers& result = | 1369 ExceptionHandlers& result = |
1445 ExceptionHandlers::ZoneHandle(reader->zone(), | 1370 ExceptionHandlers::ZoneHandle(reader->zone(), |
1446 ExceptionHandlers::New(*reader->ArrayHandle())); | 1371 ExceptionHandlers::New(*reader->ArrayHandle())); |
1447 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1372 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1448 | 1373 |
1449 // Set the object tags. | |
1450 result.set_tags(tags); | |
1451 | |
1452 if (result.num_entries() > 0) { | 1374 if (result.num_entries() > 0) { |
1453 NoSafepointScope no_safepoint; | 1375 NoSafepointScope no_safepoint; |
1454 const intptr_t len = | 1376 const intptr_t len = |
1455 result.num_entries() * sizeof(RawExceptionHandlers::HandlerInfo); | 1377 result.num_entries() * sizeof(RawExceptionHandlers::HandlerInfo); |
1456 uint8_t* data = result.UnsafeMutableNonPointer( | 1378 uint8_t* data = result.UnsafeMutableNonPointer( |
1457 reinterpret_cast<const uint8_t*>(result.raw_ptr()->data())); | 1379 reinterpret_cast<const uint8_t*>(result.raw_ptr()->data())); |
1458 reader->ReadBytes(data, len); | 1380 reader->ReadBytes(data, len); |
1459 } | 1381 } |
1460 | 1382 |
1461 return result.raw(); | 1383 return result.raw(); |
(...skipping 27 matching lines...) Expand all Loading... |
1489 | 1411 |
1490 // Allocate context object. | 1412 // Allocate context object. |
1491 int32_t num_vars = reader->Read<int32_t>(); | 1413 int32_t num_vars = reader->Read<int32_t>(); |
1492 Context& context = Context::ZoneHandle(reader->zone()); | 1414 Context& context = Context::ZoneHandle(reader->zone()); |
1493 reader->AddBackRef(object_id, &context, kIsDeserialized); | 1415 reader->AddBackRef(object_id, &context, kIsDeserialized); |
1494 if (num_vars == 0) { | 1416 if (num_vars == 0) { |
1495 context ^= reader->object_store()->empty_context(); | 1417 context ^= reader->object_store()->empty_context(); |
1496 } else { | 1418 } else { |
1497 context ^= NEW_OBJECT_WITH_LEN(Context, num_vars); | 1419 context ^= NEW_OBJECT_WITH_LEN(Context, num_vars); |
1498 | 1420 |
1499 // Set the object tags. | |
1500 context.set_tags(tags); | |
1501 | |
1502 // Set all the object fields. | 1421 // Set all the object fields. |
1503 // TODO(5411462): Need to assert No GC can happen here, even though | 1422 // TODO(5411462): Need to assert No GC can happen here, even though |
1504 // allocations may happen. | 1423 // allocations may happen. |
1505 intptr_t num_flds = (context.raw()->to(num_vars) - context.raw()->from()); | 1424 intptr_t num_flds = (context.raw()->to(num_vars) - context.raw()->from()); |
1506 for (intptr_t i = 0; i <= num_flds; i++) { | 1425 for (intptr_t i = 0; i <= num_flds; i++) { |
1507 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | 1426 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
1508 context.StorePointer((context.raw()->from() + i), | 1427 context.StorePointer((context.raw()->from() + i), |
1509 reader->PassiveObjectHandle()->raw()); | 1428 reader->PassiveObjectHandle()->raw()); |
1510 } | 1429 } |
1511 } | 1430 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1620 intptr_t object_id, | 1539 intptr_t object_id, |
1621 intptr_t tags, | 1540 intptr_t tags, |
1622 Snapshot::Kind kind) { | 1541 Snapshot::Kind kind) { |
1623 ASSERT(reader != NULL); | 1542 ASSERT(reader != NULL); |
1624 | 1543 |
1625 // Allocate ApiError object. | 1544 // Allocate ApiError object. |
1626 ApiError& api_error = | 1545 ApiError& api_error = |
1627 ApiError::ZoneHandle(reader->zone(), NEW_OBJECT(ApiError)); | 1546 ApiError::ZoneHandle(reader->zone(), NEW_OBJECT(ApiError)); |
1628 reader->AddBackRef(object_id, &api_error, kIsDeserialized); | 1547 reader->AddBackRef(object_id, &api_error, kIsDeserialized); |
1629 | 1548 |
1630 // Set the object tags. | |
1631 api_error.set_tags(tags); | |
1632 | |
1633 // Set all the object fields. | 1549 // Set all the object fields. |
1634 // TODO(5411462): Need to assert No GC can happen here, even though | 1550 // TODO(5411462): Need to assert No GC can happen here, even though |
1635 // allocations may happen. | 1551 // allocations may happen. |
1636 intptr_t num_flds = (api_error.raw()->to() - api_error.raw()->from()); | 1552 intptr_t num_flds = (api_error.raw()->to() - api_error.raw()->from()); |
1637 for (intptr_t i = 0; i <= num_flds; i++) { | 1553 for (intptr_t i = 0; i <= num_flds; i++) { |
1638 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | 1554 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
1639 api_error.StorePointer((api_error.raw()->from() + i), | 1555 api_error.StorePointer((api_error.raw()->from() + i), |
1640 reader->PassiveObjectHandle()->raw()); | 1556 reader->PassiveObjectHandle()->raw()); |
1641 } | 1557 } |
1642 | 1558 |
(...skipping 23 matching lines...) Expand all Loading... |
1666 intptr_t object_id, | 1582 intptr_t object_id, |
1667 intptr_t tags, | 1583 intptr_t tags, |
1668 Snapshot::Kind kind) { | 1584 Snapshot::Kind kind) { |
1669 ASSERT(reader != NULL); | 1585 ASSERT(reader != NULL); |
1670 | 1586 |
1671 // Allocate LanguageError object. | 1587 // Allocate LanguageError object. |
1672 LanguageError& language_error = | 1588 LanguageError& language_error = |
1673 LanguageError::ZoneHandle(reader->zone(), NEW_OBJECT(LanguageError)); | 1589 LanguageError::ZoneHandle(reader->zone(), NEW_OBJECT(LanguageError)); |
1674 reader->AddBackRef(object_id, &language_error, kIsDeserialized); | 1590 reader->AddBackRef(object_id, &language_error, kIsDeserialized); |
1675 | 1591 |
1676 // Set the object tags. | |
1677 language_error.set_tags(tags); | |
1678 | |
1679 // Set all non object fields. | 1592 // Set all non object fields. |
1680 language_error.set_token_pos(reader->Read<int32_t>()); | 1593 language_error.set_token_pos(reader->Read<int32_t>()); |
1681 language_error.set_kind(reader->Read<uint8_t>()); | 1594 language_error.set_kind(reader->Read<uint8_t>()); |
1682 | 1595 |
1683 // Set all the object fields. | 1596 // Set all the object fields. |
1684 // TODO(5411462): Need to assert No GC can happen here, even though | 1597 // TODO(5411462): Need to assert No GC can happen here, even though |
1685 // allocations may happen. | 1598 // allocations may happen. |
1686 intptr_t num_flds = | 1599 intptr_t num_flds = |
1687 (language_error.raw()->to() - language_error.raw()->from()); | 1600 (language_error.raw()->to() - language_error.raw()->from()); |
1688 for (intptr_t i = 0; i <= num_flds; i++) { | 1601 for (intptr_t i = 0; i <= num_flds; i++) { |
(...skipping 29 matching lines...) Expand all Loading... |
1718 | 1631 |
1719 | 1632 |
1720 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader, | 1633 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader, |
1721 intptr_t object_id, | 1634 intptr_t object_id, |
1722 intptr_t tags, | 1635 intptr_t tags, |
1723 Snapshot::Kind kind) { | 1636 Snapshot::Kind kind) { |
1724 UnhandledException& result = UnhandledException::ZoneHandle( | 1637 UnhandledException& result = UnhandledException::ZoneHandle( |
1725 reader->zone(), NEW_OBJECT(UnhandledException)); | 1638 reader->zone(), NEW_OBJECT(UnhandledException)); |
1726 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1639 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1727 | 1640 |
1728 // Set the object tags. | |
1729 result.set_tags(tags); | |
1730 | |
1731 // Set all the object fields. | 1641 // Set all the object fields. |
1732 // TODO(5411462): Need to assert No GC can happen here, even though | 1642 // TODO(5411462): Need to assert No GC can happen here, even though |
1733 // allocations may happen. | 1643 // allocations may happen. |
1734 intptr_t num_flds = (result.raw()->to() - result.raw()->from()); | 1644 intptr_t num_flds = (result.raw()->to() - result.raw()->from()); |
1735 for (intptr_t i = 0; i <= num_flds; i++) { | 1645 for (intptr_t i = 0; i <= num_flds; i++) { |
1736 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | 1646 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
1737 result.StorePointer((result.raw()->from() + i), | 1647 result.StorePointer((result.raw()->from() + i), |
1738 reader->PassiveObjectHandle()->raw()); | 1648 reader->PassiveObjectHandle()->raw()); |
1739 } | 1649 } |
1740 | 1650 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1777 intptr_t object_id, | 1687 intptr_t object_id, |
1778 intptr_t tags, | 1688 intptr_t tags, |
1779 Snapshot::Kind kind) { | 1689 Snapshot::Kind kind) { |
1780 ASSERT(reader != NULL); | 1690 ASSERT(reader != NULL); |
1781 | 1691 |
1782 // Create an Instance object or get canonical one if it is a canonical | 1692 // Create an Instance object or get canonical one if it is a canonical |
1783 // constant. | 1693 // constant. |
1784 Instance& obj = Instance::ZoneHandle(reader->zone(), Instance::null()); | 1694 Instance& obj = Instance::ZoneHandle(reader->zone(), Instance::null()); |
1785 if (kind == Snapshot::kFull) { | 1695 if (kind == Snapshot::kFull) { |
1786 obj = reader->NewInstance(); | 1696 obj = reader->NewInstance(); |
| 1697 // Set the canonical bit. |
| 1698 if (RawObject::IsCanonical(tags)) { |
| 1699 obj.SetCanonical(); |
| 1700 } |
1787 } else { | 1701 } else { |
1788 obj ^= Object::Allocate(kInstanceCid, | 1702 obj ^= Object::Allocate(kInstanceCid, |
1789 Instance::InstanceSize(), | 1703 Instance::InstanceSize(), |
1790 HEAP_SPACE(kind)); | 1704 HEAP_SPACE(kind)); |
1791 // When reading a script snapshot we need to canonicalize only those object | 1705 if (RawObject::IsCanonical(tags)) { |
1792 // references that are objects from the core library (loaded from a | |
1793 // full snapshot). Objects that are only in the script need not be | |
1794 // canonicalized as they are already canonical. | |
1795 // When reading a message snapshot we always have to canonicalize. | |
1796 if (RawObject::IsCanonical(tags) && | |
1797 (RawObject::IsCreatedFromSnapshot(tags) || | |
1798 (kind == Snapshot::kMessage))) { | |
1799 obj = obj.CheckAndCanonicalize(NULL); | 1706 obj = obj.CheckAndCanonicalize(NULL); |
1800 } | 1707 } |
1801 } | 1708 } |
1802 reader->AddBackRef(object_id, &obj, kIsDeserialized); | 1709 reader->AddBackRef(object_id, &obj, kIsDeserialized); |
1803 | 1710 |
1804 // Set the object tags. | |
1805 obj.set_tags(tags); | |
1806 | |
1807 return obj.raw(); | 1711 return obj.raw(); |
1808 } | 1712 } |
1809 | 1713 |
1810 | 1714 |
1811 void RawInstance::WriteTo(SnapshotWriter* writer, | 1715 void RawInstance::WriteTo(SnapshotWriter* writer, |
1812 intptr_t object_id, | 1716 intptr_t object_id, |
1813 Snapshot::Kind kind) { | 1717 Snapshot::Kind kind) { |
1814 ASSERT(writer != NULL); | 1718 ASSERT(writer != NULL); |
1815 | 1719 |
1816 // Write out the serialization header value for this object. | 1720 // Write out the serialization header value for this object. |
(...skipping 20 matching lines...) Expand all Loading... |
1837 Smi& smi = Smi::ZoneHandle(reader->zone(), | 1741 Smi& smi = Smi::ZoneHandle(reader->zone(), |
1838 Smi::New(static_cast<intptr_t>(value))); | 1742 Smi::New(static_cast<intptr_t>(value))); |
1839 reader->AddBackRef(object_id, &smi, kIsDeserialized); | 1743 reader->AddBackRef(object_id, &smi, kIsDeserialized); |
1840 return smi.raw(); | 1744 return smi.raw(); |
1841 } | 1745 } |
1842 | 1746 |
1843 // Create a Mint object or get canonical one if it is a canonical constant. | 1747 // Create a Mint object or get canonical one if it is a canonical constant. |
1844 Mint& mint = Mint::ZoneHandle(reader->zone(), Mint::null()); | 1748 Mint& mint = Mint::ZoneHandle(reader->zone(), Mint::null()); |
1845 if (kind == Snapshot::kFull) { | 1749 if (kind == Snapshot::kFull) { |
1846 mint = reader->NewMint(value); | 1750 mint = reader->NewMint(value); |
1847 // Set the object tags. | 1751 // Set the canonical bit. |
1848 mint.set_tags(tags); | 1752 if (RawObject::IsCanonical(tags)) { |
| 1753 mint.SetCanonical(); |
| 1754 } |
1849 } else { | 1755 } else { |
1850 // When reading a script snapshot we need to canonicalize only those object | 1756 // When reading a script snapshot we need to canonicalize only those object |
1851 // references that are objects from the core library (loaded from a | 1757 // references that are objects from the core library (loaded from a |
1852 // full snapshot). Objects that are only in the script need not be | 1758 // full snapshot). Objects that are only in the script need not be |
1853 // canonicalized as they are already canonical. | 1759 // canonicalized as they are already canonical. |
1854 // When reading a message snapshot we always have to canonicalize. | 1760 // When reading a message snapshot we always have to canonicalize. |
1855 if (RawObject::IsCanonical(tags) && | 1761 if (RawObject::IsCanonical(tags)) { |
1856 (RawObject::IsCreatedFromSnapshot(tags) || | |
1857 (kind == Snapshot::kMessage))) { | |
1858 mint = Mint::NewCanonical(value); | 1762 mint = Mint::NewCanonical(value); |
1859 ASSERT(mint.IsCanonical() && | 1763 ASSERT(mint.IsCanonical()); |
1860 (kind == Snapshot::kMessage || | |
1861 RawObject::IsCreatedFromSnapshot(mint.raw()->ptr()->tags_))); | |
1862 } else { | 1764 } else { |
1863 mint = Mint::New(value, HEAP_SPACE(kind)); | 1765 mint = Mint::New(value, HEAP_SPACE(kind)); |
1864 // Set the object tags. | |
1865 mint.set_tags(tags); | |
1866 } | 1766 } |
1867 } | 1767 } |
1868 reader->AddBackRef(object_id, &mint, kIsDeserialized); | 1768 reader->AddBackRef(object_id, &mint, kIsDeserialized); |
1869 return mint.raw(); | 1769 return mint.raw(); |
1870 } | 1770 } |
1871 | 1771 |
1872 | 1772 |
1873 void RawMint::WriteTo(SnapshotWriter* writer, | 1773 void RawMint::WriteTo(SnapshotWriter* writer, |
1874 intptr_t object_id, | 1774 intptr_t object_id, |
1875 Snapshot::Kind kind) { | 1775 Snapshot::Kind kind) { |
(...skipping 27 matching lines...) Expand all Loading... |
1903 intptr_t num_flds = (obj.raw()->to() - obj.raw()->from()); | 1803 intptr_t num_flds = (obj.raw()->to() - obj.raw()->from()); |
1904 for (intptr_t i = 0; i <= num_flds; i++) { | 1804 for (intptr_t i = 0; i <= num_flds; i++) { |
1905 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsInlinedObject); | 1805 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsInlinedObject); |
1906 obj.StorePointer(obj.raw()->from() + i, | 1806 obj.StorePointer(obj.raw()->from() + i, |
1907 reader->PassiveObjectHandle()->raw()); | 1807 reader->PassiveObjectHandle()->raw()); |
1908 } | 1808 } |
1909 | 1809 |
1910 // If it is a canonical constant make it one. | 1810 // If it is a canonical constant make it one. |
1911 // When reading a full snapshot we don't need to canonicalize the object | 1811 // When reading a full snapshot we don't need to canonicalize the object |
1912 // as it would already be a canonical object. | 1812 // as it would already be a canonical object. |
1913 // When reading a script snapshot we need to canonicalize only those object | 1813 // When reading a script snapshot or a message snapshot we always have |
1914 // references that are objects from the core library (loaded from a | 1814 // to canonicalize the object. |
1915 // full snapshot). Objects that are only in the script need not be | 1815 if (RawObject::IsCanonical(tags)) { |
1916 // canonicalized as they are already canonical. | 1816 if (kind == Snapshot::kFull) { |
1917 // When reading a message snapshot we always have to canonicalize the object. | 1817 // Set the canonical bit. |
1918 if (kind == Snapshot::kFull) { | 1818 obj.SetCanonical(); |
1919 // Set the object tags. | 1819 } else { |
1920 obj.set_tags(tags); | 1820 obj ^= obj.CheckAndCanonicalize(NULL); |
1921 } else if (RawObject::IsCanonical(tags) && | 1821 ASSERT(!obj.IsNull()); |
1922 (RawObject::IsCreatedFromSnapshot(tags) || | 1822 ASSERT(obj.IsCanonical()); |
1923 (kind == Snapshot::kMessage))) { | 1823 } |
1924 obj ^= obj.CheckAndCanonicalize(NULL); | |
1925 ASSERT(!obj.IsNull()); | |
1926 ASSERT(obj.IsCanonical() && | |
1927 (kind == Snapshot::kMessage || | |
1928 RawObject::IsCreatedFromSnapshot(obj.raw()->ptr()->tags_))); | |
1929 } else { | |
1930 // Set the object tags. | |
1931 obj.set_tags(tags); | |
1932 } | 1824 } |
1933 return obj.raw(); | 1825 return obj.raw(); |
1934 } | 1826 } |
1935 | 1827 |
1936 | 1828 |
1937 void RawBigint::WriteTo(SnapshotWriter* writer, | 1829 void RawBigint::WriteTo(SnapshotWriter* writer, |
1938 intptr_t object_id, | 1830 intptr_t object_id, |
1939 Snapshot::Kind kind) { | 1831 Snapshot::Kind kind) { |
1940 ASSERT(writer != NULL); | 1832 ASSERT(writer != NULL); |
1941 | 1833 |
(...skipping 16 matching lines...) Expand all Loading... |
1958 Snapshot::Kind kind) { | 1850 Snapshot::Kind kind) { |
1959 ASSERT(reader != NULL); | 1851 ASSERT(reader != NULL); |
1960 ASSERT(kind != Snapshot::kMessage); | 1852 ASSERT(kind != Snapshot::kMessage); |
1961 // Read the double value for the object. | 1853 // Read the double value for the object. |
1962 double value = reader->ReadDouble(); | 1854 double value = reader->ReadDouble(); |
1963 | 1855 |
1964 // Create a Double object or get canonical one if it is a canonical constant. | 1856 // Create a Double object or get canonical one if it is a canonical constant. |
1965 Double& dbl = Double::ZoneHandle(reader->zone(), Double::null()); | 1857 Double& dbl = Double::ZoneHandle(reader->zone(), Double::null()); |
1966 if (kind == Snapshot::kFull) { | 1858 if (kind == Snapshot::kFull) { |
1967 dbl = reader->NewDouble(value); | 1859 dbl = reader->NewDouble(value); |
1968 // Set the object tags. | 1860 // Set the canonical bit. |
1969 dbl.set_tags(tags); | 1861 if (RawObject::IsCanonical(tags)) { |
| 1862 dbl.SetCanonical(); |
| 1863 } |
1970 } else { | 1864 } else { |
1971 // When reading a script snapshot we need to canonicalize only those object | 1865 // When reading a script snapshot we need to canonicalize only those object |
1972 // references that are objects from the core library (loaded from a | 1866 // references that are objects from the core library (loaded from a |
1973 // full snapshot). Objects that are only in the script need not be | 1867 // full snapshot). Objects that are only in the script need not be |
1974 // canonicalized as they are already canonical. | 1868 // canonicalized as they are already canonical. |
1975 if (RawObject::IsCanonical(tags) && | 1869 if (RawObject::IsCanonical(tags)) { |
1976 RawObject::IsCreatedFromSnapshot(tags)) { | |
1977 dbl = Double::NewCanonical(value); | 1870 dbl = Double::NewCanonical(value); |
1978 ASSERT(dbl.IsCanonical() && | 1871 ASSERT(dbl.IsCanonical()); |
1979 (kind == Snapshot::kMessage || | |
1980 RawObject::IsCreatedFromSnapshot(dbl.raw()->ptr()->tags_))); | |
1981 } else { | 1872 } else { |
1982 dbl = Double::New(value, HEAP_SPACE(kind)); | 1873 dbl = Double::New(value, HEAP_SPACE(kind)); |
1983 // Set the object tags. | |
1984 dbl.set_tags(tags); | |
1985 } | 1874 } |
1986 } | 1875 } |
1987 reader->AddBackRef(object_id, &dbl, kIsDeserialized); | 1876 reader->AddBackRef(object_id, &dbl, kIsDeserialized); |
1988 return dbl.raw(); | 1877 return dbl.raw(); |
1989 } | 1878 } |
1990 | 1879 |
1991 | 1880 |
1992 void RawDouble::WriteTo(SnapshotWriter* writer, | 1881 void RawDouble::WriteTo(SnapshotWriter* writer, |
1993 intptr_t object_id, | 1882 intptr_t object_id, |
1994 Snapshot::Kind kind) { | 1883 Snapshot::Kind kind) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2034 // Set up canonical string object. | 1923 // Set up canonical string object. |
2035 ASSERT(reader != NULL); | 1924 ASSERT(reader != NULL); |
2036 CharacterType* ptr = reader->zone()->Alloc<CharacterType>(len); | 1925 CharacterType* ptr = reader->zone()->Alloc<CharacterType>(len); |
2037 for (intptr_t i = 0; i < len; i++) { | 1926 for (intptr_t i = 0; i < len; i++) { |
2038 ptr[i] = reader->Read<CharacterType>(); | 1927 ptr[i] = reader->Read<CharacterType>(); |
2039 } | 1928 } |
2040 *str_obj ^= (*new_symbol)(ptr, len); | 1929 *str_obj ^= (*new_symbol)(ptr, len); |
2041 } else { | 1930 } else { |
2042 // Set up the string object. | 1931 // Set up the string object. |
2043 *str_obj = StringType::New(len, HEAP_SPACE(kind)); | 1932 *str_obj = StringType::New(len, HEAP_SPACE(kind)); |
2044 str_obj->set_tags(tags); | |
2045 str_obj->SetHash(0); // Will get computed when needed. | 1933 str_obj->SetHash(0); // Will get computed when needed. |
2046 if (len == 0) { | 1934 if (len == 0) { |
2047 return; | 1935 return; |
2048 } | 1936 } |
2049 NoSafepointScope no_safepoint; | 1937 NoSafepointScope no_safepoint; |
2050 CharacterType* str_addr = StringType::CharAddr(*str_obj, 0); | 1938 CharacterType* str_addr = StringType::CharAddr(*str_obj, 0); |
2051 for (intptr_t i = 0; i < len; i++) { | 1939 for (intptr_t i = 0; i < len; i++) { |
2052 *str_addr = reader->Read<CharacterType>(); | 1940 *str_addr = reader->Read<CharacterType>(); |
2053 str_addr++; | 1941 str_addr++; |
2054 } | 1942 } |
(...skipping 10 matching lines...) Expand all Loading... |
2065 intptr_t len = reader->ReadSmiValue(); | 1953 intptr_t len = reader->ReadSmiValue(); |
2066 intptr_t hash = reader->ReadSmiValue(); | 1954 intptr_t hash = reader->ReadSmiValue(); |
2067 String& str_obj = String::Handle(reader->zone(), String::null()); | 1955 String& str_obj = String::Handle(reader->zone(), String::null()); |
2068 | 1956 |
2069 if (kind == Snapshot::kFull) { | 1957 if (kind == Snapshot::kFull) { |
2070 // We currently only expect the Dart mutator to read snapshots. | 1958 // We currently only expect the Dart mutator to read snapshots. |
2071 reader->isolate()->AssertCurrentThreadIsMutator(); | 1959 reader->isolate()->AssertCurrentThreadIsMutator(); |
2072 ASSERT(Thread::Current()->no_safepoint_scope_depth() != 0); | 1960 ASSERT(Thread::Current()->no_safepoint_scope_depth() != 0); |
2073 RawOneByteString* obj = reader->NewOneByteString(len); | 1961 RawOneByteString* obj = reader->NewOneByteString(len); |
2074 str_obj = obj; | 1962 str_obj = obj; |
2075 str_obj.set_tags(tags); | 1963 if (RawObject::IsCanonical(tags)) { |
| 1964 str_obj.SetCanonical(); |
| 1965 } |
2076 str_obj.SetHash(hash); | 1966 str_obj.SetHash(hash); |
2077 if (len > 0) { | 1967 if (len > 0) { |
2078 uint8_t* raw_ptr = CharAddr(str_obj, 0); | 1968 uint8_t* raw_ptr = CharAddr(str_obj, 0); |
2079 reader->ReadBytes(raw_ptr, len); | 1969 reader->ReadBytes(raw_ptr, len); |
2080 } | 1970 } |
2081 ASSERT((hash == 0) || (String::Hash(str_obj, 0, str_obj.Length()) == hash)); | 1971 ASSERT((hash == 0) || (String::Hash(str_obj, 0, str_obj.Length()) == hash)); |
2082 } else { | 1972 } else { |
2083 String::ReadFromImpl<OneByteString, uint8_t>( | 1973 String::ReadFromImpl<OneByteString, uint8_t>( |
2084 reader, &str_obj, len, tags, Symbols::FromLatin1, kind); | 1974 reader, &str_obj, len, tags, Symbols::FromLatin1, kind); |
2085 } | 1975 } |
2086 reader->AddBackRef(object_id, &str_obj, kIsDeserialized); | 1976 reader->AddBackRef(object_id, &str_obj, kIsDeserialized); |
2087 return raw(str_obj); | 1977 return raw(str_obj); |
2088 } | 1978 } |
2089 | 1979 |
2090 | 1980 |
2091 RawTwoByteString* TwoByteString::ReadFrom(SnapshotReader* reader, | 1981 RawTwoByteString* TwoByteString::ReadFrom(SnapshotReader* reader, |
2092 intptr_t object_id, | 1982 intptr_t object_id, |
2093 intptr_t tags, | 1983 intptr_t tags, |
2094 Snapshot::Kind kind) { | 1984 Snapshot::Kind kind) { |
2095 // Read the length so that we can determine instance size to allocate. | 1985 // Read the length so that we can determine instance size to allocate. |
2096 ASSERT(reader != NULL); | 1986 ASSERT(reader != NULL); |
2097 intptr_t len = reader->ReadSmiValue(); | 1987 intptr_t len = reader->ReadSmiValue(); |
2098 intptr_t hash = reader->ReadSmiValue(); | 1988 intptr_t hash = reader->ReadSmiValue(); |
2099 String& str_obj = String::Handle(reader->zone(), String::null()); | 1989 String& str_obj = String::Handle(reader->zone(), String::null()); |
2100 | 1990 |
2101 if (kind == Snapshot::kFull) { | 1991 if (kind == Snapshot::kFull) { |
2102 RawTwoByteString* obj = reader->NewTwoByteString(len); | 1992 RawTwoByteString* obj = reader->NewTwoByteString(len); |
2103 str_obj = obj; | 1993 str_obj = obj; |
2104 str_obj.set_tags(tags); | 1994 if (RawObject::IsCanonical(tags)) { |
| 1995 str_obj.SetCanonical(); |
| 1996 } |
2105 str_obj.SetHash(hash); | 1997 str_obj.SetHash(hash); |
2106 NoSafepointScope no_safepoint; | 1998 NoSafepointScope no_safepoint; |
2107 uint16_t* raw_ptr = (len > 0)? CharAddr(str_obj, 0) : NULL; | 1999 uint16_t* raw_ptr = (len > 0)? CharAddr(str_obj, 0) : NULL; |
2108 for (intptr_t i = 0; i < len; i++) { | 2000 for (intptr_t i = 0; i < len; i++) { |
2109 ASSERT(CharAddr(str_obj, i) == raw_ptr); // Will trigger assertions. | 2001 ASSERT(CharAddr(str_obj, i) == raw_ptr); // Will trigger assertions. |
2110 *raw_ptr = reader->Read<uint16_t>(); | 2002 *raw_ptr = reader->Read<uint16_t>(); |
2111 raw_ptr += 1; | 2003 raw_ptr += 1; |
2112 } | 2004 } |
2113 ASSERT(String::Hash(str_obj, 0, str_obj.Length()) == hash); | 2005 ASSERT(String::Hash(str_obj, 0, str_obj.Length()) == hash); |
2114 } else { | 2006 } else { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2283 intptr_t len = reader->ReadSmiValue(); | 2175 intptr_t len = reader->ReadSmiValue(); |
2284 Array* array = reinterpret_cast<Array*>(reader->GetBackRef(object_id)); | 2176 Array* array = reinterpret_cast<Array*>(reader->GetBackRef(object_id)); |
2285 if (array == NULL) { | 2177 if (array == NULL) { |
2286 array = &(Array::ZoneHandle( | 2178 array = &(Array::ZoneHandle( |
2287 reader->zone(), | 2179 reader->zone(), |
2288 NEW_OBJECT_WITH_LEN_SPACE(ImmutableArray, len, kind))); | 2180 NEW_OBJECT_WITH_LEN_SPACE(ImmutableArray, len, kind))); |
2289 reader->AddBackRef(object_id, array, kIsDeserialized); | 2181 reader->AddBackRef(object_id, array, kIsDeserialized); |
2290 } | 2182 } |
2291 reader->ArrayReadFrom(object_id, *array, len, tags); | 2183 reader->ArrayReadFrom(object_id, *array, len, tags); |
2292 if (RawObject::IsCanonical(tags)) { | 2184 if (RawObject::IsCanonical(tags)) { |
2293 *array ^= array->CheckAndCanonicalize(NULL); | 2185 if (kind == Snapshot::kFull) { |
| 2186 array->SetCanonical(); |
| 2187 } else { |
| 2188 *array ^= array->CheckAndCanonicalize(NULL); |
| 2189 } |
2294 } | 2190 } |
2295 return raw(*array); | 2191 return raw(*array); |
2296 } | 2192 } |
2297 | 2193 |
2298 | 2194 |
2299 void RawArray::WriteTo(SnapshotWriter* writer, | 2195 void RawArray::WriteTo(SnapshotWriter* writer, |
2300 intptr_t object_id, | 2196 intptr_t object_id, |
2301 Snapshot::Kind kind) { | 2197 Snapshot::Kind kind) { |
2302 ASSERT(!RawObject::IsCanonical(writer->GetObjectTags(this))); | 2198 ASSERT(!RawObject::IsCanonical(writer->GetObjectTags(this))); |
2303 writer->ArrayWriteTo(object_id, | 2199 writer->ArrayWriteTo(object_id, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2389 reader->zone(), LinkedHashMap::null()); | 2285 reader->zone(), LinkedHashMap::null()); |
2390 if (kind == Snapshot::kFull || kind == Snapshot::kScript) { | 2286 if (kind == Snapshot::kFull || kind == Snapshot::kScript) { |
2391 // The immutable maps that seed map literals are not yet VM-internal, so | 2287 // The immutable maps that seed map literals are not yet VM-internal, so |
2392 // we don't reach this. | 2288 // we don't reach this. |
2393 UNREACHABLE(); | 2289 UNREACHABLE(); |
2394 } else { | 2290 } else { |
2395 // Since the map might contain itself as a key or value, allocate first. | 2291 // Since the map might contain itself as a key or value, allocate first. |
2396 map = LinkedHashMap::NewUninitialized(HEAP_SPACE(kind)); | 2292 map = LinkedHashMap::NewUninitialized(HEAP_SPACE(kind)); |
2397 } | 2293 } |
2398 reader->AddBackRef(object_id, &map, kIsDeserialized); | 2294 reader->AddBackRef(object_id, &map, kIsDeserialized); |
2399 // Set the object tags. | |
2400 map.set_tags(tags); | |
2401 | 2295 |
2402 // Read the type arguments. | 2296 // Read the type arguments. |
2403 const intptr_t typeargs_offset = | 2297 const intptr_t typeargs_offset = |
2404 GrowableObjectArray::type_arguments_offset() / kWordSize; | 2298 GrowableObjectArray::type_arguments_offset() / kWordSize; |
2405 *reader->TypeArgumentsHandle() ^= | 2299 *reader->TypeArgumentsHandle() ^= |
2406 reader->ReadObjectImpl(kAsInlinedObject, object_id, typeargs_offset); | 2300 reader->ReadObjectImpl(kAsInlinedObject, object_id, typeargs_offset); |
2407 map.SetTypeArguments(*reader->TypeArgumentsHandle()); | 2301 map.SetTypeArguments(*reader->TypeArgumentsHandle()); |
2408 | 2302 |
2409 // Read the number of key/value pairs. | 2303 // Read the number of key/value pairs. |
2410 intptr_t len = reader->ReadSmiValue(); | 2304 intptr_t len = reader->ReadSmiValue(); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2502 | 2396 |
2503 // Create a Float32x4 object. | 2397 // Create a Float32x4 object. |
2504 Float32x4& simd = Float32x4::ZoneHandle(reader->zone(), | 2398 Float32x4& simd = Float32x4::ZoneHandle(reader->zone(), |
2505 Float32x4::null()); | 2399 Float32x4::null()); |
2506 if (kind == Snapshot::kFull) { | 2400 if (kind == Snapshot::kFull) { |
2507 simd = reader->NewFloat32x4(value0, value1, value2, value3); | 2401 simd = reader->NewFloat32x4(value0, value1, value2, value3); |
2508 } else { | 2402 } else { |
2509 simd = Float32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind)); | 2403 simd = Float32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind)); |
2510 } | 2404 } |
2511 reader->AddBackRef(object_id, &simd, kIsDeserialized); | 2405 reader->AddBackRef(object_id, &simd, kIsDeserialized); |
2512 // Set the object tags. | |
2513 simd.set_tags(tags); | |
2514 return simd.raw(); | 2406 return simd.raw(); |
2515 } | 2407 } |
2516 | 2408 |
2517 | 2409 |
2518 void RawFloat32x4::WriteTo(SnapshotWriter* writer, | 2410 void RawFloat32x4::WriteTo(SnapshotWriter* writer, |
2519 intptr_t object_id, | 2411 intptr_t object_id, |
2520 Snapshot::Kind kind) { | 2412 Snapshot::Kind kind) { |
2521 ASSERT(writer != NULL); | 2413 ASSERT(writer != NULL); |
2522 | 2414 |
2523 // Write out the serialization header value for this object. | 2415 // Write out the serialization header value for this object. |
(...skipping 24 matching lines...) Expand all Loading... |
2548 | 2440 |
2549 // Create a Float32x4 object. | 2441 // Create a Float32x4 object. |
2550 Int32x4& simd = Int32x4::ZoneHandle(reader->zone(), Int32x4::null()); | 2442 Int32x4& simd = Int32x4::ZoneHandle(reader->zone(), Int32x4::null()); |
2551 | 2443 |
2552 if (kind == Snapshot::kFull) { | 2444 if (kind == Snapshot::kFull) { |
2553 simd = reader->NewInt32x4(value0, value1, value2, value3); | 2445 simd = reader->NewInt32x4(value0, value1, value2, value3); |
2554 } else { | 2446 } else { |
2555 simd = Int32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind)); | 2447 simd = Int32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind)); |
2556 } | 2448 } |
2557 reader->AddBackRef(object_id, &simd, kIsDeserialized); | 2449 reader->AddBackRef(object_id, &simd, kIsDeserialized); |
2558 // Set the object tags. | |
2559 simd.set_tags(tags); | |
2560 return simd.raw(); | 2450 return simd.raw(); |
2561 } | 2451 } |
2562 | 2452 |
2563 | 2453 |
2564 void RawInt32x4::WriteTo(SnapshotWriter* writer, | 2454 void RawInt32x4::WriteTo(SnapshotWriter* writer, |
2565 intptr_t object_id, | 2455 intptr_t object_id, |
2566 Snapshot::Kind kind) { | 2456 Snapshot::Kind kind) { |
2567 ASSERT(writer != NULL); | 2457 ASSERT(writer != NULL); |
2568 | 2458 |
2569 // Write out the serialization header value for this object. | 2459 // Write out the serialization header value for this object. |
(...skipping 22 matching lines...) Expand all Loading... |
2592 | 2482 |
2593 // Create a Float64x2 object. | 2483 // Create a Float64x2 object. |
2594 Float64x2& simd = Float64x2::ZoneHandle(reader->zone(), | 2484 Float64x2& simd = Float64x2::ZoneHandle(reader->zone(), |
2595 Float64x2::null()); | 2485 Float64x2::null()); |
2596 if (kind == Snapshot::kFull) { | 2486 if (kind == Snapshot::kFull) { |
2597 simd = reader->NewFloat64x2(value0, value1); | 2487 simd = reader->NewFloat64x2(value0, value1); |
2598 } else { | 2488 } else { |
2599 simd = Float64x2::New(value0, value1, HEAP_SPACE(kind)); | 2489 simd = Float64x2::New(value0, value1, HEAP_SPACE(kind)); |
2600 } | 2490 } |
2601 reader->AddBackRef(object_id, &simd, kIsDeserialized); | 2491 reader->AddBackRef(object_id, &simd, kIsDeserialized); |
2602 // Set the object tags. | |
2603 simd.set_tags(tags); | |
2604 return simd.raw(); | 2492 return simd.raw(); |
2605 } | 2493 } |
2606 | 2494 |
2607 | 2495 |
2608 void RawFloat64x2::WriteTo(SnapshotWriter* writer, | 2496 void RawFloat64x2::WriteTo(SnapshotWriter* writer, |
2609 intptr_t object_id, | 2497 intptr_t object_id, |
2610 Snapshot::Kind kind) { | 2498 Snapshot::Kind kind) { |
2611 ASSERT(writer != NULL); | 2499 ASSERT(writer != NULL); |
2612 | 2500 |
2613 // Write out the serialization header value for this object. | 2501 // Write out the serialization header value for this object. |
(...skipping 21 matching lines...) Expand all Loading... |
2635 Snapshot::Kind kind) { | 2523 Snapshot::Kind kind) { |
2636 ASSERT(reader != NULL); | 2524 ASSERT(reader != NULL); |
2637 | 2525 |
2638 intptr_t cid = RawObject::ClassIdTag::decode(tags); | 2526 intptr_t cid = RawObject::ClassIdTag::decode(tags); |
2639 intptr_t len = reader->ReadSmiValue(); | 2527 intptr_t len = reader->ReadSmiValue(); |
2640 TypedData& result = TypedData::ZoneHandle(reader->zone(), | 2528 TypedData& result = TypedData::ZoneHandle(reader->zone(), |
2641 (kind == Snapshot::kFull) ? reader->NewTypedData(cid, len) | 2529 (kind == Snapshot::kFull) ? reader->NewTypedData(cid, len) |
2642 : TypedData::New(cid, len, HEAP_SPACE(kind))); | 2530 : TypedData::New(cid, len, HEAP_SPACE(kind))); |
2643 reader->AddBackRef(object_id, &result, kIsDeserialized); | 2531 reader->AddBackRef(object_id, &result, kIsDeserialized); |
2644 | 2532 |
2645 // Set the object tags. | |
2646 result.set_tags(tags); | |
2647 | |
2648 // Setup the array elements. | 2533 // Setup the array elements. |
2649 intptr_t element_size = ElementSizeInBytes(cid); | 2534 intptr_t element_size = ElementSizeInBytes(cid); |
2650 intptr_t length_in_bytes = len * element_size; | 2535 intptr_t length_in_bytes = len * element_size; |
2651 switch (cid) { | 2536 switch (cid) { |
2652 case kTypedDataInt8ArrayCid: | 2537 case kTypedDataInt8ArrayCid: |
2653 case kTypedDataUint8ArrayCid: | 2538 case kTypedDataUint8ArrayCid: |
2654 case kTypedDataUint8ClampedArrayCid: { | 2539 case kTypedDataUint8ClampedArrayCid: { |
2655 NoSafepointScope no_safepoint; | 2540 NoSafepointScope no_safepoint; |
2656 uint8_t* data = reinterpret_cast<uint8_t*>(result.DataAddr(0)); | 2541 uint8_t* data = reinterpret_cast<uint8_t*>(result.DataAddr(0)); |
2657 reader->ReadBytes(data, length_in_bytes); | 2542 reader->ReadBytes(data, length_in_bytes); |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2986 intptr_t tags, | 2871 intptr_t tags, |
2987 Snapshot::Kind kind) { | 2872 Snapshot::Kind kind) { |
2988 ASSERT(reader != NULL); | 2873 ASSERT(reader != NULL); |
2989 ASSERT(kind == Snapshot::kMessage); | 2874 ASSERT(kind == Snapshot::kMessage); |
2990 | 2875 |
2991 // Allocate JSRegExp object. | 2876 // Allocate JSRegExp object. |
2992 JSRegExp& regex = JSRegExp::ZoneHandle( | 2877 JSRegExp& regex = JSRegExp::ZoneHandle( |
2993 reader->zone(), JSRegExp::New(HEAP_SPACE(kind))); | 2878 reader->zone(), JSRegExp::New(HEAP_SPACE(kind))); |
2994 reader->AddBackRef(object_id, ®ex, kIsDeserialized); | 2879 reader->AddBackRef(object_id, ®ex, kIsDeserialized); |
2995 | 2880 |
2996 // Set the object tags. | |
2997 regex.set_tags(tags); | |
2998 | |
2999 // Read and Set all the other fields. | 2881 // Read and Set all the other fields. |
3000 regex.StoreSmi(®ex.raw_ptr()->num_bracket_expressions_, | 2882 regex.StoreSmi(®ex.raw_ptr()->num_bracket_expressions_, |
3001 reader->ReadAsSmi()); | 2883 reader->ReadAsSmi()); |
3002 *reader->StringHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); | 2884 *reader->StringHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); |
3003 regex.set_pattern(*reader->StringHandle()); | 2885 regex.set_pattern(*reader->StringHandle()); |
3004 regex.StoreNonPointer(®ex.raw_ptr()->num_registers_, | 2886 regex.StoreNonPointer(®ex.raw_ptr()->num_registers_, |
3005 reader->Read<int32_t>()); | 2887 reader->Read<int32_t>()); |
3006 regex.StoreNonPointer(®ex.raw_ptr()->type_flags_, | 2888 regex.StoreNonPointer(®ex.raw_ptr()->type_flags_, |
3007 reader->Read<int8_t>()); | 2889 reader->Read<int8_t>()); |
3008 | 2890 |
(...skipping 27 matching lines...) Expand all Loading... |
3036 intptr_t object_id, | 2918 intptr_t object_id, |
3037 intptr_t tags, | 2919 intptr_t tags, |
3038 Snapshot::Kind kind) { | 2920 Snapshot::Kind kind) { |
3039 ASSERT(reader != NULL); | 2921 ASSERT(reader != NULL); |
3040 | 2922 |
3041 // Allocate the weak property object. | 2923 // Allocate the weak property object. |
3042 WeakProperty& weak_property = WeakProperty::ZoneHandle( | 2924 WeakProperty& weak_property = WeakProperty::ZoneHandle( |
3043 reader->zone(), WeakProperty::New(HEAP_SPACE(kind))); | 2925 reader->zone(), WeakProperty::New(HEAP_SPACE(kind))); |
3044 reader->AddBackRef(object_id, &weak_property, kIsDeserialized); | 2926 reader->AddBackRef(object_id, &weak_property, kIsDeserialized); |
3045 | 2927 |
3046 // Set the object tags. | |
3047 weak_property.set_tags(tags); | |
3048 | |
3049 // Set all the object fields. | 2928 // Set all the object fields. |
3050 // TODO(5411462): Need to assert No GC can happen here, even though | 2929 // TODO(5411462): Need to assert No GC can happen here, even though |
3051 // allocations may happen. | 2930 // allocations may happen. |
3052 intptr_t num_flds = (weak_property.raw()->to() - | 2931 intptr_t num_flds = (weak_property.raw()->to() - |
3053 weak_property.raw()->from()); | 2932 weak_property.raw()->from()); |
3054 for (intptr_t i = 0; i <= num_flds; i++) { | 2933 for (intptr_t i = 0; i <= num_flds; i++) { |
3055 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | 2934 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
3056 weak_property.StorePointer((weak_property.raw()->from() + i), | 2935 weak_property.StorePointer((weak_property.raw()->from() + i), |
3057 reader->PassiveObjectHandle()->raw()); | 2936 reader->PassiveObjectHandle()->raw()); |
3058 } | 2937 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3118 // We do not allow objects with native fields in an isolate message. | 2997 // We do not allow objects with native fields in an isolate message. |
3119 writer->SetWriteException(Exceptions::kArgument, | 2998 writer->SetWriteException(Exceptions::kArgument, |
3120 "Illegal argument in isolate message" | 2999 "Illegal argument in isolate message" |
3121 " : (object is a UserTag)"); | 3000 " : (object is a UserTag)"); |
3122 } else { | 3001 } else { |
3123 UNREACHABLE(); | 3002 UNREACHABLE(); |
3124 } | 3003 } |
3125 } | 3004 } |
3126 | 3005 |
3127 } // namespace dart | 3006 } // namespace dart |
OLD | NEW |