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