Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: runtime/vm/raw_object_snapshot.cc

Issue 1918313003: Split Snapshot::kFull into kCore, kAppWithJIT, and kAppNoJIT. Remove snapshot_code flag. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: sync Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/native_entry.h" 5 #include "vm/native_entry.h"
6 #include "vm/object.h" 6 #include "vm/object.h"
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 #include "vm/snapshot.h" 8 #include "vm/snapshot.h"
9 #include "vm/stub_code.h" 9 #include "vm/stub_code.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
11 #include "vm/visitor.h" 11 #include "vm/visitor.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 #define NEW_OBJECT(type) \ 15 #define NEW_OBJECT(type) \
16 ((kind == Snapshot::kFull) ? reader->New##type() : type::New()) 16 ((Snapshot::IsFull(kind)) ? reader->New##type() : type::New())
17 17
18 #define NEW_OBJECT_WITH_LEN(type, len) \ 18 #define NEW_OBJECT_WITH_LEN(type, len) \
19 ((kind == Snapshot::kFull) ? reader->New##type(len) : type::New(len)) 19 ((Snapshot::IsFull(kind)) ? reader->New##type(len) : type::New(len))
20 20
21 #define NEW_OBJECT_WITH_LEN_SPACE(type, len, kind) \ 21 #define NEW_OBJECT_WITH_LEN_SPACE(type, len, kind) \
22 ((kind == Snapshot::kFull) ? \ 22 ((Snapshot::IsFull(kind)) ? \
23 reader->New##type(len) : type::New(len, HEAP_SPACE(kind))) 23 reader->New##type(len) : type::New(len, HEAP_SPACE(kind)))
24 24
25 #define OFFSET_OF_FROM(obj) \ 25 #define OFFSET_OF_FROM(obj) \
26 obj.raw()->from() - reinterpret_cast<RawObject**>(obj.raw()->ptr()) 26 obj.raw()->from() - reinterpret_cast<RawObject**>(obj.raw()->ptr())
27 27
28 // TODO(18854): Need to assert No GC can happen here, even though 28 // TODO(18854): Need to assert No GC can happen here, even though
29 // allocations may happen. 29 // allocations may happen.
30 #define READ_OBJECT_FIELDS(object, from, to, as_reference) \ 30 #define READ_OBJECT_FIELDS(object, from, to, as_reference) \
31 intptr_t num_flds = (to) - (from); \ 31 intptr_t num_flds = (to) - (from); \
32 intptr_t from_offset = OFFSET_OF_FROM(object); \ 32 intptr_t from_offset = OFFSET_OF_FROM(object); \
33 for (intptr_t i = 0; i <= num_flds; i++) { \ 33 for (intptr_t i = 0; i <= num_flds; i++) { \
34 (*reader->PassiveObjectHandle()) = \ 34 (*reader->PassiveObjectHandle()) = \
35 reader->ReadObjectImpl(as_reference, object_id, (i + from_offset)); \ 35 reader->ReadObjectImpl(as_reference, object_id, (i + from_offset)); \
36 object.StorePointer(((from) + i), \ 36 object.StorePointer(((from) + i), \
37 reader->PassiveObjectHandle()->raw()); \ 37 reader->PassiveObjectHandle()->raw()); \
38 } 38 }
39 39
40 RawClass* Class::ReadFrom(SnapshotReader* reader, 40 RawClass* Class::ReadFrom(SnapshotReader* reader,
41 intptr_t object_id, 41 intptr_t object_id,
42 intptr_t tags, 42 intptr_t tags,
43 Snapshot::Kind kind, 43 Snapshot::Kind kind,
44 bool as_reference) { 44 bool as_reference) {
45 ASSERT(reader != NULL); 45 ASSERT(reader != NULL);
46 46
47 Class& cls = Class::ZoneHandle(reader->zone(), Class::null()); 47 Class& cls = Class::ZoneHandle(reader->zone(), Class::null());
48 bool is_in_fullsnapshot = reader->Read<bool>(); 48 bool is_in_fullsnapshot = reader->Read<bool>();
49 if ((kind == Snapshot::kFull) || 49 if (Snapshot::IsFull(kind) ||
50 (kind == Snapshot::kScript && !is_in_fullsnapshot)) { 50 (kind == Snapshot::kScript && !is_in_fullsnapshot)) {
51 // Read in the base information. 51 // Read in the base information.
52 classid_t class_id = reader->ReadClassIDValue(); 52 classid_t class_id = reader->ReadClassIDValue();
53 53
54 // Allocate class object of specified kind. 54 // Allocate class object of specified kind.
55 if (kind == Snapshot::kFull) { 55 if (Snapshot::IsFull(kind)) {
56 cls = reader->NewClass(class_id); 56 cls = reader->NewClass(class_id);
57 } else { 57 } else {
58 if (class_id < kNumPredefinedCids) { 58 if (class_id < kNumPredefinedCids) {
59 ASSERT((class_id >= kInstanceCid) && (class_id <= kMirrorReferenceCid)); 59 ASSERT((class_id >= kInstanceCid) && (class_id <= kMirrorReferenceCid));
60 cls = reader->isolate()->class_table()->At(class_id); 60 cls = reader->isolate()->class_table()->At(class_id);
61 } else { 61 } else {
62 cls = New<Instance>(kIllegalCid); 62 cls = New<Instance>(kIllegalCid);
63 } 63 }
64 } 64 }
65 reader->AddBackRef(object_id, &cls, kIsDeserialized); 65 reader->AddBackRef(object_id, &cls, kIsDeserialized);
66 66
67 // Set all non object fields. 67 // Set all non object fields.
68 if (!RawObject::IsInternalVMdefinedClassId(class_id)) { 68 if (!RawObject::IsInternalVMdefinedClassId(class_id)) {
69 // Instance size of a VM defined class is already set up. 69 // Instance size of a VM defined class is already set up.
70 cls.set_instance_size_in_words(reader->Read<int32_t>()); 70 cls.set_instance_size_in_words(reader->Read<int32_t>());
71 cls.set_next_field_offset_in_words(reader->Read<int32_t>()); 71 cls.set_next_field_offset_in_words(reader->Read<int32_t>());
72 } 72 }
73 cls.set_type_arguments_field_offset_in_words(reader->Read<int32_t>()); 73 cls.set_type_arguments_field_offset_in_words(reader->Read<int32_t>());
74 cls.set_num_type_arguments(reader->Read<int16_t>()); 74 cls.set_num_type_arguments(reader->Read<int16_t>());
75 cls.set_num_own_type_arguments(reader->Read<int16_t>()); 75 cls.set_num_own_type_arguments(reader->Read<int16_t>());
76 cls.set_num_native_fields(reader->Read<uint16_t>()); 76 cls.set_num_native_fields(reader->Read<uint16_t>());
77 cls.set_token_pos(TokenPosition::SnapshotDecode(reader->Read<int32_t>())); 77 cls.set_token_pos(TokenPosition::SnapshotDecode(reader->Read<int32_t>()));
78 cls.set_state_bits(reader->Read<uint16_t>()); 78 cls.set_state_bits(reader->Read<uint16_t>());
79 79
80 // Set all the object fields. 80 // Set all the object fields.
81 READ_OBJECT_FIELDS(cls, cls.raw()->from(), cls.raw()->to(), kAsReference); 81 READ_OBJECT_FIELDS(cls, cls.raw()->from(), cls.raw()->to(), kAsReference);
82 ASSERT(!cls.IsInFullSnapshot() || (kind == Snapshot::kFull)); 82 ASSERT(!cls.IsInFullSnapshot() || (Snapshot::IsFull(kind)));
83 } else { 83 } else {
84 cls ^= reader->ReadClassId(object_id); 84 cls ^= reader->ReadClassId(object_id);
85 ASSERT((kind == Snapshot::kMessage) || cls.IsInFullSnapshot()); 85 ASSERT((kind == Snapshot::kMessage) || cls.IsInFullSnapshot());
86 } 86 }
87 return cls.raw(); 87 return cls.raw();
88 } 88 }
89 89
90 90
91 void RawClass::WriteTo(SnapshotWriter* writer, 91 void RawClass::WriteTo(SnapshotWriter* writer,
92 intptr_t object_id, 92 intptr_t object_id,
93 Snapshot::Kind kind, 93 Snapshot::Kind kind,
94 bool as_reference) { 94 bool as_reference) {
95 ASSERT(writer != NULL); 95 ASSERT(writer != NULL);
96 bool is_in_fullsnapshot = Class::IsInFullSnapshot(this); 96 bool is_in_fullsnapshot = Class::IsInFullSnapshot(this);
97 97
98 // Write out the serialization header value for this object. 98 // Write out the serialization header value for this object.
99 writer->WriteInlinedObjectHeader(object_id); 99 writer->WriteInlinedObjectHeader(object_id);
100 100
101 // Write out the class and tags information. 101 // Write out the class and tags information.
102 writer->WriteVMIsolateObject(kClassCid); 102 writer->WriteVMIsolateObject(kClassCid);
103 writer->WriteTags(writer->GetObjectTags(this)); 103 writer->WriteTags(writer->GetObjectTags(this));
104 104
105 // Write out the boolean is_in_fullsnapshot first as this will 105 // Write out the boolean is_in_fullsnapshot first as this will
106 // help the reader decide how the rest of the information needs 106 // help the reader decide how the rest of the information needs
107 // to be interpreted. 107 // to be interpreted.
108 writer->Write<bool>(is_in_fullsnapshot); 108 writer->Write<bool>(is_in_fullsnapshot);
109 109
110 if ((kind == Snapshot::kFull) || 110 if (Snapshot::IsFull(kind) ||
111 (kind == Snapshot::kScript && !is_in_fullsnapshot)) { 111 (kind == Snapshot::kScript && !is_in_fullsnapshot)) {
112 // Write out all the non object pointer fields. 112 // Write out all the non object pointer fields.
113 // NOTE: cpp_vtable_ is not written. 113 // NOTE: cpp_vtable_ is not written.
114 classid_t class_id = ptr()->id_; 114 classid_t class_id = ptr()->id_;
115 ASSERT(class_id != kIllegalCid); 115 ASSERT(class_id != kIllegalCid);
116 writer->Write<classid_t>(class_id); 116 writer->Write<classid_t>(class_id);
117 if (!RawObject::IsInternalVMdefinedClassId(class_id)) { 117 if (!RawObject::IsInternalVMdefinedClassId(class_id)) {
118 // We don't write the instance size of VM defined classes as they 118 // We don't write the instance size of VM defined classes as they
119 // are already setup during initialization as part of pre populating 119 // are already setup during initialization as part of pre populating
120 // the class table. 120 // the class table.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 bool as_reference) { 218 bool as_reference) {
219 ASSERT(reader != NULL); 219 ASSERT(reader != NULL);
220 220
221 // Determine if the type class of this type is in the full snapshot. 221 // Determine if the type class of this type is in the full snapshot.
222 bool typeclass_is_in_fullsnapshot = reader->Read<bool>(); 222 bool typeclass_is_in_fullsnapshot = reader->Read<bool>();
223 223
224 // Allocate type object. 224 // Allocate type object.
225 Type& type = Type::ZoneHandle(reader->zone(), NEW_OBJECT(Type)); 225 Type& type = Type::ZoneHandle(reader->zone(), NEW_OBJECT(Type));
226 bool is_canonical = RawObject::IsCanonical(tags); 226 bool is_canonical = RawObject::IsCanonical(tags);
227 bool defer_canonicalization = is_canonical && 227 bool defer_canonicalization = is_canonical &&
228 (kind != Snapshot::kFull && typeclass_is_in_fullsnapshot); 228 (!Snapshot::IsFull(kind) && typeclass_is_in_fullsnapshot);
229 reader->AddBackRef(object_id, &type, kIsDeserialized, defer_canonicalization); 229 reader->AddBackRef(object_id, &type, kIsDeserialized, defer_canonicalization);
230 230
231 // Set all non object fields. 231 // Set all non object fields.
232 type.set_token_pos(TokenPosition::SnapshotDecode(reader->Read<int32_t>())); 232 type.set_token_pos(TokenPosition::SnapshotDecode(reader->Read<int32_t>()));
233 type.set_type_state(reader->Read<int8_t>()); 233 type.set_type_state(reader->Read<int8_t>());
234 234
235 // Set all the object fields. 235 // Set all the object fields.
236 READ_OBJECT_FIELDS(type, type.raw()->from(), type.raw()->to(), kAsReference); 236 READ_OBJECT_FIELDS(type, type.raw()->from(), type.raw()->to(), kAsReference);
237 237
238 // Set the canonical bit. 238 // Set the canonical bit.
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 Snapshot::Kind kind, 439 Snapshot::Kind kind,
440 bool as_reference) { 440 bool as_reference) {
441 ASSERT(reader != NULL); 441 ASSERT(reader != NULL);
442 442
443 // Read the length so that we can determine instance size to allocate. 443 // Read the length so that we can determine instance size to allocate.
444 intptr_t len = reader->ReadSmiValue(); 444 intptr_t len = reader->ReadSmiValue();
445 445
446 TypeArguments& type_arguments = TypeArguments::ZoneHandle( 446 TypeArguments& type_arguments = TypeArguments::ZoneHandle(
447 reader->zone(), NEW_OBJECT_WITH_LEN_SPACE(TypeArguments, len, kind)); 447 reader->zone(), NEW_OBJECT_WITH_LEN_SPACE(TypeArguments, len, kind));
448 bool is_canonical = RawObject::IsCanonical(tags); 448 bool is_canonical = RawObject::IsCanonical(tags);
449 bool defer_canonicalization = is_canonical && (kind != Snapshot::kFull); 449 bool defer_canonicalization = is_canonical && (!Snapshot::IsFull(kind));
450 reader->AddBackRef(object_id, 450 reader->AddBackRef(object_id,
451 &type_arguments, 451 &type_arguments,
452 kIsDeserialized, 452 kIsDeserialized,
453 defer_canonicalization); 453 defer_canonicalization);
454 454
455 // Set the instantiations field, which is only read from a full snapshot. 455 // Set the instantiations field, which is only read from a full snapshot.
456 if (kind == Snapshot::kFull) { 456 if (Snapshot::IsFull(kind)) {
457 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); 457 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject);
458 type_arguments.set_instantiations(*(reader->ArrayHandle())); 458 type_arguments.set_instantiations(*(reader->ArrayHandle()));
459 } else { 459 } else {
460 type_arguments.set_instantiations(Object::zero_array()); 460 type_arguments.set_instantiations(Object::zero_array());
461 } 461 }
462 462
463 // Now set all the type fields. 463 // Now set all the type fields.
464 intptr_t offset = type_arguments.TypeAddr(0) - 464 intptr_t offset = type_arguments.TypeAddr(0) -
465 reinterpret_cast<RawAbstractType**>(type_arguments.raw()->ptr()); 465 reinterpret_cast<RawAbstractType**>(type_arguments.raw()->ptr());
466 for (intptr_t i = 0; i < len; i++) { 466 for (intptr_t i = 0; i < len; i++) {
(...skipping 21 matching lines...) Expand all
488 writer->WriteInlinedObjectHeader(object_id); 488 writer->WriteInlinedObjectHeader(object_id);
489 489
490 // Write out the class and tags information. 490 // Write out the class and tags information.
491 writer->WriteVMIsolateObject(kTypeArgumentsCid); 491 writer->WriteVMIsolateObject(kTypeArgumentsCid);
492 writer->WriteTags(writer->GetObjectTags(this)); 492 writer->WriteTags(writer->GetObjectTags(this));
493 493
494 // Write out the length field. 494 // Write out the length field.
495 writer->Write<RawObject*>(ptr()->length_); 495 writer->Write<RawObject*>(ptr()->length_);
496 496
497 // Write out the instantiations field, but only in a full snapshot. 497 // Write out the instantiations field, but only in a full snapshot.
498 if (kind == Snapshot::kFull) { 498 if (Snapshot::IsFull(kind)) {
499 writer->WriteObjectImpl(ptr()->instantiations_, kAsInlinedObject); 499 writer->WriteObjectImpl(ptr()->instantiations_, kAsInlinedObject);
500 } 500 }
501 501
502 // Write out the individual types. 502 // Write out the individual types.
503 intptr_t len = Smi::Value(ptr()->length_); 503 intptr_t len = Smi::Value(ptr()->length_);
504 for (intptr_t i = 0; i < len; i++) { 504 for (intptr_t i = 0; i < len; i++) {
505 writer->WriteObjectImpl(ptr()->types()[i], kAsReference); 505 writer->WriteObjectImpl(ptr()->types()[i], kAsReference);
506 } 506 }
507 } 507 }
508 508
509 509
510 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader, 510 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader,
511 intptr_t object_id, 511 intptr_t object_id,
512 intptr_t tags, 512 intptr_t tags,
513 Snapshot::Kind kind, 513 Snapshot::Kind kind,
514 bool as_reference) { 514 bool as_reference) {
515 ASSERT(reader != NULL); 515 ASSERT(reader != NULL);
516 516
517 // Allocate function object. 517 // Allocate function object.
518 PatchClass& cls = PatchClass::ZoneHandle(reader->zone(), 518 PatchClass& cls = PatchClass::ZoneHandle(reader->zone(),
519 NEW_OBJECT(PatchClass)); 519 NEW_OBJECT(PatchClass));
520 reader->AddBackRef(object_id, &cls, kIsDeserialized); 520 reader->AddBackRef(object_id, &cls, kIsDeserialized);
521 521
522 // Set all the object fields. 522 // Set all the object fields.
523 READ_OBJECT_FIELDS(cls, cls.raw()->from(), cls.raw()->to(), kAsReference); 523 READ_OBJECT_FIELDS(cls, cls.raw()->from(), cls.raw()->to(), kAsReference);
524 524
525 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 525 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
526 return cls.raw(); 526 return cls.raw();
527 } 527 }
528 528
529 529
530 void RawPatchClass::WriteTo(SnapshotWriter* writer, 530 void RawPatchClass::WriteTo(SnapshotWriter* writer,
531 intptr_t object_id, 531 intptr_t object_id,
532 Snapshot::Kind kind, 532 Snapshot::Kind kind,
533 bool as_reference) { 533 bool as_reference) {
534 ASSERT(writer != NULL); 534 ASSERT(writer != NULL);
535 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 535 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
536 536
537 // Write out the serialization header value for this object. 537 // Write out the serialization header value for this object.
538 writer->WriteInlinedObjectHeader(object_id); 538 writer->WriteInlinedObjectHeader(object_id);
539 539
540 // Write out the class and tags information. 540 // Write out the class and tags information.
541 writer->WriteVMIsolateObject(kPatchClassCid); 541 writer->WriteVMIsolateObject(kPatchClassCid);
542 writer->WriteTags(writer->GetObjectTags(this)); 542 writer->WriteTags(writer->GetObjectTags(this));
543 // Write out all the object pointer fields. 543 // Write out all the object pointer fields.
544 SnapshotWriterVisitor visitor(writer, kAsReference); 544 SnapshotWriterVisitor visitor(writer, kAsReference);
545 visitor.VisitPointers(from(), to()); 545 visitor.VisitPointers(from(), to());
546 } 546 }
547 547
548 548
549 RawClosure* Closure::ReadFrom(SnapshotReader* reader, 549 RawClosure* Closure::ReadFrom(SnapshotReader* reader,
550 intptr_t object_id, 550 intptr_t object_id,
551 intptr_t tags, 551 intptr_t tags,
552 Snapshot::Kind kind, 552 Snapshot::Kind kind,
553 bool as_reference) { 553 bool as_reference) {
554 ASSERT(reader != NULL); 554 ASSERT(reader != NULL);
555 ASSERT(kind == Snapshot::kFull); 555 ASSERT(Snapshot::IsFull(kind));
556 556
557 // Allocate closure object. 557 // Allocate closure object.
558 Closure& closure = Closure::ZoneHandle( 558 Closure& closure = Closure::ZoneHandle(
559 reader->zone(), NEW_OBJECT(Closure)); 559 reader->zone(), NEW_OBJECT(Closure));
560 reader->AddBackRef(object_id, &closure, kIsDeserialized); 560 reader->AddBackRef(object_id, &closure, kIsDeserialized);
561 561
562 // Set all the object fields. 562 // Set all the object fields.
563 READ_OBJECT_FIELDS(closure, 563 READ_OBJECT_FIELDS(closure,
564 closure.raw()->from(), closure.raw()->to(), 564 closure.raw()->from(), closure.raw()->to(),
565 kAsReference); 565 kAsReference);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 visitor.VisitPointers(from(), to()); 600 visitor.VisitPointers(from(), to());
601 } 601 }
602 602
603 603
604 RawClosureData* ClosureData::ReadFrom(SnapshotReader* reader, 604 RawClosureData* ClosureData::ReadFrom(SnapshotReader* reader,
605 intptr_t object_id, 605 intptr_t object_id,
606 intptr_t tags, 606 intptr_t tags,
607 Snapshot::Kind kind, 607 Snapshot::Kind kind,
608 bool as_reference) { 608 bool as_reference) {
609 ASSERT(reader != NULL); 609 ASSERT(reader != NULL);
610 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 610 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
611 611
612 // Allocate closure data object. 612 // Allocate closure data object.
613 ClosureData& data = ClosureData::ZoneHandle( 613 ClosureData& data = ClosureData::ZoneHandle(
614 reader->zone(), NEW_OBJECT(ClosureData)); 614 reader->zone(), NEW_OBJECT(ClosureData));
615 reader->AddBackRef(object_id, &data, kIsDeserialized); 615 reader->AddBackRef(object_id, &data, kIsDeserialized);
616 616
617 // Set all the object fields. 617 // Set all the object fields.
618 READ_OBJECT_FIELDS(data, 618 READ_OBJECT_FIELDS(data,
619 data.raw()->from(), data.raw()->to(), 619 data.raw()->from(), data.raw()->to(),
620 kAsInlinedObject); 620 kAsInlinedObject);
621 621
622 return data.raw(); 622 return data.raw();
623 } 623 }
624 624
625 625
626 void RawClosureData::WriteTo(SnapshotWriter* writer, 626 void RawClosureData::WriteTo(SnapshotWriter* writer,
627 intptr_t object_id, 627 intptr_t object_id,
628 Snapshot::Kind kind, 628 Snapshot::Kind kind,
629 bool as_reference) { 629 bool as_reference) {
630 ASSERT(writer != NULL); 630 ASSERT(writer != NULL);
631 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 631 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
632 632
633 // Write out the serialization header value for this object. 633 // Write out the serialization header value for this object.
634 writer->WriteInlinedObjectHeader(object_id); 634 writer->WriteInlinedObjectHeader(object_id);
635 635
636 // Write out the class and tags information. 636 // Write out the class and tags information.
637 writer->WriteVMIsolateObject(kClosureDataCid); 637 writer->WriteVMIsolateObject(kClosureDataCid);
638 writer->WriteTags(writer->GetObjectTags(this)); 638 writer->WriteTags(writer->GetObjectTags(this));
639 639
640 // Context scope. 640 // Context scope.
641 if (ptr()->context_scope_ == Object::empty_context_scope().raw()) { 641 if (ptr()->context_scope_ == Object::empty_context_scope().raw()) {
(...skipping 17 matching lines...) Expand all
659 writer->WriteObjectImpl(ptr()->closure_, kAsInlinedObject); 659 writer->WriteObjectImpl(ptr()->closure_, kAsInlinedObject);
660 } 660 }
661 661
662 662
663 RawRedirectionData* RedirectionData::ReadFrom(SnapshotReader* reader, 663 RawRedirectionData* RedirectionData::ReadFrom(SnapshotReader* reader,
664 intptr_t object_id, 664 intptr_t object_id,
665 intptr_t tags, 665 intptr_t tags,
666 Snapshot::Kind kind, 666 Snapshot::Kind kind,
667 bool as_reference) { 667 bool as_reference) {
668 ASSERT(reader != NULL); 668 ASSERT(reader != NULL);
669 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 669 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
670 670
671 // Allocate redirection data object. 671 // Allocate redirection data object.
672 RedirectionData& data = RedirectionData::ZoneHandle( 672 RedirectionData& data = RedirectionData::ZoneHandle(
673 reader->zone(), NEW_OBJECT(RedirectionData)); 673 reader->zone(), NEW_OBJECT(RedirectionData));
674 reader->AddBackRef(object_id, &data, kIsDeserialized); 674 reader->AddBackRef(object_id, &data, kIsDeserialized);
675 675
676 // Set all the object fields. 676 // Set all the object fields.
677 READ_OBJECT_FIELDS(data, 677 READ_OBJECT_FIELDS(data,
678 data.raw()->from(), data.raw()->to(), 678 data.raw()->from(), data.raw()->to(),
679 kAsReference); 679 kAsReference);
680 680
681 return data.raw(); 681 return data.raw();
682 } 682 }
683 683
684 684
685 void RawRedirectionData::WriteTo(SnapshotWriter* writer, 685 void RawRedirectionData::WriteTo(SnapshotWriter* writer,
686 intptr_t object_id, 686 intptr_t object_id,
687 Snapshot::Kind kind, 687 Snapshot::Kind kind,
688 bool as_reference) { 688 bool as_reference) {
689 ASSERT(writer != NULL); 689 ASSERT(writer != NULL);
690 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 690 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
691 691
692 // Write out the serialization header value for this object. 692 // Write out the serialization header value for this object.
693 writer->WriteInlinedObjectHeader(object_id); 693 writer->WriteInlinedObjectHeader(object_id);
694 694
695 // Write out the class and tags information. 695 // Write out the class and tags information.
696 writer->WriteVMIsolateObject(kRedirectionDataCid); 696 writer->WriteVMIsolateObject(kRedirectionDataCid);
697 writer->WriteTags(writer->GetObjectTags(this)); 697 writer->WriteTags(writer->GetObjectTags(this));
698 698
699 // Write out all the object pointer fields. 699 // Write out all the object pointer fields.
700 SnapshotWriterVisitor visitor(writer, kAsReference); 700 SnapshotWriterVisitor visitor(writer, kAsReference);
701 visitor.VisitPointers(from(), to()); 701 visitor.VisitPointers(from(), to());
702 } 702 }
703 703
704 704
705 RawFunction* Function::ReadFrom(SnapshotReader* reader, 705 RawFunction* Function::ReadFrom(SnapshotReader* reader,
706 intptr_t object_id, 706 intptr_t object_id,
707 intptr_t tags, 707 intptr_t tags,
708 Snapshot::Kind kind, 708 Snapshot::Kind kind,
709 bool as_reference) { 709 bool as_reference) {
710 ASSERT(reader != NULL); 710 ASSERT(reader != NULL);
711 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 711 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
712 712
713 bool is_in_fullsnapshot = reader->Read<bool>(); 713 bool is_in_fullsnapshot = reader->Read<bool>();
714 if ((kind == Snapshot::kFull) || !is_in_fullsnapshot) { 714 if ((Snapshot::IsFull(kind)) || !is_in_fullsnapshot) {
715 // Allocate function object. 715 // Allocate function object.
716 Function& func = Function::ZoneHandle( 716 Function& func = Function::ZoneHandle(
717 reader->zone(), NEW_OBJECT(Function)); 717 reader->zone(), NEW_OBJECT(Function));
718 reader->AddBackRef(object_id, &func, kIsDeserialized); 718 reader->AddBackRef(object_id, &func, kIsDeserialized);
719 719
720 // Set all the non object fields. Read the token positions now but 720 // Set all the non object fields. Read the token positions now but
721 // don't set them until after setting the kind. 721 // don't set them until after setting the kind.
722 const int32_t token_pos = reader->Read<int32_t>(); 722 const int32_t token_pos = reader->Read<int32_t>();
723 const int32_t end_token_pos = reader->Read<uint32_t>(); 723 const int32_t end_token_pos = reader->Read<uint32_t>();
724 func.set_num_fixed_parameters(reader->Read<int16_t>()); 724 func.set_num_fixed_parameters(reader->Read<int16_t>());
725 func.set_num_optional_parameters(reader->Read<int16_t>()); 725 func.set_num_optional_parameters(reader->Read<int16_t>());
726 func.set_kind_tag(reader->Read<uint32_t>()); 726 func.set_kind_tag(reader->Read<uint32_t>());
727 func.set_token_pos(TokenPosition::SnapshotDecode(token_pos)); 727 func.set_token_pos(TokenPosition::SnapshotDecode(token_pos));
728 func.set_end_token_pos(TokenPosition::SnapshotDecode(end_token_pos)); 728 func.set_end_token_pos(TokenPosition::SnapshotDecode(end_token_pos));
729 if (reader->snapshot_code()) { 729 if (Snapshot::IncludesCode(kind)) {
730 func.set_usage_counter(0); 730 func.set_usage_counter(0);
731 func.set_deoptimization_counter(0); 731 func.set_deoptimization_counter(0);
732 func.set_optimized_instruction_count(0); 732 func.set_optimized_instruction_count(0);
733 func.set_optimized_call_site_count(0); 733 func.set_optimized_call_site_count(0);
734 } else { 734 } else {
735 func.set_usage_counter(reader->Read<int32_t>()); 735 func.set_usage_counter(reader->Read<int32_t>());
736 func.set_deoptimization_counter(reader->Read<int8_t>()); 736 func.set_deoptimization_counter(reader->Read<int8_t>());
737 func.set_optimized_instruction_count(reader->Read<uint16_t>()); 737 func.set_optimized_instruction_count(reader->Read<uint16_t>());
738 func.set_optimized_call_site_count(reader->Read<uint16_t>()); 738 func.set_optimized_call_site_count(reader->Read<uint16_t>());
739 } 739 }
740 func.set_was_compiled(false); 740 func.set_was_compiled(false);
741 741
742 // Set all the object fields. 742 // Set all the object fields.
743 READ_OBJECT_FIELDS(func, 743 READ_OBJECT_FIELDS(func,
744 func.raw()->from(), func.raw()->to_snapshot(), 744 func.raw()->from(), func.raw()->to_snapshot(),
745 kAsReference); 745 kAsReference);
746 // Initialize all fields that are not part of the snapshot. 746 // Initialize all fields that are not part of the snapshot.
747 if (reader->snapshot_code()) { 747 if (Snapshot::IncludesCode(kind)) {
748 func.ClearICDataArray(); 748 func.ClearICDataArray();
749 func.ClearCode(); 749 func.ClearCode();
750 // Read the code object and fixup entry point. 750 // Read the code object and fixup entry point.
751 (*reader->CodeHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); 751 (*reader->CodeHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject);
752 func.SetInstructions(*reader->CodeHandle()); 752 func.SetInstructions(*reader->CodeHandle());
753 } else { 753 } else {
754 bool is_optimized = func.usage_counter() != 0; 754 bool is_optimized = func.usage_counter() != 0;
755 if (is_optimized) { 755 if (is_optimized) {
756 // Read the ic data array as the function is an optimized one. 756 // Read the ic data array as the function is an optimized one.
757 (*reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsReference); 757 (*reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsReference);
758 func.set_ic_data_array(*reader->ArrayHandle()); 758 func.set_ic_data_array(*reader->ArrayHandle());
759 } else { 759 } else {
760 func.ClearICDataArray(); 760 func.ClearICDataArray();
761 } 761 }
762 func.ClearCode(); 762 func.ClearCode();
763 } 763 }
764 return func.raw(); 764 return func.raw();
765 } else { 765 } else {
766 return reader->ReadFunctionId(object_id); 766 return reader->ReadFunctionId(object_id);
767 } 767 }
768 } 768 }
769 769
770 770
771 void RawFunction::WriteTo(SnapshotWriter* writer, 771 void RawFunction::WriteTo(SnapshotWriter* writer,
772 intptr_t object_id, 772 intptr_t object_id,
773 Snapshot::Kind kind, 773 Snapshot::Kind kind,
774 bool as_reference) { 774 bool as_reference) {
775 ASSERT(writer != NULL); 775 ASSERT(writer != NULL);
776 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 776 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
777 bool is_in_fullsnapshot = false; 777 bool is_in_fullsnapshot = false;
778 bool owner_is_class = false; 778 bool owner_is_class = false;
779 if ((kind == Snapshot::kScript) && !Function::IsSignatureFunction(this)) { 779 if ((kind == Snapshot::kScript) && !Function::IsSignatureFunction(this)) {
780 intptr_t tags = writer->GetObjectTags(ptr()->owner_); 780 intptr_t tags = writer->GetObjectTags(ptr()->owner_);
781 intptr_t cid = ClassIdTag::decode(tags); 781 intptr_t cid = ClassIdTag::decode(tags);
782 owner_is_class = (cid == kClassCid); 782 owner_is_class = (cid == kClassCid);
783 is_in_fullsnapshot = owner_is_class ? 783 is_in_fullsnapshot = owner_is_class ?
784 Class::IsInFullSnapshot(reinterpret_cast<RawClass*>(ptr()->owner_)) : 784 Class::IsInFullSnapshot(reinterpret_cast<RawClass*>(ptr()->owner_)) :
785 PatchClass::IsInFullSnapshot( 785 PatchClass::IsInFullSnapshot(
786 reinterpret_cast<RawPatchClass*>(ptr()->owner_)); 786 reinterpret_cast<RawPatchClass*>(ptr()->owner_));
787 } 787 }
788 788
789 // Write out the serialization header value for this object. 789 // Write out the serialization header value for this object.
790 writer->WriteInlinedObjectHeader(object_id); 790 writer->WriteInlinedObjectHeader(object_id);
791 791
792 // Write out the class and tags information. 792 // Write out the class and tags information.
793 writer->WriteVMIsolateObject(kFunctionCid); 793 writer->WriteVMIsolateObject(kFunctionCid);
794 writer->WriteTags(writer->GetObjectTags(this)); 794 writer->WriteTags(writer->GetObjectTags(this));
795 795
796 // Write out the boolean is_in_fullsnapshot first as this will 796 // Write out the boolean is_in_fullsnapshot first as this will
797 // help the reader decide how the rest of the information needs 797 // help the reader decide how the rest of the information needs
798 // to be interpreted. 798 // to be interpreted.
799 writer->Write<bool>(is_in_fullsnapshot); 799 writer->Write<bool>(is_in_fullsnapshot);
800 800
801 if (kind == Snapshot::kFull || !is_in_fullsnapshot) { 801 if (Snapshot::IsFull(kind) || !is_in_fullsnapshot) {
802 bool is_optimized = Code::IsOptimized(ptr()->code_); 802 bool is_optimized = Code::IsOptimized(ptr()->code_);
803 803
804 // Write out all the non object fields. 804 // Write out all the non object fields.
805 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode()); 805 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode());
806 writer->Write<int32_t>(ptr()->end_token_pos_.SnapshotEncode()); 806 writer->Write<int32_t>(ptr()->end_token_pos_.SnapshotEncode());
807 writer->Write<int16_t>(ptr()->num_fixed_parameters_); 807 writer->Write<int16_t>(ptr()->num_fixed_parameters_);
808 writer->Write<int16_t>(ptr()->num_optional_parameters_); 808 writer->Write<int16_t>(ptr()->num_optional_parameters_);
809 writer->Write<uint32_t>(ptr()->kind_tag_); 809 writer->Write<uint32_t>(ptr()->kind_tag_);
810 if (writer->snapshot_code()) { 810 if (Snapshot::IncludesCode(kind)) {
811 // Omit fields used to support de/reoptimization. 811 // Omit fields used to support de/reoptimization.
812 } else { 812 } else {
813 if (is_optimized) { 813 if (is_optimized) {
814 writer->Write<int32_t>(FLAG_optimization_counter_threshold); 814 writer->Write<int32_t>(FLAG_optimization_counter_threshold);
815 } else { 815 } else {
816 writer->Write<int32_t>(0); 816 writer->Write<int32_t>(0);
817 } 817 }
818 writer->Write<int8_t>(ptr()->deoptimization_counter_); 818 writer->Write<int8_t>(ptr()->deoptimization_counter_);
819 writer->Write<uint16_t>(ptr()->optimized_instruction_count_); 819 writer->Write<uint16_t>(ptr()->optimized_instruction_count_);
820 writer->Write<uint16_t>(ptr()->optimized_call_site_count_); 820 writer->Write<uint16_t>(ptr()->optimized_call_site_count_);
821 } 821 }
822 822
823 // Write out all the object pointer fields. 823 // Write out all the object pointer fields.
824 SnapshotWriterVisitor visitor(writer, kAsReference); 824 SnapshotWriterVisitor visitor(writer, kAsReference);
825 visitor.VisitPointers(from(), to_snapshot()); 825 visitor.VisitPointers(from(), to_snapshot());
826 if (writer->snapshot_code()) { 826 if (Snapshot::IncludesCode(kind)) {
827 ASSERT(ptr()->ic_data_array_ == Array::null()); 827 ASSERT(ptr()->ic_data_array_ == Array::null());
828 ASSERT((ptr()->code_ == ptr()->unoptimized_code_) || 828 ASSERT((ptr()->code_ == ptr()->unoptimized_code_) ||
829 (ptr()->unoptimized_code_ == Code::null())); 829 (ptr()->unoptimized_code_ == Code::null()));
830 // Write out the code object as we are generating a precompiled snapshot. 830 // Write out the code object as we are generating a precompiled snapshot.
831 writer->WriteObjectImpl(ptr()->code_, kAsInlinedObject); 831 writer->WriteObjectImpl(ptr()->code_, kAsInlinedObject);
832 } else if (is_optimized) { 832 } else if (is_optimized) {
833 // Write out the ic data array as the function is optimized or 833 // Write out the ic data array as the function is optimized or
834 // we are generating a precompiled snapshot. 834 // we are generating a precompiled snapshot.
835 writer->WriteObjectImpl(ptr()->ic_data_array_, kAsReference); 835 writer->WriteObjectImpl(ptr()->ic_data_array_, kAsReference);
836 } 836 }
837 } else { 837 } else {
838 writer->WriteFunctionId(this, owner_is_class); 838 writer->WriteFunctionId(this, owner_is_class);
839 } 839 }
840 } 840 }
841 841
842 842
843 RawField* Field::ReadFrom(SnapshotReader* reader, 843 RawField* Field::ReadFrom(SnapshotReader* reader,
844 intptr_t object_id, 844 intptr_t object_id,
845 intptr_t tags, 845 intptr_t tags,
846 Snapshot::Kind kind, 846 Snapshot::Kind kind,
847 bool as_reference) { 847 bool as_reference) {
848 ASSERT(reader != NULL); 848 ASSERT(reader != NULL);
849 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 849 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
850 850
851 // Allocate field object. 851 // Allocate field object.
852 Field& field = Field::ZoneHandle(reader->zone(), NEW_OBJECT(Field)); 852 Field& field = Field::ZoneHandle(reader->zone(), NEW_OBJECT(Field));
853 reader->AddBackRef(object_id, &field, kIsDeserialized); 853 reader->AddBackRef(object_id, &field, kIsDeserialized);
854 854
855 // Set all non object fields. 855 // Set all non object fields.
856 if (reader->snapshot_code()) { 856 if (Snapshot::IncludesCode(kind)) {
857 field.set_token_pos(TokenPosition::kNoSource); 857 field.set_token_pos(TokenPosition::kNoSource);
858 ASSERT(!FLAG_use_field_guards); 858 ASSERT(!FLAG_use_field_guards);
859 } else { 859 } else {
860 field.set_token_pos( 860 field.set_token_pos(
861 TokenPosition::SnapshotDecode(reader->Read<int32_t>())); 861 TokenPosition::SnapshotDecode(reader->Read<int32_t>()));
862 field.set_guarded_cid(reader->Read<int32_t>()); 862 field.set_guarded_cid(reader->Read<int32_t>());
863 field.set_is_nullable(reader->Read<int32_t>()); 863 field.set_is_nullable(reader->Read<int32_t>());
864 } 864 }
865 field.set_kind_bits(reader->Read<uint8_t>()); 865 field.set_kind_bits(reader->Read<uint8_t>());
866 866
867 // Set all the object fields. 867 // Set all the object fields.
868 RawObject** toobj = reader->snapshot_code()
869 ? field.raw()->to_precompiled_snapshot()
870 : field.raw()->to();
871 READ_OBJECT_FIELDS(field, 868 READ_OBJECT_FIELDS(field,
872 field.raw()->from(), toobj, 869 field.raw()->from(),
870 field.raw()->to_snapshot(kind),
873 kAsReference); 871 kAsReference);
874 872
875 if (!FLAG_use_field_guards) { 873 if (!FLAG_use_field_guards) {
876 field.set_guarded_cid(kDynamicCid); 874 field.set_guarded_cid(kDynamicCid);
877 field.set_is_nullable(true); 875 field.set_is_nullable(true);
878 field.set_guarded_list_length(Field::kNoFixedLength); 876 field.set_guarded_list_length(Field::kNoFixedLength);
879 field.set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset); 877 field.set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset);
880 } else { 878 } else {
881 field.InitializeGuardedListLengthInObjectOffset(); 879 field.InitializeGuardedListLengthInObjectOffset();
882 } 880 }
883 881
884 return field.raw(); 882 return field.raw();
885 } 883 }
886 884
887 885
888 void RawField::WriteTo(SnapshotWriter* writer, 886 void RawField::WriteTo(SnapshotWriter* writer,
889 intptr_t object_id, 887 intptr_t object_id,
890 Snapshot::Kind kind, 888 Snapshot::Kind kind,
891 bool as_reference) { 889 bool as_reference) {
892 ASSERT(writer != NULL); 890 ASSERT(writer != NULL);
893 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 891 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
894 892
895 // Write out the serialization header value for this object. 893 // Write out the serialization header value for this object.
896 writer->WriteInlinedObjectHeader(object_id); 894 writer->WriteInlinedObjectHeader(object_id);
897 895
898 // Write out the class and tags information. 896 // Write out the class and tags information.
899 writer->WriteVMIsolateObject(kFieldCid); 897 writer->WriteVMIsolateObject(kFieldCid);
900 writer->WriteTags(writer->GetObjectTags(this)); 898 writer->WriteTags(writer->GetObjectTags(this));
901 899
902 // Write out all the non object fields. 900 // Write out all the non object fields.
903 if (!writer->snapshot_code()) { 901 if (!Snapshot::IncludesCode(kind)) {
904 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode()); 902 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode());
905 writer->Write<int32_t>(ptr()->guarded_cid_); 903 writer->Write<int32_t>(ptr()->guarded_cid_);
906 writer->Write<int32_t>(ptr()->is_nullable_); 904 writer->Write<int32_t>(ptr()->is_nullable_);
907 } 905 }
908 writer->Write<uint8_t>(ptr()->kind_bits_); 906 writer->Write<uint8_t>(ptr()->kind_bits_);
909 907
910 // Write out the name. 908 // Write out the name.
911 writer->WriteObjectImpl(ptr()->name_, kAsReference); 909 writer->WriteObjectImpl(ptr()->name_, kAsReference);
912 // Write out the owner. 910 // Write out the owner.
913 writer->WriteObjectImpl(ptr()->owner_, kAsReference); 911 writer->WriteObjectImpl(ptr()->owner_, kAsReference);
914 // Write out the type. 912 // Write out the type.
915 writer->WriteObjectImpl(ptr()->type_, kAsReference); 913 writer->WriteObjectImpl(ptr()->type_, kAsReference);
916 // Write out the initial static value or field offset. 914 // Write out the initial static value or field offset.
917 if (Field::StaticBit::decode(ptr()->kind_bits_)) { 915 if (Field::StaticBit::decode(ptr()->kind_bits_)) {
918 if (writer->snapshot_code()) { 916 if (Snapshot::IncludesCode(kind)) {
919 // For precompiled static fields, the value was already reset and 917 // For precompiled static fields, the value was already reset and
920 // initializer_ now contains a Function. 918 // initializer_ now contains a Function.
921 writer->WriteObjectImpl(ptr()->value_.static_value_, kAsReference); 919 writer->WriteObjectImpl(ptr()->value_.static_value_, kAsReference);
922 } else { 920 } else {
923 // Otherwise, for static fields we write out the initial static value. 921 // Otherwise, for static fields we write out the initial static value.
924 writer->WriteObjectImpl(ptr()->initializer_.saved_value_, kAsReference); 922 writer->WriteObjectImpl(ptr()->initializer_.saved_value_, kAsReference);
925 } 923 }
926 } else { 924 } else {
927 writer->WriteObjectImpl(ptr()->value_.offset_, kAsReference); 925 writer->WriteObjectImpl(ptr()->value_.offset_, kAsReference);
928 } 926 }
929 // Write out the initializer function or saved initial value. 927 // Write out the initializer function or saved initial value.
930 if (writer->snapshot_code()) { 928 if (Snapshot::IncludesCode(kind)) {
931 writer->WriteObjectImpl(ptr()->initializer_.precompiled_, kAsReference); 929 writer->WriteObjectImpl(ptr()->initializer_.precompiled_, kAsReference);
932 } else { 930 } else {
933 writer->WriteObjectImpl(ptr()->initializer_.saved_value_, kAsReference); 931 writer->WriteObjectImpl(ptr()->initializer_.saved_value_, kAsReference);
934 } 932 }
935 if (!writer->snapshot_code()) { 933 if (!Snapshot::IncludesCode(kind)) {
936 // Write out the dependent code. 934 // Write out the dependent code.
937 writer->WriteObjectImpl(ptr()->dependent_code_, kAsReference); 935 writer->WriteObjectImpl(ptr()->dependent_code_, kAsReference);
938 // Write out the guarded list length. 936 // Write out the guarded list length.
939 writer->WriteObjectImpl(ptr()->guarded_list_length_, kAsReference); 937 writer->WriteObjectImpl(ptr()->guarded_list_length_, kAsReference);
940 } 938 }
941 } 939 }
942 940
943 941
944 RawLiteralToken* LiteralToken::ReadFrom(SnapshotReader* reader, 942 RawLiteralToken* LiteralToken::ReadFrom(SnapshotReader* reader,
945 intptr_t object_id, 943 intptr_t object_id,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 visitor.VisitPointers(from(), to()); 987 visitor.VisitPointers(from(), to());
990 } 988 }
991 989
992 990
993 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, 991 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader,
994 intptr_t object_id, 992 intptr_t object_id,
995 intptr_t tags, 993 intptr_t tags,
996 Snapshot::Kind kind, 994 Snapshot::Kind kind,
997 bool as_reference) { 995 bool as_reference) {
998 ASSERT(reader != NULL); 996 ASSERT(reader != NULL);
999 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 997 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
1000 998
1001 // Read the length so that we can determine number of tokens to read. 999 // Read the length so that we can determine number of tokens to read.
1002 intptr_t len = reader->ReadSmiValue(); 1000 intptr_t len = reader->ReadSmiValue();
1003 1001
1004 // Create the token stream object. 1002 // Create the token stream object.
1005 TokenStream& token_stream = TokenStream::ZoneHandle( 1003 TokenStream& token_stream = TokenStream::ZoneHandle(
1006 reader->zone(), NEW_OBJECT_WITH_LEN(TokenStream, len)); 1004 reader->zone(), NEW_OBJECT_WITH_LEN(TokenStream, len));
1007 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); 1005 reader->AddBackRef(object_id, &token_stream, kIsDeserialized);
1008 1006
1009 // Read the stream of tokens into the TokenStream object for script 1007 // Read the stream of tokens into the TokenStream object for script
(...skipping 13 matching lines...) Expand all
1023 1021
1024 return token_stream.raw(); 1022 return token_stream.raw();
1025 } 1023 }
1026 1024
1027 1025
1028 void RawTokenStream::WriteTo(SnapshotWriter* writer, 1026 void RawTokenStream::WriteTo(SnapshotWriter* writer,
1029 intptr_t object_id, 1027 intptr_t object_id,
1030 Snapshot::Kind kind, 1028 Snapshot::Kind kind,
1031 bool as_reference) { 1029 bool as_reference) {
1032 ASSERT(writer != NULL); 1030 ASSERT(writer != NULL);
1033 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1031 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
1034 1032
1035 // Write out the serialization header value for this object. 1033 // Write out the serialization header value for this object.
1036 writer->WriteInlinedObjectHeader(object_id); 1034 writer->WriteInlinedObjectHeader(object_id);
1037 1035
1038 // Write out the class and tags information. 1036 // Write out the class and tags information.
1039 writer->WriteVMIsolateObject(kTokenStreamCid); 1037 writer->WriteVMIsolateObject(kTokenStreamCid);
1040 writer->WriteTags(writer->GetObjectTags(this)); 1038 writer->WriteTags(writer->GetObjectTags(this));
1041 1039
1042 // Write out the length field and the token stream. 1040 // Write out the length field and the token stream.
1043 RawExternalTypedData* stream = ptr()->stream_; 1041 RawExternalTypedData* stream = ptr()->stream_;
1044 intptr_t len = Smi::Value(stream->ptr()->length_); 1042 intptr_t len = Smi::Value(stream->ptr()->length_);
1045 writer->Write<RawObject*>(stream->ptr()->length_); 1043 writer->Write<RawObject*>(stream->ptr()->length_);
1046 writer->WriteBytes(stream->ptr()->data_, len); 1044 writer->WriteBytes(stream->ptr()->data_, len);
1047 1045
1048 // Write out the literal/identifier token array. 1046 // Write out the literal/identifier token array.
1049 writer->WriteObjectImpl(ptr()->token_objects_, kAsInlinedObject); 1047 writer->WriteObjectImpl(ptr()->token_objects_, kAsInlinedObject);
1050 // Write out the private key in use by the token stream. 1048 // Write out the private key in use by the token stream.
1051 writer->WriteObjectImpl(ptr()->private_key_, kAsInlinedObject); 1049 writer->WriteObjectImpl(ptr()->private_key_, kAsInlinedObject);
1052 } 1050 }
1053 1051
1054 1052
1055 RawScript* Script::ReadFrom(SnapshotReader* reader, 1053 RawScript* Script::ReadFrom(SnapshotReader* reader,
1056 intptr_t object_id, 1054 intptr_t object_id,
1057 intptr_t tags, 1055 intptr_t tags,
1058 Snapshot::Kind kind, 1056 Snapshot::Kind kind,
1059 bool as_reference) { 1057 bool as_reference) {
1060 ASSERT(reader != NULL); 1058 ASSERT(reader != NULL);
1061 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1059 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
1062 1060
1063 // Allocate script object. 1061 // Allocate script object.
1064 Script& script = Script::ZoneHandle(reader->zone(), NEW_OBJECT(Script)); 1062 Script& script = Script::ZoneHandle(reader->zone(), NEW_OBJECT(Script));
1065 reader->AddBackRef(object_id, &script, kIsDeserialized); 1063 reader->AddBackRef(object_id, &script, kIsDeserialized);
1066 1064
1067 script.StoreNonPointer(&script.raw_ptr()->line_offset_, 1065 script.StoreNonPointer(&script.raw_ptr()->line_offset_,
1068 reader->Read<int32_t>()); 1066 reader->Read<int32_t>());
1069 script.StoreNonPointer(&script.raw_ptr()->col_offset_, 1067 script.StoreNonPointer(&script.raw_ptr()->col_offset_,
1070 reader->Read<int32_t>()); 1068 reader->Read<int32_t>());
1071 script.StoreNonPointer(&script.raw_ptr()->kind_, 1069 script.StoreNonPointer(&script.raw_ptr()->kind_,
1072 reader->Read<int8_t>()); 1070 reader->Read<int8_t>());
1073 1071
1074 *reader->StringHandle() ^= String::null(); 1072 *reader->StringHandle() ^= String::null();
1075 script.set_source(*reader->StringHandle()); 1073 script.set_source(*reader->StringHandle());
1076 *reader->StreamHandle() ^= TokenStream::null(); 1074 *reader->StreamHandle() ^= TokenStream::null();
1077 script.set_tokens(*reader->StreamHandle()); 1075 script.set_tokens(*reader->StreamHandle());
1078 1076
1079 // Set all the object fields. 1077 // Set all the object fields.
1080 // TODO(5411462): Need to assert No GC can happen here, even though 1078 // TODO(5411462): Need to assert No GC can happen here, even though
1081 // allocations may happen. 1079 // allocations may happen.
1082 RawObject** toobj = reader->snapshot_code() 1080 intptr_t num_flds = (script.raw()->to_snapshot(kind) - script.raw()->from());
1083 ? script.raw()->to_precompiled_snapshot()
1084 : script.raw()->to_snapshot();
1085 intptr_t num_flds = (toobj - script.raw()->from());
1086 for (intptr_t i = 0; i <= num_flds; i++) { 1081 for (intptr_t i = 0; i <= num_flds; i++) {
1087 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); 1082 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference);
1088 script.StorePointer((script.raw()->from() + i), 1083 script.StorePointer((script.raw()->from() + i),
1089 reader->PassiveObjectHandle()->raw()); 1084 reader->PassiveObjectHandle()->raw());
1090 } 1085 }
1091 1086
1092 return script.raw(); 1087 return script.raw();
1093 } 1088 }
1094 1089
1095 1090
1096 void RawScript::WriteTo(SnapshotWriter* writer, 1091 void RawScript::WriteTo(SnapshotWriter* writer,
1097 intptr_t object_id, 1092 intptr_t object_id,
1098 Snapshot::Kind kind, 1093 Snapshot::Kind kind,
1099 bool as_reference) { 1094 bool as_reference) {
1100 ASSERT(writer != NULL); 1095 ASSERT(writer != NULL);
1101 ASSERT(tokens_ != TokenStream::null()); 1096 ASSERT(tokens_ != TokenStream::null());
1102 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1097 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
1103 1098
1104 // Write out the serialization header value for this object. 1099 // Write out the serialization header value for this object.
1105 writer->WriteInlinedObjectHeader(object_id); 1100 writer->WriteInlinedObjectHeader(object_id);
1106 1101
1107 // Write out the class and tags information. 1102 // Write out the class and tags information.
1108 writer->WriteVMIsolateObject(kScriptCid); 1103 writer->WriteVMIsolateObject(kScriptCid);
1109 writer->WriteTags(writer->GetObjectTags(this)); 1104 writer->WriteTags(writer->GetObjectTags(this));
1110 1105
1111 // Write out all the non object fields. 1106 // Write out all the non object fields.
1112 writer->Write<int32_t>(ptr()->line_offset_); 1107 writer->Write<int32_t>(ptr()->line_offset_);
1113 writer->Write<int32_t>(ptr()->col_offset_); 1108 writer->Write<int32_t>(ptr()->col_offset_);
1114 writer->Write<int8_t>(ptr()->kind_); 1109 writer->Write<int8_t>(ptr()->kind_);
1115 1110
1116 // Write out all the object pointer fields. 1111 // Write out all the object pointer fields.
1117 SnapshotWriterVisitor visitor(writer, kAsReference); 1112 SnapshotWriterVisitor visitor(writer, kAsReference);
1118 RawObject** toobj = writer->snapshot_code() ? to_precompiled_snapshot() 1113 visitor.VisitPointers(from(), to_snapshot(kind));
1119 : to_snapshot();
1120 visitor.VisitPointers(from(), toobj);
1121 } 1114 }
1122 1115
1123 1116
1124 RawLibrary* Library::ReadFrom(SnapshotReader* reader, 1117 RawLibrary* Library::ReadFrom(SnapshotReader* reader,
1125 intptr_t object_id, 1118 intptr_t object_id,
1126 intptr_t tags, 1119 intptr_t tags,
1127 Snapshot::Kind kind, 1120 Snapshot::Kind kind,
1128 bool as_reference) { 1121 bool as_reference) {
1129 ASSERT(reader != NULL); 1122 ASSERT(reader != NULL);
1130 ASSERT(kind != Snapshot::kMessage); 1123 ASSERT(kind != Snapshot::kMessage);
(...skipping 17 matching lines...) Expand all
1148 library.StoreNonPointer(&library.raw_ptr()->num_imports_, 1141 library.StoreNonPointer(&library.raw_ptr()->num_imports_,
1149 reader->Read<uint16_t>()); 1142 reader->Read<uint16_t>());
1150 library.StoreNonPointer(&library.raw_ptr()->load_state_, 1143 library.StoreNonPointer(&library.raw_ptr()->load_state_,
1151 reader->Read<int8_t>()); 1144 reader->Read<int8_t>());
1152 library.StoreNonPointer(&library.raw_ptr()->corelib_imported_, 1145 library.StoreNonPointer(&library.raw_ptr()->corelib_imported_,
1153 reader->Read<bool>()); 1146 reader->Read<bool>());
1154 library.StoreNonPointer(&library.raw_ptr()->is_dart_scheme_, 1147 library.StoreNonPointer(&library.raw_ptr()->is_dart_scheme_,
1155 reader->Read<bool>()); 1148 reader->Read<bool>());
1156 library.StoreNonPointer(&library.raw_ptr()->debuggable_, 1149 library.StoreNonPointer(&library.raw_ptr()->debuggable_,
1157 reader->Read<bool>()); 1150 reader->Read<bool>());
1158 if (kind == Snapshot::kFull) { 1151 if (Snapshot::IsFull(kind)) {
1159 is_in_fullsnapshot = true; 1152 is_in_fullsnapshot = true;
1160 } 1153 }
1161 library.StoreNonPointer(&library.raw_ptr()->is_in_fullsnapshot_, 1154 library.StoreNonPointer(&library.raw_ptr()->is_in_fullsnapshot_,
1162 is_in_fullsnapshot); 1155 is_in_fullsnapshot);
1163 // The native resolver and symbolizer are not serialized. 1156 // The native resolver and symbolizer are not serialized.
1164 library.set_native_entry_resolver(NULL); 1157 library.set_native_entry_resolver(NULL);
1165 library.set_native_entry_symbol_resolver(NULL); 1158 library.set_native_entry_symbol_resolver(NULL);
1166 1159
1167 // Set all the object fields. 1160 // Set all the object fields.
1168 // TODO(5411462): Need to assert No GC can happen here, even though 1161 // TODO(5411462): Need to assert No GC can happen here, even though
1169 // allocations may happen. 1162 // allocations may happen.
1170 intptr_t num_flds = (library.raw()->to_snapshot() - library.raw()->from()); 1163 intptr_t num_flds = (library.raw()->to_snapshot() - library.raw()->from());
1171 for (intptr_t i = 0; i <= num_flds; i++) { 1164 for (intptr_t i = 0; i <= num_flds; i++) {
1172 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); 1165 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference);
1173 library.StorePointer((library.raw()->from() + i), 1166 library.StorePointer((library.raw()->from() + i),
1174 reader->PassiveObjectHandle()->raw()); 1167 reader->PassiveObjectHandle()->raw());
1175 } 1168 }
1176 // Initialize cache of resolved names. 1169 // Initialize cache of resolved names.
1177 const intptr_t kInitialNameCacheSize = 64; 1170 const intptr_t kInitialNameCacheSize = 64;
1178 if (kind != Snapshot::kFull) { 1171 if (!Snapshot::IsFull(kind)) {
1179 // The cache of resolved names in library scope is not serialized. 1172 // The cache of resolved names in library scope is not serialized.
1180 library.InitResolvedNamesCache(kInitialNameCacheSize); 1173 library.InitResolvedNamesCache(kInitialNameCacheSize);
1181 library.Register(); 1174 library.Register();
1182 } else { 1175 } else {
1183 library.InitResolvedNamesCache(kInitialNameCacheSize, reader); 1176 library.InitResolvedNamesCache(kInitialNameCacheSize, reader);
1184 } 1177 }
1185 library.StorePointer(&library.raw_ptr()->exported_names_, Array::null()); 1178 library.StorePointer(&library.raw_ptr()->exported_names_, Array::null());
1186 // Initialize cache of loaded scripts. 1179 // Initialize cache of loaded scripts.
1187 library.StorePointer(&library.raw_ptr()->loaded_scripts_, Array::null()); 1180 library.StorePointer(&library.raw_ptr()->loaded_scripts_, Array::null());
1188 } 1181 }
(...skipping 17 matching lines...) Expand all
1206 1199
1207 // Write out the boolean is_in_fullsnapshot_ first as this will 1200 // Write out the boolean is_in_fullsnapshot_ first as this will
1208 // help the reader decide how the rest of the information needs 1201 // help the reader decide how the rest of the information needs
1209 // to be interpreted. 1202 // to be interpreted.
1210 writer->Write<bool>(ptr()->is_in_fullsnapshot_); 1203 writer->Write<bool>(ptr()->is_in_fullsnapshot_);
1211 1204
1212 if ((kind == Snapshot::kScript) && ptr()->is_in_fullsnapshot_) { 1205 if ((kind == Snapshot::kScript) && ptr()->is_in_fullsnapshot_) {
1213 // Write out library URL so that it can be looked up when reading. 1206 // Write out library URL so that it can be looked up when reading.
1214 writer->WriteObjectImpl(ptr()->url_, kAsInlinedObject); 1207 writer->WriteObjectImpl(ptr()->url_, kAsInlinedObject);
1215 } else { 1208 } else {
1216 ASSERT((kind == Snapshot::kFull) || !ptr()->is_in_fullsnapshot_); 1209 ASSERT((Snapshot::IsFull(kind)) || !ptr()->is_in_fullsnapshot_);
1217 // Write out all non object fields. 1210 // Write out all non object fields.
1218 ASSERT(ptr()->index_ != static_cast<classid_t>(-1)); 1211 ASSERT(ptr()->index_ != static_cast<classid_t>(-1));
1219 writer->WriteClassIDValue(ptr()->index_); 1212 writer->WriteClassIDValue(ptr()->index_);
1220 writer->Write<uint16_t>(ptr()->num_imports_); 1213 writer->Write<uint16_t>(ptr()->num_imports_);
1221 writer->Write<int8_t>(ptr()->load_state_); 1214 writer->Write<int8_t>(ptr()->load_state_);
1222 writer->Write<bool>(ptr()->corelib_imported_); 1215 writer->Write<bool>(ptr()->corelib_imported_);
1223 writer->Write<bool>(ptr()->is_dart_scheme_); 1216 writer->Write<bool>(ptr()->is_dart_scheme_);
1224 writer->Write<bool>(ptr()->debuggable_); 1217 writer->Write<bool>(ptr()->debuggable_);
1225 // We do not serialize the native resolver or symbolizer. These need to be 1218 // We do not serialize the native resolver or symbolizer. These need to be
1226 // explicitly set after deserialization. 1219 // explicitly set after deserialization.
1227 1220
1228 // We do not write the loaded_scripts_ and resolved_names_ caches to the 1221 // We do not write the loaded_scripts_ and resolved_names_ caches to the
1229 // snapshot. They get initialized when reading the library from the 1222 // snapshot. They get initialized when reading the library from the
1230 // snapshot and will be rebuilt lazily. 1223 // snapshot and will be rebuilt lazily.
1231 // Write out all the object pointer fields. 1224 // Write out all the object pointer fields.
1232 SnapshotWriterVisitor visitor(writer, kAsReference); 1225 SnapshotWriterVisitor visitor(writer, kAsReference);
1233 visitor.VisitPointers(from(), to_snapshot()); 1226 visitor.VisitPointers(from(), to_snapshot());
1234 } 1227 }
1235 } 1228 }
1236 1229
1237 1230
1238 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader, 1231 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader,
1239 intptr_t object_id, 1232 intptr_t object_id,
1240 intptr_t tags, 1233 intptr_t tags,
1241 Snapshot::Kind kind, 1234 Snapshot::Kind kind,
1242 bool as_reference) { 1235 bool as_reference) {
1243 ASSERT(reader != NULL); 1236 ASSERT(reader != NULL);
1244 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1237 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
1245 1238
1246 // Allocate library prefix object. 1239 // Allocate library prefix object.
1247 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle( 1240 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(
1248 reader->zone(), NEW_OBJECT(LibraryPrefix)); 1241 reader->zone(), NEW_OBJECT(LibraryPrefix));
1249 reader->AddBackRef(object_id, &prefix, kIsDeserialized); 1242 reader->AddBackRef(object_id, &prefix, kIsDeserialized);
1250 1243
1251 // Set all non object fields. 1244 // Set all non object fields.
1252 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_, 1245 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_,
1253 reader->Read<int16_t>()); 1246 reader->Read<int16_t>());
1254 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_, 1247 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_,
1255 reader->Read<bool>()); 1248 reader->Read<bool>());
1256 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>()); 1249 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>());
1257 1250
1258 // Set all the object fields. 1251 // Set all the object fields.
1259 RawObject** toobj = reader->snapshot_code()
1260 ? prefix.raw()->to_precompiled_snapshot()
1261 : prefix.raw()->to();
1262 READ_OBJECT_FIELDS(prefix, 1252 READ_OBJECT_FIELDS(prefix,
1263 prefix.raw()->from(), toobj, 1253 prefix.raw()->from(),
1254 prefix.raw()->to_snapshot(kind),
1264 kAsReference); 1255 kAsReference);
1265 if (reader->snapshot_code()) { 1256 if (Snapshot::IncludesCode(kind)) {
1266 prefix.StorePointer(&prefix.raw_ptr()->imports_, 1257 prefix.StorePointer(&prefix.raw_ptr()->imports_,
1267 Array::null()); 1258 Array::null());
1268 prefix.StorePointer(&prefix.raw_ptr()->dependent_code_, 1259 prefix.StorePointer(&prefix.raw_ptr()->dependent_code_,
1269 Array::null()); 1260 Array::null());
1270 } 1261 }
1271 1262
1272 return prefix.raw(); 1263 return prefix.raw();
1273 } 1264 }
1274 1265
1275 1266
1276 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, 1267 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer,
1277 intptr_t object_id, 1268 intptr_t object_id,
1278 Snapshot::Kind kind, 1269 Snapshot::Kind kind,
1279 bool as_reference) { 1270 bool as_reference) {
1280 ASSERT(writer != NULL); 1271 ASSERT(writer != NULL);
1281 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1272 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
1282 1273
1283 // Write out the serialization header value for this object. 1274 // Write out the serialization header value for this object.
1284 writer->WriteInlinedObjectHeader(object_id); 1275 writer->WriteInlinedObjectHeader(object_id);
1285 1276
1286 // Write out the class and tags information. 1277 // Write out the class and tags information.
1287 writer->WriteIndexedObject(kLibraryPrefixCid); 1278 writer->WriteIndexedObject(kLibraryPrefixCid);
1288 writer->WriteTags(writer->GetObjectTags(this)); 1279 writer->WriteTags(writer->GetObjectTags(this));
1289 1280
1290 // Write out all non object fields. 1281 // Write out all non object fields.
1291 writer->Write<int16_t>(ptr()->num_imports_); 1282 writer->Write<int16_t>(ptr()->num_imports_);
1292 writer->Write<bool>(ptr()->is_deferred_load_); 1283 writer->Write<bool>(ptr()->is_deferred_load_);
1293 writer->Write<bool>(ptr()->is_loaded_); 1284 writer->Write<bool>(ptr()->is_loaded_);
1294 1285
1295 // Write out all the object pointer fields. 1286 // Write out all the object pointer fields.
1296 SnapshotWriterVisitor visitor(writer, kAsReference); 1287 SnapshotWriterVisitor visitor(writer, kAsReference);
1297 RawObject** toobj = writer->snapshot_code() ? to_precompiled_snapshot() 1288 visitor.VisitPointers(from(), to_snapshot(kind));
1298 : to();
1299 visitor.VisitPointers(from(), toobj);
1300 } 1289 }
1301 1290
1302 1291
1303 RawNamespace* Namespace::ReadFrom(SnapshotReader* reader, 1292 RawNamespace* Namespace::ReadFrom(SnapshotReader* reader,
1304 intptr_t object_id, 1293 intptr_t object_id,
1305 intptr_t tags, 1294 intptr_t tags,
1306 Snapshot::Kind kind, 1295 Snapshot::Kind kind,
1307 bool as_reference) { 1296 bool as_reference) {
1308 ASSERT(reader != NULL); 1297 ASSERT(reader != NULL);
1309 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1298 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
1310 1299
1311 // Allocate Namespace object. 1300 // Allocate Namespace object.
1312 Namespace& ns = Namespace::ZoneHandle( 1301 Namespace& ns = Namespace::ZoneHandle(
1313 reader->zone(), NEW_OBJECT(Namespace)); 1302 reader->zone(), NEW_OBJECT(Namespace));
1314 reader->AddBackRef(object_id, &ns, kIsDeserialized); 1303 reader->AddBackRef(object_id, &ns, kIsDeserialized);
1315 1304
1316 // Set all the object fields. 1305 // Set all the object fields.
1317 READ_OBJECT_FIELDS(ns, ns.raw()->from(), ns.raw()->to(), kAsReference); 1306 READ_OBJECT_FIELDS(ns, ns.raw()->from(), ns.raw()->to(), kAsReference);
1318 1307
1319 return ns.raw(); 1308 return ns.raw();
1320 } 1309 }
1321 1310
1322 1311
1323 void RawNamespace::WriteTo(SnapshotWriter* writer, 1312 void RawNamespace::WriteTo(SnapshotWriter* writer,
1324 intptr_t object_id, 1313 intptr_t object_id,
1325 Snapshot::Kind kind, 1314 Snapshot::Kind kind,
1326 bool as_reference) { 1315 bool as_reference) {
1327 ASSERT(writer != NULL); 1316 ASSERT(writer != NULL);
1328 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1317 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
1329 1318
1330 // Write out the serialization header value for this object. 1319 // Write out the serialization header value for this object.
1331 writer->WriteInlinedObjectHeader(object_id); 1320 writer->WriteInlinedObjectHeader(object_id);
1332 1321
1333 // Write out the class and tags information. 1322 // Write out the class and tags information.
1334 writer->WriteVMIsolateObject(kNamespaceCid); 1323 writer->WriteVMIsolateObject(kNamespaceCid);
1335 writer->WriteTags(writer->GetObjectTags(this)); 1324 writer->WriteTags(writer->GetObjectTags(this));
1336 1325
1337 // Write out all the object pointer fields. 1326 // Write out all the object pointer fields.
1338 SnapshotWriterVisitor visitor(writer, kAsReference); 1327 SnapshotWriterVisitor visitor(writer, kAsReference);
(...skipping 12 matching lines...) Expand all
1351 return sum; 1340 return sum;
1352 } 1341 }
1353 #endif 1342 #endif
1354 1343
1355 1344
1356 RawCode* Code::ReadFrom(SnapshotReader* reader, 1345 RawCode* Code::ReadFrom(SnapshotReader* reader,
1357 intptr_t object_id, 1346 intptr_t object_id,
1358 intptr_t tags, 1347 intptr_t tags,
1359 Snapshot::Kind kind, 1348 Snapshot::Kind kind,
1360 bool as_reference) { 1349 bool as_reference) {
1361 ASSERT(reader->snapshot_code()); 1350 ASSERT(Snapshot::IncludesCode(kind));
1362 ASSERT(kind == Snapshot::kFull); 1351 ASSERT(Snapshot::IsFull(kind));
1363 1352
1364 Code& result = Code::ZoneHandle(reader->zone(), NEW_OBJECT_WITH_LEN(Code, 0)); 1353 Code& result = Code::ZoneHandle(reader->zone(), NEW_OBJECT_WITH_LEN(Code, 0));
1365 reader->AddBackRef(object_id, &result, kIsDeserialized); 1354 reader->AddBackRef(object_id, &result, kIsDeserialized);
1366 1355
1367 result.set_compile_timestamp(0); 1356 result.set_compile_timestamp(0);
1368 result.set_state_bits(reader->Read<int32_t>()); 1357 result.set_state_bits(reader->Read<int32_t>());
1369 result.set_lazy_deopt_pc_offset(-1); 1358 result.set_lazy_deopt_pc_offset(-1);
1370 1359
1371 int32_t text_offset = reader->Read<int32_t>(); 1360 int32_t text_offset = reader->Read<int32_t>();
1372 int32_t instructions_size = reader->Read<int32_t>(); 1361 int32_t instructions_size = reader->Read<int32_t>();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 ASSERT(result.EntryPoint() == entry_point); 1419 ASSERT(result.EntryPoint() == entry_point);
1431 1420
1432 return result.raw(); 1421 return result.raw();
1433 } 1422 }
1434 1423
1435 1424
1436 void RawCode::WriteTo(SnapshotWriter* writer, 1425 void RawCode::WriteTo(SnapshotWriter* writer,
1437 intptr_t object_id, 1426 intptr_t object_id,
1438 Snapshot::Kind kind, 1427 Snapshot::Kind kind,
1439 bool as_reference) { 1428 bool as_reference) {
1440 ASSERT(writer->snapshot_code()); 1429 ASSERT(Snapshot::IncludesCode(kind));
1441 ASSERT(kind == Snapshot::kFull); 1430 ASSERT(Snapshot::IsFull(kind));
1442 1431
1443 intptr_t pointer_offsets_length = 1432 intptr_t pointer_offsets_length =
1444 Code::PtrOffBits::decode(ptr()->state_bits_); 1433 Code::PtrOffBits::decode(ptr()->state_bits_);
1445 if (pointer_offsets_length != 0) { 1434 if (pointer_offsets_length != 0) {
1446 // Should only be IA32. 1435 // Should only be IA32.
1447 FATAL("Cannot serialize code with embedded pointers"); 1436 FATAL("Cannot serialize code with embedded pointers");
1448 } 1437 }
1449 1438
1450 // Write out the serialization header value for this object. 1439 // Write out the serialization header value for this object.
1451 writer->WriteInlinedObjectHeader(object_id); 1440 writer->WriteInlinedObjectHeader(object_id);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 bool as_reference) { 1482 bool as_reference) {
1494 UNREACHABLE(); 1483 UNREACHABLE();
1495 } 1484 }
1496 1485
1497 1486
1498 RawObjectPool* ObjectPool::ReadFrom(SnapshotReader* reader, 1487 RawObjectPool* ObjectPool::ReadFrom(SnapshotReader* reader,
1499 intptr_t object_id, 1488 intptr_t object_id,
1500 intptr_t tags, 1489 intptr_t tags,
1501 Snapshot::Kind kind, 1490 Snapshot::Kind kind,
1502 bool as_reference) { 1491 bool as_reference) {
1503 ASSERT(reader->snapshot_code()); 1492 ASSERT(Snapshot::IncludesCode(kind));
1504 ASSERT(kind == Snapshot::kFull); 1493 ASSERT(Snapshot::IsFull(kind));
1505 1494
1506 intptr_t len = reader->Read<intptr_t>(); 1495 intptr_t len = reader->Read<intptr_t>();
1507 ObjectPool* result = NULL; 1496 ObjectPool* result = NULL;
1508 DeserializeState state; 1497 DeserializeState state;
1509 if (!as_reference) { 1498 if (!as_reference) {
1510 result = reinterpret_cast<ObjectPool*>(reader->GetBackRef(object_id)); 1499 result = reinterpret_cast<ObjectPool*>(reader->GetBackRef(object_id));
1511 state = kIsDeserialized; 1500 state = kIsDeserialized;
1512 } else { 1501 } else {
1513 state = kIsNotDeserialized; 1502 state = kIsNotDeserialized;
1514 } 1503 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 } 1545 }
1557 } 1546 }
1558 return result->raw(); 1547 return result->raw();
1559 } 1548 }
1560 1549
1561 1550
1562 void RawObjectPool::WriteTo(SnapshotWriter* writer, 1551 void RawObjectPool::WriteTo(SnapshotWriter* writer,
1563 intptr_t object_id, 1552 intptr_t object_id,
1564 Snapshot::Kind kind, 1553 Snapshot::Kind kind,
1565 bool as_reference) { 1554 bool as_reference) {
1566 ASSERT(writer->snapshot_code()); 1555 ASSERT(Snapshot::IncludesCode(kind));
1567 ASSERT(kind == Snapshot::kFull); 1556 ASSERT(Snapshot::IsFull(kind));
1568 intptr_t tags = writer->GetObjectTags(this); 1557 intptr_t tags = writer->GetObjectTags(this);
1569 intptr_t length = ptr()->length_; 1558 intptr_t length = ptr()->length_;
1570 1559
1571 if (as_reference) { 1560 if (as_reference) {
1572 // Write out the serialization header value for this object. 1561 // Write out the serialization header value for this object.
1573 writer->WriteInlinedObjectHeader(kOmittedObjectId); 1562 writer->WriteInlinedObjectHeader(kOmittedObjectId);
1574 1563
1575 // Write out the class information. 1564 // Write out the class information.
1576 writer->WriteVMIsolateObject(kObjectPoolCid); 1565 writer->WriteVMIsolateObject(kObjectPoolCid);
1577 writer->WriteTags(tags); 1566 writer->WriteTags(tags);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 } 1615 }
1627 } 1616 }
1628 } 1617 }
1629 1618
1630 1619
1631 RawPcDescriptors* PcDescriptors::ReadFrom(SnapshotReader* reader, 1620 RawPcDescriptors* PcDescriptors::ReadFrom(SnapshotReader* reader,
1632 intptr_t object_id, 1621 intptr_t object_id,
1633 intptr_t tags, 1622 intptr_t tags,
1634 Snapshot::Kind kind, 1623 Snapshot::Kind kind,
1635 bool as_reference) { 1624 bool as_reference) {
1636 ASSERT(reader->snapshot_code()); 1625 ASSERT(Snapshot::IncludesCode(kind));
1637 ASSERT(kind == Snapshot::kFull); 1626 ASSERT(Snapshot::IsFull(kind));
1638 1627
1639 intptr_t offset = reader->Read<int32_t>(); 1628 intptr_t offset = reader->Read<int32_t>();
1640 PcDescriptors& result = PcDescriptors::ZoneHandle(reader->zone()); 1629 PcDescriptors& result = PcDescriptors::ZoneHandle(reader->zone());
1641 result ^= reader->GetObjectAt(offset); 1630 result ^= reader->GetObjectAt(offset);
1642 reader->AddBackRef(object_id, &result, kIsDeserialized); 1631 reader->AddBackRef(object_id, &result, kIsDeserialized);
1643 1632
1644 return result.raw(); 1633 return result.raw();
1645 } 1634 }
1646 1635
1647 1636
1648 void RawPcDescriptors::WriteTo(SnapshotWriter* writer, 1637 void RawPcDescriptors::WriteTo(SnapshotWriter* writer,
1649 intptr_t object_id, 1638 intptr_t object_id,
1650 Snapshot::Kind kind, 1639 Snapshot::Kind kind,
1651 bool as_reference) { 1640 bool as_reference) {
1652 ASSERT(writer->snapshot_code()); 1641 ASSERT(Snapshot::IncludesCode(kind));
1653 ASSERT(kind == Snapshot::kFull); 1642 ASSERT(Snapshot::IsFull(kind));
1654 1643
1655 // Write out the serialization header value for this object. 1644 // Write out the serialization header value for this object.
1656 writer->WriteInlinedObjectHeader(object_id); 1645 writer->WriteInlinedObjectHeader(object_id);
1657 writer->WriteIndexedObject(kPcDescriptorsCid); 1646 writer->WriteIndexedObject(kPcDescriptorsCid);
1658 writer->WriteTags(writer->GetObjectTags(this)); 1647 writer->WriteTags(writer->GetObjectTags(this));
1659 1648
1660 writer->Write<int32_t>(writer->GetObjectId(this)); 1649 writer->Write<int32_t>(writer->GetObjectId(this));
1661 } 1650 }
1662 1651
1663 1652
1664 RawCodeSourceMap* CodeSourceMap::ReadFrom(SnapshotReader* reader, 1653 RawCodeSourceMap* CodeSourceMap::ReadFrom(SnapshotReader* reader,
1665 intptr_t object_id, 1654 intptr_t object_id,
1666 intptr_t tags, 1655 intptr_t tags,
1667 Snapshot::Kind kind, 1656 Snapshot::Kind kind,
1668 bool as_reference) { 1657 bool as_reference) {
1669 ASSERT(reader->snapshot_code()); 1658 ASSERT(Snapshot::IncludesCode(kind));
1670 ASSERT(kind == Snapshot::kFull); 1659 ASSERT(Snapshot::IsFull(kind));
1671 1660
1672 const int32_t length = reader->Read<int32_t>(); 1661 const int32_t length = reader->Read<int32_t>();
1673 CodeSourceMap& result = 1662 CodeSourceMap& result =
1674 CodeSourceMap::ZoneHandle(reader->zone(), 1663 CodeSourceMap::ZoneHandle(reader->zone(),
1675 NEW_OBJECT_WITH_LEN(CodeSourceMap, length)); 1664 NEW_OBJECT_WITH_LEN(CodeSourceMap, length));
1676 reader->AddBackRef(object_id, &result, kIsDeserialized); 1665 reader->AddBackRef(object_id, &result, kIsDeserialized);
1677 1666
1678 if (result.Length() > 0) { 1667 if (result.Length() > 0) {
1679 NoSafepointScope no_safepoint; 1668 NoSafepointScope no_safepoint;
1680 intptr_t len = result.Length(); 1669 intptr_t len = result.Length();
1681 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data()); 1670 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data());
1682 reader->ReadBytes(data, len); 1671 reader->ReadBytes(data, len);
1683 } 1672 }
1684 1673
1685 return result.raw(); 1674 return result.raw();
1686 } 1675 }
1687 1676
1688 1677
1689 void RawCodeSourceMap::WriteTo(SnapshotWriter* writer, 1678 void RawCodeSourceMap::WriteTo(SnapshotWriter* writer,
1690 intptr_t object_id, 1679 intptr_t object_id,
1691 Snapshot::Kind kind, 1680 Snapshot::Kind kind,
1692 bool as_reference) { 1681 bool as_reference) {
1693 ASSERT(writer->snapshot_code()); 1682 ASSERT(Snapshot::IncludesCode(kind));
1694 ASSERT(kind == Snapshot::kFull); 1683 ASSERT(Snapshot::IsFull(kind));
1695 1684
1696 // Write out the serialization header value for this object. 1685 // Write out the serialization header value for this object.
1697 writer->WriteInlinedObjectHeader(object_id); 1686 writer->WriteInlinedObjectHeader(object_id);
1698 writer->WriteIndexedObject(kCodeSourceMapCid); 1687 writer->WriteIndexedObject(kCodeSourceMapCid);
1699 writer->WriteTags(writer->GetObjectTags(this)); 1688 writer->WriteTags(writer->GetObjectTags(this));
1700 writer->Write<int32_t>(ptr()->length_); 1689 writer->Write<int32_t>(ptr()->length_);
1701 if (ptr()->length_ > 0) { 1690 if (ptr()->length_ > 0) {
1702 intptr_t len = ptr()->length_; 1691 intptr_t len = ptr()->length_;
1703 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); 1692 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data());
1704 writer->WriteBytes(data, len); 1693 writer->WriteBytes(data, len);
1705 } 1694 }
1706 } 1695 }
1707 1696
1708 1697
1709 RawStackmap* Stackmap::ReadFrom(SnapshotReader* reader, 1698 RawStackmap* Stackmap::ReadFrom(SnapshotReader* reader,
1710 intptr_t object_id, 1699 intptr_t object_id,
1711 intptr_t tags, 1700 intptr_t tags,
1712 Snapshot::Kind kind, 1701 Snapshot::Kind kind,
1713 bool as_reference) { 1702 bool as_reference) {
1714 ASSERT(reader->snapshot_code()); 1703 ASSERT(Snapshot::IncludesCode(kind));
1715 ASSERT(kind == Snapshot::kFull); 1704 ASSERT(Snapshot::IsFull(kind));
1716 1705
1717 intptr_t offset = reader->Read<int32_t>(); 1706 intptr_t offset = reader->Read<int32_t>();
1718 Stackmap& result = Stackmap::ZoneHandle(reader->zone()); 1707 Stackmap& result = Stackmap::ZoneHandle(reader->zone());
1719 result ^= reader->GetObjectAt(offset); 1708 result ^= reader->GetObjectAt(offset);
1720 reader->AddBackRef(object_id, &result, kIsDeserialized); 1709 reader->AddBackRef(object_id, &result, kIsDeserialized);
1721 1710
1722 return result.raw(); 1711 return result.raw();
1723 } 1712 }
1724 1713
1725 1714
1726 void RawStackmap::WriteTo(SnapshotWriter* writer, 1715 void RawStackmap::WriteTo(SnapshotWriter* writer,
1727 intptr_t object_id, 1716 intptr_t object_id,
1728 Snapshot::Kind kind, 1717 Snapshot::Kind kind,
1729 bool as_reference) { 1718 bool as_reference) {
1730 ASSERT(writer->snapshot_code()); 1719 ASSERT(Snapshot::IncludesCode(kind));
1731 ASSERT(kind == Snapshot::kFull); 1720 ASSERT(Snapshot::IsFull(kind));
1732 1721
1733 // Write out the serialization header value for this object. 1722 // Write out the serialization header value for this object.
1734 writer->WriteInlinedObjectHeader(object_id); 1723 writer->WriteInlinedObjectHeader(object_id);
1735 writer->WriteIndexedObject(kStackmapCid); 1724 writer->WriteIndexedObject(kStackmapCid);
1736 writer->WriteTags(writer->GetObjectTags(this)); 1725 writer->WriteTags(writer->GetObjectTags(this));
1737 1726
1738 writer->Write<int32_t>(writer->GetObjectId(this)); 1727 writer->Write<int32_t>(writer->GetObjectId(this));
1739 } 1728 }
1740 1729
1741 1730
1742 RawLocalVarDescriptors* LocalVarDescriptors::ReadFrom(SnapshotReader* reader, 1731 RawLocalVarDescriptors* LocalVarDescriptors::ReadFrom(SnapshotReader* reader,
1743 intptr_t object_id, 1732 intptr_t object_id,
1744 intptr_t tags, 1733 intptr_t tags,
1745 Snapshot::Kind kind, 1734 Snapshot::Kind kind,
1746 bool as_reference) { 1735 bool as_reference) {
1747 ASSERT(reader->snapshot_code()); 1736 ASSERT(Snapshot::IncludesCode(kind));
1748 ASSERT(kind == Snapshot::kFull); 1737 ASSERT(Snapshot::IsFull(kind));
1749 1738
1750 const int32_t num_entries = reader->Read<int32_t>(); 1739 const int32_t num_entries = reader->Read<int32_t>();
1751 1740
1752 LocalVarDescriptors& result = 1741 LocalVarDescriptors& result =
1753 LocalVarDescriptors::ZoneHandle(reader->zone(), 1742 LocalVarDescriptors::ZoneHandle(reader->zone(),
1754 NEW_OBJECT_WITH_LEN(LocalVarDescriptors, 1743 NEW_OBJECT_WITH_LEN(LocalVarDescriptors,
1755 num_entries)); 1744 num_entries));
1756 reader->AddBackRef(object_id, &result, kIsDeserialized); 1745 reader->AddBackRef(object_id, &result, kIsDeserialized);
1757 1746
1758 for (intptr_t i = 0; i < num_entries; i++) { 1747 for (intptr_t i = 0; i < num_entries; i++) {
(...skipping 11 matching lines...) Expand all
1770 } 1759 }
1771 1760
1772 return result.raw(); 1761 return result.raw();
1773 } 1762 }
1774 1763
1775 1764
1776 void RawLocalVarDescriptors::WriteTo(SnapshotWriter* writer, 1765 void RawLocalVarDescriptors::WriteTo(SnapshotWriter* writer,
1777 intptr_t object_id, 1766 intptr_t object_id,
1778 Snapshot::Kind kind, 1767 Snapshot::Kind kind,
1779 bool as_reference) { 1768 bool as_reference) {
1780 ASSERT(writer->snapshot_code()); 1769 ASSERT(Snapshot::IncludesCode(kind));
1781 ASSERT(kind == Snapshot::kFull); 1770 ASSERT(Snapshot::IsFull(kind));
1782 1771
1783 // Write out the serialization header value for this object. 1772 // Write out the serialization header value for this object.
1784 writer->WriteInlinedObjectHeader(object_id); 1773 writer->WriteInlinedObjectHeader(object_id);
1785 writer->WriteIndexedObject(kLocalVarDescriptorsCid); 1774 writer->WriteIndexedObject(kLocalVarDescriptorsCid);
1786 writer->WriteTags(writer->GetObjectTags(this)); 1775 writer->WriteTags(writer->GetObjectTags(this));
1787 writer->Write<int32_t>(ptr()->num_entries_); 1776 writer->Write<int32_t>(ptr()->num_entries_);
1788 for (intptr_t i = 0; i < ptr()->num_entries_; i++) { 1777 for (intptr_t i = 0; i < ptr()->num_entries_; i++) {
1789 writer->WriteObjectImpl(ptr()->names()[i], kAsReference); 1778 writer->WriteObjectImpl(ptr()->names()[i], kAsReference);
1790 } 1779 }
1791 if (ptr()->num_entries_ > 0) { 1780 if (ptr()->num_entries_ > 0) {
1792 intptr_t len = ptr()->num_entries_ * sizeof(VarInfo); 1781 intptr_t len = ptr()->num_entries_ * sizeof(VarInfo);
1793 uint8_t* data = reinterpret_cast<uint8_t*>(this->data()); 1782 uint8_t* data = reinterpret_cast<uint8_t*>(this->data());
1794 writer->WriteBytes(data, len); 1783 writer->WriteBytes(data, len);
1795 } 1784 }
1796 } 1785 }
1797 1786
1798 1787
1799 RawExceptionHandlers* ExceptionHandlers::ReadFrom(SnapshotReader* reader, 1788 RawExceptionHandlers* ExceptionHandlers::ReadFrom(SnapshotReader* reader,
1800 intptr_t object_id, 1789 intptr_t object_id,
1801 intptr_t tags, 1790 intptr_t tags,
1802 Snapshot::Kind kind, 1791 Snapshot::Kind kind,
1803 bool as_reference) { 1792 bool as_reference) {
1804 ASSERT(reader->snapshot_code()); 1793 ASSERT(Snapshot::IncludesCode(kind));
1805 ASSERT(kind == Snapshot::kFull); 1794 ASSERT(Snapshot::IsFull(kind));
1806 1795
1807 const int32_t num_entries = reader->Read<int32_t>(); 1796 const int32_t num_entries = reader->Read<int32_t>();
1808 ExceptionHandlers& result = 1797 ExceptionHandlers& result =
1809 ExceptionHandlers::ZoneHandle(reader->zone(), 1798 ExceptionHandlers::ZoneHandle(reader->zone(),
1810 NEW_OBJECT_WITH_LEN(ExceptionHandlers, 1799 NEW_OBJECT_WITH_LEN(ExceptionHandlers,
1811 num_entries)); 1800 num_entries));
1812 reader->AddBackRef(object_id, &result, kIsDeserialized); 1801 reader->AddBackRef(object_id, &result, kIsDeserialized);
1813 1802
1814 if (result.num_entries() > 0) { 1803 if (result.num_entries() > 0) {
1815 NoSafepointScope no_safepoint; 1804 NoSafepointScope no_safepoint;
1816 const intptr_t len = 1805 const intptr_t len =
1817 result.num_entries() * sizeof(RawExceptionHandlers::HandlerInfo); 1806 result.num_entries() * sizeof(RawExceptionHandlers::HandlerInfo);
1818 uint8_t* data = result.UnsafeMutableNonPointer( 1807 uint8_t* data = result.UnsafeMutableNonPointer(
1819 reinterpret_cast<const uint8_t*>(result.raw_ptr()->data())); 1808 reinterpret_cast<const uint8_t*>(result.raw_ptr()->data()));
1820 reader->ReadBytes(data, len); 1809 reader->ReadBytes(data, len);
1821 } 1810 }
1822 1811
1823 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); 1812 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject);
1824 result.StorePointer(&result.raw_ptr()->handled_types_data_, 1813 result.StorePointer(&result.raw_ptr()->handled_types_data_,
1825 reader->ArrayHandle()->raw()); 1814 reader->ArrayHandle()->raw());
1826 1815
1827 return result.raw(); 1816 return result.raw();
1828 } 1817 }
1829 1818
1830 1819
1831 void RawExceptionHandlers::WriteTo(SnapshotWriter* writer, 1820 void RawExceptionHandlers::WriteTo(SnapshotWriter* writer,
1832 intptr_t object_id, 1821 intptr_t object_id,
1833 Snapshot::Kind kind, 1822 Snapshot::Kind kind,
1834 bool as_reference) { 1823 bool as_reference) {
1835 ASSERT(writer->snapshot_code()); 1824 ASSERT(Snapshot::IncludesCode(kind));
1836 ASSERT(kind == Snapshot::kFull); 1825 ASSERT(Snapshot::IsFull(kind));
1837 1826
1838 // Write out the serialization header value for this object. 1827 // Write out the serialization header value for this object.
1839 writer->WriteInlinedObjectHeader(object_id); 1828 writer->WriteInlinedObjectHeader(object_id);
1840 writer->WriteIndexedObject(kExceptionHandlersCid); 1829 writer->WriteIndexedObject(kExceptionHandlersCid);
1841 writer->WriteTags(writer->GetObjectTags(this)); 1830 writer->WriteTags(writer->GetObjectTags(this));
1842 writer->Write<int32_t>(ptr()->num_entries_); 1831 writer->Write<int32_t>(ptr()->num_entries_);
1843 1832
1844 if (ptr()->num_entries_ > 0) { 1833 if (ptr()->num_entries_ > 0) {
1845 intptr_t len = ptr()->num_entries_ * sizeof(HandlerInfo); 1834 intptr_t len = ptr()->num_entries_ * sizeof(HandlerInfo);
1846 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); 1835 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 intptr_t object_id, 1898 intptr_t object_id,
1910 intptr_t tags, 1899 intptr_t tags,
1911 Snapshot::Kind kind, 1900 Snapshot::Kind kind,
1912 bool as_reference) { 1901 bool as_reference) {
1913 ASSERT(reader != NULL); 1902 ASSERT(reader != NULL);
1914 1903
1915 // Allocate context object. 1904 // Allocate context object.
1916 bool is_implicit = reader->Read<bool>(); 1905 bool is_implicit = reader->Read<bool>();
1917 if (is_implicit) { 1906 if (is_implicit) {
1918 ContextScope& context_scope = ContextScope::ZoneHandle(); 1907 ContextScope& context_scope = ContextScope::ZoneHandle();
1919 if (kind == Snapshot::kFull) { 1908 if (Snapshot::IsFull(kind)) {
1920 context_scope = reader->NewContextScope(1); 1909 context_scope = reader->NewContextScope(1);
1921 context_scope.set_is_implicit(true); 1910 context_scope.set_is_implicit(true);
1922 } else { 1911 } else {
1923 context_scope = ContextScope::New(1, true); 1912 context_scope = ContextScope::New(1, true);
1924 } 1913 }
1925 reader->AddBackRef(object_id, &context_scope, kIsDeserialized); 1914 reader->AddBackRef(object_id, &context_scope, kIsDeserialized);
1926 1915
1927 *reader->TypeHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); 1916 *reader->TypeHandle() ^= reader->ReadObjectImpl(kAsInlinedObject);
1928 1917
1929 // Create a descriptor for 'this' variable. 1918 // Create a descriptor for 'this' variable.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 } 1957 }
1969 UNREACHABLE(); 1958 UNREACHABLE();
1970 } 1959 }
1971 1960
1972 1961
1973 RawICData* ICData::ReadFrom(SnapshotReader* reader, 1962 RawICData* ICData::ReadFrom(SnapshotReader* reader,
1974 intptr_t object_id, 1963 intptr_t object_id,
1975 intptr_t tags, 1964 intptr_t tags,
1976 Snapshot::Kind kind, 1965 Snapshot::Kind kind,
1977 bool as_reference) { 1966 bool as_reference) {
1978 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1967 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
1979 1968
1980 ICData& result = ICData::ZoneHandle(reader->zone(), NEW_OBJECT(ICData)); 1969 ICData& result = ICData::ZoneHandle(reader->zone(), NEW_OBJECT(ICData));
1981 reader->AddBackRef(object_id, &result, kIsDeserialized); 1970 reader->AddBackRef(object_id, &result, kIsDeserialized);
1982 1971
1983 result.set_deopt_id(reader->Read<int32_t>()); 1972 result.set_deopt_id(reader->Read<int32_t>());
1984 result.set_state_bits(reader->Read<uint32_t>()); 1973 result.set_state_bits(reader->Read<uint32_t>());
1985 #if defined(TAG_IC_DATA) 1974 #if defined(TAG_IC_DATA)
1986 result.set_tag(reader->Read<int16_t>()); 1975 result.set_tag(reader->Read<int16_t>());
1987 #endif 1976 #endif
1988 1977
1989 // Set all the object fields. 1978 // Set all the object fields.
1990 RawObject** toobj = reader->snapshot_code()
1991 ? result.raw()->to_precompiled_snapshot()
1992 : result.raw()->to();
1993 READ_OBJECT_FIELDS(result, 1979 READ_OBJECT_FIELDS(result,
1994 result.raw()->from(), toobj, 1980 result.raw()->from(),
1981 result.raw()->to_snapshot(kind),
1995 kAsReference); 1982 kAsReference);
1996 if (reader->snapshot_code()) { 1983 if (kind == Snapshot::kAppNoJIT) {
1997 result.set_owner(Function::Handle(reader->zone())); 1984 result.set_owner(Function::Handle(reader->zone()));
1998 } 1985 }
1999 1986
2000 return result.raw(); 1987 return result.raw();
2001 } 1988 }
2002 1989
2003 1990
2004 void RawICData::WriteTo(SnapshotWriter* writer, 1991 void RawICData::WriteTo(SnapshotWriter* writer,
2005 intptr_t object_id, 1992 intptr_t object_id,
2006 Snapshot::Kind kind, 1993 Snapshot::Kind kind,
2007 bool as_reference) { 1994 bool as_reference) {
2008 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1995 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
2009 1996
2010 // Write out the serialization header value for this object. 1997 // Write out the serialization header value for this object.
2011 writer->WriteInlinedObjectHeader(object_id); 1998 writer->WriteInlinedObjectHeader(object_id);
2012 1999
2013 // Write out the class and tags information. 2000 // Write out the class and tags information.
2014 writer->WriteVMIsolateObject(kICDataCid); 2001 writer->WriteVMIsolateObject(kICDataCid);
2015 writer->WriteTags(writer->GetObjectTags(this)); 2002 writer->WriteTags(writer->GetObjectTags(this));
2016 2003
2017 // Write out all the non object fields. 2004 // Write out all the non object fields.
2018 writer->Write<int32_t>(ptr()->deopt_id_); 2005 writer->Write<int32_t>(ptr()->deopt_id_);
2019 writer->Write<uint32_t>(ptr()->state_bits_); 2006 writer->Write<uint32_t>(ptr()->state_bits_);
2020 #if defined(TAG_IC_DATA) 2007 #if defined(TAG_IC_DATA)
2021 writer->Write<int16_t>(ptr()->tag_); 2008 writer->Write<int16_t>(ptr()->tag_);
2022 #endif 2009 #endif
2023 2010
2024 // Write out all the object pointer fields. 2011 // Write out all the object pointer fields.
2025 // In precompiled snapshots, omit the owner field. The owner field may 2012 // In precompiled snapshots, omit the owner field. The owner field may
2026 // refer to a function which was always inlined and no longer needed. 2013 // refer to a function which was always inlined and no longer needed.
2027 SnapshotWriterVisitor visitor(writer, kAsReference); 2014 SnapshotWriterVisitor visitor(writer, kAsReference);
2028 RawObject** toobj = writer->snapshot_code() ? to_precompiled_snapshot() 2015 visitor.VisitPointers(from(), to_snapshot(kind));
2029 : to();
2030 visitor.VisitPointers(from(), toobj);
2031 } 2016 }
2032 2017
2033 2018
2034 RawMegamorphicCache* MegamorphicCache::ReadFrom(SnapshotReader* reader, 2019 RawMegamorphicCache* MegamorphicCache::ReadFrom(SnapshotReader* reader,
2035 intptr_t object_id, 2020 intptr_t object_id,
2036 intptr_t tags, 2021 intptr_t tags,
2037 Snapshot::Kind kind, 2022 Snapshot::Kind kind,
2038 bool as_reference) { 2023 bool as_reference) {
2039 ASSERT(reader->snapshot_code()); 2024 ASSERT(Snapshot::IncludesCode(kind));
2040 ASSERT(kind == Snapshot::kFull); 2025 ASSERT(Snapshot::IsFull(kind));
2041 2026
2042 MegamorphicCache& result = 2027 MegamorphicCache& result =
2043 MegamorphicCache::ZoneHandle(reader->zone(), 2028 MegamorphicCache::ZoneHandle(reader->zone(),
2044 NEW_OBJECT(MegamorphicCache)); 2029 NEW_OBJECT(MegamorphicCache));
2045 reader->AddBackRef(object_id, &result, kIsDeserialized); 2030 reader->AddBackRef(object_id, &result, kIsDeserialized);
2046 2031
2047 result.set_filled_entry_count(reader->Read<int32_t>()); 2032 result.set_filled_entry_count(reader->Read<int32_t>());
2048 2033
2049 // Set all the object fields. 2034 // Set all the object fields.
2050 READ_OBJECT_FIELDS(result, 2035 READ_OBJECT_FIELDS(result,
2051 result.raw()->from(), result.raw()->to(), 2036 result.raw()->from(), result.raw()->to(),
2052 kAsReference); 2037 kAsReference);
2053 2038
2054 return result.raw(); 2039 return result.raw();
2055 } 2040 }
2056 2041
2057 2042
2058 void RawMegamorphicCache::WriteTo(SnapshotWriter* writer, 2043 void RawMegamorphicCache::WriteTo(SnapshotWriter* writer,
2059 intptr_t object_id, 2044 intptr_t object_id,
2060 Snapshot::Kind kind, 2045 Snapshot::Kind kind,
2061 bool as_reference) { 2046 bool as_reference) {
2062 ASSERT(writer->snapshot_code()); 2047 ASSERT(Snapshot::IncludesCode(kind));
2063 ASSERT(kind == Snapshot::kFull); 2048 ASSERT(Snapshot::IsFull(kind));
2064 2049
2065 // Write out the serialization header value for this object. 2050 // Write out the serialization header value for this object.
2066 writer->WriteInlinedObjectHeader(object_id); 2051 writer->WriteInlinedObjectHeader(object_id);
2067 2052
2068 // Write out the class and tags information. 2053 // Write out the class and tags information.
2069 writer->WriteVMIsolateObject(kMegamorphicCacheCid); 2054 writer->WriteVMIsolateObject(kMegamorphicCacheCid);
2070 writer->WriteTags(writer->GetObjectTags(this)); 2055 writer->WriteTags(writer->GetObjectTags(this));
2071 2056
2072 // Write out all the non object fields. 2057 // Write out all the non object fields.
2073 writer->Write<int32_t>(ptr()->filled_entry_count_); 2058 writer->Write<int32_t>(ptr()->filled_entry_count_);
2074 2059
2075 // Write out all the object pointer fields. 2060 // Write out all the object pointer fields.
2076 SnapshotWriterVisitor visitor(writer, kAsReference); 2061 SnapshotWriterVisitor visitor(writer, kAsReference);
2077 visitor.VisitPointers(from(), to()); 2062 visitor.VisitPointers(from(), to());
2078 } 2063 }
2079 2064
2080 2065
2081 RawSubtypeTestCache* SubtypeTestCache::ReadFrom(SnapshotReader* reader, 2066 RawSubtypeTestCache* SubtypeTestCache::ReadFrom(SnapshotReader* reader,
2082 intptr_t object_id, 2067 intptr_t object_id,
2083 intptr_t tags, 2068 intptr_t tags,
2084 Snapshot::Kind kind, 2069 Snapshot::Kind kind,
2085 bool as_reference) { 2070 bool as_reference) {
2086 ASSERT(reader->snapshot_code()); 2071 ASSERT(Snapshot::IncludesCode(kind));
2087 ASSERT(kind == Snapshot::kFull); 2072 ASSERT(Snapshot::IsFull(kind));
2088 2073
2089 SubtypeTestCache& result = 2074 SubtypeTestCache& result =
2090 SubtypeTestCache::ZoneHandle(reader->zone(), 2075 SubtypeTestCache::ZoneHandle(reader->zone(),
2091 NEW_OBJECT(SubtypeTestCache)); 2076 NEW_OBJECT(SubtypeTestCache));
2092 reader->AddBackRef(object_id, &result, kIsDeserialized); 2077 reader->AddBackRef(object_id, &result, kIsDeserialized);
2093 2078
2094 // Set all the object fields. 2079 // Set all the object fields.
2095 // TODO(5411462): Need to assert No GC can happen here, even though 2080 // TODO(5411462): Need to assert No GC can happen here, even though
2096 // allocations may happen. 2081 // allocations may happen.
2097 (*reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsReference); 2082 (*reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsReference);
2098 result.StorePointer(&result.raw_ptr()->cache_, 2083 result.StorePointer(&result.raw_ptr()->cache_,
2099 reader->ArrayHandle()->raw()); 2084 reader->ArrayHandle()->raw());
2100 2085
2101 return result.raw(); 2086 return result.raw();
2102 } 2087 }
2103 2088
2104 2089
2105 void RawSubtypeTestCache::WriteTo(SnapshotWriter* writer, 2090 void RawSubtypeTestCache::WriteTo(SnapshotWriter* writer,
2106 intptr_t object_id, 2091 intptr_t object_id,
2107 Snapshot::Kind kind, 2092 Snapshot::Kind kind,
2108 bool as_reference) { 2093 bool as_reference) {
2109 ASSERT(writer->snapshot_code()); 2094 ASSERT(Snapshot::IncludesCode(kind));
2110 ASSERT(kind == Snapshot::kFull); 2095 ASSERT(Snapshot::IsFull(kind));
2111 2096
2112 // Write out the serialization header value for this object. 2097 // Write out the serialization header value for this object.
2113 writer->WriteInlinedObjectHeader(object_id); 2098 writer->WriteInlinedObjectHeader(object_id);
2114 2099
2115 // Write out the class and tags information. 2100 // Write out the class and tags information.
2116 writer->WriteVMIsolateObject(kSubtypeTestCacheCid); 2101 writer->WriteVMIsolateObject(kSubtypeTestCacheCid);
2117 writer->WriteTags(writer->GetObjectTags(this)); 2102 writer->WriteTags(writer->GetObjectTags(this));
2118 2103
2119 // Write out all the object pointer fields. 2104 // Write out all the object pointer fields.
2120 writer->WriteObjectImpl(ptr()->cache_, kAsReference); 2105 writer->WriteObjectImpl(ptr()->cache_, kAsReference);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 RawInstance* Instance::ReadFrom(SnapshotReader* reader, 2270 RawInstance* Instance::ReadFrom(SnapshotReader* reader,
2286 intptr_t object_id, 2271 intptr_t object_id,
2287 intptr_t tags, 2272 intptr_t tags,
2288 Snapshot::Kind kind, 2273 Snapshot::Kind kind,
2289 bool as_reference) { 2274 bool as_reference) {
2290 ASSERT(reader != NULL); 2275 ASSERT(reader != NULL);
2291 2276
2292 // Create an Instance object or get canonical one if it is a canonical 2277 // Create an Instance object or get canonical one if it is a canonical
2293 // constant. 2278 // constant.
2294 Instance& obj = Instance::ZoneHandle(reader->zone(), Instance::null()); 2279 Instance& obj = Instance::ZoneHandle(reader->zone(), Instance::null());
2295 if (kind == Snapshot::kFull) { 2280 if (Snapshot::IsFull(kind)) {
2296 obj = reader->NewInstance(); 2281 obj = reader->NewInstance();
2297 // Set the canonical bit. 2282 // Set the canonical bit.
2298 if (RawObject::IsCanonical(tags)) { 2283 if (RawObject::IsCanonical(tags)) {
2299 obj.SetCanonical(); 2284 obj.SetCanonical();
2300 } 2285 }
2301 } else { 2286 } else {
2302 obj ^= Object::Allocate(kInstanceCid, 2287 obj ^= Object::Allocate(kInstanceCid,
2303 Instance::InstanceSize(), 2288 Instance::InstanceSize(),
2304 HEAP_SPACE(kind)); 2289 HEAP_SPACE(kind));
2305 if (RawObject::IsCanonical(tags)) { 2290 if (RawObject::IsCanonical(tags)) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 // architecture, if so return the object as a Smi. 2326 // architecture, if so return the object as a Smi.
2342 if (Smi::IsValid(value)) { 2327 if (Smi::IsValid(value)) {
2343 Smi& smi = Smi::ZoneHandle(reader->zone(), 2328 Smi& smi = Smi::ZoneHandle(reader->zone(),
2344 Smi::New(static_cast<intptr_t>(value))); 2329 Smi::New(static_cast<intptr_t>(value)));
2345 reader->AddBackRef(object_id, &smi, kIsDeserialized); 2330 reader->AddBackRef(object_id, &smi, kIsDeserialized);
2346 return smi.raw(); 2331 return smi.raw();
2347 } 2332 }
2348 2333
2349 // Create a Mint object or get canonical one if it is a canonical constant. 2334 // Create a Mint object or get canonical one if it is a canonical constant.
2350 Mint& mint = Mint::ZoneHandle(reader->zone(), Mint::null()); 2335 Mint& mint = Mint::ZoneHandle(reader->zone(), Mint::null());
2351 if (kind == Snapshot::kFull) { 2336 if (Snapshot::IsFull(kind)) {
2352 mint = reader->NewMint(value); 2337 mint = reader->NewMint(value);
2353 // Set the canonical bit. 2338 // Set the canonical bit.
2354 if (RawObject::IsCanonical(tags)) { 2339 if (RawObject::IsCanonical(tags)) {
2355 mint.SetCanonical(); 2340 mint.SetCanonical();
2356 } 2341 }
2357 } else { 2342 } else {
2358 // When reading a script snapshot we need to canonicalize only those object 2343 // When reading a script snapshot we need to canonicalize only those object
2359 // references that are objects from the core library (loaded from a 2344 // references that are objects from the core library (loaded from a
2360 // full snapshot). Objects that are only in the script need not be 2345 // full snapshot). Objects that are only in the script need not be
2361 // canonicalized as they are already canonical. 2346 // canonicalized as they are already canonical.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2403 2388
2404 // Set all the object fields. 2389 // Set all the object fields.
2405 READ_OBJECT_FIELDS(obj, obj.raw()->from(), obj.raw()->to(), kAsInlinedObject); 2390 READ_OBJECT_FIELDS(obj, obj.raw()->from(), obj.raw()->to(), kAsInlinedObject);
2406 2391
2407 // If it is a canonical constant make it one. 2392 // If it is a canonical constant make it one.
2408 // When reading a full snapshot we don't need to canonicalize the object 2393 // When reading a full snapshot we don't need to canonicalize the object
2409 // as it would already be a canonical object. 2394 // as it would already be a canonical object.
2410 // When reading a script snapshot or a message snapshot we always have 2395 // When reading a script snapshot or a message snapshot we always have
2411 // to canonicalize the object. 2396 // to canonicalize the object.
2412 if (RawObject::IsCanonical(tags)) { 2397 if (RawObject::IsCanonical(tags)) {
2413 if (kind == Snapshot::kFull) { 2398 if (Snapshot::IsFull(kind)) {
2414 // Set the canonical bit. 2399 // Set the canonical bit.
2415 obj.SetCanonical(); 2400 obj.SetCanonical();
2416 } else { 2401 } else {
2417 obj ^= obj.CheckAndCanonicalize(reader->thread(), NULL); 2402 obj ^= obj.CheckAndCanonicalize(reader->thread(), NULL);
2418 ASSERT(!obj.IsNull()); 2403 ASSERT(!obj.IsNull());
2419 ASSERT(obj.IsCanonical()); 2404 ASSERT(obj.IsCanonical());
2420 } 2405 }
2421 } 2406 }
2422 return obj.raw(); 2407 return obj.raw();
2423 } 2408 }
(...skipping 23 matching lines...) Expand all
2447 intptr_t tags, 2432 intptr_t tags,
2448 Snapshot::Kind kind, 2433 Snapshot::Kind kind,
2449 bool as_reference) { 2434 bool as_reference) {
2450 ASSERT(reader != NULL); 2435 ASSERT(reader != NULL);
2451 ASSERT(kind != Snapshot::kMessage); 2436 ASSERT(kind != Snapshot::kMessage);
2452 // Read the double value for the object. 2437 // Read the double value for the object.
2453 double value = reader->ReadDouble(); 2438 double value = reader->ReadDouble();
2454 2439
2455 // Create a Double object or get canonical one if it is a canonical constant. 2440 // Create a Double object or get canonical one if it is a canonical constant.
2456 Double& dbl = Double::ZoneHandle(reader->zone(), Double::null()); 2441 Double& dbl = Double::ZoneHandle(reader->zone(), Double::null());
2457 if (kind == Snapshot::kFull) { 2442 if (Snapshot::IsFull(kind)) {
2458 dbl = reader->NewDouble(value); 2443 dbl = reader->NewDouble(value);
2459 // Set the canonical bit. 2444 // Set the canonical bit.
2460 if (RawObject::IsCanonical(tags)) { 2445 if (RawObject::IsCanonical(tags)) {
2461 dbl.SetCanonical(); 2446 dbl.SetCanonical();
2462 } 2447 }
2463 } else { 2448 } else {
2464 // When reading a script snapshot we need to canonicalize only those object 2449 // When reading a script snapshot we need to canonicalize only those object
2465 // references that are objects from the core library (loaded from a 2450 // references that are objects from the core library (loaded from a
2466 // full snapshot). Objects that are only in the script need not be 2451 // full snapshot). Objects that are only in the script need not be
2467 // canonicalized as they are already canonical. 2452 // canonicalized as they are already canonical.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2544 } 2529 }
2545 } 2530 }
2546 } 2531 }
2547 2532
2548 2533
2549 RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader, 2534 RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader,
2550 intptr_t object_id, 2535 intptr_t object_id,
2551 intptr_t tags, 2536 intptr_t tags,
2552 Snapshot::Kind kind, 2537 Snapshot::Kind kind,
2553 bool as_reference) { 2538 bool as_reference) {
2554 if (reader->snapshot_code()) { 2539 if (Snapshot::IncludesCode(kind)) {
2555 ASSERT(kind == Snapshot::kFull); 2540 ASSERT(Snapshot::IsFull(kind));
2556 intptr_t offset = reader->Read<int32_t>(); 2541 intptr_t offset = reader->Read<int32_t>();
2557 String& result = String::ZoneHandle(reader->zone()); 2542 String& result = String::ZoneHandle(reader->zone());
2558 result ^= reader->GetObjectAt(offset); 2543 result ^= reader->GetObjectAt(offset);
2559 reader->AddBackRef(object_id, &result, kIsDeserialized); 2544 reader->AddBackRef(object_id, &result, kIsDeserialized);
2560 return raw(result); 2545 return raw(result);
2561 } 2546 }
2562 // Read the length so that we can determine instance size to allocate. 2547 // Read the length so that we can determine instance size to allocate.
2563 ASSERT(reader != NULL); 2548 ASSERT(reader != NULL);
2564 intptr_t len = reader->ReadSmiValue(); 2549 intptr_t len = reader->ReadSmiValue();
2565 intptr_t hash = reader->ReadSmiValue(); 2550 intptr_t hash = reader->ReadSmiValue();
2566 String& str_obj = String::ZoneHandle(reader->zone(), String::null()); 2551 String& str_obj = String::ZoneHandle(reader->zone(), String::null());
2567 2552
2568 if (kind == Snapshot::kFull) { 2553 if (Snapshot::IsFull(kind)) {
2569 // We currently only expect the Dart mutator to read snapshots. 2554 // We currently only expect the Dart mutator to read snapshots.
2570 reader->isolate()->AssertCurrentThreadIsMutator(); 2555 reader->isolate()->AssertCurrentThreadIsMutator();
2571 ASSERT(Thread::Current()->no_safepoint_scope_depth() != 0); 2556 ASSERT(Thread::Current()->no_safepoint_scope_depth() != 0);
2572 RawOneByteString* obj = reader->NewOneByteString(len); 2557 RawOneByteString* obj = reader->NewOneByteString(len);
2573 str_obj = obj; 2558 str_obj = obj;
2574 if (RawObject::IsCanonical(tags)) { 2559 if (RawObject::IsCanonical(tags)) {
2575 str_obj.SetCanonical(); 2560 str_obj.SetCanonical();
2576 } 2561 }
2577 str_obj.SetHash(hash); 2562 str_obj.SetHash(hash);
2578 if (len > 0) { 2563 if (len > 0) {
(...skipping 14 matching lines...) Expand all
2593 intptr_t object_id, 2578 intptr_t object_id,
2594 intptr_t tags, 2579 intptr_t tags,
2595 Snapshot::Kind kind, 2580 Snapshot::Kind kind,
2596 bool as_reference) { 2581 bool as_reference) {
2597 // Read the length so that we can determine instance size to allocate. 2582 // Read the length so that we can determine instance size to allocate.
2598 ASSERT(reader != NULL); 2583 ASSERT(reader != NULL);
2599 intptr_t len = reader->ReadSmiValue(); 2584 intptr_t len = reader->ReadSmiValue();
2600 intptr_t hash = reader->ReadSmiValue(); 2585 intptr_t hash = reader->ReadSmiValue();
2601 String& str_obj = String::ZoneHandle(reader->zone(), String::null()); 2586 String& str_obj = String::ZoneHandle(reader->zone(), String::null());
2602 2587
2603 if (kind == Snapshot::kFull) { 2588 if (Snapshot::IsFull(kind)) {
2604 RawTwoByteString* obj = reader->NewTwoByteString(len); 2589 RawTwoByteString* obj = reader->NewTwoByteString(len);
2605 str_obj = obj; 2590 str_obj = obj;
2606 if (RawObject::IsCanonical(tags)) { 2591 if (RawObject::IsCanonical(tags)) {
2607 str_obj.SetCanonical(); 2592 str_obj.SetCanonical();
2608 } 2593 }
2609 str_obj.SetHash(hash); 2594 str_obj.SetHash(hash);
2610 NoSafepointScope no_safepoint; 2595 NoSafepointScope no_safepoint;
2611 uint16_t* raw_ptr = (len > 0)? CharAddr(str_obj, 0) : NULL; 2596 uint16_t* raw_ptr = (len > 0)? CharAddr(str_obj, 0) : NULL;
2612 for (intptr_t i = 0; i < len; i++) { 2597 for (intptr_t i = 0; i < len; i++) {
2613 ASSERT(CharAddr(str_obj, i) == raw_ptr); // Will trigger assertions. 2598 ASSERT(CharAddr(str_obj, i) == raw_ptr); // Will trigger assertions.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2659 } 2644 }
2660 } 2645 }
2661 } 2646 }
2662 } 2647 }
2663 2648
2664 2649
2665 void RawOneByteString::WriteTo(SnapshotWriter* writer, 2650 void RawOneByteString::WriteTo(SnapshotWriter* writer,
2666 intptr_t object_id, 2651 intptr_t object_id,
2667 Snapshot::Kind kind, 2652 Snapshot::Kind kind,
2668 bool as_reference) { 2653 bool as_reference) {
2669 if (writer->snapshot_code()) { 2654 if (Snapshot::IncludesCode(kind)) {
2670 ASSERT(writer->snapshot_code()); 2655 ASSERT(Snapshot::IncludesCode(kind));
2671 ASSERT(kind == Snapshot::kFull); 2656 ASSERT(Snapshot::IsFull(kind));
2672 // Assert that hash is computed. 2657 // Assert that hash is computed.
2673 if (ptr()->hash_ == NULL) { 2658 if (ptr()->hash_ == NULL) {
2674 ptr()->hash_ = Smi::New(String::Hash(ptr()->data(), 2659 ptr()->hash_ = Smi::New(String::Hash(ptr()->data(),
2675 Smi::Value(ptr()->length_))); 2660 Smi::Value(ptr()->length_)));
2676 } 2661 }
2677 ASSERT(ptr()->hash_ != NULL); 2662 ASSERT(ptr()->hash_ != NULL);
2678 // Write out the serialization header value for this object. 2663 // Write out the serialization header value for this object.
2679 writer->WriteInlinedObjectHeader(object_id); 2664 writer->WriteInlinedObjectHeader(object_id);
2680 writer->WriteIndexedObject(kOneByteStringCid); 2665 writer->WriteIndexedObject(kOneByteStringCid);
2681 writer->WriteTags(writer->GetObjectTags(this)); 2666 writer->WriteTags(writer->GetObjectTags(this));
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
2831 if (array == NULL) { 2816 if (array == NULL) {
2832 array = &(Array::ZoneHandle( 2817 array = &(Array::ZoneHandle(
2833 reader->zone(), 2818 reader->zone(),
2834 NEW_OBJECT_WITH_LEN_SPACE(ImmutableArray, len, kind))); 2819 NEW_OBJECT_WITH_LEN_SPACE(ImmutableArray, len, kind)));
2835 reader->AddBackRef(object_id, array, state); 2820 reader->AddBackRef(object_id, array, state);
2836 } 2821 }
2837 if (!as_reference) { 2822 if (!as_reference) {
2838 // Read all the individual elements for inlined objects. 2823 // Read all the individual elements for inlined objects.
2839 reader->ArrayReadFrom(object_id, *array, len, tags); 2824 reader->ArrayReadFrom(object_id, *array, len, tags);
2840 if (RawObject::IsCanonical(tags)) { 2825 if (RawObject::IsCanonical(tags)) {
2841 if (kind == Snapshot::kFull) { 2826 if (Snapshot::IsFull(kind)) {
2842 array->SetCanonical(); 2827 array->SetCanonical();
2843 } else { 2828 } else {
2844 *array ^= array->CheckAndCanonicalize(reader->thread(), NULL); 2829 *array ^= array->CheckAndCanonicalize(reader->thread(), NULL);
2845 } 2830 }
2846 } 2831 }
2847 } 2832 }
2848 return raw(*array); 2833 return raw(*array);
2849 } 2834 }
2850 2835
2851 2836
(...skipping 29 matching lines...) Expand all
2881 RawGrowableObjectArray* GrowableObjectArray::ReadFrom(SnapshotReader* reader, 2866 RawGrowableObjectArray* GrowableObjectArray::ReadFrom(SnapshotReader* reader,
2882 intptr_t object_id, 2867 intptr_t object_id,
2883 intptr_t tags, 2868 intptr_t tags,
2884 Snapshot::Kind kind, 2869 Snapshot::Kind kind,
2885 bool as_reference) { 2870 bool as_reference) {
2886 ASSERT(reader != NULL); 2871 ASSERT(reader != NULL);
2887 2872
2888 // Read the length so that we can determine instance size to allocate. 2873 // Read the length so that we can determine instance size to allocate.
2889 GrowableObjectArray& array = GrowableObjectArray::ZoneHandle( 2874 GrowableObjectArray& array = GrowableObjectArray::ZoneHandle(
2890 reader->zone(), GrowableObjectArray::null()); 2875 reader->zone(), GrowableObjectArray::null());
2891 if (kind == Snapshot::kFull) { 2876 if (Snapshot::IsFull(kind)) {
2892 array = reader->NewGrowableObjectArray(); 2877 array = reader->NewGrowableObjectArray();
2893 } else { 2878 } else {
2894 array = GrowableObjectArray::New(0, HEAP_SPACE(kind)); 2879 array = GrowableObjectArray::New(0, HEAP_SPACE(kind));
2895 } 2880 }
2896 reader->AddBackRef(object_id, &array, kIsDeserialized); 2881 reader->AddBackRef(object_id, &array, kIsDeserialized);
2897 2882
2898 // Read type arguments of growable array object. 2883 // Read type arguments of growable array object.
2899 const intptr_t typeargs_offset = 2884 const intptr_t typeargs_offset =
2900 GrowableObjectArray::type_arguments_offset() / kWordSize; 2885 GrowableObjectArray::type_arguments_offset() / kWordSize;
2901 *reader->TypeArgumentsHandle() ^= 2886 *reader->TypeArgumentsHandle() ^=
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2940 2925
2941 RawLinkedHashMap* LinkedHashMap::ReadFrom(SnapshotReader* reader, 2926 RawLinkedHashMap* LinkedHashMap::ReadFrom(SnapshotReader* reader,
2942 intptr_t object_id, 2927 intptr_t object_id,
2943 intptr_t tags, 2928 intptr_t tags,
2944 Snapshot::Kind kind, 2929 Snapshot::Kind kind,
2945 bool as_reference) { 2930 bool as_reference) {
2946 ASSERT(reader != NULL); 2931 ASSERT(reader != NULL);
2947 2932
2948 LinkedHashMap& map = LinkedHashMap::ZoneHandle( 2933 LinkedHashMap& map = LinkedHashMap::ZoneHandle(
2949 reader->zone(), LinkedHashMap::null()); 2934 reader->zone(), LinkedHashMap::null());
2950 if ((kind == Snapshot::kFull && !reader->snapshot_code()) || 2935 if ((Snapshot::IsFull(kind) && !Snapshot::IncludesCode(kind)) ||
2951 kind == Snapshot::kScript) { 2936 kind == Snapshot::kScript) {
2952 // The immutable maps that seed map literals are not yet VM-internal, so 2937 // The immutable maps that seed map literals are not yet VM-internal, so
2953 // we don't reach this. 2938 // we don't reach this.
2954 UNREACHABLE(); 2939 UNREACHABLE();
2955 } else { 2940 } else {
2956 // Since the map might contain itself as a key or value, allocate first. 2941 // Since the map might contain itself as a key or value, allocate first.
2957 if (kind == Snapshot::kFull) { 2942 if (Snapshot::IsFull(kind)) {
2958 map = reader->NewLinkedHashMap(); 2943 map = reader->NewLinkedHashMap();
2959 } else { 2944 } else {
2960 map = LinkedHashMap::NewUninitialized(HEAP_SPACE(kind)); 2945 map = LinkedHashMap::NewUninitialized(HEAP_SPACE(kind));
2961 } 2946 }
2962 } 2947 }
2963 reader->AddBackRef(object_id, &map, kIsDeserialized); 2948 reader->AddBackRef(object_id, &map, kIsDeserialized);
2964 2949
2965 // Read the type arguments. 2950 // Read the type arguments.
2966 const intptr_t typeargs_offset = 2951 const intptr_t typeargs_offset =
2967 GrowableObjectArray::type_arguments_offset() / kWordSize; 2952 GrowableObjectArray::type_arguments_offset() / kWordSize;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2999 data.SetAt(i, *reader->PassiveObjectHandle()); 2984 data.SetAt(i, *reader->PassiveObjectHandle());
3000 } 2985 }
3001 return map.raw(); 2986 return map.raw();
3002 } 2987 }
3003 2988
3004 2989
3005 void RawLinkedHashMap::WriteTo(SnapshotWriter* writer, 2990 void RawLinkedHashMap::WriteTo(SnapshotWriter* writer,
3006 intptr_t object_id, 2991 intptr_t object_id,
3007 Snapshot::Kind kind, 2992 Snapshot::Kind kind,
3008 bool as_reference) { 2993 bool as_reference) {
3009 if ((kind == Snapshot::kFull && !writer->snapshot_code()) || 2994 if ((Snapshot::IsFull(kind) && !Snapshot::IncludesCode(kind)) ||
3010 kind == Snapshot::kScript) { 2995 kind == Snapshot::kScript) {
3011 // The immutable maps that seed map literals are not yet VM-internal, so 2996 // The immutable maps that seed map literals are not yet VM-internal, so
3012 // we don't reach this. 2997 // we don't reach this.
3013 } 2998 }
3014 ASSERT(writer != NULL); 2999 ASSERT(writer != NULL);
3015 3000
3016 // Write out the serialization header value for this object. 3001 // Write out the serialization header value for this object.
3017 writer->WriteInlinedObjectHeader(object_id); 3002 writer->WriteInlinedObjectHeader(object_id);
3018 3003
3019 // Write out the class and tags information. 3004 // Write out the class and tags information.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3062 ASSERT(reader != NULL); 3047 ASSERT(reader != NULL);
3063 // Read the values. 3048 // Read the values.
3064 float value0 = reader->Read<float>(); 3049 float value0 = reader->Read<float>();
3065 float value1 = reader->Read<float>(); 3050 float value1 = reader->Read<float>();
3066 float value2 = reader->Read<float>(); 3051 float value2 = reader->Read<float>();
3067 float value3 = reader->Read<float>(); 3052 float value3 = reader->Read<float>();
3068 3053
3069 // Create a Float32x4 object. 3054 // Create a Float32x4 object.
3070 Float32x4& simd = Float32x4::ZoneHandle(reader->zone(), 3055 Float32x4& simd = Float32x4::ZoneHandle(reader->zone(),
3071 Float32x4::null()); 3056 Float32x4::null());
3072 if (kind == Snapshot::kFull) { 3057 if (Snapshot::IsFull(kind)) {
3073 simd = reader->NewFloat32x4(value0, value1, value2, value3); 3058 simd = reader->NewFloat32x4(value0, value1, value2, value3);
3074 } else { 3059 } else {
3075 simd = Float32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind)); 3060 simd = Float32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind));
3076 } 3061 }
3077 reader->AddBackRef(object_id, &simd, kIsDeserialized); 3062 reader->AddBackRef(object_id, &simd, kIsDeserialized);
3078 return simd.raw(); 3063 return simd.raw();
3079 } 3064 }
3080 3065
3081 3066
3082 void RawFloat32x4::WriteTo(SnapshotWriter* writer, 3067 void RawFloat32x4::WriteTo(SnapshotWriter* writer,
(...skipping 25 matching lines...) Expand all
3108 ASSERT(reader != NULL); 3093 ASSERT(reader != NULL);
3109 // Read the values. 3094 // Read the values.
3110 uint32_t value0 = reader->Read<uint32_t>(); 3095 uint32_t value0 = reader->Read<uint32_t>();
3111 uint32_t value1 = reader->Read<uint32_t>(); 3096 uint32_t value1 = reader->Read<uint32_t>();
3112 uint32_t value2 = reader->Read<uint32_t>(); 3097 uint32_t value2 = reader->Read<uint32_t>();
3113 uint32_t value3 = reader->Read<uint32_t>(); 3098 uint32_t value3 = reader->Read<uint32_t>();
3114 3099
3115 // Create a Float32x4 object. 3100 // Create a Float32x4 object.
3116 Int32x4& simd = Int32x4::ZoneHandle(reader->zone(), Int32x4::null()); 3101 Int32x4& simd = Int32x4::ZoneHandle(reader->zone(), Int32x4::null());
3117 3102
3118 if (kind == Snapshot::kFull) { 3103 if (Snapshot::IsFull(kind)) {
3119 simd = reader->NewInt32x4(value0, value1, value2, value3); 3104 simd = reader->NewInt32x4(value0, value1, value2, value3);
3120 } else { 3105 } else {
3121 simd = Int32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind)); 3106 simd = Int32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind));
3122 } 3107 }
3123 reader->AddBackRef(object_id, &simd, kIsDeserialized); 3108 reader->AddBackRef(object_id, &simd, kIsDeserialized);
3124 return simd.raw(); 3109 return simd.raw();
3125 } 3110 }
3126 3111
3127 3112
3128 void RawInt32x4::WriteTo(SnapshotWriter* writer, 3113 void RawInt32x4::WriteTo(SnapshotWriter* writer,
(...skipping 23 matching lines...) Expand all
3152 Snapshot::Kind kind, 3137 Snapshot::Kind kind,
3153 bool as_reference) { 3138 bool as_reference) {
3154 ASSERT(reader != NULL); 3139 ASSERT(reader != NULL);
3155 // Read the values. 3140 // Read the values.
3156 double value0 = reader->Read<double>(); 3141 double value0 = reader->Read<double>();
3157 double value1 = reader->Read<double>(); 3142 double value1 = reader->Read<double>();
3158 3143
3159 // Create a Float64x2 object. 3144 // Create a Float64x2 object.
3160 Float64x2& simd = Float64x2::ZoneHandle(reader->zone(), 3145 Float64x2& simd = Float64x2::ZoneHandle(reader->zone(),
3161 Float64x2::null()); 3146 Float64x2::null());
3162 if (kind == Snapshot::kFull) { 3147 if (Snapshot::IsFull(kind)) {
3163 simd = reader->NewFloat64x2(value0, value1); 3148 simd = reader->NewFloat64x2(value0, value1);
3164 } else { 3149 } else {
3165 simd = Float64x2::New(value0, value1, HEAP_SPACE(kind)); 3150 simd = Float64x2::New(value0, value1, HEAP_SPACE(kind));
3166 } 3151 }
3167 reader->AddBackRef(object_id, &simd, kIsDeserialized); 3152 reader->AddBackRef(object_id, &simd, kIsDeserialized);
3168 return simd.raw(); 3153 return simd.raw();
3169 } 3154 }
3170 3155
3171 3156
3172 void RawFloat64x2::WriteTo(SnapshotWriter* writer, 3157 void RawFloat64x2::WriteTo(SnapshotWriter* writer,
(...skipping 24 matching lines...) Expand all
3197 RawTypedData* TypedData::ReadFrom(SnapshotReader* reader, 3182 RawTypedData* TypedData::ReadFrom(SnapshotReader* reader,
3198 intptr_t object_id, 3183 intptr_t object_id,
3199 intptr_t tags, 3184 intptr_t tags,
3200 Snapshot::Kind kind, 3185 Snapshot::Kind kind,
3201 bool as_reference) { 3186 bool as_reference) {
3202 ASSERT(reader != NULL); 3187 ASSERT(reader != NULL);
3203 3188
3204 intptr_t cid = RawObject::ClassIdTag::decode(tags); 3189 intptr_t cid = RawObject::ClassIdTag::decode(tags);
3205 intptr_t len = reader->ReadSmiValue(); 3190 intptr_t len = reader->ReadSmiValue();
3206 TypedData& result = TypedData::ZoneHandle(reader->zone(), 3191 TypedData& result = TypedData::ZoneHandle(reader->zone(),
3207 (kind == Snapshot::kFull) ? reader->NewTypedData(cid, len) 3192 (Snapshot::IsFull(kind)) ? reader->NewTypedData(cid, len)
3208 : TypedData::New(cid, len, HEAP_SPACE(kind))); 3193 : TypedData::New(cid, len, HEAP_SPACE(kind)));
3209 reader->AddBackRef(object_id, &result, kIsDeserialized); 3194 reader->AddBackRef(object_id, &result, kIsDeserialized);
3210 3195
3211 // Setup the array elements. 3196 // Setup the array elements.
3212 intptr_t element_size = ElementSizeInBytes(cid); 3197 intptr_t element_size = ElementSizeInBytes(cid);
3213 intptr_t length_in_bytes = len * element_size; 3198 intptr_t length_in_bytes = len * element_size;
3214 switch (cid) { 3199 switch (cid) {
3215 case kTypedDataInt8ArrayCid: 3200 case kTypedDataInt8ArrayCid:
3216 case kTypedDataUint8ArrayCid: 3201 case kTypedDataUint8ArrayCid:
3217 case kTypedDataUint8ClampedArrayCid: { 3202 case kTypedDataUint8ClampedArrayCid: {
(...skipping 28 matching lines...) Expand all
3246 break; 3231 break;
3247 default: 3232 default:
3248 UNREACHABLE(); 3233 UNREACHABLE();
3249 } 3234 }
3250 // If it is a canonical constant make it one. 3235 // If it is a canonical constant make it one.
3251 // When reading a full snapshot we don't need to canonicalize the object 3236 // When reading a full snapshot we don't need to canonicalize the object
3252 // as it would already be a canonical object. 3237 // as it would already be a canonical object.
3253 // When reading a script snapshot or a message snapshot we always have 3238 // When reading a script snapshot or a message snapshot we always have
3254 // to canonicalize the object. 3239 // to canonicalize the object.
3255 if (RawObject::IsCanonical(tags)) { 3240 if (RawObject::IsCanonical(tags)) {
3256 if (kind == Snapshot::kFull) { 3241 if (Snapshot::IsFull(kind)) {
3257 // Set the canonical bit. 3242 // Set the canonical bit.
3258 result.SetCanonical(); 3243 result.SetCanonical();
3259 } else { 3244 } else {
3260 result ^= result.CheckAndCanonicalize(reader->thread(), NULL); 3245 result ^= result.CheckAndCanonicalize(reader->thread(), NULL);
3261 ASSERT(!result.IsNull()); 3246 ASSERT(!result.IsNull());
3262 ASSERT(result.IsCanonical()); 3247 ASSERT(result.IsCanonical());
3263 } 3248 }
3264 } 3249 }
3265 return result.raw(); 3250 return result.raw();
3266 } 3251 }
3267 #undef TYPED_DATA_READ 3252 #undef TYPED_DATA_READ
3268 3253
3269 3254
3270 RawExternalTypedData* ExternalTypedData::ReadFrom(SnapshotReader* reader, 3255 RawExternalTypedData* ExternalTypedData::ReadFrom(SnapshotReader* reader,
3271 intptr_t object_id, 3256 intptr_t object_id,
3272 intptr_t tags, 3257 intptr_t tags,
3273 Snapshot::Kind kind, 3258 Snapshot::Kind kind,
3274 bool as_reference) { 3259 bool as_reference) {
3275 ASSERT(kind != Snapshot::kFull); 3260 ASSERT(!Snapshot::IsFull(kind));
3276 intptr_t cid = RawObject::ClassIdTag::decode(tags); 3261 intptr_t cid = RawObject::ClassIdTag::decode(tags);
3277 intptr_t length = reader->ReadSmiValue(); 3262 intptr_t length = reader->ReadSmiValue();
3278 uint8_t* data = reinterpret_cast<uint8_t*>(reader->ReadRawPointerValue()); 3263 uint8_t* data = reinterpret_cast<uint8_t*>(reader->ReadRawPointerValue());
3279 ExternalTypedData& obj = ExternalTypedData::ZoneHandle( 3264 ExternalTypedData& obj = ExternalTypedData::ZoneHandle(
3280 ExternalTypedData::New(cid, data, length)); 3265 ExternalTypedData::New(cid, data, length));
3281 reader->AddBackRef(object_id, &obj, kIsDeserialized); 3266 reader->AddBackRef(object_id, &obj, kIsDeserialized);
3282 void* peer = reinterpret_cast<void*>(reader->ReadRawPointerValue()); 3267 void* peer = reinterpret_cast<void*>(reader->ReadRawPointerValue());
3283 Dart_WeakPersistentHandleFinalizer callback = 3268 Dart_WeakPersistentHandleFinalizer callback =
3284 reinterpret_cast<Dart_WeakPersistentHandleFinalizer>( 3269 reinterpret_cast<Dart_WeakPersistentHandleFinalizer>(
3285 reader->ReadRawPointerValue()); 3270 reader->ReadRawPointerValue());
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
3475 UNREACHABLE(); 3460 UNREACHABLE();
3476 } 3461 }
3477 } 3462 }
3478 3463
3479 3464
3480 RawSendPort* SendPort::ReadFrom(SnapshotReader* reader, 3465 RawSendPort* SendPort::ReadFrom(SnapshotReader* reader,
3481 intptr_t object_id, 3466 intptr_t object_id,
3482 intptr_t tags, 3467 intptr_t tags,
3483 Snapshot::Kind kind, 3468 Snapshot::Kind kind,
3484 bool as_reference) { 3469 bool as_reference) {
3485 ASSERT(kind == Snapshot::kMessage || reader->snapshot_code()); 3470 ASSERT(kind == Snapshot::kMessage || Snapshot::IncludesCode(kind));
3486 3471
3487 uint64_t id = reader->Read<uint64_t>(); 3472 uint64_t id = reader->Read<uint64_t>();
3488 uint64_t origin_id = reader->Read<uint64_t>(); 3473 uint64_t origin_id = reader->Read<uint64_t>();
3489 3474
3490 SendPort& result = SendPort::ZoneHandle(reader->zone()); 3475 SendPort& result = SendPort::ZoneHandle(reader->zone());
3491 if (reader->snapshot_code()) { 3476 if (Snapshot::IncludesCode(kind)) {
3492 // TODO(rmacnak): Reset fields in precompiled snapshots and assert 3477 // TODO(rmacnak): Reset fields in precompiled snapshots and assert
3493 // this is unreachable. 3478 // this is unreachable.
3494 } else { 3479 } else {
3495 result = SendPort::New(id, origin_id); 3480 result = SendPort::New(id, origin_id);
3496 } 3481 }
3497 reader->AddBackRef(object_id, &result, kIsDeserialized); 3482 reader->AddBackRef(object_id, &result, kIsDeserialized);
3498 return result.raw(); 3483 return result.raw();
3499 } 3484 }
3500 3485
3501 3486
(...skipping 11 matching lines...) Expand all
3513 writer->Write<uint64_t>(ptr()->id_); 3498 writer->Write<uint64_t>(ptr()->id_);
3514 writer->Write<uint64_t>(ptr()->origin_id_); 3499 writer->Write<uint64_t>(ptr()->origin_id_);
3515 } 3500 }
3516 3501
3517 3502
3518 RawStacktrace* Stacktrace::ReadFrom(SnapshotReader* reader, 3503 RawStacktrace* Stacktrace::ReadFrom(SnapshotReader* reader,
3519 intptr_t object_id, 3504 intptr_t object_id,
3520 intptr_t tags, 3505 intptr_t tags,
3521 Snapshot::Kind kind, 3506 Snapshot::Kind kind,
3522 bool as_reference) { 3507 bool as_reference) {
3523 if (kind == Snapshot::kFull) { 3508 if (Snapshot::IsFull(kind)) {
3524 Stacktrace& result = Stacktrace::ZoneHandle(reader->zone(), 3509 Stacktrace& result = Stacktrace::ZoneHandle(reader->zone(),
3525 reader->NewStacktrace()); 3510 reader->NewStacktrace());
3526 reader->AddBackRef(object_id, &result, kIsDeserialized); 3511 reader->AddBackRef(object_id, &result, kIsDeserialized);
3527 3512
3528 bool expand_inlined = reader->Read<bool>(); 3513 bool expand_inlined = reader->Read<bool>();
3529 result.set_expand_inlined(expand_inlined); 3514 result.set_expand_inlined(expand_inlined);
3530 3515
3531 // Set all the object fields. 3516 // Set all the object fields.
3532 READ_OBJECT_FIELDS(result, 3517 READ_OBJECT_FIELDS(result,
3533 result.raw()->from(), result.raw()->to(), 3518 result.raw()->from(), result.raw()->to(),
3534 kAsReference); 3519 kAsReference);
3535 3520
3536 return result.raw(); 3521 return result.raw();
3537 } 3522 }
3538 UNREACHABLE(); // Stacktraces are not sent in a snapshot. 3523 UNREACHABLE(); // Stacktraces are not sent in a snapshot.
3539 return Stacktrace::null(); 3524 return Stacktrace::null();
3540 } 3525 }
3541 3526
3542 3527
3543 void RawStacktrace::WriteTo(SnapshotWriter* writer, 3528 void RawStacktrace::WriteTo(SnapshotWriter* writer,
3544 intptr_t object_id, 3529 intptr_t object_id,
3545 Snapshot::Kind kind, 3530 Snapshot::Kind kind,
3546 bool as_reference) { 3531 bool as_reference) {
3547 if (kind == Snapshot::kFull) { 3532 if (Snapshot::IsFull(kind)) {
3548 ASSERT(writer != NULL); 3533 ASSERT(writer != NULL);
3549 ASSERT(this == Isolate::Current()->object_store()-> 3534 ASSERT(this == Isolate::Current()->object_store()->
3550 preallocated_stack_trace()); 3535 preallocated_stack_trace());
3551 3536
3552 // Write out the serialization header value for this object. 3537 // Write out the serialization header value for this object.
3553 writer->WriteInlinedObjectHeader(object_id); 3538 writer->WriteInlinedObjectHeader(object_id);
3554 3539
3555 // Write out the class and tags information. 3540 // Write out the class and tags information.
3556 writer->WriteIndexedObject(kStacktraceCid); 3541 writer->WriteIndexedObject(kStacktraceCid);
3557 writer->WriteTags(writer->GetObjectTags(this)); 3542 writer->WriteTags(writer->GetObjectTags(this));
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
3710 // We do not allow objects with native fields in an isolate message. 3695 // We do not allow objects with native fields in an isolate message.
3711 writer->SetWriteException(Exceptions::kArgument, 3696 writer->SetWriteException(Exceptions::kArgument,
3712 "Illegal argument in isolate message" 3697 "Illegal argument in isolate message"
3713 " : (object is a UserTag)"); 3698 " : (object is a UserTag)");
3714 } else { 3699 } else {
3715 UNREACHABLE(); 3700 UNREACHABLE();
3716 } 3701 }
3717 } 3702 }
3718 3703
3719 } // namespace dart 3704 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698