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" |
11 | 11 |
12 namespace dart { | 12 namespace dart { |
13 | 13 |
14 #define NEW_OBJECT(type) \ | 14 #define NEW_OBJECT(type) \ |
15 ((kind == Snapshot::kFull) ? reader->New##type() : type::New()) | 15 ((kind == Snapshot::kFull) ? reader->New##type() : type::New()) |
16 | 16 |
17 #define NEW_OBJECT_WITH_LEN(type, len) \ | 17 #define NEW_OBJECT_WITH_LEN(type, len) \ |
18 ((kind == Snapshot::kFull) ? reader->New##type(len) : type::New(len)) | 18 ((kind == Snapshot::kFull) ? reader->New##type(len) : type::New(len)) |
19 | 19 |
20 #define NEW_OBJECT_WITH_LEN_SPACE(type, len, kind) \ | 20 #define NEW_OBJECT_WITH_LEN_SPACE(type, len, kind) \ |
21 ((kind == Snapshot::kFull) ? \ | 21 ((kind == Snapshot::kFull) ? \ |
22 reader->New##type(len) : type::New(len, HEAP_SPACE(kind))) | 22 reader->New##type(len) : type::New(len, HEAP_SPACE(kind))) |
23 | 23 |
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 // TODO(18854): Need to assert No GC can happen here, even though | |
28 // allocations may happen. | |
29 #define READ_POINTERS(object, as_reference) \ | |
30 intptr_t num_flds = object.raw()->to() - object.raw()->from(); \ | |
31 intptr_t from_offset = OFFSET_OF_FROM(object); \ | |
32 for (intptr_t i = 0; i <= num_flds; i++) { \ | |
33 (*reader->PassiveObjectHandle()) = \ | |
34 reader->ReadObjectImpl(as_reference, object_id, (i + from_offset)); \ | |
35 object.StorePointer((object.raw()->from() + i), \ | |
36 reader->PassiveObjectHandle()->raw()); \ | |
37 } | |
siva
2015/09/01 20:58:49
Instead of READ_POINTERS why not call it READ_OBJE
rmacnak
2015/09/01 23:43:47
Done.
| |
38 | |
27 RawClass* Class::ReadFrom(SnapshotReader* reader, | 39 RawClass* Class::ReadFrom(SnapshotReader* reader, |
28 intptr_t object_id, | 40 intptr_t object_id, |
29 intptr_t tags, | 41 intptr_t tags, |
30 Snapshot::Kind kind) { | 42 Snapshot::Kind kind) { |
31 ASSERT(reader != NULL); | 43 ASSERT(reader != NULL); |
32 | 44 |
33 Class& cls = Class::ZoneHandle(reader->zone(), Class::null()); | 45 Class& cls = Class::ZoneHandle(reader->zone(), Class::null()); |
34 bool is_in_fullsnapshot = reader->Read<bool>(); | 46 bool is_in_fullsnapshot = reader->Read<bool>(); |
35 if ((kind == Snapshot::kFull) || | 47 if ((kind == Snapshot::kFull) || |
36 (kind == Snapshot::kScript && !is_in_fullsnapshot)) { | 48 (kind == Snapshot::kScript && !is_in_fullsnapshot)) { |
(...skipping 20 matching lines...) Expand all Loading... | |
57 cls.set_next_field_offset_in_words(reader->Read<int32_t>()); | 69 cls.set_next_field_offset_in_words(reader->Read<int32_t>()); |
58 } | 70 } |
59 cls.set_type_arguments_field_offset_in_words(reader->Read<int32_t>()); | 71 cls.set_type_arguments_field_offset_in_words(reader->Read<int32_t>()); |
60 cls.set_num_type_arguments(reader->Read<int16_t>()); | 72 cls.set_num_type_arguments(reader->Read<int16_t>()); |
61 cls.set_num_own_type_arguments(reader->Read<int16_t>()); | 73 cls.set_num_own_type_arguments(reader->Read<int16_t>()); |
62 cls.set_num_native_fields(reader->Read<uint16_t>()); | 74 cls.set_num_native_fields(reader->Read<uint16_t>()); |
63 cls.set_token_pos(reader->Read<int32_t>()); | 75 cls.set_token_pos(reader->Read<int32_t>()); |
64 cls.set_state_bits(reader->Read<uint16_t>()); | 76 cls.set_state_bits(reader->Read<uint16_t>()); |
65 | 77 |
66 // Set all the object fields. | 78 // Set all the object fields. |
67 // TODO(5411462): Need to assert No GC can happen here, even though | 79 READ_POINTERS(cls, kAsReference); |
68 // allocations may happen. | 80 |
69 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); | |
70 intptr_t from_offset = OFFSET_OF_FROM(cls); | |
71 for (intptr_t i = 0; i <= num_flds; i++) { | |
72 (*reader->PassiveObjectHandle()) = | |
73 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); | |
74 cls.StorePointer((cls.raw()->from() + i), | |
75 reader->PassiveObjectHandle()->raw()); | |
76 } | |
77 ASSERT(!cls.IsInFullSnapshot() || (kind == Snapshot::kFull)); | 81 ASSERT(!cls.IsInFullSnapshot() || (kind == Snapshot::kFull)); |
78 } else { | 82 } else { |
79 cls ^= reader->ReadClassId(object_id); | 83 cls ^= reader->ReadClassId(object_id); |
80 ASSERT((kind == Snapshot::kMessage) || cls.IsInFullSnapshot()); | 84 ASSERT((kind == Snapshot::kMessage) || cls.IsInFullSnapshot()); |
81 } | 85 } |
82 return cls.raw(); | 86 return cls.raw(); |
83 } | 87 } |
84 | 88 |
85 | 89 |
86 void RawClass::WriteTo(SnapshotWriter* writer, | 90 void RawClass::WriteTo(SnapshotWriter* writer, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 | 150 |
147 // Allocate unresolved class object. | 151 // Allocate unresolved class object. |
148 UnresolvedClass& unresolved_class = UnresolvedClass::ZoneHandle( | 152 UnresolvedClass& unresolved_class = UnresolvedClass::ZoneHandle( |
149 reader->zone(), NEW_OBJECT(UnresolvedClass)); | 153 reader->zone(), NEW_OBJECT(UnresolvedClass)); |
150 reader->AddBackRef(object_id, &unresolved_class, kIsDeserialized); | 154 reader->AddBackRef(object_id, &unresolved_class, kIsDeserialized); |
151 | 155 |
152 // Set all non object fields. | 156 // Set all non object fields. |
153 unresolved_class.set_token_pos(reader->Read<int32_t>()); | 157 unresolved_class.set_token_pos(reader->Read<int32_t>()); |
154 | 158 |
155 // Set all the object fields. | 159 // Set all the object fields. |
156 // TODO(5411462): Need to assert No GC can happen here, even though | 160 READ_POINTERS(unresolved_class, kAsReference); |
157 // allocations may happen. | 161 |
158 intptr_t num_flds = (unresolved_class.raw()->to() - | |
159 unresolved_class.raw()->from()); | |
160 for (intptr_t i = 0; i <= num_flds; i++) { | |
161 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | |
162 unresolved_class.StorePointer((unresolved_class.raw()->from() + i), | |
163 reader->PassiveObjectHandle()->raw()); | |
164 } | |
165 return unresolved_class.raw(); | 162 return unresolved_class.raw(); |
166 } | 163 } |
167 | 164 |
168 | 165 |
169 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, | 166 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, |
170 intptr_t object_id, | 167 intptr_t object_id, |
171 Snapshot::Kind kind) { | 168 Snapshot::Kind kind) { |
172 ASSERT(writer != NULL); | 169 ASSERT(writer != NULL); |
173 | 170 |
174 // Write out the serialization header value for this object. | 171 // Write out the serialization header value for this object. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 bool is_canonical = RawObject::IsCanonical(tags); | 214 bool is_canonical = RawObject::IsCanonical(tags); |
218 bool defer_canonicalization = is_canonical && | 215 bool defer_canonicalization = is_canonical && |
219 (kind != Snapshot::kFull && typeclass_is_in_fullsnapshot); | 216 (kind != Snapshot::kFull && typeclass_is_in_fullsnapshot); |
220 reader->AddBackRef(object_id, &type, kIsDeserialized, defer_canonicalization); | 217 reader->AddBackRef(object_id, &type, kIsDeserialized, defer_canonicalization); |
221 | 218 |
222 // Set all non object fields. | 219 // Set all non object fields. |
223 type.set_token_pos(reader->Read<int32_t>()); | 220 type.set_token_pos(reader->Read<int32_t>()); |
224 type.set_type_state(reader->Read<int8_t>()); | 221 type.set_type_state(reader->Read<int8_t>()); |
225 | 222 |
226 // Set all the object fields. | 223 // Set all the object fields. |
227 // TODO(5411462): Need to assert No GC can happen here, even though | 224 READ_POINTERS(type, kAsReference); |
228 // allocations may happen. | |
229 intptr_t num_flds = (type.raw()->to() - type.raw()->from()); | |
230 intptr_t from_offset = OFFSET_OF_FROM(type); | |
231 for (intptr_t i = 0; i <= num_flds; i++) { | |
232 (*reader->PassiveObjectHandle()) = | |
233 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); | |
234 type.StorePointer((type.raw()->from() + i), | |
235 reader->PassiveObjectHandle()->raw()); | |
236 } | |
237 | 225 |
238 // Set the canonical bit. | 226 // Set the canonical bit. |
239 if (!defer_canonicalization && RawObject::IsCanonical(tags)) { | 227 if (!defer_canonicalization && RawObject::IsCanonical(tags)) { |
240 type.SetCanonical(); | 228 type.SetCanonical(); |
241 } | 229 } |
242 | 230 |
243 return type.raw(); | 231 return type.raw(); |
244 } | 232 } |
245 | 233 |
246 | 234 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 intptr_t tags, | 275 intptr_t tags, |
288 Snapshot::Kind kind) { | 276 Snapshot::Kind kind) { |
289 ASSERT(reader != NULL); | 277 ASSERT(reader != NULL); |
290 | 278 |
291 // Allocate type ref object. | 279 // Allocate type ref object. |
292 TypeRef& type_ref = TypeRef::ZoneHandle( | 280 TypeRef& type_ref = TypeRef::ZoneHandle( |
293 reader->zone(), NEW_OBJECT(TypeRef)); | 281 reader->zone(), NEW_OBJECT(TypeRef)); |
294 reader->AddBackRef(object_id, &type_ref, kIsDeserialized); | 282 reader->AddBackRef(object_id, &type_ref, kIsDeserialized); |
295 | 283 |
296 // Set all the object fields. | 284 // Set all the object fields. |
297 // TODO(5411462): Need to assert No GC can happen here, even though | 285 READ_POINTERS(type_ref, kAsReference); |
298 // allocations may happen. | |
299 intptr_t num_flds = (type_ref.raw()->to() - type_ref.raw()->from()); | |
300 intptr_t from_offset = OFFSET_OF_FROM(type_ref); | |
301 for (intptr_t i = 0; i <= num_flds; i++) { | |
302 (*reader->PassiveObjectHandle()) = | |
303 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); | |
304 type_ref.StorePointer((type_ref.raw()->from() + i), | |
305 reader->PassiveObjectHandle()->raw()); | |
306 } | |
307 | 286 |
308 return type_ref.raw(); | 287 return type_ref.raw(); |
309 } | 288 } |
310 | 289 |
311 | 290 |
312 void RawTypeRef::WriteTo(SnapshotWriter* writer, | 291 void RawTypeRef::WriteTo(SnapshotWriter* writer, |
313 intptr_t object_id, | 292 intptr_t object_id, |
314 Snapshot::Kind kind) { | 293 Snapshot::Kind kind) { |
315 ASSERT(writer != NULL); | 294 ASSERT(writer != NULL); |
316 | 295 |
(...skipping 20 matching lines...) Expand all Loading... | |
337 TypeParameter& type_parameter = TypeParameter::ZoneHandle( | 316 TypeParameter& type_parameter = TypeParameter::ZoneHandle( |
338 reader->zone(), NEW_OBJECT(TypeParameter)); | 317 reader->zone(), NEW_OBJECT(TypeParameter)); |
339 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized); | 318 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized); |
340 | 319 |
341 // Set all non object fields. | 320 // Set all non object fields. |
342 type_parameter.set_token_pos(reader->Read<int32_t>()); | 321 type_parameter.set_token_pos(reader->Read<int32_t>()); |
343 type_parameter.set_index(reader->Read<int16_t>()); | 322 type_parameter.set_index(reader->Read<int16_t>()); |
344 type_parameter.set_type_state(reader->Read<int8_t>()); | 323 type_parameter.set_type_state(reader->Read<int8_t>()); |
345 | 324 |
346 // Set all the object fields. | 325 // Set all the object fields. |
347 // TODO(5411462): Need to assert No GC can happen here, even though | 326 READ_POINTERS(type_parameter, kAsReference); |
348 // allocations may happen. | |
349 intptr_t num_flds = (type_parameter.raw()->to() - | |
350 type_parameter.raw()->from()); | |
351 intptr_t from_offset = OFFSET_OF_FROM(type_parameter); | |
352 for (intptr_t i = 0; i <= num_flds; i++) { | |
353 (*reader->PassiveObjectHandle()) = | |
354 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); | |
355 type_parameter.StorePointer((type_parameter.raw()->from() + i), | |
356 reader->PassiveObjectHandle()->raw()); | |
357 } | |
358 | 327 |
359 return type_parameter.raw(); | 328 return type_parameter.raw(); |
360 } | 329 } |
361 | 330 |
362 | 331 |
363 void RawTypeParameter::WriteTo(SnapshotWriter* writer, | 332 void RawTypeParameter::WriteTo(SnapshotWriter* writer, |
364 intptr_t object_id, | 333 intptr_t object_id, |
365 Snapshot::Kind kind) { | 334 Snapshot::Kind kind) { |
366 ASSERT(writer != NULL); | 335 ASSERT(writer != NULL); |
367 | 336 |
(...skipping 23 matching lines...) Expand all Loading... | |
391 intptr_t tags, | 360 intptr_t tags, |
392 Snapshot::Kind kind) { | 361 Snapshot::Kind kind) { |
393 ASSERT(reader != NULL); | 362 ASSERT(reader != NULL); |
394 | 363 |
395 // Allocate bounded type object. | 364 // Allocate bounded type object. |
396 BoundedType& bounded_type = BoundedType::ZoneHandle( | 365 BoundedType& bounded_type = BoundedType::ZoneHandle( |
397 reader->zone(), NEW_OBJECT(BoundedType)); | 366 reader->zone(), NEW_OBJECT(BoundedType)); |
398 reader->AddBackRef(object_id, &bounded_type, kIsDeserialized); | 367 reader->AddBackRef(object_id, &bounded_type, kIsDeserialized); |
399 | 368 |
400 // Set all the object fields. | 369 // Set all the object fields. |
401 // TODO(5411462): Need to assert No GC can happen here, even though | 370 READ_POINTERS(bounded_type, kAsReference); |
402 // allocations may happen. | |
403 intptr_t num_flds = (bounded_type.raw()->to() - | |
404 bounded_type.raw()->from()); | |
405 intptr_t from_offset = OFFSET_OF_FROM(bounded_type); | |
406 for (intptr_t i = 0; i <= num_flds; i++) { | |
407 (*reader->PassiveObjectHandle()) = | |
408 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); | |
409 bounded_type.StorePointer((bounded_type.raw()->from() + i), | |
410 reader->PassiveObjectHandle()->raw()); | |
411 } | |
412 | 371 |
413 return bounded_type.raw(); | 372 return bounded_type.raw(); |
414 } | 373 } |
415 | 374 |
416 | 375 |
417 void RawBoundedType::WriteTo(SnapshotWriter* writer, | 376 void RawBoundedType::WriteTo(SnapshotWriter* writer, |
418 intptr_t object_id, | 377 intptr_t object_id, |
419 Snapshot::Kind kind) { | 378 Snapshot::Kind kind) { |
420 ASSERT(writer != NULL); | 379 ASSERT(writer != NULL); |
421 | 380 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
525 intptr_t tags, | 484 intptr_t tags, |
526 Snapshot::Kind kind) { | 485 Snapshot::Kind kind) { |
527 ASSERT(reader != NULL); | 486 ASSERT(reader != NULL); |
528 | 487 |
529 // Allocate function object. | 488 // Allocate function object. |
530 PatchClass& cls = PatchClass::ZoneHandle(reader->zone(), | 489 PatchClass& cls = PatchClass::ZoneHandle(reader->zone(), |
531 NEW_OBJECT(PatchClass)); | 490 NEW_OBJECT(PatchClass)); |
532 reader->AddBackRef(object_id, &cls, kIsDeserialized); | 491 reader->AddBackRef(object_id, &cls, kIsDeserialized); |
533 | 492 |
534 // Set all the object fields. | 493 // Set all the object fields. |
535 // TODO(5411462): Need to assert No GC can happen here, even though | 494 READ_POINTERS(cls, kAsReference); |
536 // allocations may happen. | 495 |
537 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); | |
538 for (intptr_t i = 0; i <= num_flds; i++) { | |
539 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | |
540 cls.StorePointer((cls.raw()->from() + i), | |
541 reader->PassiveObjectHandle()->raw()); | |
542 } | |
543 ASSERT(((kind == Snapshot::kScript) && | 496 ASSERT(((kind == Snapshot::kScript) && |
544 !Class::IsInFullSnapshot(cls.source_class())) || | 497 !Class::IsInFullSnapshot(cls.source_class())) || |
545 (kind == Snapshot::kFull)); | 498 (kind == Snapshot::kFull)); |
546 | 499 |
547 return cls.raw(); | 500 return cls.raw(); |
548 } | 501 } |
549 | 502 |
550 | 503 |
551 void RawPatchClass::WriteTo(SnapshotWriter* writer, | 504 void RawPatchClass::WriteTo(SnapshotWriter* writer, |
552 intptr_t object_id, | 505 intptr_t object_id, |
(...skipping 19 matching lines...) Expand all Loading... | |
572 Snapshot::Kind kind) { | 525 Snapshot::Kind kind) { |
573 ASSERT(reader != NULL); | 526 ASSERT(reader != NULL); |
574 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 527 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
575 | 528 |
576 // Allocate closure data object. | 529 // Allocate closure data object. |
577 ClosureData& data = ClosureData::ZoneHandle( | 530 ClosureData& data = ClosureData::ZoneHandle( |
578 reader->zone(), NEW_OBJECT(ClosureData)); | 531 reader->zone(), NEW_OBJECT(ClosureData)); |
579 reader->AddBackRef(object_id, &data, kIsDeserialized); | 532 reader->AddBackRef(object_id, &data, kIsDeserialized); |
580 | 533 |
581 // Set all the object fields. | 534 // Set all the object fields. |
582 // TODO(5411462): Need to assert No GC can happen here, even though | 535 READ_POINTERS(data, kAsReference); |
583 // allocations may happen. | |
584 intptr_t num_flds = (data.raw()->to() - data.raw()->from()); | |
585 for (intptr_t i = 0; i <= num_flds; i++) { | |
586 *(data.raw()->from() + i) = reader->ReadObjectImpl(kAsReference); | |
587 } | |
588 | 536 |
589 return data.raw(); | 537 return data.raw(); |
590 } | 538 } |
591 | 539 |
592 | 540 |
593 void RawClosureData::WriteTo(SnapshotWriter* writer, | 541 void RawClosureData::WriteTo(SnapshotWriter* writer, |
594 intptr_t object_id, | 542 intptr_t object_id, |
595 Snapshot::Kind kind) { | 543 Snapshot::Kind kind) { |
596 ASSERT(writer != NULL); | 544 ASSERT(writer != NULL); |
597 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 545 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
(...skipping 27 matching lines...) Expand all Loading... | |
625 Snapshot::Kind kind) { | 573 Snapshot::Kind kind) { |
626 ASSERT(reader != NULL); | 574 ASSERT(reader != NULL); |
627 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 575 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
628 | 576 |
629 // Allocate redirection data object. | 577 // Allocate redirection data object. |
630 RedirectionData& data = RedirectionData::ZoneHandle( | 578 RedirectionData& data = RedirectionData::ZoneHandle( |
631 reader->zone(), NEW_OBJECT(RedirectionData)); | 579 reader->zone(), NEW_OBJECT(RedirectionData)); |
632 reader->AddBackRef(object_id, &data, kIsDeserialized); | 580 reader->AddBackRef(object_id, &data, kIsDeserialized); |
633 | 581 |
634 // Set all the object fields. | 582 // Set all the object fields. |
635 // TODO(5411462): Need to assert No GC can happen here, even though | 583 READ_POINTERS(data, kAsReference); |
636 // allocations may happen. | |
637 intptr_t num_flds = (data.raw()->to() - data.raw()->from()); | |
638 intptr_t from_offset = OFFSET_OF_FROM(data); | |
639 for (intptr_t i = 0; i <= num_flds; i++) { | |
640 (*reader->PassiveObjectHandle()) = | |
641 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); | |
642 data.StorePointer((data.raw()->from() + i), | |
643 reader->PassiveObjectHandle()->raw()); | |
644 } | |
645 | 584 |
646 return data.raw(); | 585 return data.raw(); |
647 } | 586 } |
648 | 587 |
649 | 588 |
650 void RawRedirectionData::WriteTo(SnapshotWriter* writer, | 589 void RawRedirectionData::WriteTo(SnapshotWriter* writer, |
651 intptr_t object_id, | 590 intptr_t object_id, |
652 Snapshot::Kind kind) { | 591 Snapshot::Kind kind) { |
653 ASSERT(writer != NULL); | 592 ASSERT(writer != NULL); |
654 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 593 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
700 (*reader->PassiveObjectHandle()) = | 639 (*reader->PassiveObjectHandle()) = |
701 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); | 640 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); |
702 func.StorePointer((func.raw()->from() + i), | 641 func.StorePointer((func.raw()->from() + i), |
703 reader->PassiveObjectHandle()->raw()); | 642 reader->PassiveObjectHandle()->raw()); |
704 } | 643 } |
705 | 644 |
706 if (!reader->snapshot_code()) { | 645 if (!reader->snapshot_code()) { |
707 // Initialize all fields that are not part of the snapshot. | 646 // Initialize all fields that are not part of the snapshot. |
708 func.ClearICDataArray(); | 647 func.ClearICDataArray(); |
709 func.ClearCode(); | 648 func.ClearCode(); |
649 } else { | |
650 // TODO(rmacnak): Fix entry_point_. | |
710 } | 651 } |
711 return func.raw(); | 652 return func.raw(); |
712 } | 653 } |
713 | 654 |
714 | 655 |
715 void RawFunction::WriteTo(SnapshotWriter* writer, | 656 void RawFunction::WriteTo(SnapshotWriter* writer, |
716 intptr_t object_id, | 657 intptr_t object_id, |
717 Snapshot::Kind kind) { | 658 Snapshot::Kind kind) { |
718 ASSERT(writer != NULL); | 659 ASSERT(writer != NULL); |
719 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 660 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
754 Field& field = Field::ZoneHandle(reader->zone(), NEW_OBJECT(Field)); | 695 Field& field = Field::ZoneHandle(reader->zone(), NEW_OBJECT(Field)); |
755 reader->AddBackRef(object_id, &field, kIsDeserialized); | 696 reader->AddBackRef(object_id, &field, kIsDeserialized); |
756 | 697 |
757 // Set all non object fields. | 698 // Set all non object fields. |
758 field.set_token_pos(reader->Read<int32_t>()); | 699 field.set_token_pos(reader->Read<int32_t>()); |
759 field.set_guarded_cid(reader->Read<int32_t>()); | 700 field.set_guarded_cid(reader->Read<int32_t>()); |
760 field.set_is_nullable(reader->Read<int32_t>()); | 701 field.set_is_nullable(reader->Read<int32_t>()); |
761 field.set_kind_bits(reader->Read<uint8_t>()); | 702 field.set_kind_bits(reader->Read<uint8_t>()); |
762 | 703 |
763 // Set all the object fields. | 704 // Set all the object fields. |
764 // TODO(5411462): Need to assert No GC can happen here, even though | 705 READ_POINTERS(field, kAsReference); |
765 // allocations may happen. | |
766 intptr_t num_flds = (field.raw()->to() - field.raw()->from()); | |
767 intptr_t from_offset = OFFSET_OF_FROM(field); | |
768 for (intptr_t i = 0; i <= num_flds; i++) { | |
769 (*reader->PassiveObjectHandle()) = | |
770 reader->ReadObjectImpl(kAsReference, object_id, (i + from_offset)); | |
771 field.StorePointer((field.raw()->from() + i), | |
772 reader->PassiveObjectHandle()->raw()); | |
773 } | |
774 | 706 |
775 field.InitializeGuardedListLengthInObjectOffset(); | 707 field.InitializeGuardedListLengthInObjectOffset(); |
776 | 708 |
777 return field.raw(); | 709 return field.raw(); |
778 } | 710 } |
779 | 711 |
780 | 712 |
781 void RawField::WriteTo(SnapshotWriter* writer, | 713 void RawField::WriteTo(SnapshotWriter* writer, |
782 intptr_t object_id, | 714 intptr_t object_id, |
783 Snapshot::Kind kind) { | 715 Snapshot::Kind kind) { |
(...skipping 29 matching lines...) Expand all Loading... | |
813 // Create the literal token object. | 745 // Create the literal token object. |
814 LiteralToken& literal_token = LiteralToken::ZoneHandle( | 746 LiteralToken& literal_token = LiteralToken::ZoneHandle( |
815 reader->zone(), NEW_OBJECT(LiteralToken)); | 747 reader->zone(), NEW_OBJECT(LiteralToken)); |
816 reader->AddBackRef(object_id, &literal_token, kIsDeserialized); | 748 reader->AddBackRef(object_id, &literal_token, kIsDeserialized); |
817 | 749 |
818 // Read the token attributes. | 750 // Read the token attributes. |
819 Token::Kind token_kind = static_cast<Token::Kind>(reader->Read<int32_t>()); | 751 Token::Kind token_kind = static_cast<Token::Kind>(reader->Read<int32_t>()); |
820 literal_token.set_kind(token_kind); | 752 literal_token.set_kind(token_kind); |
821 | 753 |
822 // Set all the object fields. | 754 // Set all the object fields. |
823 // TODO(5411462): Need to assert No GC can happen here, even though | 755 READ_POINTERS(literal_token, kAsReference); |
824 // allocations may happen. | |
825 intptr_t num_flds = (literal_token.raw()->to() - literal_token.raw()->from()); | |
826 for (intptr_t i = 0; i <= num_flds; i++) { | |
827 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | |
828 literal_token.StorePointer((literal_token.raw()->from() + i), | |
829 reader->PassiveObjectHandle()->raw()); | |
830 } | |
831 | 756 |
832 return literal_token.raw(); | 757 return literal_token.raw(); |
833 } | 758 } |
834 | 759 |
835 | 760 |
836 void RawLiteralToken::WriteTo(SnapshotWriter* writer, | 761 void RawLiteralToken::WriteTo(SnapshotWriter* writer, |
837 intptr_t object_id, | 762 intptr_t object_id, |
838 Snapshot::Kind kind) { | 763 Snapshot::Kind kind) { |
839 ASSERT(writer != NULL); | 764 ASSERT(writer != NULL); |
840 ASSERT(kind != Snapshot::kMessage); | 765 ASSERT(kind != Snapshot::kMessage); |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1095 reader->AddBackRef(object_id, &prefix, kIsDeserialized); | 1020 reader->AddBackRef(object_id, &prefix, kIsDeserialized); |
1096 | 1021 |
1097 // Set all non object fields. | 1022 // Set all non object fields. |
1098 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_, | 1023 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_, |
1099 reader->Read<int16_t>()); | 1024 reader->Read<int16_t>()); |
1100 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_, | 1025 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_, |
1101 reader->Read<bool>()); | 1026 reader->Read<bool>()); |
1102 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>()); | 1027 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>()); |
1103 | 1028 |
1104 // Set all the object fields. | 1029 // Set all the object fields. |
1105 // TODO(5411462): Need to assert No GC can happen here, even though | 1030 READ_POINTERS(prefix, kAsReference); |
1106 // allocations may happen. | |
1107 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from()); | |
1108 for (intptr_t i = 0; i <= num_flds; i++) { | |
1109 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | |
1110 prefix.StorePointer((prefix.raw()->from() + i), | |
1111 reader->PassiveObjectHandle()->raw()); | |
1112 } | |
1113 | 1031 |
1114 return prefix.raw(); | 1032 return prefix.raw(); |
1115 } | 1033 } |
1116 | 1034 |
1117 | 1035 |
1118 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, | 1036 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, |
1119 intptr_t object_id, | 1037 intptr_t object_id, |
1120 Snapshot::Kind kind) { | 1038 Snapshot::Kind kind) { |
1121 ASSERT(writer != NULL); | 1039 ASSERT(writer != NULL); |
1122 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 1040 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
(...skipping 22 matching lines...) Expand all Loading... | |
1145 Snapshot::Kind kind) { | 1063 Snapshot::Kind kind) { |
1146 ASSERT(reader != NULL); | 1064 ASSERT(reader != NULL); |
1147 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 1065 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
1148 | 1066 |
1149 // Allocate Namespace object. | 1067 // Allocate Namespace object. |
1150 Namespace& ns = Namespace::ZoneHandle( | 1068 Namespace& ns = Namespace::ZoneHandle( |
1151 reader->zone(), NEW_OBJECT(Namespace)); | 1069 reader->zone(), NEW_OBJECT(Namespace)); |
1152 reader->AddBackRef(object_id, &ns, kIsDeserialized); | 1070 reader->AddBackRef(object_id, &ns, kIsDeserialized); |
1153 | 1071 |
1154 // Set all the object fields. | 1072 // Set all the object fields. |
1155 // TODO(5411462): Need to assert No GC can happen here, even though | 1073 READ_POINTERS(ns, kAsReference); |
1156 // allocations may happen. | |
1157 intptr_t num_flds = (ns.raw()->to() - ns.raw()->from()); | |
1158 for (intptr_t i = 0; i <= num_flds; i++) { | |
1159 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | |
1160 ns.StorePointer((ns.raw()->from() + i), | |
1161 reader->PassiveObjectHandle()->raw()); | |
1162 } | |
1163 | 1074 |
1164 return ns.raw(); | 1075 return ns.raw(); |
1165 } | 1076 } |
1166 | 1077 |
1167 | 1078 |
1168 void RawNamespace::WriteTo(SnapshotWriter* writer, | 1079 void RawNamespace::WriteTo(SnapshotWriter* writer, |
1169 intptr_t object_id, | 1080 intptr_t object_id, |
1170 Snapshot::Kind kind) { | 1081 Snapshot::Kind kind) { |
1171 ASSERT(writer != NULL); | 1082 ASSERT(writer != NULL); |
1172 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 1083 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
1173 | 1084 |
1174 // Write out the serialization header value for this object. | 1085 // Write out the serialization header value for this object. |
1175 writer->WriteInlinedObjectHeader(object_id); | 1086 writer->WriteInlinedObjectHeader(object_id); |
1176 | 1087 |
1177 // Write out the class and tags information. | 1088 // Write out the class and tags information. |
1178 writer->WriteVMIsolateObject(kNamespaceCid); | 1089 writer->WriteVMIsolateObject(kNamespaceCid); |
1179 writer->WriteTags(writer->GetObjectTags(this)); | 1090 writer->WriteTags(writer->GetObjectTags(this)); |
1180 | 1091 |
1181 // Write out all the object pointer fields. | 1092 // Write out all the object pointer fields. |
1182 SnapshotWriterVisitor visitor(writer); | 1093 SnapshotWriterVisitor visitor(writer); |
1183 visitor.VisitPointers(from(), to()); | 1094 visitor.VisitPointers(from(), to()); |
1184 } | 1095 } |
1185 | 1096 |
1186 | 1097 |
1187 RawCode* Code::ReadFrom(SnapshotReader* reader, | 1098 RawCode* Code::ReadFrom(SnapshotReader* reader, |
1188 intptr_t object_id, | 1099 intptr_t object_id, |
1189 intptr_t tags, | 1100 intptr_t tags, |
1190 Snapshot::Kind kind) { | 1101 Snapshot::Kind kind) { |
1191 UNREACHABLE(); // Untested. | |
1192 ASSERT(reader->snapshot_code()); | 1102 ASSERT(reader->snapshot_code()); |
1193 ASSERT(kind == Snapshot::kFull); | 1103 ASSERT(kind == Snapshot::kFull); |
1194 | 1104 |
1195 Code& result = Code::ZoneHandle(reader->zone(), NEW_OBJECT_WITH_LEN(Code, 0)); | 1105 Code& result = Code::ZoneHandle(reader->zone(), NEW_OBJECT_WITH_LEN(Code, 0)); |
1196 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1106 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1197 | 1107 |
1198 result.set_compile_timestamp(reader->Read<int64_t>()); | 1108 result.set_compile_timestamp(reader->Read<int64_t>()); |
1199 result.set_state_bits(reader->Read<int32_t>()); | 1109 result.set_state_bits(reader->Read<int32_t>()); |
1200 result.set_entry_patch_pc_offset(reader->Read<int32_t>()); | 1110 result.set_entry_patch_pc_offset(reader->Read<int32_t>()); |
1201 result.set_patch_code_pc_offset(reader->Read<int32_t>()); | 1111 result.set_patch_code_pc_offset(reader->Read<int32_t>()); |
1202 result.set_lazy_deopt_pc_offset(reader->Read<int32_t>()); | 1112 result.set_lazy_deopt_pc_offset(reader->Read<int32_t>()); |
1203 | 1113 |
1204 // Set all the object fields. | 1114 // Set all the object fields. |
1205 // TODO(5411462): Need to assert No GC can happen here, even though | 1115 READ_POINTERS(result, kAsReference); |
1206 // allocations may happen. | 1116 |
1207 intptr_t num_flds = (result.raw()->to() - result.raw()->from()); | 1117 // TODO(rmacnak): Fix entry_point_. |
1208 for (intptr_t i = 0; i <= num_flds; i++) { | |
1209 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | |
1210 result.StorePointer((result.raw()->from() + i), | |
1211 reader->PassiveObjectHandle()->raw()); | |
1212 } | |
1213 | 1118 |
1214 return result.raw(); | 1119 return result.raw(); |
1215 } | 1120 } |
1216 | 1121 |
1217 | 1122 |
1218 void RawCode::WriteTo(SnapshotWriter* writer, | 1123 void RawCode::WriteTo(SnapshotWriter* writer, |
1219 intptr_t object_id, | 1124 intptr_t object_id, |
1220 Snapshot::Kind kind) { | 1125 Snapshot::Kind kind) { |
1221 ASSERT(writer->snapshot_code()); | 1126 ASSERT(writer->snapshot_code()); |
1222 ASSERT(kind == Snapshot::kFull); | 1127 ASSERT(kind == Snapshot::kFull); |
(...skipping 22 matching lines...) Expand all Loading... | |
1245 // Write out all the object pointer fields. | 1150 // Write out all the object pointer fields. |
1246 SnapshotWriterVisitor visitor(writer); | 1151 SnapshotWriterVisitor visitor(writer); |
1247 visitor.VisitPointers(from(), to()); | 1152 visitor.VisitPointers(from(), to()); |
1248 } | 1153 } |
1249 | 1154 |
1250 | 1155 |
1251 RawInstructions* Instructions::ReadFrom(SnapshotReader* reader, | 1156 RawInstructions* Instructions::ReadFrom(SnapshotReader* reader, |
1252 intptr_t object_id, | 1157 intptr_t object_id, |
1253 intptr_t tags, | 1158 intptr_t tags, |
1254 Snapshot::Kind kind) { | 1159 Snapshot::Kind kind) { |
1255 UNREACHABLE(); // Untested. | |
1256 ASSERT(reader->snapshot_code()); | 1160 ASSERT(reader->snapshot_code()); |
1257 ASSERT(kind == Snapshot::kFull); | 1161 ASSERT(kind == Snapshot::kFull); |
1258 | 1162 |
1259 intptr_t id = reader->Read<int32_t>(); | 1163 intptr_t full_tags = static_cast<uword>(reader->Read<intptr_t>()); |
1164 intptr_t offset = reader->Read<int32_t>(); | |
1260 Instructions& result = | 1165 Instructions& result = |
1261 Instructions::ZoneHandle(reader->zone(), | 1166 Instructions::ZoneHandle(reader->zone(), |
1262 reader->GetInstructionsById(id)); | 1167 reader->GetInstructionsAt(offset, full_tags)); |
1263 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1168 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1169 | |
1170 { | |
1171 // TODO(rmacnak): Drop after calling convention change. | |
1172 Code::CheckedHandle(reader->ReadObjectImpl(kAsReference)); | |
1173 ObjectPool::CheckedHandle(reader->ReadObjectImpl(kAsReference)); | |
1174 } | |
1175 | |
1264 return result.raw(); | 1176 return result.raw(); |
1265 } | 1177 } |
1266 | 1178 |
1267 | 1179 |
1268 void RawInstructions::WriteTo(SnapshotWriter* writer, | 1180 void RawInstructions::WriteTo(SnapshotWriter* writer, |
1269 intptr_t object_id, | 1181 intptr_t object_id, |
1270 Snapshot::Kind kind) { | 1182 Snapshot::Kind kind) { |
1271 ASSERT(writer->snapshot_code()); | 1183 ASSERT(writer->snapshot_code()); |
1272 ASSERT(kind == Snapshot::kFull); | 1184 ASSERT(kind == Snapshot::kFull); |
1273 | 1185 |
1274 { | 1186 { |
1275 // TODO(rmacnak): Drop after calling convention change. | 1187 // TODO(rmacnak): Drop after calling convention change. |
1276 writer->WriteInlinedObjectHeader(object_id); | 1188 writer->WriteInlinedObjectHeader(object_id); |
1277 writer->WriteVMIsolateObject(kInstructionsCid); | 1189 writer->WriteVMIsolateObject(kInstructionsCid); |
1278 writer->WriteTags(writer->GetObjectTags(this)); | 1190 writer->WriteTags(writer->GetObjectTags(this)); |
1191 } | |
1192 | |
1193 writer->Write<intptr_t>(writer->GetObjectTags(this)); // For sanity check. | |
1194 | |
1195 // Temporarily restore the object header for writing to the text section. | |
1196 // TODO(asiva): Don't mutate object headers during serialization. | |
1197 uword object_tags = writer->GetObjectTags(this); | |
1198 uword snapshot_tags = ptr()->tags_; | |
1199 ptr()->tags_ = object_tags; | |
1200 writer->Write<int32_t>(writer->GetInstructionsId(this)); | |
1201 ptr()->tags_ = snapshot_tags; | |
1202 | |
1203 { | |
1204 // TODO(rmacnak): Drop after calling convention change. | |
1279 writer->WriteObjectImpl(ptr()->code_, kAsReference); | 1205 writer->WriteObjectImpl(ptr()->code_, kAsReference); |
1280 writer->WriteObjectImpl(ptr()->object_pool_, kAsReference); | 1206 writer->WriteObjectImpl(ptr()->object_pool_, kAsReference); |
1281 } | 1207 } |
1282 | |
1283 writer->Write<int32_t>(writer->GetInstructionsId(this)); | |
1284 } | 1208 } |
1285 | 1209 |
1286 | 1210 |
1287 RawObjectPool* ObjectPool::ReadFrom(SnapshotReader* reader, | 1211 RawObjectPool* ObjectPool::ReadFrom(SnapshotReader* reader, |
1288 intptr_t object_id, | 1212 intptr_t object_id, |
1289 intptr_t tags, | 1213 intptr_t tags, |
1290 Snapshot::Kind kind) { | 1214 Snapshot::Kind kind) { |
1291 UNREACHABLE(); // Untested. | |
1292 ASSERT(reader->snapshot_code()); | 1215 ASSERT(reader->snapshot_code()); |
1293 ASSERT(kind == Snapshot::kFull); | 1216 ASSERT(kind == Snapshot::kFull); |
1294 | 1217 |
1295 intptr_t length = reader->Read<intptr_t>(); | 1218 intptr_t length = reader->Read<intptr_t>(); |
1296 | 1219 |
1297 ObjectPool& result = | 1220 ObjectPool& result = |
1298 ObjectPool::ZoneHandle(reader->zone(), | 1221 ObjectPool::ZoneHandle(reader->zone(), |
1299 NEW_OBJECT_WITH_LEN(ObjectPool, length)); | 1222 NEW_OBJECT_WITH_LEN(ObjectPool, length)); |
1300 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1223 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1301 | 1224 |
1302 RawTypedData* info_array = result.raw_ptr()->info_array_->ptr(); | 1225 const TypedData& info_array = |
1226 TypedData::Handle(reader->NewTypedData(kTypedDataInt8ArrayCid, length)); | |
1227 result.set_info_array(info_array); | |
1303 | 1228 |
1304 // Set all the object fields. | 1229 NoSafepointScope no_safepoint; |
1305 // TODO(5411462): Need to assert No GC can happen here, even though | |
1306 // allocations may happen. | |
1307 for (intptr_t i = 0; i < length; i++) { | 1230 for (intptr_t i = 0; i < length; i++) { |
1308 ObjectPool::EntryType entry_type = | 1231 ObjectPool::EntryType entry_type = |
1309 static_cast<ObjectPool::EntryType>(reader->Read<uint8_t>()); | 1232 static_cast<ObjectPool::EntryType>(reader->Read<int8_t>()); |
1310 info_array->data()[i] = entry_type; | 1233 *reinterpret_cast<int8_t*>(info_array.DataAddr(i)) = entry_type; |
1311 switch (entry_type) { | 1234 switch (entry_type) { |
1312 case ObjectPool::kTaggedObject: { | 1235 case ObjectPool::kTaggedObject: { |
1313 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | 1236 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
1314 result.SetObjectAt(i, *(reader->PassiveObjectHandle())); | 1237 result.SetObjectAt(i, *(reader->PassiveObjectHandle())); |
1315 break; | 1238 break; |
1316 } | 1239 } |
1317 case ObjectPool::kImmediate: { | 1240 case ObjectPool::kImmediate: { |
1318 intptr_t raw_value = reader->Read<intptr_t>(); | 1241 intptr_t raw_value = reader->Read<intptr_t>(); |
1319 result.SetRawValueAt(i, raw_value); | 1242 result.SetRawValueAt(i, raw_value); |
1320 break; | 1243 break; |
(...skipping 27 matching lines...) Expand all Loading... | |
1348 writer->WriteTags(writer->GetObjectTags(this)); | 1271 writer->WriteTags(writer->GetObjectTags(this)); |
1349 | 1272 |
1350 intptr_t length = ptr()->length_; | 1273 intptr_t length = ptr()->length_; |
1351 RawTypedData* info_array = ptr()->info_array_->ptr(); | 1274 RawTypedData* info_array = ptr()->info_array_->ptr(); |
1352 ASSERT(info_array != TypedData::null()); | 1275 ASSERT(info_array != TypedData::null()); |
1353 | 1276 |
1354 writer->Write<intptr_t>(length); | 1277 writer->Write<intptr_t>(length); |
1355 for (intptr_t i = 0; i < length; i++) { | 1278 for (intptr_t i = 0; i < length; i++) { |
1356 ObjectPool::EntryType entry_type = | 1279 ObjectPool::EntryType entry_type = |
1357 static_cast<ObjectPool::EntryType>(info_array->data()[i]); | 1280 static_cast<ObjectPool::EntryType>(info_array->data()[i]); |
1358 writer->Write<uint8_t>(entry_type); | 1281 writer->Write<int8_t>(entry_type); |
1359 Entry& entry = ptr()->data()[i]; | 1282 Entry& entry = ptr()->data()[i]; |
1360 switch (entry_type) { | 1283 switch (entry_type) { |
1361 case ObjectPool::kTaggedObject: | 1284 case ObjectPool::kTaggedObject: |
1362 writer->WriteObjectImpl(entry.raw_obj_, kAsReference); | 1285 writer->WriteObjectImpl(entry.raw_obj_, kAsReference); |
1363 break; | 1286 break; |
1364 case ObjectPool::kImmediate: | 1287 case ObjectPool::kImmediate: |
1365 writer->Write<intptr_t>(entry.raw_value_); | 1288 writer->Write<intptr_t>(entry.raw_value_); |
1366 break; | 1289 break; |
1367 case ObjectPool::kExternalLabel: | 1290 case ObjectPool::kExternalLabel: |
1368 // TODO(rmacnak): Write symbolically. | 1291 // TODO(rmacnak): Write symbolically. |
1369 writer->Write<intptr_t>(entry.raw_value_); | 1292 writer->Write<intptr_t>(entry.raw_value_); |
1370 break; | 1293 break; |
1371 default: | 1294 default: |
1372 UNREACHABLE(); | 1295 UNREACHABLE(); |
1373 } | 1296 } |
1374 } | 1297 } |
1375 } | 1298 } |
1376 | 1299 |
1377 | 1300 |
1378 RawPcDescriptors* PcDescriptors::ReadFrom(SnapshotReader* reader, | 1301 RawPcDescriptors* PcDescriptors::ReadFrom(SnapshotReader* reader, |
1379 intptr_t object_id, | 1302 intptr_t object_id, |
1380 intptr_t tags, | 1303 intptr_t tags, |
1381 Snapshot::Kind kind) { | 1304 Snapshot::Kind kind) { |
1382 UNREACHABLE(); // Untested. | |
1383 ASSERT(reader->snapshot_code()); | 1305 ASSERT(reader->snapshot_code()); |
1306 ASSERT(kind == Snapshot::kFull); | |
1384 | 1307 |
1385 const int32_t length = reader->Read<int32_t>(); | 1308 const int32_t length = reader->Read<int32_t>(); |
1386 PcDescriptors& result = PcDescriptors::ZoneHandle(reader->zone(), | 1309 PcDescriptors& result = |
1387 PcDescriptors::New(length)); | 1310 PcDescriptors::ZoneHandle(reader->zone(), |
1311 NEW_OBJECT_WITH_LEN(PcDescriptors, length)); | |
1388 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1312 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1389 | 1313 |
1390 if (result.Length() > 0) { | 1314 if (result.Length() > 0) { |
1391 NoSafepointScope no_safepoint; | 1315 NoSafepointScope no_safepoint; |
1392 intptr_t len = result.Length(); | 1316 intptr_t len = result.Length(); |
1393 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data()); | 1317 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data()); |
1394 reader->ReadBytes(data, len); | 1318 reader->ReadBytes(data, len); |
1395 } | 1319 } |
1396 | 1320 |
1397 return result.raw(); | 1321 return result.raw(); |
1398 } | 1322 } |
1399 | 1323 |
1400 | 1324 |
1401 void RawPcDescriptors::WriteTo(SnapshotWriter* writer, | 1325 void RawPcDescriptors::WriteTo(SnapshotWriter* writer, |
1402 intptr_t object_id, | 1326 intptr_t object_id, |
1403 Snapshot::Kind kind) { | 1327 Snapshot::Kind kind) { |
1404 ASSERT(writer->snapshot_code()); | 1328 ASSERT(writer->snapshot_code()); |
1329 ASSERT(kind == Snapshot::kFull); | |
1405 | 1330 |
1406 // Write out the serialization header value for this object. | 1331 // Write out the serialization header value for this object. |
1407 writer->WriteInlinedObjectHeader(object_id); | 1332 writer->WriteInlinedObjectHeader(object_id); |
1408 writer->WriteIndexedObject(kPcDescriptorsCid); | 1333 writer->WriteIndexedObject(kPcDescriptorsCid); |
1409 writer->WriteTags(writer->GetObjectTags(this)); | 1334 writer->WriteTags(writer->GetObjectTags(this)); |
1410 writer->Write<int32_t>(ptr()->length_); | 1335 writer->Write<int32_t>(ptr()->length_); |
1411 if (ptr()->length_ > 0) { | 1336 if (ptr()->length_ > 0) { |
1412 intptr_t len = ptr()->length_; | 1337 intptr_t len = ptr()->length_; |
1413 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); | 1338 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); |
1414 writer->WriteBytes(data, len); | 1339 writer->WriteBytes(data, len); |
1415 } | 1340 } |
1416 } | 1341 } |
1417 | 1342 |
1418 | 1343 |
1419 RawStackmap* Stackmap::ReadFrom(SnapshotReader* reader, | 1344 RawStackmap* Stackmap::ReadFrom(SnapshotReader* reader, |
1420 intptr_t object_id, | 1345 intptr_t object_id, |
1421 intptr_t tags, | 1346 intptr_t tags, |
1422 Snapshot::Kind kind) { | 1347 Snapshot::Kind kind) { |
1423 UNREACHABLE(); // Untested. | |
1424 ASSERT(reader->snapshot_code()); | 1348 ASSERT(reader->snapshot_code()); |
1349 ASSERT(kind == Snapshot::kFull); | |
1425 | 1350 |
1426 const int32_t length = reader->Read<int32_t>(); | 1351 const int32_t length = reader->Read<int32_t>(); |
1427 const int32_t register_bit_count = reader->Read<int32_t>(); | |
1428 const uword pc_offset = reader->Read<uint32_t>(); | |
1429 | |
1430 Stackmap& result = | 1352 Stackmap& result = |
1431 Stackmap::ZoneHandle(reader->zone(), | 1353 Stackmap::ZoneHandle(reader->zone(), |
1432 Stackmap::New(length, register_bit_count, pc_offset)); | 1354 reader->NewStackmap(length)); |
siva
2015/09/01 20:58:49
This could also be created as NEW_OBJECT_WITH_LEN
| |
1433 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1355 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1434 | 1356 |
1435 if (result.Length() > 0) { | 1357 result.SetRegisterBitCount(reader->Read<int32_t>()); |
1358 result.SetPcOffset(reader->Read<uint32_t>()); | |
1359 | |
1360 if (length > 0) { | |
1436 NoSafepointScope no_safepoint; | 1361 NoSafepointScope no_safepoint; |
1437 intptr_t len = (result.Length() + 7) / 8; | 1362 intptr_t len = (result.Length() + 7) / 8; |
1438 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data()); | 1363 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data()); |
1439 reader->ReadBytes(data, len); | 1364 reader->ReadBytes(data, len); |
1440 } | 1365 } |
1441 | 1366 |
1442 return result.raw(); | 1367 return result.raw(); |
1443 } | 1368 } |
1444 | 1369 |
1445 | 1370 |
1446 void RawStackmap::WriteTo(SnapshotWriter* writer, | 1371 void RawStackmap::WriteTo(SnapshotWriter* writer, |
1447 intptr_t object_id, | 1372 intptr_t object_id, |
1448 Snapshot::Kind kind) { | 1373 Snapshot::Kind kind) { |
1449 ASSERT(writer->snapshot_code()); | 1374 ASSERT(writer->snapshot_code()); |
1375 ASSERT(kind == Snapshot::kFull); | |
1450 | 1376 |
1451 // Write out the serialization header value for this object. | 1377 // Write out the serialization header value for this object. |
1452 writer->WriteInlinedObjectHeader(object_id); | 1378 writer->WriteInlinedObjectHeader(object_id); |
1453 writer->WriteIndexedObject(kStackmapCid); | 1379 writer->WriteIndexedObject(kStackmapCid); |
1454 writer->WriteTags(writer->GetObjectTags(this)); | 1380 writer->WriteTags(writer->GetObjectTags(this)); |
1381 | |
1455 writer->Write<int32_t>(ptr()->length_); | 1382 writer->Write<int32_t>(ptr()->length_); |
1456 writer->Write<int32_t>(ptr()->register_bit_count_); | 1383 writer->Write<int32_t>(ptr()->register_bit_count_); |
1457 writer->Write<uint32_t>(ptr()->pc_offset_); | 1384 writer->Write<uint32_t>(ptr()->pc_offset_); |
1458 if (ptr()->length_ > 0) { | 1385 if (ptr()->length_ > 0) { |
1459 intptr_t len = (ptr()->length_ + 7) / 8; | 1386 intptr_t len = (ptr()->length_ + 7) / 8; |
1460 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); | 1387 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); |
1461 writer->WriteBytes(data, len); | 1388 writer->WriteBytes(data, len); |
1462 } | 1389 } |
1463 } | 1390 } |
1464 | 1391 |
1465 | 1392 |
1466 RawLocalVarDescriptors* LocalVarDescriptors::ReadFrom(SnapshotReader* reader, | 1393 RawLocalVarDescriptors* LocalVarDescriptors::ReadFrom(SnapshotReader* reader, |
1467 intptr_t object_id, | 1394 intptr_t object_id, |
1468 intptr_t tags, | 1395 intptr_t tags, |
1469 Snapshot::Kind kind) { | 1396 Snapshot::Kind kind) { |
1470 UNREACHABLE(); // Untested. | |
1471 ASSERT(reader->snapshot_code()); | 1397 ASSERT(reader->snapshot_code()); |
1398 ASSERT(kind == Snapshot::kFull); | |
1472 | 1399 |
1473 const int32_t num_entries = reader->Read<int32_t>(); | 1400 const int32_t num_entries = reader->Read<int32_t>(); |
1474 | 1401 |
1475 LocalVarDescriptors& result = | 1402 LocalVarDescriptors& result = |
1476 LocalVarDescriptors::ZoneHandle(reader->zone(), | 1403 LocalVarDescriptors::ZoneHandle(reader->zone(), |
1477 LocalVarDescriptors::New(num_entries)); | 1404 NEW_OBJECT_WITH_LEN(LocalVarDescriptors, |
1405 num_entries)); | |
1478 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1406 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1479 | 1407 |
1480 for (intptr_t i = 0; i < num_entries; i++) { | 1408 for (intptr_t i = 0; i < num_entries; i++) { |
1481 (*reader->StringHandle()) ^= reader->ReadObjectImpl(kAsReference); | 1409 (*reader->StringHandle()) ^= reader->ReadObjectImpl(kAsReference); |
siva
2015/09/01 20:58:49
The write side is writing as kAsInlinedObject and
rmacnak
2015/09/01 23:43:47
Done.
| |
1482 result.StorePointer(result.raw()->nameAddrAt(i), | 1410 result.StorePointer(result.raw()->nameAddrAt(i), |
1483 reader->StringHandle()->raw()); | 1411 reader->StringHandle()->raw()); |
1484 } | 1412 } |
1485 | 1413 |
1486 if (num_entries > 0) { | 1414 if (num_entries > 0) { |
1487 NoSafepointScope no_safepoint; | 1415 NoSafepointScope no_safepoint; |
1488 intptr_t len = num_entries * sizeof(RawLocalVarDescriptors::VarInfo); | 1416 intptr_t len = num_entries * sizeof(RawLocalVarDescriptors::VarInfo); |
1489 uint8_t* data = result.UnsafeMutableNonPointer( | 1417 uint8_t* data = result.UnsafeMutableNonPointer( |
1490 reinterpret_cast<const uint8_t*>(result.raw()->data())); | 1418 reinterpret_cast<const uint8_t*>(result.raw()->data())); |
1491 reader->ReadBytes(data, len); | 1419 reader->ReadBytes(data, len); |
1492 } | 1420 } |
1493 | 1421 |
1494 return result.raw(); | 1422 return result.raw(); |
1495 } | 1423 } |
1496 | 1424 |
1497 | 1425 |
1498 void RawLocalVarDescriptors::WriteTo(SnapshotWriter* writer, | 1426 void RawLocalVarDescriptors::WriteTo(SnapshotWriter* writer, |
1499 intptr_t object_id, | 1427 intptr_t object_id, |
1500 Snapshot::Kind kind) { | 1428 Snapshot::Kind kind) { |
1501 ASSERT(writer->snapshot_code()); | 1429 ASSERT(writer->snapshot_code()); |
1430 ASSERT(kind == Snapshot::kFull); | |
1502 | 1431 |
1503 // Write out the serialization header value for this object. | 1432 // Write out the serialization header value for this object. |
1504 writer->WriteInlinedObjectHeader(object_id); | 1433 writer->WriteInlinedObjectHeader(object_id); |
1505 writer->WriteIndexedObject(kLocalVarDescriptorsCid); | 1434 writer->WriteIndexedObject(kLocalVarDescriptorsCid); |
1506 writer->WriteTags(writer->GetObjectTags(this)); | 1435 writer->WriteTags(writer->GetObjectTags(this)); |
1507 writer->Write<int32_t>(ptr()->num_entries_); | 1436 writer->Write<int32_t>(ptr()->num_entries_); |
1508 for (intptr_t i = 0; i < ptr()->num_entries_; i++) { | 1437 for (intptr_t i = 0; i < ptr()->num_entries_; i++) { |
1509 writer->WriteObjectImpl(ptr()->names()[i], kAsInlinedObject); | 1438 writer->WriteObjectImpl(ptr()->names()[i], kAsInlinedObject); |
1510 } | 1439 } |
1511 if (ptr()->num_entries_ > 0) { | 1440 if (ptr()->num_entries_ > 0) { |
1512 intptr_t len = ptr()->num_entries_ * sizeof(VarInfo); | 1441 intptr_t len = ptr()->num_entries_ * sizeof(VarInfo); |
1513 uint8_t* data = reinterpret_cast<uint8_t*>(this->data()); | 1442 uint8_t* data = reinterpret_cast<uint8_t*>(this->data()); |
1514 writer->WriteBytes(data, len); | 1443 writer->WriteBytes(data, len); |
1515 } | 1444 } |
1516 } | 1445 } |
1517 | 1446 |
1518 | 1447 |
1519 RawExceptionHandlers* ExceptionHandlers::ReadFrom(SnapshotReader* reader, | 1448 RawExceptionHandlers* ExceptionHandlers::ReadFrom(SnapshotReader* reader, |
1520 intptr_t object_id, | 1449 intptr_t object_id, |
1521 intptr_t tags, | 1450 intptr_t tags, |
1522 Snapshot::Kind kind) { | 1451 Snapshot::Kind kind) { |
1523 UNREACHABLE(); // Untested. | |
1524 ASSERT(reader->snapshot_code()); | 1452 ASSERT(reader->snapshot_code()); |
1453 ASSERT(kind == Snapshot::kFull); | |
1525 | 1454 |
1526 // handled_types_data. | 1455 const int32_t num_entries = reader->Read<int32_t>(); |
1527 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); | |
1528 | |
1529 ExceptionHandlers& result = | 1456 ExceptionHandlers& result = |
1530 ExceptionHandlers::ZoneHandle(reader->zone(), | 1457 ExceptionHandlers::ZoneHandle(reader->zone(), |
1531 ExceptionHandlers::New(*reader->ArrayHandle())); | 1458 NEW_OBJECT_WITH_LEN(ExceptionHandlers, |
1459 num_entries)); | |
1532 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1460 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1533 | 1461 |
1534 if (result.num_entries() > 0) { | 1462 if (result.num_entries() > 0) { |
1535 NoSafepointScope no_safepoint; | 1463 NoSafepointScope no_safepoint; |
1536 const intptr_t len = | 1464 const intptr_t len = |
1537 result.num_entries() * sizeof(RawExceptionHandlers::HandlerInfo); | 1465 result.num_entries() * sizeof(RawExceptionHandlers::HandlerInfo); |
1538 uint8_t* data = result.UnsafeMutableNonPointer( | 1466 uint8_t* data = result.UnsafeMutableNonPointer( |
1539 reinterpret_cast<const uint8_t*>(result.raw_ptr()->data())); | 1467 reinterpret_cast<const uint8_t*>(result.raw_ptr()->data())); |
1540 reader->ReadBytes(data, len); | 1468 reader->ReadBytes(data, len); |
1541 } | 1469 } |
1542 | 1470 |
1471 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); | |
1472 result.StorePointer(&result.raw_ptr()->handled_types_data_, | |
1473 reader->ArrayHandle()->raw()); | |
1474 | |
1543 return result.raw(); | 1475 return result.raw(); |
1544 } | 1476 } |
1545 | 1477 |
1546 | 1478 |
1547 void RawExceptionHandlers::WriteTo(SnapshotWriter* writer, | 1479 void RawExceptionHandlers::WriteTo(SnapshotWriter* writer, |
1548 intptr_t object_id, | 1480 intptr_t object_id, |
1549 Snapshot::Kind kind) { | 1481 Snapshot::Kind kind) { |
1550 ASSERT(writer->snapshot_code()); | 1482 ASSERT(writer->snapshot_code()); |
1483 ASSERT(kind == Snapshot::kFull); | |
1551 | 1484 |
1552 // Write out the serialization header value for this object. | 1485 // Write out the serialization header value for this object. |
1553 writer->WriteInlinedObjectHeader(object_id); | 1486 writer->WriteInlinedObjectHeader(object_id); |
1554 writer->WriteIndexedObject(kExceptionHandlersCid); | 1487 writer->WriteIndexedObject(kExceptionHandlersCid); |
1555 writer->WriteTags(writer->GetObjectTags(this)); | 1488 writer->WriteTags(writer->GetObjectTags(this)); |
1556 writer->WriteObjectImpl(ptr()->handled_types_data_, kAsInlinedObject); | 1489 writer->Write<int32_t>(ptr()->num_entries_); |
1557 | 1490 |
1558 if (ptr()->num_entries_ > 0) { | 1491 if (ptr()->num_entries_ > 0) { |
1559 intptr_t len = ptr()->num_entries_ * sizeof(HandlerInfo); | 1492 intptr_t len = ptr()->num_entries_ * sizeof(HandlerInfo); |
1560 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); | 1493 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); |
1561 writer->WriteBytes(data, len); | 1494 writer->WriteBytes(data, len); |
1562 } | 1495 } |
1496 | |
1497 writer->WriteObjectImpl(ptr()->handled_types_data_, kAsInlinedObject); | |
1563 } | 1498 } |
1564 | 1499 |
1565 | 1500 |
1566 RawContext* Context::ReadFrom(SnapshotReader* reader, | 1501 RawContext* Context::ReadFrom(SnapshotReader* reader, |
1567 intptr_t object_id, | 1502 intptr_t object_id, |
1568 intptr_t tags, | 1503 intptr_t tags, |
1569 Snapshot::Kind kind) { | 1504 Snapshot::Kind kind) { |
1570 ASSERT(reader != NULL); | 1505 ASSERT(reader != NULL); |
1571 | 1506 |
1572 // Allocate context object. | 1507 // Allocate context object. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1628 intptr_t object_id, | 1563 intptr_t object_id, |
1629 Snapshot::Kind kind) { | 1564 Snapshot::Kind kind) { |
1630 UNREACHABLE(); | 1565 UNREACHABLE(); |
1631 } | 1566 } |
1632 | 1567 |
1633 | 1568 |
1634 RawICData* ICData::ReadFrom(SnapshotReader* reader, | 1569 RawICData* ICData::ReadFrom(SnapshotReader* reader, |
1635 intptr_t object_id, | 1570 intptr_t object_id, |
1636 intptr_t tags, | 1571 intptr_t tags, |
1637 Snapshot::Kind kind) { | 1572 Snapshot::Kind kind) { |
1638 UNREACHABLE(); // Untested. | |
1639 ASSERT(reader->snapshot_code()); | 1573 ASSERT(reader->snapshot_code()); |
1640 ASSERT(kind == Snapshot::kFull); | 1574 ASSERT(kind == Snapshot::kFull); |
1641 | 1575 |
1642 ICData& result = ICData::ZoneHandle(reader->zone(), NEW_OBJECT(ICData)); | 1576 ICData& result = ICData::ZoneHandle(reader->zone(), NEW_OBJECT(ICData)); |
1643 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1577 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1644 | 1578 |
1645 result.set_deopt_id(reader->Read<int32_t>()); | 1579 result.set_deopt_id(reader->Read<int32_t>()); |
1646 result.set_state_bits(reader->Read<uint32_t>()); | 1580 result.set_state_bits(reader->Read<uint32_t>()); |
1647 | 1581 |
1648 // Set all the object fields. | 1582 // Set all the object fields. |
1649 // TODO(5411462): Need to assert No GC can happen here, even though | 1583 READ_POINTERS(result, kAsReference); |
1650 // allocations may happen. | |
1651 intptr_t num_flds = (result.raw()->to() - result.raw()->from()); | |
1652 for (intptr_t i = 0; i <= num_flds; i++) { | |
1653 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | |
1654 result.StorePointer((result.raw()->from() + i), | |
1655 reader->PassiveObjectHandle()->raw()); | |
1656 } | |
1657 | 1584 |
1658 return result.raw(); | 1585 return result.raw(); |
1659 } | 1586 } |
1660 | 1587 |
1661 | 1588 |
1662 void RawICData::WriteTo(SnapshotWriter* writer, | 1589 void RawICData::WriteTo(SnapshotWriter* writer, |
1663 intptr_t object_id, | 1590 intptr_t object_id, |
1664 Snapshot::Kind kind) { | 1591 Snapshot::Kind kind) { |
1665 ASSERT(writer->snapshot_code()); | 1592 ASSERT(writer->snapshot_code()); |
1666 ASSERT(kind == Snapshot::kFull); | 1593 ASSERT(kind == Snapshot::kFull); |
(...skipping 12 matching lines...) Expand all Loading... | |
1679 // Write out all the object pointer fields. | 1606 // Write out all the object pointer fields. |
1680 SnapshotWriterVisitor visitor(writer); | 1607 SnapshotWriterVisitor visitor(writer); |
1681 visitor.VisitPointers(from(), to()); | 1608 visitor.VisitPointers(from(), to()); |
1682 } | 1609 } |
1683 | 1610 |
1684 | 1611 |
1685 RawMegamorphicCache* MegamorphicCache::ReadFrom(SnapshotReader* reader, | 1612 RawMegamorphicCache* MegamorphicCache::ReadFrom(SnapshotReader* reader, |
1686 intptr_t object_id, | 1613 intptr_t object_id, |
1687 intptr_t tags, | 1614 intptr_t tags, |
1688 Snapshot::Kind kind) { | 1615 Snapshot::Kind kind) { |
1689 UNREACHABLE(); // Untested. | |
1690 ASSERT(reader->snapshot_code()); | 1616 ASSERT(reader->snapshot_code()); |
1691 ASSERT(kind == Snapshot::kFull); | 1617 ASSERT(kind == Snapshot::kFull); |
1692 | 1618 |
1693 MegamorphicCache& result = | 1619 MegamorphicCache& result = |
1694 MegamorphicCache::ZoneHandle(reader->zone(), | 1620 MegamorphicCache::ZoneHandle(reader->zone(), |
1695 NEW_OBJECT(MegamorphicCache)); | 1621 NEW_OBJECT(MegamorphicCache)); |
1696 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1622 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1697 | 1623 |
1698 result.set_filled_entry_count(reader->Read<int32_t>()); | 1624 result.set_filled_entry_count(reader->Read<int32_t>()); |
1699 | 1625 |
1700 // Set all the object fields. | 1626 // Set all the object fields. |
1701 // TODO(5411462): Need to assert No GC can happen here, even though | 1627 READ_POINTERS(result, kAsReference); |
1702 // allocations may happen. | |
1703 intptr_t num_flds = (result.raw()->to() - result.raw()->from()); | |
1704 for (intptr_t i = 0; i <= num_flds; i++) { | |
1705 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | |
1706 result.StorePointer((result.raw()->from() + i), | |
1707 reader->PassiveObjectHandle()->raw()); | |
1708 } | |
1709 | 1628 |
1710 return result.raw(); | 1629 return result.raw(); |
1711 } | 1630 } |
1712 | 1631 |
1713 | 1632 |
1714 void RawMegamorphicCache::WriteTo(SnapshotWriter* writer, | 1633 void RawMegamorphicCache::WriteTo(SnapshotWriter* writer, |
1715 intptr_t object_id, | 1634 intptr_t object_id, |
1716 Snapshot::Kind kind) { | 1635 Snapshot::Kind kind) { |
1717 ASSERT(writer->snapshot_code()); | 1636 ASSERT(writer->snapshot_code()); |
1718 ASSERT(kind == Snapshot::kFull); | 1637 ASSERT(kind == Snapshot::kFull); |
(...skipping 11 matching lines...) Expand all Loading... | |
1730 // Write out all the object pointer fields. | 1649 // Write out all the object pointer fields. |
1731 SnapshotWriterVisitor visitor(writer); | 1650 SnapshotWriterVisitor visitor(writer); |
1732 visitor.VisitPointers(from(), to()); | 1651 visitor.VisitPointers(from(), to()); |
1733 } | 1652 } |
1734 | 1653 |
1735 | 1654 |
1736 RawSubtypeTestCache* SubtypeTestCache::ReadFrom(SnapshotReader* reader, | 1655 RawSubtypeTestCache* SubtypeTestCache::ReadFrom(SnapshotReader* reader, |
1737 intptr_t object_id, | 1656 intptr_t object_id, |
1738 intptr_t tags, | 1657 intptr_t tags, |
1739 Snapshot::Kind kind) { | 1658 Snapshot::Kind kind) { |
1740 UNREACHABLE(); // Untested. | |
1741 ASSERT(reader->snapshot_code()); | 1659 ASSERT(reader->snapshot_code()); |
1742 ASSERT(kind == Snapshot::kFull); | 1660 ASSERT(kind == Snapshot::kFull); |
1743 | 1661 |
1744 SubtypeTestCache& result = | 1662 SubtypeTestCache& result = |
1745 SubtypeTestCache::ZoneHandle(reader->zone(), | 1663 SubtypeTestCache::ZoneHandle(reader->zone(), |
1746 NEW_OBJECT(SubtypeTestCache)); | 1664 NEW_OBJECT(SubtypeTestCache)); |
1747 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1665 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1748 | 1666 |
1749 // Set all the object fields. | 1667 // Set all the object fields. |
1750 // TODO(5411462): Need to assert No GC can happen here, even though | 1668 // TODO(5411462): Need to assert No GC can happen here, even though |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1796 intptr_t tags, | 1714 intptr_t tags, |
1797 Snapshot::Kind kind) { | 1715 Snapshot::Kind kind) { |
1798 ASSERT(reader != NULL); | 1716 ASSERT(reader != NULL); |
1799 | 1717 |
1800 // Allocate ApiError object. | 1718 // Allocate ApiError object. |
1801 ApiError& api_error = | 1719 ApiError& api_error = |
1802 ApiError::ZoneHandle(reader->zone(), NEW_OBJECT(ApiError)); | 1720 ApiError::ZoneHandle(reader->zone(), NEW_OBJECT(ApiError)); |
1803 reader->AddBackRef(object_id, &api_error, kIsDeserialized); | 1721 reader->AddBackRef(object_id, &api_error, kIsDeserialized); |
1804 | 1722 |
1805 // Set all the object fields. | 1723 // Set all the object fields. |
1806 // TODO(5411462): Need to assert No GC can happen here, even though | 1724 READ_POINTERS(api_error, kAsReference); |
1807 // allocations may happen. | |
1808 intptr_t num_flds = (api_error.raw()->to() - api_error.raw()->from()); | |
1809 for (intptr_t i = 0; i <= num_flds; i++) { | |
1810 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | |
1811 api_error.StorePointer((api_error.raw()->from() + i), | |
1812 reader->PassiveObjectHandle()->raw()); | |
1813 } | |
1814 | 1725 |
1815 return api_error.raw(); | 1726 return api_error.raw(); |
1816 } | 1727 } |
1817 | 1728 |
1818 | 1729 |
1819 void RawApiError::WriteTo(SnapshotWriter* writer, | 1730 void RawApiError::WriteTo(SnapshotWriter* writer, |
1820 intptr_t object_id, | 1731 intptr_t object_id, |
1821 Snapshot::Kind kind) { | 1732 Snapshot::Kind kind) { |
1822 ASSERT(writer != NULL); | 1733 ASSERT(writer != NULL); |
1823 | 1734 |
(...skipping 19 matching lines...) Expand all Loading... | |
1843 // Allocate LanguageError object. | 1754 // Allocate LanguageError object. |
1844 LanguageError& language_error = | 1755 LanguageError& language_error = |
1845 LanguageError::ZoneHandle(reader->zone(), NEW_OBJECT(LanguageError)); | 1756 LanguageError::ZoneHandle(reader->zone(), NEW_OBJECT(LanguageError)); |
1846 reader->AddBackRef(object_id, &language_error, kIsDeserialized); | 1757 reader->AddBackRef(object_id, &language_error, kIsDeserialized); |
1847 | 1758 |
1848 // Set all non object fields. | 1759 // Set all non object fields. |
1849 language_error.set_token_pos(reader->Read<int32_t>()); | 1760 language_error.set_token_pos(reader->Read<int32_t>()); |
1850 language_error.set_kind(reader->Read<uint8_t>()); | 1761 language_error.set_kind(reader->Read<uint8_t>()); |
1851 | 1762 |
1852 // Set all the object fields. | 1763 // Set all the object fields. |
1853 // TODO(5411462): Need to assert No GC can happen here, even though | 1764 READ_POINTERS(language_error, kAsReference); |
1854 // allocations may happen. | |
1855 intptr_t num_flds = | |
1856 (language_error.raw()->to() - language_error.raw()->from()); | |
1857 for (intptr_t i = 0; i <= num_flds; i++) { | |
1858 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | |
1859 language_error.StorePointer((language_error.raw()->from() + i), | |
1860 reader->PassiveObjectHandle()->raw()); | |
1861 } | |
1862 | 1765 |
1863 return language_error.raw(); | 1766 return language_error.raw(); |
1864 } | 1767 } |
1865 | 1768 |
1866 | 1769 |
1867 void RawLanguageError::WriteTo(SnapshotWriter* writer, | 1770 void RawLanguageError::WriteTo(SnapshotWriter* writer, |
1868 intptr_t object_id, | 1771 intptr_t object_id, |
1869 Snapshot::Kind kind) { | 1772 Snapshot::Kind kind) { |
1870 ASSERT(writer != NULL); | 1773 ASSERT(writer != NULL); |
1871 | 1774 |
(...skipping 16 matching lines...) Expand all Loading... | |
1888 | 1791 |
1889 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader, | 1792 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader, |
1890 intptr_t object_id, | 1793 intptr_t object_id, |
1891 intptr_t tags, | 1794 intptr_t tags, |
1892 Snapshot::Kind kind) { | 1795 Snapshot::Kind kind) { |
1893 UnhandledException& result = UnhandledException::ZoneHandle( | 1796 UnhandledException& result = UnhandledException::ZoneHandle( |
1894 reader->zone(), NEW_OBJECT(UnhandledException)); | 1797 reader->zone(), NEW_OBJECT(UnhandledException)); |
1895 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1798 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1896 | 1799 |
1897 // Set all the object fields. | 1800 // Set all the object fields. |
1898 // TODO(5411462): Need to assert No GC can happen here, even though | 1801 READ_POINTERS(result, kAsReference); |
1899 // allocations may happen. | |
1900 intptr_t num_flds = (result.raw()->to() - result.raw()->from()); | |
1901 for (intptr_t i = 0; i <= num_flds; i++) { | |
1902 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | |
1903 result.StorePointer((result.raw()->from() + i), | |
1904 reader->PassiveObjectHandle()->raw()); | |
1905 } | |
1906 | 1802 |
1907 return result.raw(); | 1803 return result.raw(); |
1908 } | 1804 } |
1909 | 1805 |
1910 | 1806 |
1911 void RawUnhandledException::WriteTo(SnapshotWriter* writer, | 1807 void RawUnhandledException::WriteTo(SnapshotWriter* writer, |
1912 intptr_t object_id, | 1808 intptr_t object_id, |
1913 Snapshot::Kind kind) { | 1809 Snapshot::Kind kind) { |
1914 // Write out the serialization header value for this object. | 1810 // Write out the serialization header value for this object. |
1915 writer->WriteInlinedObjectHeader(object_id); | 1811 writer->WriteInlinedObjectHeader(object_id); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2047 intptr_t object_id, | 1943 intptr_t object_id, |
2048 intptr_t tags, | 1944 intptr_t tags, |
2049 Snapshot::Kind kind) { | 1945 Snapshot::Kind kind) { |
2050 ASSERT(reader != NULL); | 1946 ASSERT(reader != NULL); |
2051 | 1947 |
2052 // Allocate bigint object. | 1948 // Allocate bigint object. |
2053 Bigint& obj = Bigint::ZoneHandle(reader->zone(), NEW_OBJECT(Bigint)); | 1949 Bigint& obj = Bigint::ZoneHandle(reader->zone(), NEW_OBJECT(Bigint)); |
2054 reader->AddBackRef(object_id, &obj, kIsDeserialized); | 1950 reader->AddBackRef(object_id, &obj, kIsDeserialized); |
2055 | 1951 |
2056 // Set all the object fields. | 1952 // Set all the object fields. |
2057 // TODO(5411462): Need to assert No GC can happen here, even though | 1953 READ_POINTERS(obj, kAsInlinedObject); |
2058 // allocations may happen. | |
2059 intptr_t num_flds = (obj.raw()->to() - obj.raw()->from()); | |
2060 for (intptr_t i = 0; i <= num_flds; i++) { | |
2061 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsInlinedObject); | |
2062 obj.StorePointer(obj.raw()->from() + i, | |
2063 reader->PassiveObjectHandle()->raw()); | |
2064 } | |
2065 | 1954 |
2066 // If it is a canonical constant make it one. | 1955 // If it is a canonical constant make it one. |
2067 // When reading a full snapshot we don't need to canonicalize the object | 1956 // When reading a full snapshot we don't need to canonicalize the object |
2068 // as it would already be a canonical object. | 1957 // as it would already be a canonical object. |
2069 // When reading a script snapshot or a message snapshot we always have | 1958 // When reading a script snapshot or a message snapshot we always have |
2070 // to canonicalize the object. | 1959 // to canonicalize the object. |
2071 if (RawObject::IsCanonical(tags)) { | 1960 if (RawObject::IsCanonical(tags)) { |
2072 if (kind == Snapshot::kFull) { | 1961 if (kind == Snapshot::kFull) { |
2073 // Set the canonical bit. | 1962 // Set the canonical bit. |
2074 obj.SetCanonical(); | 1963 obj.SetCanonical(); |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2532 | 2421 |
2533 | 2422 |
2534 RawLinkedHashMap* LinkedHashMap::ReadFrom(SnapshotReader* reader, | 2423 RawLinkedHashMap* LinkedHashMap::ReadFrom(SnapshotReader* reader, |
2535 intptr_t object_id, | 2424 intptr_t object_id, |
2536 intptr_t tags, | 2425 intptr_t tags, |
2537 Snapshot::Kind kind) { | 2426 Snapshot::Kind kind) { |
2538 ASSERT(reader != NULL); | 2427 ASSERT(reader != NULL); |
2539 | 2428 |
2540 LinkedHashMap& map = LinkedHashMap::ZoneHandle( | 2429 LinkedHashMap& map = LinkedHashMap::ZoneHandle( |
2541 reader->zone(), LinkedHashMap::null()); | 2430 reader->zone(), LinkedHashMap::null()); |
2542 if (kind == Snapshot::kFull || kind == Snapshot::kScript) { | 2431 if ((kind == Snapshot::kFull && !reader->snapshot_code()) || |
2432 kind == Snapshot::kScript) { | |
2543 // The immutable maps that seed map literals are not yet VM-internal, so | 2433 // The immutable maps that seed map literals are not yet VM-internal, so |
2544 // we don't reach this. | 2434 // we don't reach this. |
2545 UNREACHABLE(); | 2435 UNREACHABLE(); |
2546 } else { | 2436 } else { |
2547 // Since the map might contain itself as a key or value, allocate first. | 2437 // Since the map might contain itself as a key or value, allocate first. |
2548 map = LinkedHashMap::NewUninitialized(HEAP_SPACE(kind)); | 2438 if (kind == Snapshot::kFull) { |
2439 map = reader->NewLinkedHashMap(); | |
2440 } else { | |
2441 map = LinkedHashMap::NewUninitialized(HEAP_SPACE(kind)); | |
2442 } | |
2549 } | 2443 } |
2550 reader->AddBackRef(object_id, &map, kIsDeserialized); | 2444 reader->AddBackRef(object_id, &map, kIsDeserialized); |
2551 | 2445 |
2552 // Read the type arguments. | 2446 // Read the type arguments. |
2553 const intptr_t typeargs_offset = | 2447 const intptr_t typeargs_offset = |
2554 GrowableObjectArray::type_arguments_offset() / kWordSize; | 2448 GrowableObjectArray::type_arguments_offset() / kWordSize; |
2555 *reader->TypeArgumentsHandle() ^= | 2449 *reader->TypeArgumentsHandle() ^= |
2556 reader->ReadObjectImpl(kAsInlinedObject, object_id, typeargs_offset); | 2450 reader->ReadObjectImpl(kAsInlinedObject, object_id, typeargs_offset); |
2557 map.SetTypeArguments(*reader->TypeArgumentsHandle()); | 2451 map.SetTypeArguments(*reader->TypeArgumentsHandle()); |
2558 | 2452 |
2559 // Read the number of key/value pairs. | 2453 // Read the number of key/value pairs. |
2560 intptr_t len = reader->ReadSmiValue(); | 2454 intptr_t len = reader->ReadSmiValue(); |
2561 intptr_t used_data = (len << 1); | 2455 intptr_t used_data = (len << 1); |
2562 map.SetUsedData(used_data); | 2456 map.SetUsedData(used_data); |
2563 | 2457 |
2564 // Allocate the data array. | 2458 // Allocate the data array. |
2565 intptr_t data_size = Utils::Maximum( | 2459 intptr_t data_size = Utils::Maximum( |
2566 Utils::RoundUpToPowerOfTwo(used_data), | 2460 Utils::RoundUpToPowerOfTwo(used_data), |
2567 static_cast<uintptr_t>(LinkedHashMap::kInitialIndexSize)); | 2461 static_cast<uintptr_t>(LinkedHashMap::kInitialIndexSize)); |
2568 Array& data = Array::ZoneHandle(reader->zone(), | 2462 Array& data = Array::ZoneHandle(reader->zone(), |
2569 Array::New(data_size, HEAP_SPACE(kind))); | 2463 NEW_OBJECT_WITH_LEN_SPACE(Array, |
2464 data_size, | |
2465 kind)); | |
2570 map.SetData(data); | 2466 map.SetData(data); |
2571 map.SetDeletedKeys(0); | 2467 map.SetDeletedKeys(0); |
2572 | 2468 |
2573 // The index and hashMask is regenerated by the maps themselves on demand. | 2469 // The index and hashMask is regenerated by the maps themselves on demand. |
2574 // Thus, the index will probably be allocated in new space (unless it's huge). | 2470 // Thus, the index will probably be allocated in new space (unless it's huge). |
2575 // TODO(koda): Eagerly rehash here when no keys have user-defined '==', and | 2471 // TODO(koda): Eagerly rehash here when no keys have user-defined '==', and |
2576 // in particular, if/when (const) maps are needed in the VM isolate snapshot. | 2472 // in particular, if/when (const) maps are needed in the VM isolate snapshot. |
2577 ASSERT(reader->isolate() != Dart::vm_isolate()); | 2473 ASSERT(reader->isolate() != Dart::vm_isolate()); |
2578 map.SetHashMask(0); // Prefer sentinel 0 over null for better type feedback. | 2474 map.SetHashMask(0); // Prefer sentinel 0 over null for better type feedback. |
2579 | 2475 |
2580 // Read the keys and values. | 2476 // Read the keys and values. |
2581 bool as_reference = RawObject::IsCanonical(tags) ? false : true; | 2477 bool as_reference = RawObject::IsCanonical(tags) ? false : true; |
2582 for (intptr_t i = 0; i < used_data; i++) { | 2478 for (intptr_t i = 0; i < used_data; i++) { |
2583 *reader->PassiveObjectHandle() = reader->ReadObjectImpl(as_reference); | 2479 *reader->PassiveObjectHandle() = reader->ReadObjectImpl(as_reference); |
2584 data.SetAt(i, *reader->PassiveObjectHandle()); | 2480 data.SetAt(i, *reader->PassiveObjectHandle()); |
2585 } | 2481 } |
2586 return map.raw(); | 2482 return map.raw(); |
2587 } | 2483 } |
2588 | 2484 |
2589 | 2485 |
2590 void RawLinkedHashMap::WriteTo(SnapshotWriter* writer, | 2486 void RawLinkedHashMap::WriteTo(SnapshotWriter* writer, |
2591 intptr_t object_id, | 2487 intptr_t object_id, |
2592 Snapshot::Kind kind) { | 2488 Snapshot::Kind kind) { |
2593 if (kind == Snapshot::kFull || kind == Snapshot::kScript) { | 2489 if ((kind == Snapshot::kFull && !writer->snapshot_code()) || |
2490 kind == Snapshot::kScript) { | |
2594 // The immutable maps that seed map literals are not yet VM-internal, so | 2491 // The immutable maps that seed map literals are not yet VM-internal, so |
2595 // we don't reach this. | 2492 // we don't reach this. |
2596 UNREACHABLE(); | |
2597 } | 2493 } |
2598 ASSERT(writer != NULL); | 2494 ASSERT(writer != NULL); |
2599 | 2495 |
2600 // Write out the serialization header value for this object. | 2496 // Write out the serialization header value for this object. |
2601 writer->WriteInlinedObjectHeader(object_id); | 2497 writer->WriteInlinedObjectHeader(object_id); |
2602 | 2498 |
2603 // Write out the class and tags information. | 2499 // Write out the class and tags information. |
2604 writer->WriteIndexedObject(kLinkedHashMapCid); | 2500 writer->WriteIndexedObject(kLinkedHashMapCid); |
2605 const uword tags = writer->GetObjectTags(this); | 2501 const uword tags = writer->GetObjectTags(this); |
2606 writer->WriteTags(tags); | 2502 writer->WriteTags(tags); |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3032 } else { | 2928 } else { |
3033 UNREACHABLE(); | 2929 UNREACHABLE(); |
3034 } | 2930 } |
3035 } | 2931 } |
3036 | 2932 |
3037 | 2933 |
3038 RawSendPort* SendPort::ReadFrom(SnapshotReader* reader, | 2934 RawSendPort* SendPort::ReadFrom(SnapshotReader* reader, |
3039 intptr_t object_id, | 2935 intptr_t object_id, |
3040 intptr_t tags, | 2936 intptr_t tags, |
3041 Snapshot::Kind kind) { | 2937 Snapshot::Kind kind) { |
2938 ASSERT(kind == Snapshot::kMessage || reader->snapshot_code()); | |
2939 | |
3042 uint64_t id = reader->Read<uint64_t>(); | 2940 uint64_t id = reader->Read<uint64_t>(); |
3043 uint64_t origin_id = reader->Read<uint64_t>(); | 2941 uint64_t origin_id = reader->Read<uint64_t>(); |
3044 | 2942 |
3045 SendPort& result = SendPort::ZoneHandle(reader->zone(), | 2943 SendPort& result = SendPort::ZoneHandle(reader->zone()); |
3046 SendPort::New(id, origin_id)); | 2944 if (reader->snapshot_code()) { |
2945 // TODO(rmacnak): Reset fields in precompiled snapshots and assert | |
2946 // this is unreachable. | |
2947 } else { | |
2948 result = SendPort::New(id, origin_id); | |
2949 } | |
3047 reader->AddBackRef(object_id, &result, kIsDeserialized); | 2950 reader->AddBackRef(object_id, &result, kIsDeserialized); |
3048 return result.raw(); | 2951 return result.raw(); |
3049 } | 2952 } |
3050 | 2953 |
3051 | 2954 |
3052 void RawSendPort::WriteTo(SnapshotWriter* writer, | 2955 void RawSendPort::WriteTo(SnapshotWriter* writer, |
3053 intptr_t object_id, | 2956 intptr_t object_id, |
3054 Snapshot::Kind kind) { | 2957 Snapshot::Kind kind) { |
3055 // Write out the serialization header value for this object. | 2958 // Write out the serialization header value for this object. |
3056 writer->WriteInlinedObjectHeader(object_id); | 2959 writer->WriteInlinedObjectHeader(object_id); |
3057 | 2960 |
3058 // Write out the class and tags information. | 2961 // Write out the class and tags information. |
3059 writer->WriteIndexedObject(kSendPortCid); | 2962 writer->WriteIndexedObject(kSendPortCid); |
3060 writer->WriteTags(writer->GetObjectTags(this)); | 2963 writer->WriteTags(writer->GetObjectTags(this)); |
3061 | 2964 |
3062 writer->Write<uint64_t>(ptr()->id_); | 2965 writer->Write<uint64_t>(ptr()->id_); |
3063 writer->Write<uint64_t>(ptr()->origin_id_); | 2966 writer->Write<uint64_t>(ptr()->origin_id_); |
3064 } | 2967 } |
3065 | 2968 |
3066 | 2969 |
3067 RawStacktrace* Stacktrace::ReadFrom(SnapshotReader* reader, | 2970 RawStacktrace* Stacktrace::ReadFrom(SnapshotReader* reader, |
3068 intptr_t object_id, | 2971 intptr_t object_id, |
3069 intptr_t tags, | 2972 intptr_t tags, |
3070 Snapshot::Kind kind) { | 2973 Snapshot::Kind kind) { |
3071 if (kind == Snapshot::kFull) { | 2974 if (kind == Snapshot::kFull) { |
3072 Stacktrace& result = Stacktrace::ZoneHandle(reader->zone(), | 2975 Stacktrace& result = Stacktrace::ZoneHandle(reader->zone(), |
3073 reader->NewStacktrace()); | 2976 reader->NewStacktrace()); |
3074 reader->AddBackRef(object_id, &result, kIsDeserialized); | 2977 reader->AddBackRef(object_id, &result, kIsDeserialized); |
3075 | 2978 |
3076 // Set all the object fields. | |
3077 // TODO(5411462): Need to assert No GC can happen here, even though | |
3078 // allocations may happen. | |
3079 intptr_t num_flds = (result.raw()->to() - result.raw()->from()); | |
3080 for (intptr_t i = 0; i <= num_flds; i++) { | |
3081 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | |
3082 result.StorePointer((result.raw()->from() + i), | |
3083 reader->PassiveObjectHandle()->raw()); | |
3084 } | |
3085 | |
3086 bool expand_inlined = reader->Read<bool>(); | 2979 bool expand_inlined = reader->Read<bool>(); |
3087 result.set_expand_inlined(expand_inlined); | 2980 result.set_expand_inlined(expand_inlined); |
3088 | 2981 |
2982 // Set all the object fields. | |
2983 READ_POINTERS(result, kAsReference); | |
2984 | |
3089 return result.raw(); | 2985 return result.raw(); |
3090 } | 2986 } |
3091 UNREACHABLE(); // Stacktraces are not sent in a snapshot. | 2987 UNREACHABLE(); // Stacktraces are not sent in a snapshot. |
3092 return Stacktrace::null(); | 2988 return Stacktrace::null(); |
3093 } | 2989 } |
3094 | 2990 |
3095 | 2991 |
3096 void RawStacktrace::WriteTo(SnapshotWriter* writer, | 2992 void RawStacktrace::WriteTo(SnapshotWriter* writer, |
3097 intptr_t object_id, | 2993 intptr_t object_id, |
3098 Snapshot::Kind kind) { | 2994 Snapshot::Kind kind) { |
3099 if (kind == Snapshot::kFull) { | 2995 if (kind == Snapshot::kFull) { |
3100 ASSERT(writer != NULL); | 2996 ASSERT(writer != NULL); |
3101 ASSERT(this == Isolate::Current()->object_store()-> | 2997 ASSERT(this == Isolate::Current()->object_store()-> |
3102 preallocated_stack_trace()); | 2998 preallocated_stack_trace()); |
3103 | 2999 |
3104 // Write out the serialization header value for this object. | 3000 // Write out the serialization header value for this object. |
3105 writer->WriteInlinedObjectHeader(object_id); | 3001 writer->WriteInlinedObjectHeader(object_id); |
3106 | 3002 |
3107 // Write out the class and tags information. | 3003 // Write out the class and tags information. |
3108 writer->WriteIndexedObject(kStacktraceCid); | 3004 writer->WriteIndexedObject(kStacktraceCid); |
3109 writer->WriteTags(writer->GetObjectTags(this)); | 3005 writer->WriteTags(writer->GetObjectTags(this)); |
3110 | 3006 |
3007 writer->Write(ptr()->expand_inlined_); | |
3008 | |
3111 // Write out all the object pointer fields. | 3009 // Write out all the object pointer fields. |
3112 SnapshotWriterVisitor visitor(writer); | 3010 SnapshotWriterVisitor visitor(writer); |
3113 visitor.VisitPointers(from(), to()); | 3011 visitor.VisitPointers(from(), to()); |
3114 | |
3115 writer->Write(ptr()->expand_inlined_); | |
3116 } else { | 3012 } else { |
3117 // Stacktraces are not allowed in other snapshot forms. | 3013 // Stacktraces are not allowed in other snapshot forms. |
3118 writer->SetWriteException(Exceptions::kArgument, | 3014 writer->SetWriteException(Exceptions::kArgument, |
3119 "Illegal argument in isolate message" | 3015 "Illegal argument in isolate message" |
3120 " : (object is a stacktrace)"); | 3016 " : (object is a stacktrace)"); |
3121 } | 3017 } |
3122 } | 3018 } |
3123 | 3019 |
3124 | 3020 |
3125 RawJSRegExp* JSRegExp::ReadFrom(SnapshotReader* reader, | 3021 RawJSRegExp* JSRegExp::ReadFrom(SnapshotReader* reader, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3175 intptr_t tags, | 3071 intptr_t tags, |
3176 Snapshot::Kind kind) { | 3072 Snapshot::Kind kind) { |
3177 ASSERT(reader != NULL); | 3073 ASSERT(reader != NULL); |
3178 | 3074 |
3179 // Allocate the weak property object. | 3075 // Allocate the weak property object. |
3180 WeakProperty& weak_property = WeakProperty::ZoneHandle( | 3076 WeakProperty& weak_property = WeakProperty::ZoneHandle( |
3181 reader->zone(), WeakProperty::New(HEAP_SPACE(kind))); | 3077 reader->zone(), WeakProperty::New(HEAP_SPACE(kind))); |
3182 reader->AddBackRef(object_id, &weak_property, kIsDeserialized); | 3078 reader->AddBackRef(object_id, &weak_property, kIsDeserialized); |
3183 | 3079 |
3184 // Set all the object fields. | 3080 // Set all the object fields. |
3185 // TODO(5411462): Need to assert No GC can happen here, even though | 3081 READ_POINTERS(weak_property, kAsReference); |
3186 // allocations may happen. | |
3187 intptr_t num_flds = (weak_property.raw()->to() - | |
3188 weak_property.raw()->from()); | |
3189 for (intptr_t i = 0; i <= num_flds; i++) { | |
3190 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | |
3191 weak_property.StorePointer((weak_property.raw()->from() + i), | |
3192 reader->PassiveObjectHandle()->raw()); | |
3193 } | |
3194 | 3082 |
3195 return weak_property.raw(); | 3083 return weak_property.raw(); |
3196 } | 3084 } |
3197 | 3085 |
3198 | 3086 |
3199 void RawWeakProperty::WriteTo(SnapshotWriter* writer, | 3087 void RawWeakProperty::WriteTo(SnapshotWriter* writer, |
3200 intptr_t object_id, | 3088 intptr_t object_id, |
3201 Snapshot::Kind kind) { | 3089 Snapshot::Kind kind) { |
3202 ASSERT(writer != NULL); | 3090 ASSERT(writer != NULL); |
3203 | 3091 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3253 // We do not allow objects with native fields in an isolate message. | 3141 // We do not allow objects with native fields in an isolate message. |
3254 writer->SetWriteException(Exceptions::kArgument, | 3142 writer->SetWriteException(Exceptions::kArgument, |
3255 "Illegal argument in isolate message" | 3143 "Illegal argument in isolate message" |
3256 " : (object is a UserTag)"); | 3144 " : (object is a UserTag)"); |
3257 } else { | 3145 } else { |
3258 UNREACHABLE(); | 3146 UNREACHABLE(); |
3259 } | 3147 } |
3260 } | 3148 } |
3261 | 3149 |
3262 } // namespace dart | 3150 } // namespace dart |
OLD | NEW |