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

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: 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
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() 868 RawObject** toobj = Snapshot::IncludesCode(kind)
869 ? field.raw()->to_precompiled_snapshot() 869 ? field.raw()->to_precompiled_snapshot()
870 : field.raw()->to(); 870 : field.raw()->to();
siva 2016/04/26 22:27:47 Why not add a to_snapshot(kind) function here to f
rmacnak 2016/04/26 23:38:23 Done.
871 READ_OBJECT_FIELDS(field, 871 READ_OBJECT_FIELDS(field,
872 field.raw()->from(), toobj, 872 field.raw()->from(), toobj,
873 kAsReference); 873 kAsReference);
874 874
875 if (!FLAG_use_field_guards) { 875 if (!FLAG_use_field_guards) {
876 field.set_guarded_cid(kDynamicCid); 876 field.set_guarded_cid(kDynamicCid);
877 field.set_is_nullable(true); 877 field.set_is_nullable(true);
878 field.set_guarded_list_length(Field::kNoFixedLength); 878 field.set_guarded_list_length(Field::kNoFixedLength);
879 field.set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset); 879 field.set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset);
880 } else { 880 } else {
881 field.InitializeGuardedListLengthInObjectOffset(); 881 field.InitializeGuardedListLengthInObjectOffset();
882 } 882 }
883 883
884 return field.raw(); 884 return field.raw();
885 } 885 }
886 886
887 887
888 void RawField::WriteTo(SnapshotWriter* writer, 888 void RawField::WriteTo(SnapshotWriter* writer,
889 intptr_t object_id, 889 intptr_t object_id,
890 Snapshot::Kind kind, 890 Snapshot::Kind kind,
891 bool as_reference) { 891 bool as_reference) {
892 ASSERT(writer != NULL); 892 ASSERT(writer != NULL);
893 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 893 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
894 894
895 // Write out the serialization header value for this object. 895 // Write out the serialization header value for this object.
896 writer->WriteInlinedObjectHeader(object_id); 896 writer->WriteInlinedObjectHeader(object_id);
897 897
898 // Write out the class and tags information. 898 // Write out the class and tags information.
899 writer->WriteVMIsolateObject(kFieldCid); 899 writer->WriteVMIsolateObject(kFieldCid);
900 writer->WriteTags(writer->GetObjectTags(this)); 900 writer->WriteTags(writer->GetObjectTags(this));
901 901
902 // Write out all the non object fields. 902 // Write out all the non object fields.
903 if (!writer->snapshot_code()) { 903 if (!Snapshot::IncludesCode(kind)) {
904 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode()); 904 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode());
905 writer->Write<int32_t>(ptr()->guarded_cid_); 905 writer->Write<int32_t>(ptr()->guarded_cid_);
906 writer->Write<int32_t>(ptr()->is_nullable_); 906 writer->Write<int32_t>(ptr()->is_nullable_);
907 } 907 }
908 writer->Write<uint8_t>(ptr()->kind_bits_); 908 writer->Write<uint8_t>(ptr()->kind_bits_);
909 909
910 // Write out the name. 910 // Write out the name.
911 writer->WriteObjectImpl(ptr()->name_, kAsReference); 911 writer->WriteObjectImpl(ptr()->name_, kAsReference);
912 // Write out the owner. 912 // Write out the owner.
913 writer->WriteObjectImpl(ptr()->owner_, kAsReference); 913 writer->WriteObjectImpl(ptr()->owner_, kAsReference);
914 // Write out the type. 914 // Write out the type.
915 writer->WriteObjectImpl(ptr()->type_, kAsReference); 915 writer->WriteObjectImpl(ptr()->type_, kAsReference);
916 // Write out the initial static value or field offset. 916 // Write out the initial static value or field offset.
917 if (Field::StaticBit::decode(ptr()->kind_bits_)) { 917 if (Field::StaticBit::decode(ptr()->kind_bits_)) {
918 if (writer->snapshot_code()) { 918 if (Snapshot::IncludesCode(kind)) {
919 // For precompiled static fields, the value was already reset and 919 // For precompiled static fields, the value was already reset and
920 // initializer_ now contains a Function. 920 // initializer_ now contains a Function.
921 writer->WriteObjectImpl(ptr()->value_.static_value_, kAsReference); 921 writer->WriteObjectImpl(ptr()->value_.static_value_, kAsReference);
922 } else { 922 } else {
923 // Otherwise, for static fields we write out the initial static value. 923 // Otherwise, for static fields we write out the initial static value.
924 writer->WriteObjectImpl(ptr()->initializer_.saved_value_, kAsReference); 924 writer->WriteObjectImpl(ptr()->initializer_.saved_value_, kAsReference);
925 } 925 }
926 } else { 926 } else {
927 writer->WriteObjectImpl(ptr()->value_.offset_, kAsReference); 927 writer->WriteObjectImpl(ptr()->value_.offset_, kAsReference);
928 } 928 }
929 // Write out the initializer function or saved initial value. 929 // Write out the initializer function or saved initial value.
930 if (writer->snapshot_code()) { 930 if (Snapshot::IncludesCode(kind)) {
931 writer->WriteObjectImpl(ptr()->initializer_.precompiled_, kAsReference); 931 writer->WriteObjectImpl(ptr()->initializer_.precompiled_, kAsReference);
932 } else { 932 } else {
933 writer->WriteObjectImpl(ptr()->initializer_.saved_value_, kAsReference); 933 writer->WriteObjectImpl(ptr()->initializer_.saved_value_, kAsReference);
934 } 934 }
935 if (!writer->snapshot_code()) { 935 if (!Snapshot::IncludesCode(kind)) {
936 // Write out the dependent code. 936 // Write out the dependent code.
937 writer->WriteObjectImpl(ptr()->dependent_code_, kAsReference); 937 writer->WriteObjectImpl(ptr()->dependent_code_, kAsReference);
938 // Write out the guarded list length. 938 // Write out the guarded list length.
939 writer->WriteObjectImpl(ptr()->guarded_list_length_, kAsReference); 939 writer->WriteObjectImpl(ptr()->guarded_list_length_, kAsReference);
940 } 940 }
941 } 941 }
942 942
943 943
944 RawLiteralToken* LiteralToken::ReadFrom(SnapshotReader* reader, 944 RawLiteralToken* LiteralToken::ReadFrom(SnapshotReader* reader,
945 intptr_t object_id, 945 intptr_t object_id,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 visitor.VisitPointers(from(), to()); 989 visitor.VisitPointers(from(), to());
990 } 990 }
991 991
992 992
993 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, 993 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader,
994 intptr_t object_id, 994 intptr_t object_id,
995 intptr_t tags, 995 intptr_t tags,
996 Snapshot::Kind kind, 996 Snapshot::Kind kind,
997 bool as_reference) { 997 bool as_reference) {
998 ASSERT(reader != NULL); 998 ASSERT(reader != NULL);
999 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 999 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
1000 1000
1001 // Read the length so that we can determine number of tokens to read. 1001 // Read the length so that we can determine number of tokens to read.
1002 intptr_t len = reader->ReadSmiValue(); 1002 intptr_t len = reader->ReadSmiValue();
1003 1003
1004 // Create the token stream object. 1004 // Create the token stream object.
1005 TokenStream& token_stream = TokenStream::ZoneHandle( 1005 TokenStream& token_stream = TokenStream::ZoneHandle(
1006 reader->zone(), NEW_OBJECT_WITH_LEN(TokenStream, len)); 1006 reader->zone(), NEW_OBJECT_WITH_LEN(TokenStream, len));
1007 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); 1007 reader->AddBackRef(object_id, &token_stream, kIsDeserialized);
1008 1008
1009 // Read the stream of tokens into the TokenStream object for script 1009 // Read the stream of tokens into the TokenStream object for script
(...skipping 13 matching lines...) Expand all
1023 1023
1024 return token_stream.raw(); 1024 return token_stream.raw();
1025 } 1025 }
1026 1026
1027 1027
1028 void RawTokenStream::WriteTo(SnapshotWriter* writer, 1028 void RawTokenStream::WriteTo(SnapshotWriter* writer,
1029 intptr_t object_id, 1029 intptr_t object_id,
1030 Snapshot::Kind kind, 1030 Snapshot::Kind kind,
1031 bool as_reference) { 1031 bool as_reference) {
1032 ASSERT(writer != NULL); 1032 ASSERT(writer != NULL);
1033 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1033 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
1034 1034
1035 // Write out the serialization header value for this object. 1035 // Write out the serialization header value for this object.
1036 writer->WriteInlinedObjectHeader(object_id); 1036 writer->WriteInlinedObjectHeader(object_id);
1037 1037
1038 // Write out the class and tags information. 1038 // Write out the class and tags information.
1039 writer->WriteVMIsolateObject(kTokenStreamCid); 1039 writer->WriteVMIsolateObject(kTokenStreamCid);
1040 writer->WriteTags(writer->GetObjectTags(this)); 1040 writer->WriteTags(writer->GetObjectTags(this));
1041 1041
1042 // Write out the length field and the token stream. 1042 // Write out the length field and the token stream.
1043 RawExternalTypedData* stream = ptr()->stream_; 1043 RawExternalTypedData* stream = ptr()->stream_;
1044 intptr_t len = Smi::Value(stream->ptr()->length_); 1044 intptr_t len = Smi::Value(stream->ptr()->length_);
1045 writer->Write<RawObject*>(stream->ptr()->length_); 1045 writer->Write<RawObject*>(stream->ptr()->length_);
1046 writer->WriteBytes(stream->ptr()->data_, len); 1046 writer->WriteBytes(stream->ptr()->data_, len);
1047 1047
1048 // Write out the literal/identifier token array. 1048 // Write out the literal/identifier token array.
1049 writer->WriteObjectImpl(ptr()->token_objects_, kAsInlinedObject); 1049 writer->WriteObjectImpl(ptr()->token_objects_, kAsInlinedObject);
1050 // Write out the private key in use by the token stream. 1050 // Write out the private key in use by the token stream.
1051 writer->WriteObjectImpl(ptr()->private_key_, kAsInlinedObject); 1051 writer->WriteObjectImpl(ptr()->private_key_, kAsInlinedObject);
1052 } 1052 }
1053 1053
1054 1054
1055 RawScript* Script::ReadFrom(SnapshotReader* reader, 1055 RawScript* Script::ReadFrom(SnapshotReader* reader,
1056 intptr_t object_id, 1056 intptr_t object_id,
1057 intptr_t tags, 1057 intptr_t tags,
1058 Snapshot::Kind kind, 1058 Snapshot::Kind kind,
1059 bool as_reference) { 1059 bool as_reference) {
1060 ASSERT(reader != NULL); 1060 ASSERT(reader != NULL);
1061 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1061 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
1062 1062
1063 // Allocate script object. 1063 // Allocate script object.
1064 Script& script = Script::ZoneHandle(reader->zone(), NEW_OBJECT(Script)); 1064 Script& script = Script::ZoneHandle(reader->zone(), NEW_OBJECT(Script));
1065 reader->AddBackRef(object_id, &script, kIsDeserialized); 1065 reader->AddBackRef(object_id, &script, kIsDeserialized);
1066 1066
1067 script.StoreNonPointer(&script.raw_ptr()->line_offset_, 1067 script.StoreNonPointer(&script.raw_ptr()->line_offset_,
1068 reader->Read<int32_t>()); 1068 reader->Read<int32_t>());
1069 script.StoreNonPointer(&script.raw_ptr()->col_offset_, 1069 script.StoreNonPointer(&script.raw_ptr()->col_offset_,
1070 reader->Read<int32_t>()); 1070 reader->Read<int32_t>());
1071 script.StoreNonPointer(&script.raw_ptr()->kind_, 1071 script.StoreNonPointer(&script.raw_ptr()->kind_,
1072 reader->Read<int8_t>()); 1072 reader->Read<int8_t>());
1073 1073
1074 *reader->StringHandle() ^= String::null(); 1074 *reader->StringHandle() ^= String::null();
1075 script.set_source(*reader->StringHandle()); 1075 script.set_source(*reader->StringHandle());
1076 *reader->StreamHandle() ^= TokenStream::null(); 1076 *reader->StreamHandle() ^= TokenStream::null();
1077 script.set_tokens(*reader->StreamHandle()); 1077 script.set_tokens(*reader->StreamHandle());
1078 1078
1079 // Set all the object fields. 1079 // Set all the object fields.
1080 // TODO(5411462): Need to assert No GC can happen here, even though 1080 // TODO(5411462): Need to assert No GC can happen here, even though
1081 // allocations may happen. 1081 // allocations may happen.
1082 RawObject** toobj = reader->snapshot_code() 1082 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++) { 1083 for (intptr_t i = 0; i <= num_flds; i++) {
1087 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); 1084 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference);
1088 script.StorePointer((script.raw()->from() + i), 1085 script.StorePointer((script.raw()->from() + i),
1089 reader->PassiveObjectHandle()->raw()); 1086 reader->PassiveObjectHandle()->raw());
1090 } 1087 }
1091 1088
1092 return script.raw(); 1089 return script.raw();
1093 } 1090 }
1094 1091
1095 1092
1096 void RawScript::WriteTo(SnapshotWriter* writer, 1093 void RawScript::WriteTo(SnapshotWriter* writer,
1097 intptr_t object_id, 1094 intptr_t object_id,
1098 Snapshot::Kind kind, 1095 Snapshot::Kind kind,
1099 bool as_reference) { 1096 bool as_reference) {
1100 ASSERT(writer != NULL); 1097 ASSERT(writer != NULL);
1101 ASSERT(tokens_ != TokenStream::null()); 1098 ASSERT(tokens_ != TokenStream::null());
1102 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1099 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
1103 1100
1104 // Write out the serialization header value for this object. 1101 // Write out the serialization header value for this object.
1105 writer->WriteInlinedObjectHeader(object_id); 1102 writer->WriteInlinedObjectHeader(object_id);
1106 1103
1107 // Write out the class and tags information. 1104 // Write out the class and tags information.
1108 writer->WriteVMIsolateObject(kScriptCid); 1105 writer->WriteVMIsolateObject(kScriptCid);
1109 writer->WriteTags(writer->GetObjectTags(this)); 1106 writer->WriteTags(writer->GetObjectTags(this));
1110 1107
1111 // Write out all the non object fields. 1108 // Write out all the non object fields.
1112 writer->Write<int32_t>(ptr()->line_offset_); 1109 writer->Write<int32_t>(ptr()->line_offset_);
1113 writer->Write<int32_t>(ptr()->col_offset_); 1110 writer->Write<int32_t>(ptr()->col_offset_);
1114 writer->Write<int8_t>(ptr()->kind_); 1111 writer->Write<int8_t>(ptr()->kind_);
1115 1112
1116 // Write out all the object pointer fields. 1113 // Write out all the object pointer fields.
1117 SnapshotWriterVisitor visitor(writer, kAsReference); 1114 SnapshotWriterVisitor visitor(writer, kAsReference);
1118 RawObject** toobj = writer->snapshot_code() ? to_precompiled_snapshot() 1115 visitor.VisitPointers(from(), to_snapshot(kind));
1119 : to_snapshot();
1120 visitor.VisitPointers(from(), toobj);
1121 } 1116 }
1122 1117
1123 1118
1124 RawLibrary* Library::ReadFrom(SnapshotReader* reader, 1119 RawLibrary* Library::ReadFrom(SnapshotReader* reader,
1125 intptr_t object_id, 1120 intptr_t object_id,
1126 intptr_t tags, 1121 intptr_t tags,
1127 Snapshot::Kind kind, 1122 Snapshot::Kind kind,
1128 bool as_reference) { 1123 bool as_reference) {
1129 ASSERT(reader != NULL); 1124 ASSERT(reader != NULL);
1130 ASSERT(kind != Snapshot::kMessage); 1125 ASSERT(kind != Snapshot::kMessage);
(...skipping 17 matching lines...) Expand all
1148 library.StoreNonPointer(&library.raw_ptr()->num_imports_, 1143 library.StoreNonPointer(&library.raw_ptr()->num_imports_,
1149 reader->Read<uint16_t>()); 1144 reader->Read<uint16_t>());
1150 library.StoreNonPointer(&library.raw_ptr()->load_state_, 1145 library.StoreNonPointer(&library.raw_ptr()->load_state_,
1151 reader->Read<int8_t>()); 1146 reader->Read<int8_t>());
1152 library.StoreNonPointer(&library.raw_ptr()->corelib_imported_, 1147 library.StoreNonPointer(&library.raw_ptr()->corelib_imported_,
1153 reader->Read<bool>()); 1148 reader->Read<bool>());
1154 library.StoreNonPointer(&library.raw_ptr()->is_dart_scheme_, 1149 library.StoreNonPointer(&library.raw_ptr()->is_dart_scheme_,
1155 reader->Read<bool>()); 1150 reader->Read<bool>());
1156 library.StoreNonPointer(&library.raw_ptr()->debuggable_, 1151 library.StoreNonPointer(&library.raw_ptr()->debuggable_,
1157 reader->Read<bool>()); 1152 reader->Read<bool>());
1158 if (kind == Snapshot::kFull) { 1153 if (Snapshot::IsFull(kind)) {
1159 is_in_fullsnapshot = true; 1154 is_in_fullsnapshot = true;
1160 } 1155 }
1161 library.StoreNonPointer(&library.raw_ptr()->is_in_fullsnapshot_, 1156 library.StoreNonPointer(&library.raw_ptr()->is_in_fullsnapshot_,
1162 is_in_fullsnapshot); 1157 is_in_fullsnapshot);
1163 // The native resolver and symbolizer are not serialized. 1158 // The native resolver and symbolizer are not serialized.
1164 library.set_native_entry_resolver(NULL); 1159 library.set_native_entry_resolver(NULL);
1165 library.set_native_entry_symbol_resolver(NULL); 1160 library.set_native_entry_symbol_resolver(NULL);
1166 1161
1167 // Set all the object fields. 1162 // Set all the object fields.
1168 // TODO(5411462): Need to assert No GC can happen here, even though 1163 // TODO(5411462): Need to assert No GC can happen here, even though
1169 // allocations may happen. 1164 // allocations may happen.
1170 intptr_t num_flds = (library.raw()->to_snapshot() - library.raw()->from()); 1165 intptr_t num_flds = (library.raw()->to_snapshot() - library.raw()->from());
1171 for (intptr_t i = 0; i <= num_flds; i++) { 1166 for (intptr_t i = 0; i <= num_flds; i++) {
1172 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); 1167 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference);
1173 library.StorePointer((library.raw()->from() + i), 1168 library.StorePointer((library.raw()->from() + i),
1174 reader->PassiveObjectHandle()->raw()); 1169 reader->PassiveObjectHandle()->raw());
1175 } 1170 }
1176 // Initialize cache of resolved names. 1171 // Initialize cache of resolved names.
1177 const intptr_t kInitialNameCacheSize = 64; 1172 const intptr_t kInitialNameCacheSize = 64;
1178 if (kind != Snapshot::kFull) { 1173 if (!Snapshot::IsFull(kind)) {
1179 // The cache of resolved names in library scope is not serialized. 1174 // The cache of resolved names in library scope is not serialized.
1180 library.InitResolvedNamesCache(kInitialNameCacheSize); 1175 library.InitResolvedNamesCache(kInitialNameCacheSize);
1181 library.Register(); 1176 library.Register();
1182 } else { 1177 } else {
1183 library.InitResolvedNamesCache(kInitialNameCacheSize, reader); 1178 library.InitResolvedNamesCache(kInitialNameCacheSize, reader);
1184 } 1179 }
1185 library.StorePointer(&library.raw_ptr()->exported_names_, Array::null()); 1180 library.StorePointer(&library.raw_ptr()->exported_names_, Array::null());
1186 // Initialize cache of loaded scripts. 1181 // Initialize cache of loaded scripts.
1187 library.StorePointer(&library.raw_ptr()->loaded_scripts_, Array::null()); 1182 library.StorePointer(&library.raw_ptr()->loaded_scripts_, Array::null());
1188 } 1183 }
(...skipping 17 matching lines...) Expand all
1206 1201
1207 // Write out the boolean is_in_fullsnapshot_ first as this will 1202 // Write out the boolean is_in_fullsnapshot_ first as this will
1208 // help the reader decide how the rest of the information needs 1203 // help the reader decide how the rest of the information needs
1209 // to be interpreted. 1204 // to be interpreted.
1210 writer->Write<bool>(ptr()->is_in_fullsnapshot_); 1205 writer->Write<bool>(ptr()->is_in_fullsnapshot_);
1211 1206
1212 if ((kind == Snapshot::kScript) && ptr()->is_in_fullsnapshot_) { 1207 if ((kind == Snapshot::kScript) && ptr()->is_in_fullsnapshot_) {
1213 // Write out library URL so that it can be looked up when reading. 1208 // Write out library URL so that it can be looked up when reading.
1214 writer->WriteObjectImpl(ptr()->url_, kAsInlinedObject); 1209 writer->WriteObjectImpl(ptr()->url_, kAsInlinedObject);
1215 } else { 1210 } else {
1216 ASSERT((kind == Snapshot::kFull) || !ptr()->is_in_fullsnapshot_); 1211 ASSERT((Snapshot::IsFull(kind)) || !ptr()->is_in_fullsnapshot_);
1217 // Write out all non object fields. 1212 // Write out all non object fields.
1218 ASSERT(ptr()->index_ != static_cast<classid_t>(-1)); 1213 ASSERT(ptr()->index_ != static_cast<classid_t>(-1));
1219 writer->WriteClassIDValue(ptr()->index_); 1214 writer->WriteClassIDValue(ptr()->index_);
1220 writer->Write<uint16_t>(ptr()->num_imports_); 1215 writer->Write<uint16_t>(ptr()->num_imports_);
1221 writer->Write<int8_t>(ptr()->load_state_); 1216 writer->Write<int8_t>(ptr()->load_state_);
1222 writer->Write<bool>(ptr()->corelib_imported_); 1217 writer->Write<bool>(ptr()->corelib_imported_);
1223 writer->Write<bool>(ptr()->is_dart_scheme_); 1218 writer->Write<bool>(ptr()->is_dart_scheme_);
1224 writer->Write<bool>(ptr()->debuggable_); 1219 writer->Write<bool>(ptr()->debuggable_);
1225 // We do not serialize the native resolver or symbolizer. These need to be 1220 // We do not serialize the native resolver or symbolizer. These need to be
1226 // explicitly set after deserialization. 1221 // explicitly set after deserialization.
1227 1222
1228 // We do not write the loaded_scripts_ and resolved_names_ caches to the 1223 // We do not write the loaded_scripts_ and resolved_names_ caches to the
1229 // snapshot. They get initialized when reading the library from the 1224 // snapshot. They get initialized when reading the library from the
1230 // snapshot and will be rebuilt lazily. 1225 // snapshot and will be rebuilt lazily.
1231 // Write out all the object pointer fields. 1226 // Write out all the object pointer fields.
1232 SnapshotWriterVisitor visitor(writer, kAsReference); 1227 SnapshotWriterVisitor visitor(writer, kAsReference);
1233 visitor.VisitPointers(from(), to_snapshot()); 1228 visitor.VisitPointers(from(), to_snapshot());
1234 } 1229 }
1235 } 1230 }
1236 1231
1237 1232
1238 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader, 1233 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader,
1239 intptr_t object_id, 1234 intptr_t object_id,
1240 intptr_t tags, 1235 intptr_t tags,
1241 Snapshot::Kind kind, 1236 Snapshot::Kind kind,
1242 bool as_reference) { 1237 bool as_reference) {
1243 ASSERT(reader != NULL); 1238 ASSERT(reader != NULL);
1244 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1239 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
1245 1240
1246 // Allocate library prefix object. 1241 // Allocate library prefix object.
1247 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle( 1242 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(
1248 reader->zone(), NEW_OBJECT(LibraryPrefix)); 1243 reader->zone(), NEW_OBJECT(LibraryPrefix));
1249 reader->AddBackRef(object_id, &prefix, kIsDeserialized); 1244 reader->AddBackRef(object_id, &prefix, kIsDeserialized);
1250 1245
1251 // Set all non object fields. 1246 // Set all non object fields.
1252 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_, 1247 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_,
1253 reader->Read<int16_t>()); 1248 reader->Read<int16_t>());
1254 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_, 1249 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_,
1255 reader->Read<bool>()); 1250 reader->Read<bool>());
1256 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>()); 1251 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>());
1257 1252
1258 // Set all the object fields. 1253 // Set all the object fields.
1259 RawObject** toobj = reader->snapshot_code() 1254 RawObject** toobj = Snapshot::IncludesCode(kind)
1260 ? prefix.raw()->to_precompiled_snapshot() 1255 ? prefix.raw()->to_precompiled_snapshot()
1261 : prefix.raw()->to(); 1256 : prefix.raw()->to();
1262 READ_OBJECT_FIELDS(prefix, 1257 READ_OBJECT_FIELDS(prefix,
1263 prefix.raw()->from(), toobj, 1258 prefix.raw()->from(), toobj,
1264 kAsReference); 1259 kAsReference);
1265 if (reader->snapshot_code()) { 1260 if (Snapshot::IncludesCode(kind)) {
1266 prefix.StorePointer(&prefix.raw_ptr()->imports_, 1261 prefix.StorePointer(&prefix.raw_ptr()->imports_,
1267 Array::null()); 1262 Array::null());
1268 prefix.StorePointer(&prefix.raw_ptr()->dependent_code_, 1263 prefix.StorePointer(&prefix.raw_ptr()->dependent_code_,
1269 Array::null()); 1264 Array::null());
1270 } 1265 }
1271 1266
1272 return prefix.raw(); 1267 return prefix.raw();
1273 } 1268 }
1274 1269
1275 1270
1276 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, 1271 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer,
1277 intptr_t object_id, 1272 intptr_t object_id,
1278 Snapshot::Kind kind, 1273 Snapshot::Kind kind,
1279 bool as_reference) { 1274 bool as_reference) {
1280 ASSERT(writer != NULL); 1275 ASSERT(writer != NULL);
1281 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1276 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
1282 1277
1283 // Write out the serialization header value for this object. 1278 // Write out the serialization header value for this object.
1284 writer->WriteInlinedObjectHeader(object_id); 1279 writer->WriteInlinedObjectHeader(object_id);
1285 1280
1286 // Write out the class and tags information. 1281 // Write out the class and tags information.
1287 writer->WriteIndexedObject(kLibraryPrefixCid); 1282 writer->WriteIndexedObject(kLibraryPrefixCid);
1288 writer->WriteTags(writer->GetObjectTags(this)); 1283 writer->WriteTags(writer->GetObjectTags(this));
1289 1284
1290 // Write out all non object fields. 1285 // Write out all non object fields.
1291 writer->Write<int16_t>(ptr()->num_imports_); 1286 writer->Write<int16_t>(ptr()->num_imports_);
1292 writer->Write<bool>(ptr()->is_deferred_load_); 1287 writer->Write<bool>(ptr()->is_deferred_load_);
1293 writer->Write<bool>(ptr()->is_loaded_); 1288 writer->Write<bool>(ptr()->is_loaded_);
1294 1289
1295 // Write out all the object pointer fields. 1290 // Write out all the object pointer fields.
1296 SnapshotWriterVisitor visitor(writer, kAsReference); 1291 SnapshotWriterVisitor visitor(writer, kAsReference);
1297 RawObject** toobj = writer->snapshot_code() ? to_precompiled_snapshot() 1292 RawObject** toobj = Snapshot::IncludesCode(kind) ? to_precompiled_snapshot()
1298 : to(); 1293 : to();
siva 2016/04/26 22:27:47 Why did you not add a to_snapshot(kind) function f
rmacnak 2016/04/26 23:38:23 Done.
1299 visitor.VisitPointers(from(), toobj); 1294 visitor.VisitPointers(from(), toobj);
1300 } 1295 }
1301 1296
1302 1297
1303 RawNamespace* Namespace::ReadFrom(SnapshotReader* reader, 1298 RawNamespace* Namespace::ReadFrom(SnapshotReader* reader,
1304 intptr_t object_id, 1299 intptr_t object_id,
1305 intptr_t tags, 1300 intptr_t tags,
1306 Snapshot::Kind kind, 1301 Snapshot::Kind kind,
1307 bool as_reference) { 1302 bool as_reference) {
1308 ASSERT(reader != NULL); 1303 ASSERT(reader != NULL);
1309 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1304 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
1310 1305
1311 // Allocate Namespace object. 1306 // Allocate Namespace object.
1312 Namespace& ns = Namespace::ZoneHandle( 1307 Namespace& ns = Namespace::ZoneHandle(
1313 reader->zone(), NEW_OBJECT(Namespace)); 1308 reader->zone(), NEW_OBJECT(Namespace));
1314 reader->AddBackRef(object_id, &ns, kIsDeserialized); 1309 reader->AddBackRef(object_id, &ns, kIsDeserialized);
1315 1310
1316 // Set all the object fields. 1311 // Set all the object fields.
1317 READ_OBJECT_FIELDS(ns, ns.raw()->from(), ns.raw()->to(), kAsReference); 1312 READ_OBJECT_FIELDS(ns, ns.raw()->from(), ns.raw()->to(), kAsReference);
1318 1313
1319 return ns.raw(); 1314 return ns.raw();
1320 } 1315 }
1321 1316
1322 1317
1323 void RawNamespace::WriteTo(SnapshotWriter* writer, 1318 void RawNamespace::WriteTo(SnapshotWriter* writer,
1324 intptr_t object_id, 1319 intptr_t object_id,
1325 Snapshot::Kind kind, 1320 Snapshot::Kind kind,
1326 bool as_reference) { 1321 bool as_reference) {
1327 ASSERT(writer != NULL); 1322 ASSERT(writer != NULL);
1328 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1323 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
1329 1324
1330 // Write out the serialization header value for this object. 1325 // Write out the serialization header value for this object.
1331 writer->WriteInlinedObjectHeader(object_id); 1326 writer->WriteInlinedObjectHeader(object_id);
1332 1327
1333 // Write out the class and tags information. 1328 // Write out the class and tags information.
1334 writer->WriteVMIsolateObject(kNamespaceCid); 1329 writer->WriteVMIsolateObject(kNamespaceCid);
1335 writer->WriteTags(writer->GetObjectTags(this)); 1330 writer->WriteTags(writer->GetObjectTags(this));
1336 1331
1337 // Write out all the object pointer fields. 1332 // Write out all the object pointer fields.
1338 SnapshotWriterVisitor visitor(writer, kAsReference); 1333 SnapshotWriterVisitor visitor(writer, kAsReference);
(...skipping 12 matching lines...) Expand all
1351 return sum; 1346 return sum;
1352 } 1347 }
1353 #endif 1348 #endif
1354 1349
1355 1350
1356 RawCode* Code::ReadFrom(SnapshotReader* reader, 1351 RawCode* Code::ReadFrom(SnapshotReader* reader,
1357 intptr_t object_id, 1352 intptr_t object_id,
1358 intptr_t tags, 1353 intptr_t tags,
1359 Snapshot::Kind kind, 1354 Snapshot::Kind kind,
1360 bool as_reference) { 1355 bool as_reference) {
1361 ASSERT(reader->snapshot_code()); 1356 ASSERT(Snapshot::IncludesCode(kind));
1362 ASSERT(kind == Snapshot::kFull); 1357 ASSERT(Snapshot::IsFull(kind));
1363 1358
1364 Code& result = Code::ZoneHandle(reader->zone(), NEW_OBJECT_WITH_LEN(Code, 0)); 1359 Code& result = Code::ZoneHandle(reader->zone(), NEW_OBJECT_WITH_LEN(Code, 0));
1365 reader->AddBackRef(object_id, &result, kIsDeserialized); 1360 reader->AddBackRef(object_id, &result, kIsDeserialized);
1366 1361
1367 result.set_compile_timestamp(0); 1362 result.set_compile_timestamp(0);
1368 result.set_state_bits(reader->Read<int32_t>()); 1363 result.set_state_bits(reader->Read<int32_t>());
1369 result.set_lazy_deopt_pc_offset(-1); 1364 result.set_lazy_deopt_pc_offset(-1);
1370 1365
1371 int32_t text_offset = reader->Read<int32_t>(); 1366 int32_t text_offset = reader->Read<int32_t>();
1372 int32_t instructions_size = reader->Read<int32_t>(); 1367 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); 1425 ASSERT(result.EntryPoint() == entry_point);
1431 1426
1432 return result.raw(); 1427 return result.raw();
1433 } 1428 }
1434 1429
1435 1430
1436 void RawCode::WriteTo(SnapshotWriter* writer, 1431 void RawCode::WriteTo(SnapshotWriter* writer,
1437 intptr_t object_id, 1432 intptr_t object_id,
1438 Snapshot::Kind kind, 1433 Snapshot::Kind kind,
1439 bool as_reference) { 1434 bool as_reference) {
1440 ASSERT(writer->snapshot_code()); 1435 ASSERT(Snapshot::IncludesCode(kind));
1441 ASSERT(kind == Snapshot::kFull); 1436 ASSERT(Snapshot::IsFull(kind));
1442 1437
1443 intptr_t pointer_offsets_length = 1438 intptr_t pointer_offsets_length =
1444 Code::PtrOffBits::decode(ptr()->state_bits_); 1439 Code::PtrOffBits::decode(ptr()->state_bits_);
1445 if (pointer_offsets_length != 0) { 1440 if (pointer_offsets_length != 0) {
1446 // Should only be IA32. 1441 // Should only be IA32.
1447 FATAL("Cannot serialize code with embedded pointers"); 1442 FATAL("Cannot serialize code with embedded pointers");
1448 } 1443 }
1449 1444
1450 // Write out the serialization header value for this object. 1445 // Write out the serialization header value for this object.
1451 writer->WriteInlinedObjectHeader(object_id); 1446 writer->WriteInlinedObjectHeader(object_id);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 bool as_reference) { 1488 bool as_reference) {
1494 UNREACHABLE(); 1489 UNREACHABLE();
1495 } 1490 }
1496 1491
1497 1492
1498 RawObjectPool* ObjectPool::ReadFrom(SnapshotReader* reader, 1493 RawObjectPool* ObjectPool::ReadFrom(SnapshotReader* reader,
1499 intptr_t object_id, 1494 intptr_t object_id,
1500 intptr_t tags, 1495 intptr_t tags,
1501 Snapshot::Kind kind, 1496 Snapshot::Kind kind,
1502 bool as_reference) { 1497 bool as_reference) {
1503 ASSERT(reader->snapshot_code()); 1498 ASSERT(Snapshot::IncludesCode(kind));
1504 ASSERT(kind == Snapshot::kFull); 1499 ASSERT(Snapshot::IsFull(kind));
1505 1500
1506 intptr_t len = reader->Read<intptr_t>(); 1501 intptr_t len = reader->Read<intptr_t>();
1507 ObjectPool* result = NULL; 1502 ObjectPool* result = NULL;
1508 DeserializeState state; 1503 DeserializeState state;
1509 if (!as_reference) { 1504 if (!as_reference) {
1510 result = reinterpret_cast<ObjectPool*>(reader->GetBackRef(object_id)); 1505 result = reinterpret_cast<ObjectPool*>(reader->GetBackRef(object_id));
1511 state = kIsDeserialized; 1506 state = kIsDeserialized;
1512 } else { 1507 } else {
1513 state = kIsNotDeserialized; 1508 state = kIsNotDeserialized;
1514 } 1509 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 } 1551 }
1557 } 1552 }
1558 return result->raw(); 1553 return result->raw();
1559 } 1554 }
1560 1555
1561 1556
1562 void RawObjectPool::WriteTo(SnapshotWriter* writer, 1557 void RawObjectPool::WriteTo(SnapshotWriter* writer,
1563 intptr_t object_id, 1558 intptr_t object_id,
1564 Snapshot::Kind kind, 1559 Snapshot::Kind kind,
1565 bool as_reference) { 1560 bool as_reference) {
1566 ASSERT(writer->snapshot_code()); 1561 ASSERT(Snapshot::IncludesCode(kind));
1567 ASSERT(kind == Snapshot::kFull); 1562 ASSERT(Snapshot::IsFull(kind));
1568 intptr_t tags = writer->GetObjectTags(this); 1563 intptr_t tags = writer->GetObjectTags(this);
1569 intptr_t length = ptr()->length_; 1564 intptr_t length = ptr()->length_;
1570 1565
1571 if (as_reference) { 1566 if (as_reference) {
1572 // Write out the serialization header value for this object. 1567 // Write out the serialization header value for this object.
1573 writer->WriteInlinedObjectHeader(kOmittedObjectId); 1568 writer->WriteInlinedObjectHeader(kOmittedObjectId);
1574 1569
1575 // Write out the class information. 1570 // Write out the class information.
1576 writer->WriteVMIsolateObject(kObjectPoolCid); 1571 writer->WriteVMIsolateObject(kObjectPoolCid);
1577 writer->WriteTags(tags); 1572 writer->WriteTags(tags);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 } 1621 }
1627 } 1622 }
1628 } 1623 }
1629 1624
1630 1625
1631 RawPcDescriptors* PcDescriptors::ReadFrom(SnapshotReader* reader, 1626 RawPcDescriptors* PcDescriptors::ReadFrom(SnapshotReader* reader,
1632 intptr_t object_id, 1627 intptr_t object_id,
1633 intptr_t tags, 1628 intptr_t tags,
1634 Snapshot::Kind kind, 1629 Snapshot::Kind kind,
1635 bool as_reference) { 1630 bool as_reference) {
1636 ASSERT(reader->snapshot_code()); 1631 ASSERT(Snapshot::IncludesCode(kind));
1637 ASSERT(kind == Snapshot::kFull); 1632 ASSERT(Snapshot::IsFull(kind));
1638 1633
1639 intptr_t offset = reader->Read<int32_t>(); 1634 intptr_t offset = reader->Read<int32_t>();
1640 PcDescriptors& result = PcDescriptors::ZoneHandle(reader->zone()); 1635 PcDescriptors& result = PcDescriptors::ZoneHandle(reader->zone());
1641 result ^= reader->GetObjectAt(offset); 1636 result ^= reader->GetObjectAt(offset);
1642 reader->AddBackRef(object_id, &result, kIsDeserialized); 1637 reader->AddBackRef(object_id, &result, kIsDeserialized);
1643 1638
1644 return result.raw(); 1639 return result.raw();
1645 } 1640 }
1646 1641
1647 1642
1648 void RawPcDescriptors::WriteTo(SnapshotWriter* writer, 1643 void RawPcDescriptors::WriteTo(SnapshotWriter* writer,
1649 intptr_t object_id, 1644 intptr_t object_id,
1650 Snapshot::Kind kind, 1645 Snapshot::Kind kind,
1651 bool as_reference) { 1646 bool as_reference) {
1652 ASSERT(writer->snapshot_code()); 1647 ASSERT(Snapshot::IncludesCode(kind));
1653 ASSERT(kind == Snapshot::kFull); 1648 ASSERT(Snapshot::IsFull(kind));
1654 1649
1655 // Write out the serialization header value for this object. 1650 // Write out the serialization header value for this object.
1656 writer->WriteInlinedObjectHeader(object_id); 1651 writer->WriteInlinedObjectHeader(object_id);
1657 writer->WriteIndexedObject(kPcDescriptorsCid); 1652 writer->WriteIndexedObject(kPcDescriptorsCid);
1658 writer->WriteTags(writer->GetObjectTags(this)); 1653 writer->WriteTags(writer->GetObjectTags(this));
1659 1654
1660 writer->Write<int32_t>(writer->GetObjectId(this)); 1655 writer->Write<int32_t>(writer->GetObjectId(this));
1661 } 1656 }
1662 1657
1663 1658
1664 RawCodeSourceMap* CodeSourceMap::ReadFrom(SnapshotReader* reader, 1659 RawCodeSourceMap* CodeSourceMap::ReadFrom(SnapshotReader* reader,
1665 intptr_t object_id, 1660 intptr_t object_id,
1666 intptr_t tags, 1661 intptr_t tags,
1667 Snapshot::Kind kind, 1662 Snapshot::Kind kind,
1668 bool as_reference) { 1663 bool as_reference) {
1669 ASSERT(reader->snapshot_code()); 1664 ASSERT(Snapshot::IncludesCode(kind));
1670 ASSERT(kind == Snapshot::kFull); 1665 ASSERT(Snapshot::IsFull(kind));
1671 1666
1672 const int32_t length = reader->Read<int32_t>(); 1667 const int32_t length = reader->Read<int32_t>();
1673 CodeSourceMap& result = 1668 CodeSourceMap& result =
1674 CodeSourceMap::ZoneHandle(reader->zone(), 1669 CodeSourceMap::ZoneHandle(reader->zone(),
1675 NEW_OBJECT_WITH_LEN(CodeSourceMap, length)); 1670 NEW_OBJECT_WITH_LEN(CodeSourceMap, length));
1676 reader->AddBackRef(object_id, &result, kIsDeserialized); 1671 reader->AddBackRef(object_id, &result, kIsDeserialized);
1677 1672
1678 if (result.Length() > 0) { 1673 if (result.Length() > 0) {
1679 NoSafepointScope no_safepoint; 1674 NoSafepointScope no_safepoint;
1680 intptr_t len = result.Length(); 1675 intptr_t len = result.Length();
1681 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data()); 1676 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data());
1682 reader->ReadBytes(data, len); 1677 reader->ReadBytes(data, len);
1683 } 1678 }
1684 1679
1685 return result.raw(); 1680 return result.raw();
1686 } 1681 }
1687 1682
1688 1683
1689 void RawCodeSourceMap::WriteTo(SnapshotWriter* writer, 1684 void RawCodeSourceMap::WriteTo(SnapshotWriter* writer,
1690 intptr_t object_id, 1685 intptr_t object_id,
1691 Snapshot::Kind kind, 1686 Snapshot::Kind kind,
1692 bool as_reference) { 1687 bool as_reference) {
1693 ASSERT(writer->snapshot_code()); 1688 ASSERT(Snapshot::IncludesCode(kind));
1694 ASSERT(kind == Snapshot::kFull); 1689 ASSERT(Snapshot::IsFull(kind));
1695 1690
1696 // Write out the serialization header value for this object. 1691 // Write out the serialization header value for this object.
1697 writer->WriteInlinedObjectHeader(object_id); 1692 writer->WriteInlinedObjectHeader(object_id);
1698 writer->WriteIndexedObject(kCodeSourceMapCid); 1693 writer->WriteIndexedObject(kCodeSourceMapCid);
1699 writer->WriteTags(writer->GetObjectTags(this)); 1694 writer->WriteTags(writer->GetObjectTags(this));
1700 writer->Write<int32_t>(ptr()->length_); 1695 writer->Write<int32_t>(ptr()->length_);
1701 if (ptr()->length_ > 0) { 1696 if (ptr()->length_ > 0) {
1702 intptr_t len = ptr()->length_; 1697 intptr_t len = ptr()->length_;
1703 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); 1698 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data());
1704 writer->WriteBytes(data, len); 1699 writer->WriteBytes(data, len);
1705 } 1700 }
1706 } 1701 }
1707 1702
1708 1703
1709 RawStackmap* Stackmap::ReadFrom(SnapshotReader* reader, 1704 RawStackmap* Stackmap::ReadFrom(SnapshotReader* reader,
1710 intptr_t object_id, 1705 intptr_t object_id,
1711 intptr_t tags, 1706 intptr_t tags,
1712 Snapshot::Kind kind, 1707 Snapshot::Kind kind,
1713 bool as_reference) { 1708 bool as_reference) {
1714 ASSERT(reader->snapshot_code()); 1709 ASSERT(Snapshot::IncludesCode(kind));
1715 ASSERT(kind == Snapshot::kFull); 1710 ASSERT(Snapshot::IsFull(kind));
1716 1711
1717 intptr_t offset = reader->Read<int32_t>(); 1712 intptr_t offset = reader->Read<int32_t>();
1718 Stackmap& result = Stackmap::ZoneHandle(reader->zone()); 1713 Stackmap& result = Stackmap::ZoneHandle(reader->zone());
1719 result ^= reader->GetObjectAt(offset); 1714 result ^= reader->GetObjectAt(offset);
1720 reader->AddBackRef(object_id, &result, kIsDeserialized); 1715 reader->AddBackRef(object_id, &result, kIsDeserialized);
1721 1716
1722 return result.raw(); 1717 return result.raw();
1723 } 1718 }
1724 1719
1725 1720
1726 void RawStackmap::WriteTo(SnapshotWriter* writer, 1721 void RawStackmap::WriteTo(SnapshotWriter* writer,
1727 intptr_t object_id, 1722 intptr_t object_id,
1728 Snapshot::Kind kind, 1723 Snapshot::Kind kind,
1729 bool as_reference) { 1724 bool as_reference) {
1730 ASSERT(writer->snapshot_code()); 1725 ASSERT(Snapshot::IncludesCode(kind));
1731 ASSERT(kind == Snapshot::kFull); 1726 ASSERT(Snapshot::IsFull(kind));
1732 1727
1733 // Write out the serialization header value for this object. 1728 // Write out the serialization header value for this object.
1734 writer->WriteInlinedObjectHeader(object_id); 1729 writer->WriteInlinedObjectHeader(object_id);
1735 writer->WriteIndexedObject(kStackmapCid); 1730 writer->WriteIndexedObject(kStackmapCid);
1736 writer->WriteTags(writer->GetObjectTags(this)); 1731 writer->WriteTags(writer->GetObjectTags(this));
1737 1732
1738 writer->Write<int32_t>(writer->GetObjectId(this)); 1733 writer->Write<int32_t>(writer->GetObjectId(this));
1739 } 1734 }
1740 1735
1741 1736
1742 RawLocalVarDescriptors* LocalVarDescriptors::ReadFrom(SnapshotReader* reader, 1737 RawLocalVarDescriptors* LocalVarDescriptors::ReadFrom(SnapshotReader* reader,
1743 intptr_t object_id, 1738 intptr_t object_id,
1744 intptr_t tags, 1739 intptr_t tags,
1745 Snapshot::Kind kind, 1740 Snapshot::Kind kind,
1746 bool as_reference) { 1741 bool as_reference) {
1747 ASSERT(reader->snapshot_code()); 1742 ASSERT(Snapshot::IncludesCode(kind));
1748 ASSERT(kind == Snapshot::kFull); 1743 ASSERT(Snapshot::IsFull(kind));
1749 1744
1750 const int32_t num_entries = reader->Read<int32_t>(); 1745 const int32_t num_entries = reader->Read<int32_t>();
1751 1746
1752 LocalVarDescriptors& result = 1747 LocalVarDescriptors& result =
1753 LocalVarDescriptors::ZoneHandle(reader->zone(), 1748 LocalVarDescriptors::ZoneHandle(reader->zone(),
1754 NEW_OBJECT_WITH_LEN(LocalVarDescriptors, 1749 NEW_OBJECT_WITH_LEN(LocalVarDescriptors,
1755 num_entries)); 1750 num_entries));
1756 reader->AddBackRef(object_id, &result, kIsDeserialized); 1751 reader->AddBackRef(object_id, &result, kIsDeserialized);
1757 1752
1758 for (intptr_t i = 0; i < num_entries; i++) { 1753 for (intptr_t i = 0; i < num_entries; i++) {
(...skipping 11 matching lines...) Expand all
1770 } 1765 }
1771 1766
1772 return result.raw(); 1767 return result.raw();
1773 } 1768 }
1774 1769
1775 1770
1776 void RawLocalVarDescriptors::WriteTo(SnapshotWriter* writer, 1771 void RawLocalVarDescriptors::WriteTo(SnapshotWriter* writer,
1777 intptr_t object_id, 1772 intptr_t object_id,
1778 Snapshot::Kind kind, 1773 Snapshot::Kind kind,
1779 bool as_reference) { 1774 bool as_reference) {
1780 ASSERT(writer->snapshot_code()); 1775 ASSERT(Snapshot::IncludesCode(kind));
1781 ASSERT(kind == Snapshot::kFull); 1776 ASSERT(Snapshot::IsFull(kind));
1782 1777
1783 // Write out the serialization header value for this object. 1778 // Write out the serialization header value for this object.
1784 writer->WriteInlinedObjectHeader(object_id); 1779 writer->WriteInlinedObjectHeader(object_id);
1785 writer->WriteIndexedObject(kLocalVarDescriptorsCid); 1780 writer->WriteIndexedObject(kLocalVarDescriptorsCid);
1786 writer->WriteTags(writer->GetObjectTags(this)); 1781 writer->WriteTags(writer->GetObjectTags(this));
1787 writer->Write<int32_t>(ptr()->num_entries_); 1782 writer->Write<int32_t>(ptr()->num_entries_);
1788 for (intptr_t i = 0; i < ptr()->num_entries_; i++) { 1783 for (intptr_t i = 0; i < ptr()->num_entries_; i++) {
1789 writer->WriteObjectImpl(ptr()->names()[i], kAsReference); 1784 writer->WriteObjectImpl(ptr()->names()[i], kAsReference);
1790 } 1785 }
1791 if (ptr()->num_entries_ > 0) { 1786 if (ptr()->num_entries_ > 0) {
1792 intptr_t len = ptr()->num_entries_ * sizeof(VarInfo); 1787 intptr_t len = ptr()->num_entries_ * sizeof(VarInfo);
1793 uint8_t* data = reinterpret_cast<uint8_t*>(this->data()); 1788 uint8_t* data = reinterpret_cast<uint8_t*>(this->data());
1794 writer->WriteBytes(data, len); 1789 writer->WriteBytes(data, len);
1795 } 1790 }
1796 } 1791 }
1797 1792
1798 1793
1799 RawExceptionHandlers* ExceptionHandlers::ReadFrom(SnapshotReader* reader, 1794 RawExceptionHandlers* ExceptionHandlers::ReadFrom(SnapshotReader* reader,
1800 intptr_t object_id, 1795 intptr_t object_id,
1801 intptr_t tags, 1796 intptr_t tags,
1802 Snapshot::Kind kind, 1797 Snapshot::Kind kind,
1803 bool as_reference) { 1798 bool as_reference) {
1804 ASSERT(reader->snapshot_code()); 1799 ASSERT(Snapshot::IncludesCode(kind));
1805 ASSERT(kind == Snapshot::kFull); 1800 ASSERT(Snapshot::IsFull(kind));
1806 1801
1807 const int32_t num_entries = reader->Read<int32_t>(); 1802 const int32_t num_entries = reader->Read<int32_t>();
1808 ExceptionHandlers& result = 1803 ExceptionHandlers& result =
1809 ExceptionHandlers::ZoneHandle(reader->zone(), 1804 ExceptionHandlers::ZoneHandle(reader->zone(),
1810 NEW_OBJECT_WITH_LEN(ExceptionHandlers, 1805 NEW_OBJECT_WITH_LEN(ExceptionHandlers,
1811 num_entries)); 1806 num_entries));
1812 reader->AddBackRef(object_id, &result, kIsDeserialized); 1807 reader->AddBackRef(object_id, &result, kIsDeserialized);
1813 1808
1814 if (result.num_entries() > 0) { 1809 if (result.num_entries() > 0) {
1815 NoSafepointScope no_safepoint; 1810 NoSafepointScope no_safepoint;
1816 const intptr_t len = 1811 const intptr_t len =
1817 result.num_entries() * sizeof(RawExceptionHandlers::HandlerInfo); 1812 result.num_entries() * sizeof(RawExceptionHandlers::HandlerInfo);
1818 uint8_t* data = result.UnsafeMutableNonPointer( 1813 uint8_t* data = result.UnsafeMutableNonPointer(
1819 reinterpret_cast<const uint8_t*>(result.raw_ptr()->data())); 1814 reinterpret_cast<const uint8_t*>(result.raw_ptr()->data()));
1820 reader->ReadBytes(data, len); 1815 reader->ReadBytes(data, len);
1821 } 1816 }
1822 1817
1823 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); 1818 *(reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject);
1824 result.StorePointer(&result.raw_ptr()->handled_types_data_, 1819 result.StorePointer(&result.raw_ptr()->handled_types_data_,
1825 reader->ArrayHandle()->raw()); 1820 reader->ArrayHandle()->raw());
1826 1821
1827 return result.raw(); 1822 return result.raw();
1828 } 1823 }
1829 1824
1830 1825
1831 void RawExceptionHandlers::WriteTo(SnapshotWriter* writer, 1826 void RawExceptionHandlers::WriteTo(SnapshotWriter* writer,
1832 intptr_t object_id, 1827 intptr_t object_id,
1833 Snapshot::Kind kind, 1828 Snapshot::Kind kind,
1834 bool as_reference) { 1829 bool as_reference) {
1835 ASSERT(writer->snapshot_code()); 1830 ASSERT(Snapshot::IncludesCode(kind));
1836 ASSERT(kind == Snapshot::kFull); 1831 ASSERT(Snapshot::IsFull(kind));
1837 1832
1838 // Write out the serialization header value for this object. 1833 // Write out the serialization header value for this object.
1839 writer->WriteInlinedObjectHeader(object_id); 1834 writer->WriteInlinedObjectHeader(object_id);
1840 writer->WriteIndexedObject(kExceptionHandlersCid); 1835 writer->WriteIndexedObject(kExceptionHandlersCid);
1841 writer->WriteTags(writer->GetObjectTags(this)); 1836 writer->WriteTags(writer->GetObjectTags(this));
1842 writer->Write<int32_t>(ptr()->num_entries_); 1837 writer->Write<int32_t>(ptr()->num_entries_);
1843 1838
1844 if (ptr()->num_entries_ > 0) { 1839 if (ptr()->num_entries_ > 0) {
1845 intptr_t len = ptr()->num_entries_ * sizeof(HandlerInfo); 1840 intptr_t len = ptr()->num_entries_ * sizeof(HandlerInfo);
1846 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); 1841 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, 1904 intptr_t object_id,
1910 intptr_t tags, 1905 intptr_t tags,
1911 Snapshot::Kind kind, 1906 Snapshot::Kind kind,
1912 bool as_reference) { 1907 bool as_reference) {
1913 ASSERT(reader != NULL); 1908 ASSERT(reader != NULL);
1914 1909
1915 // Allocate context object. 1910 // Allocate context object.
1916 bool is_implicit = reader->Read<bool>(); 1911 bool is_implicit = reader->Read<bool>();
1917 if (is_implicit) { 1912 if (is_implicit) {
1918 ContextScope& context_scope = ContextScope::ZoneHandle(); 1913 ContextScope& context_scope = ContextScope::ZoneHandle();
1919 if (kind == Snapshot::kFull) { 1914 if (Snapshot::IsFull(kind)) {
1920 context_scope = reader->NewContextScope(1); 1915 context_scope = reader->NewContextScope(1);
1921 context_scope.set_is_implicit(true); 1916 context_scope.set_is_implicit(true);
1922 } else { 1917 } else {
1923 context_scope = ContextScope::New(1, true); 1918 context_scope = ContextScope::New(1, true);
1924 } 1919 }
1925 reader->AddBackRef(object_id, &context_scope, kIsDeserialized); 1920 reader->AddBackRef(object_id, &context_scope, kIsDeserialized);
1926 1921
1927 *reader->TypeHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); 1922 *reader->TypeHandle() ^= reader->ReadObjectImpl(kAsInlinedObject);
1928 1923
1929 // Create a descriptor for 'this' variable. 1924 // Create a descriptor for 'this' variable.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 } 1963 }
1969 UNREACHABLE(); 1964 UNREACHABLE();
1970 } 1965 }
1971 1966
1972 1967
1973 RawICData* ICData::ReadFrom(SnapshotReader* reader, 1968 RawICData* ICData::ReadFrom(SnapshotReader* reader,
1974 intptr_t object_id, 1969 intptr_t object_id,
1975 intptr_t tags, 1970 intptr_t tags,
1976 Snapshot::Kind kind, 1971 Snapshot::Kind kind,
1977 bool as_reference) { 1972 bool as_reference) {
1978 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1973 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
1979 1974
1980 ICData& result = ICData::ZoneHandle(reader->zone(), NEW_OBJECT(ICData)); 1975 ICData& result = ICData::ZoneHandle(reader->zone(), NEW_OBJECT(ICData));
1981 reader->AddBackRef(object_id, &result, kIsDeserialized); 1976 reader->AddBackRef(object_id, &result, kIsDeserialized);
1982 1977
1983 result.set_deopt_id(reader->Read<int32_t>()); 1978 result.set_deopt_id(reader->Read<int32_t>());
1984 result.set_state_bits(reader->Read<uint32_t>()); 1979 result.set_state_bits(reader->Read<uint32_t>());
1985 #if defined(TAG_IC_DATA) 1980 #if defined(TAG_IC_DATA)
1986 result.set_tag(reader->Read<int16_t>()); 1981 result.set_tag(reader->Read<int16_t>());
1987 #endif 1982 #endif
1988 1983
1989 // Set all the object fields. 1984 // Set all the object fields.
1990 RawObject** toobj = reader->snapshot_code() 1985 RawObject** toobj = Snapshot::IncludesCode(kind)
1991 ? result.raw()->to_precompiled_snapshot() 1986 ? result.raw()->to_precompiled_snapshot()
1992 : result.raw()->to(); 1987 : result.raw()->to();
1993 READ_OBJECT_FIELDS(result, 1988 READ_OBJECT_FIELDS(result,
1994 result.raw()->from(), toobj, 1989 result.raw()->from(), toobj,
1995 kAsReference); 1990 kAsReference);
1996 if (reader->snapshot_code()) { 1991 if (Snapshot::IncludesCode(kind)) {
1997 result.set_owner(Function::Handle(reader->zone())); 1992 result.set_owner(Function::Handle(reader->zone()));
1998 } 1993 }
1999 1994
2000 return result.raw(); 1995 return result.raw();
2001 } 1996 }
2002 1997
2003 1998
2004 void RawICData::WriteTo(SnapshotWriter* writer, 1999 void RawICData::WriteTo(SnapshotWriter* writer,
2005 intptr_t object_id, 2000 intptr_t object_id,
2006 Snapshot::Kind kind, 2001 Snapshot::Kind kind,
2007 bool as_reference) { 2002 bool as_reference) {
2008 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 2003 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
2009 2004
2010 // Write out the serialization header value for this object. 2005 // Write out the serialization header value for this object.
2011 writer->WriteInlinedObjectHeader(object_id); 2006 writer->WriteInlinedObjectHeader(object_id);
2012 2007
2013 // Write out the class and tags information. 2008 // Write out the class and tags information.
2014 writer->WriteVMIsolateObject(kICDataCid); 2009 writer->WriteVMIsolateObject(kICDataCid);
2015 writer->WriteTags(writer->GetObjectTags(this)); 2010 writer->WriteTags(writer->GetObjectTags(this));
2016 2011
2017 // Write out all the non object fields. 2012 // Write out all the non object fields.
2018 writer->Write<int32_t>(ptr()->deopt_id_); 2013 writer->Write<int32_t>(ptr()->deopt_id_);
2019 writer->Write<uint32_t>(ptr()->state_bits_); 2014 writer->Write<uint32_t>(ptr()->state_bits_);
2020 #if defined(TAG_IC_DATA) 2015 #if defined(TAG_IC_DATA)
2021 writer->Write<int16_t>(ptr()->tag_); 2016 writer->Write<int16_t>(ptr()->tag_);
2022 #endif 2017 #endif
2023 2018
2024 // Write out all the object pointer fields. 2019 // Write out all the object pointer fields.
2025 // In precompiled snapshots, omit the owner field. The owner field may 2020 // In precompiled snapshots, omit the owner field. The owner field may
2026 // refer to a function which was always inlined and no longer needed. 2021 // refer to a function which was always inlined and no longer needed.
2027 SnapshotWriterVisitor visitor(writer, kAsReference); 2022 SnapshotWriterVisitor visitor(writer, kAsReference);
2028 RawObject** toobj = writer->snapshot_code() ? to_precompiled_snapshot() 2023 RawObject** toobj = Snapshot::IncludesCode(kind) ? to_precompiled_snapshot()
2029 : to(); 2024 : to();
siva 2016/04/26 22:27:47 Ditto comment about to_snapshot(kind);
rmacnak 2016/04/26 23:38:23 Done.
2030 visitor.VisitPointers(from(), toobj); 2025 visitor.VisitPointers(from(), toobj);
2031 } 2026 }
2032 2027
2033 2028
2034 RawMegamorphicCache* MegamorphicCache::ReadFrom(SnapshotReader* reader, 2029 RawMegamorphicCache* MegamorphicCache::ReadFrom(SnapshotReader* reader,
2035 intptr_t object_id, 2030 intptr_t object_id,
2036 intptr_t tags, 2031 intptr_t tags,
2037 Snapshot::Kind kind, 2032 Snapshot::Kind kind,
2038 bool as_reference) { 2033 bool as_reference) {
2039 ASSERT(reader->snapshot_code()); 2034 ASSERT(Snapshot::IncludesCode(kind));
2040 ASSERT(kind == Snapshot::kFull); 2035 ASSERT(Snapshot::IsFull(kind));
2041 2036
2042 MegamorphicCache& result = 2037 MegamorphicCache& result =
2043 MegamorphicCache::ZoneHandle(reader->zone(), 2038 MegamorphicCache::ZoneHandle(reader->zone(),
2044 NEW_OBJECT(MegamorphicCache)); 2039 NEW_OBJECT(MegamorphicCache));
2045 reader->AddBackRef(object_id, &result, kIsDeserialized); 2040 reader->AddBackRef(object_id, &result, kIsDeserialized);
2046 2041
2047 result.set_filled_entry_count(reader->Read<int32_t>()); 2042 result.set_filled_entry_count(reader->Read<int32_t>());
2048 2043
2049 // Set all the object fields. 2044 // Set all the object fields.
2050 READ_OBJECT_FIELDS(result, 2045 READ_OBJECT_FIELDS(result,
2051 result.raw()->from(), result.raw()->to(), 2046 result.raw()->from(), result.raw()->to(),
2052 kAsReference); 2047 kAsReference);
2053 2048
2054 return result.raw(); 2049 return result.raw();
2055 } 2050 }
2056 2051
2057 2052
2058 void RawMegamorphicCache::WriteTo(SnapshotWriter* writer, 2053 void RawMegamorphicCache::WriteTo(SnapshotWriter* writer,
2059 intptr_t object_id, 2054 intptr_t object_id,
2060 Snapshot::Kind kind, 2055 Snapshot::Kind kind,
2061 bool as_reference) { 2056 bool as_reference) {
2062 ASSERT(writer->snapshot_code()); 2057 ASSERT(Snapshot::IncludesCode(kind));
2063 ASSERT(kind == Snapshot::kFull); 2058 ASSERT(Snapshot::IsFull(kind));
2064 2059
2065 // Write out the serialization header value for this object. 2060 // Write out the serialization header value for this object.
2066 writer->WriteInlinedObjectHeader(object_id); 2061 writer->WriteInlinedObjectHeader(object_id);
2067 2062
2068 // Write out the class and tags information. 2063 // Write out the class and tags information.
2069 writer->WriteVMIsolateObject(kMegamorphicCacheCid); 2064 writer->WriteVMIsolateObject(kMegamorphicCacheCid);
2070 writer->WriteTags(writer->GetObjectTags(this)); 2065 writer->WriteTags(writer->GetObjectTags(this));
2071 2066
2072 // Write out all the non object fields. 2067 // Write out all the non object fields.
2073 writer->Write<int32_t>(ptr()->filled_entry_count_); 2068 writer->Write<int32_t>(ptr()->filled_entry_count_);
2074 2069
2075 // Write out all the object pointer fields. 2070 // Write out all the object pointer fields.
2076 SnapshotWriterVisitor visitor(writer, kAsReference); 2071 SnapshotWriterVisitor visitor(writer, kAsReference);
2077 visitor.VisitPointers(from(), to()); 2072 visitor.VisitPointers(from(), to());
2078 } 2073 }
2079 2074
2080 2075
2081 RawSubtypeTestCache* SubtypeTestCache::ReadFrom(SnapshotReader* reader, 2076 RawSubtypeTestCache* SubtypeTestCache::ReadFrom(SnapshotReader* reader,
2082 intptr_t object_id, 2077 intptr_t object_id,
2083 intptr_t tags, 2078 intptr_t tags,
2084 Snapshot::Kind kind, 2079 Snapshot::Kind kind,
2085 bool as_reference) { 2080 bool as_reference) {
2086 ASSERT(reader->snapshot_code()); 2081 ASSERT(Snapshot::IncludesCode(kind));
2087 ASSERT(kind == Snapshot::kFull); 2082 ASSERT(Snapshot::IsFull(kind));
2088 2083
2089 SubtypeTestCache& result = 2084 SubtypeTestCache& result =
2090 SubtypeTestCache::ZoneHandle(reader->zone(), 2085 SubtypeTestCache::ZoneHandle(reader->zone(),
2091 NEW_OBJECT(SubtypeTestCache)); 2086 NEW_OBJECT(SubtypeTestCache));
2092 reader->AddBackRef(object_id, &result, kIsDeserialized); 2087 reader->AddBackRef(object_id, &result, kIsDeserialized);
2093 2088
2094 // Set all the object fields. 2089 // Set all the object fields.
2095 // TODO(5411462): Need to assert No GC can happen here, even though 2090 // TODO(5411462): Need to assert No GC can happen here, even though
2096 // allocations may happen. 2091 // allocations may happen.
2097 (*reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsReference); 2092 (*reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsReference);
2098 result.StorePointer(&result.raw_ptr()->cache_, 2093 result.StorePointer(&result.raw_ptr()->cache_,
2099 reader->ArrayHandle()->raw()); 2094 reader->ArrayHandle()->raw());
2100 2095
2101 return result.raw(); 2096 return result.raw();
2102 } 2097 }
2103 2098
2104 2099
2105 void RawSubtypeTestCache::WriteTo(SnapshotWriter* writer, 2100 void RawSubtypeTestCache::WriteTo(SnapshotWriter* writer,
2106 intptr_t object_id, 2101 intptr_t object_id,
2107 Snapshot::Kind kind, 2102 Snapshot::Kind kind,
2108 bool as_reference) { 2103 bool as_reference) {
2109 ASSERT(writer->snapshot_code()); 2104 ASSERT(Snapshot::IncludesCode(kind));
2110 ASSERT(kind == Snapshot::kFull); 2105 ASSERT(Snapshot::IsFull(kind));
2111 2106
2112 // Write out the serialization header value for this object. 2107 // Write out the serialization header value for this object.
2113 writer->WriteInlinedObjectHeader(object_id); 2108 writer->WriteInlinedObjectHeader(object_id);
2114 2109
2115 // Write out the class and tags information. 2110 // Write out the class and tags information.
2116 writer->WriteVMIsolateObject(kSubtypeTestCacheCid); 2111 writer->WriteVMIsolateObject(kSubtypeTestCacheCid);
2117 writer->WriteTags(writer->GetObjectTags(this)); 2112 writer->WriteTags(writer->GetObjectTags(this));
2118 2113
2119 // Write out all the object pointer fields. 2114 // Write out all the object pointer fields.
2120 writer->WriteObjectImpl(ptr()->cache_, kAsReference); 2115 writer->WriteObjectImpl(ptr()->cache_, kAsReference);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 RawInstance* Instance::ReadFrom(SnapshotReader* reader, 2280 RawInstance* Instance::ReadFrom(SnapshotReader* reader,
2286 intptr_t object_id, 2281 intptr_t object_id,
2287 intptr_t tags, 2282 intptr_t tags,
2288 Snapshot::Kind kind, 2283 Snapshot::Kind kind,
2289 bool as_reference) { 2284 bool as_reference) {
2290 ASSERT(reader != NULL); 2285 ASSERT(reader != NULL);
2291 2286
2292 // Create an Instance object or get canonical one if it is a canonical 2287 // Create an Instance object or get canonical one if it is a canonical
2293 // constant. 2288 // constant.
2294 Instance& obj = Instance::ZoneHandle(reader->zone(), Instance::null()); 2289 Instance& obj = Instance::ZoneHandle(reader->zone(), Instance::null());
2295 if (kind == Snapshot::kFull) { 2290 if (Snapshot::IsFull(kind)) {
2296 obj = reader->NewInstance(); 2291 obj = reader->NewInstance();
2297 // Set the canonical bit. 2292 // Set the canonical bit.
2298 if (RawObject::IsCanonical(tags)) { 2293 if (RawObject::IsCanonical(tags)) {
2299 obj.SetCanonical(); 2294 obj.SetCanonical();
2300 } 2295 }
2301 } else { 2296 } else {
2302 obj ^= Object::Allocate(kInstanceCid, 2297 obj ^= Object::Allocate(kInstanceCid,
2303 Instance::InstanceSize(), 2298 Instance::InstanceSize(),
2304 HEAP_SPACE(kind)); 2299 HEAP_SPACE(kind));
2305 if (RawObject::IsCanonical(tags)) { 2300 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. 2336 // architecture, if so return the object as a Smi.
2342 if (Smi::IsValid(value)) { 2337 if (Smi::IsValid(value)) {
2343 Smi& smi = Smi::ZoneHandle(reader->zone(), 2338 Smi& smi = Smi::ZoneHandle(reader->zone(),
2344 Smi::New(static_cast<intptr_t>(value))); 2339 Smi::New(static_cast<intptr_t>(value)));
2345 reader->AddBackRef(object_id, &smi, kIsDeserialized); 2340 reader->AddBackRef(object_id, &smi, kIsDeserialized);
2346 return smi.raw(); 2341 return smi.raw();
2347 } 2342 }
2348 2343
2349 // Create a Mint object or get canonical one if it is a canonical constant. 2344 // Create a Mint object or get canonical one if it is a canonical constant.
2350 Mint& mint = Mint::ZoneHandle(reader->zone(), Mint::null()); 2345 Mint& mint = Mint::ZoneHandle(reader->zone(), Mint::null());
2351 if (kind == Snapshot::kFull) { 2346 if (Snapshot::IsFull(kind)) {
2352 mint = reader->NewMint(value); 2347 mint = reader->NewMint(value);
2353 // Set the canonical bit. 2348 // Set the canonical bit.
2354 if (RawObject::IsCanonical(tags)) { 2349 if (RawObject::IsCanonical(tags)) {
2355 mint.SetCanonical(); 2350 mint.SetCanonical();
2356 } 2351 }
2357 } else { 2352 } else {
2358 // When reading a script snapshot we need to canonicalize only those object 2353 // When reading a script snapshot we need to canonicalize only those object
2359 // references that are objects from the core library (loaded from a 2354 // references that are objects from the core library (loaded from a
2360 // full snapshot). Objects that are only in the script need not be 2355 // full snapshot). Objects that are only in the script need not be
2361 // canonicalized as they are already canonical. 2356 // canonicalized as they are already canonical.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2403 2398
2404 // Set all the object fields. 2399 // Set all the object fields.
2405 READ_OBJECT_FIELDS(obj, obj.raw()->from(), obj.raw()->to(), kAsInlinedObject); 2400 READ_OBJECT_FIELDS(obj, obj.raw()->from(), obj.raw()->to(), kAsInlinedObject);
2406 2401
2407 // If it is a canonical constant make it one. 2402 // If it is a canonical constant make it one.
2408 // When reading a full snapshot we don't need to canonicalize the object 2403 // When reading a full snapshot we don't need to canonicalize the object
2409 // as it would already be a canonical object. 2404 // as it would already be a canonical object.
2410 // When reading a script snapshot or a message snapshot we always have 2405 // When reading a script snapshot or a message snapshot we always have
2411 // to canonicalize the object. 2406 // to canonicalize the object.
2412 if (RawObject::IsCanonical(tags)) { 2407 if (RawObject::IsCanonical(tags)) {
2413 if (kind == Snapshot::kFull) { 2408 if (Snapshot::IsFull(kind)) {
2414 // Set the canonical bit. 2409 // Set the canonical bit.
2415 obj.SetCanonical(); 2410 obj.SetCanonical();
2416 } else { 2411 } else {
2417 obj ^= obj.CheckAndCanonicalize(reader->thread(), NULL); 2412 obj ^= obj.CheckAndCanonicalize(reader->thread(), NULL);
2418 ASSERT(!obj.IsNull()); 2413 ASSERT(!obj.IsNull());
2419 ASSERT(obj.IsCanonical()); 2414 ASSERT(obj.IsCanonical());
2420 } 2415 }
2421 } 2416 }
2422 return obj.raw(); 2417 return obj.raw();
2423 } 2418 }
(...skipping 23 matching lines...) Expand all
2447 intptr_t tags, 2442 intptr_t tags,
2448 Snapshot::Kind kind, 2443 Snapshot::Kind kind,
2449 bool as_reference) { 2444 bool as_reference) {
2450 ASSERT(reader != NULL); 2445 ASSERT(reader != NULL);
2451 ASSERT(kind != Snapshot::kMessage); 2446 ASSERT(kind != Snapshot::kMessage);
2452 // Read the double value for the object. 2447 // Read the double value for the object.
2453 double value = reader->ReadDouble(); 2448 double value = reader->ReadDouble();
2454 2449
2455 // Create a Double object or get canonical one if it is a canonical constant. 2450 // Create a Double object or get canonical one if it is a canonical constant.
2456 Double& dbl = Double::ZoneHandle(reader->zone(), Double::null()); 2451 Double& dbl = Double::ZoneHandle(reader->zone(), Double::null());
2457 if (kind == Snapshot::kFull) { 2452 if (Snapshot::IsFull(kind)) {
2458 dbl = reader->NewDouble(value); 2453 dbl = reader->NewDouble(value);
2459 // Set the canonical bit. 2454 // Set the canonical bit.
2460 if (RawObject::IsCanonical(tags)) { 2455 if (RawObject::IsCanonical(tags)) {
2461 dbl.SetCanonical(); 2456 dbl.SetCanonical();
2462 } 2457 }
2463 } else { 2458 } else {
2464 // When reading a script snapshot we need to canonicalize only those object 2459 // When reading a script snapshot we need to canonicalize only those object
2465 // references that are objects from the core library (loaded from a 2460 // references that are objects from the core library (loaded from a
2466 // full snapshot). Objects that are only in the script need not be 2461 // full snapshot). Objects that are only in the script need not be
2467 // canonicalized as they are already canonical. 2462 // canonicalized as they are already canonical.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2544 } 2539 }
2545 } 2540 }
2546 } 2541 }
2547 2542
2548 2543
2549 RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader, 2544 RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader,
2550 intptr_t object_id, 2545 intptr_t object_id,
2551 intptr_t tags, 2546 intptr_t tags,
2552 Snapshot::Kind kind, 2547 Snapshot::Kind kind,
2553 bool as_reference) { 2548 bool as_reference) {
2554 if (reader->snapshot_code()) { 2549 if (Snapshot::IncludesCode(kind)) {
2555 ASSERT(kind == Snapshot::kFull); 2550 ASSERT(Snapshot::IsFull(kind));
2556 intptr_t offset = reader->Read<int32_t>(); 2551 intptr_t offset = reader->Read<int32_t>();
2557 String& result = String::ZoneHandle(reader->zone()); 2552 String& result = String::ZoneHandle(reader->zone());
2558 result ^= reader->GetObjectAt(offset); 2553 result ^= reader->GetObjectAt(offset);
2559 reader->AddBackRef(object_id, &result, kIsDeserialized); 2554 reader->AddBackRef(object_id, &result, kIsDeserialized);
2560 return raw(result); 2555 return raw(result);
2561 } 2556 }
2562 // Read the length so that we can determine instance size to allocate. 2557 // Read the length so that we can determine instance size to allocate.
2563 ASSERT(reader != NULL); 2558 ASSERT(reader != NULL);
2564 intptr_t len = reader->ReadSmiValue(); 2559 intptr_t len = reader->ReadSmiValue();
2565 intptr_t hash = reader->ReadSmiValue(); 2560 intptr_t hash = reader->ReadSmiValue();
2566 String& str_obj = String::ZoneHandle(reader->zone(), String::null()); 2561 String& str_obj = String::ZoneHandle(reader->zone(), String::null());
2567 2562
2568 if (kind == Snapshot::kFull) { 2563 if (Snapshot::IsFull(kind)) {
2569 // We currently only expect the Dart mutator to read snapshots. 2564 // We currently only expect the Dart mutator to read snapshots.
2570 reader->isolate()->AssertCurrentThreadIsMutator(); 2565 reader->isolate()->AssertCurrentThreadIsMutator();
2571 ASSERT(Thread::Current()->no_safepoint_scope_depth() != 0); 2566 ASSERT(Thread::Current()->no_safepoint_scope_depth() != 0);
2572 RawOneByteString* obj = reader->NewOneByteString(len); 2567 RawOneByteString* obj = reader->NewOneByteString(len);
2573 str_obj = obj; 2568 str_obj = obj;
2574 if (RawObject::IsCanonical(tags)) { 2569 if (RawObject::IsCanonical(tags)) {
2575 str_obj.SetCanonical(); 2570 str_obj.SetCanonical();
2576 } 2571 }
2577 str_obj.SetHash(hash); 2572 str_obj.SetHash(hash);
2578 if (len > 0) { 2573 if (len > 0) {
(...skipping 14 matching lines...) Expand all
2593 intptr_t object_id, 2588 intptr_t object_id,
2594 intptr_t tags, 2589 intptr_t tags,
2595 Snapshot::Kind kind, 2590 Snapshot::Kind kind,
2596 bool as_reference) { 2591 bool as_reference) {
2597 // Read the length so that we can determine instance size to allocate. 2592 // Read the length so that we can determine instance size to allocate.
2598 ASSERT(reader != NULL); 2593 ASSERT(reader != NULL);
2599 intptr_t len = reader->ReadSmiValue(); 2594 intptr_t len = reader->ReadSmiValue();
2600 intptr_t hash = reader->ReadSmiValue(); 2595 intptr_t hash = reader->ReadSmiValue();
2601 String& str_obj = String::ZoneHandle(reader->zone(), String::null()); 2596 String& str_obj = String::ZoneHandle(reader->zone(), String::null());
2602 2597
2603 if (kind == Snapshot::kFull) { 2598 if (Snapshot::IsFull(kind)) {
2604 RawTwoByteString* obj = reader->NewTwoByteString(len); 2599 RawTwoByteString* obj = reader->NewTwoByteString(len);
2605 str_obj = obj; 2600 str_obj = obj;
2606 if (RawObject::IsCanonical(tags)) { 2601 if (RawObject::IsCanonical(tags)) {
2607 str_obj.SetCanonical(); 2602 str_obj.SetCanonical();
2608 } 2603 }
2609 str_obj.SetHash(hash); 2604 str_obj.SetHash(hash);
2610 NoSafepointScope no_safepoint; 2605 NoSafepointScope no_safepoint;
2611 uint16_t* raw_ptr = (len > 0)? CharAddr(str_obj, 0) : NULL; 2606 uint16_t* raw_ptr = (len > 0)? CharAddr(str_obj, 0) : NULL;
2612 for (intptr_t i = 0; i < len; i++) { 2607 for (intptr_t i = 0; i < len; i++) {
2613 ASSERT(CharAddr(str_obj, i) == raw_ptr); // Will trigger assertions. 2608 ASSERT(CharAddr(str_obj, i) == raw_ptr); // Will trigger assertions.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2659 } 2654 }
2660 } 2655 }
2661 } 2656 }
2662 } 2657 }
2663 2658
2664 2659
2665 void RawOneByteString::WriteTo(SnapshotWriter* writer, 2660 void RawOneByteString::WriteTo(SnapshotWriter* writer,
2666 intptr_t object_id, 2661 intptr_t object_id,
2667 Snapshot::Kind kind, 2662 Snapshot::Kind kind,
2668 bool as_reference) { 2663 bool as_reference) {
2669 if (writer->snapshot_code()) { 2664 if (Snapshot::IncludesCode(kind)) {
2670 ASSERT(writer->snapshot_code()); 2665 ASSERT(Snapshot::IncludesCode(kind));
2671 ASSERT(kind == Snapshot::kFull); 2666 ASSERT(Snapshot::IsFull(kind));
2672 // Assert that hash is computed. 2667 // Assert that hash is computed.
2673 if (ptr()->hash_ == NULL) { 2668 if (ptr()->hash_ == NULL) {
2674 ptr()->hash_ = Smi::New(String::Hash(ptr()->data(), 2669 ptr()->hash_ = Smi::New(String::Hash(ptr()->data(),
2675 Smi::Value(ptr()->length_))); 2670 Smi::Value(ptr()->length_)));
2676 } 2671 }
2677 ASSERT(ptr()->hash_ != NULL); 2672 ASSERT(ptr()->hash_ != NULL);
2678 // Write out the serialization header value for this object. 2673 // Write out the serialization header value for this object.
2679 writer->WriteInlinedObjectHeader(object_id); 2674 writer->WriteInlinedObjectHeader(object_id);
2680 writer->WriteIndexedObject(kOneByteStringCid); 2675 writer->WriteIndexedObject(kOneByteStringCid);
2681 writer->WriteTags(writer->GetObjectTags(this)); 2676 writer->WriteTags(writer->GetObjectTags(this));
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
2831 if (array == NULL) { 2826 if (array == NULL) {
2832 array = &(Array::ZoneHandle( 2827 array = &(Array::ZoneHandle(
2833 reader->zone(), 2828 reader->zone(),
2834 NEW_OBJECT_WITH_LEN_SPACE(ImmutableArray, len, kind))); 2829 NEW_OBJECT_WITH_LEN_SPACE(ImmutableArray, len, kind)));
2835 reader->AddBackRef(object_id, array, state); 2830 reader->AddBackRef(object_id, array, state);
2836 } 2831 }
2837 if (!as_reference) { 2832 if (!as_reference) {
2838 // Read all the individual elements for inlined objects. 2833 // Read all the individual elements for inlined objects.
2839 reader->ArrayReadFrom(object_id, *array, len, tags); 2834 reader->ArrayReadFrom(object_id, *array, len, tags);
2840 if (RawObject::IsCanonical(tags)) { 2835 if (RawObject::IsCanonical(tags)) {
2841 if (kind == Snapshot::kFull) { 2836 if (Snapshot::IsFull(kind)) {
2842 array->SetCanonical(); 2837 array->SetCanonical();
2843 } else { 2838 } else {
2844 *array ^= array->CheckAndCanonicalize(reader->thread(), NULL); 2839 *array ^= array->CheckAndCanonicalize(reader->thread(), NULL);
2845 } 2840 }
2846 } 2841 }
2847 } 2842 }
2848 return raw(*array); 2843 return raw(*array);
2849 } 2844 }
2850 2845
2851 2846
(...skipping 29 matching lines...) Expand all
2881 RawGrowableObjectArray* GrowableObjectArray::ReadFrom(SnapshotReader* reader, 2876 RawGrowableObjectArray* GrowableObjectArray::ReadFrom(SnapshotReader* reader,
2882 intptr_t object_id, 2877 intptr_t object_id,
2883 intptr_t tags, 2878 intptr_t tags,
2884 Snapshot::Kind kind, 2879 Snapshot::Kind kind,
2885 bool as_reference) { 2880 bool as_reference) {
2886 ASSERT(reader != NULL); 2881 ASSERT(reader != NULL);
2887 2882
2888 // Read the length so that we can determine instance size to allocate. 2883 // Read the length so that we can determine instance size to allocate.
2889 GrowableObjectArray& array = GrowableObjectArray::ZoneHandle( 2884 GrowableObjectArray& array = GrowableObjectArray::ZoneHandle(
2890 reader->zone(), GrowableObjectArray::null()); 2885 reader->zone(), GrowableObjectArray::null());
2891 if (kind == Snapshot::kFull) { 2886 if (Snapshot::IsFull(kind)) {
2892 array = reader->NewGrowableObjectArray(); 2887 array = reader->NewGrowableObjectArray();
2893 } else { 2888 } else {
2894 array = GrowableObjectArray::New(0, HEAP_SPACE(kind)); 2889 array = GrowableObjectArray::New(0, HEAP_SPACE(kind));
2895 } 2890 }
2896 reader->AddBackRef(object_id, &array, kIsDeserialized); 2891 reader->AddBackRef(object_id, &array, kIsDeserialized);
2897 2892
2898 // Read type arguments of growable array object. 2893 // Read type arguments of growable array object.
2899 const intptr_t typeargs_offset = 2894 const intptr_t typeargs_offset =
2900 GrowableObjectArray::type_arguments_offset() / kWordSize; 2895 GrowableObjectArray::type_arguments_offset() / kWordSize;
2901 *reader->TypeArgumentsHandle() ^= 2896 *reader->TypeArgumentsHandle() ^=
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2940 2935
2941 RawLinkedHashMap* LinkedHashMap::ReadFrom(SnapshotReader* reader, 2936 RawLinkedHashMap* LinkedHashMap::ReadFrom(SnapshotReader* reader,
2942 intptr_t object_id, 2937 intptr_t object_id,
2943 intptr_t tags, 2938 intptr_t tags,
2944 Snapshot::Kind kind, 2939 Snapshot::Kind kind,
2945 bool as_reference) { 2940 bool as_reference) {
2946 ASSERT(reader != NULL); 2941 ASSERT(reader != NULL);
2947 2942
2948 LinkedHashMap& map = LinkedHashMap::ZoneHandle( 2943 LinkedHashMap& map = LinkedHashMap::ZoneHandle(
2949 reader->zone(), LinkedHashMap::null()); 2944 reader->zone(), LinkedHashMap::null());
2950 if ((kind == Snapshot::kFull && !reader->snapshot_code()) || 2945 if ((Snapshot::IsFull(kind) && !Snapshot::IncludesCode(kind)) ||
2951 kind == Snapshot::kScript) { 2946 kind == Snapshot::kScript) {
2952 // The immutable maps that seed map literals are not yet VM-internal, so 2947 // The immutable maps that seed map literals are not yet VM-internal, so
2953 // we don't reach this. 2948 // we don't reach this.
2954 UNREACHABLE(); 2949 UNREACHABLE();
2955 } else { 2950 } else {
2956 // Since the map might contain itself as a key or value, allocate first. 2951 // Since the map might contain itself as a key or value, allocate first.
2957 if (kind == Snapshot::kFull) { 2952 if (Snapshot::IsFull(kind)) {
2958 map = reader->NewLinkedHashMap(); 2953 map = reader->NewLinkedHashMap();
2959 } else { 2954 } else {
2960 map = LinkedHashMap::NewUninitialized(HEAP_SPACE(kind)); 2955 map = LinkedHashMap::NewUninitialized(HEAP_SPACE(kind));
2961 } 2956 }
2962 } 2957 }
2963 reader->AddBackRef(object_id, &map, kIsDeserialized); 2958 reader->AddBackRef(object_id, &map, kIsDeserialized);
2964 2959
2965 // Read the type arguments. 2960 // Read the type arguments.
2966 const intptr_t typeargs_offset = 2961 const intptr_t typeargs_offset =
2967 GrowableObjectArray::type_arguments_offset() / kWordSize; 2962 GrowableObjectArray::type_arguments_offset() / kWordSize;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2999 data.SetAt(i, *reader->PassiveObjectHandle()); 2994 data.SetAt(i, *reader->PassiveObjectHandle());
3000 } 2995 }
3001 return map.raw(); 2996 return map.raw();
3002 } 2997 }
3003 2998
3004 2999
3005 void RawLinkedHashMap::WriteTo(SnapshotWriter* writer, 3000 void RawLinkedHashMap::WriteTo(SnapshotWriter* writer,
3006 intptr_t object_id, 3001 intptr_t object_id,
3007 Snapshot::Kind kind, 3002 Snapshot::Kind kind,
3008 bool as_reference) { 3003 bool as_reference) {
3009 if ((kind == Snapshot::kFull && !writer->snapshot_code()) || 3004 if ((Snapshot::IsFull(kind) && !Snapshot::IncludesCode(kind)) ||
3010 kind == Snapshot::kScript) { 3005 kind == Snapshot::kScript) {
3011 // The immutable maps that seed map literals are not yet VM-internal, so 3006 // The immutable maps that seed map literals are not yet VM-internal, so
3012 // we don't reach this. 3007 // we don't reach this.
3013 } 3008 }
3014 ASSERT(writer != NULL); 3009 ASSERT(writer != NULL);
3015 3010
3016 // Write out the serialization header value for this object. 3011 // Write out the serialization header value for this object.
3017 writer->WriteInlinedObjectHeader(object_id); 3012 writer->WriteInlinedObjectHeader(object_id);
3018 3013
3019 // Write out the class and tags information. 3014 // Write out the class and tags information.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3062 ASSERT(reader != NULL); 3057 ASSERT(reader != NULL);
3063 // Read the values. 3058 // Read the values.
3064 float value0 = reader->Read<float>(); 3059 float value0 = reader->Read<float>();
3065 float value1 = reader->Read<float>(); 3060 float value1 = reader->Read<float>();
3066 float value2 = reader->Read<float>(); 3061 float value2 = reader->Read<float>();
3067 float value3 = reader->Read<float>(); 3062 float value3 = reader->Read<float>();
3068 3063
3069 // Create a Float32x4 object. 3064 // Create a Float32x4 object.
3070 Float32x4& simd = Float32x4::ZoneHandle(reader->zone(), 3065 Float32x4& simd = Float32x4::ZoneHandle(reader->zone(),
3071 Float32x4::null()); 3066 Float32x4::null());
3072 if (kind == Snapshot::kFull) { 3067 if (Snapshot::IsFull(kind)) {
3073 simd = reader->NewFloat32x4(value0, value1, value2, value3); 3068 simd = reader->NewFloat32x4(value0, value1, value2, value3);
3074 } else { 3069 } else {
3075 simd = Float32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind)); 3070 simd = Float32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind));
3076 } 3071 }
3077 reader->AddBackRef(object_id, &simd, kIsDeserialized); 3072 reader->AddBackRef(object_id, &simd, kIsDeserialized);
3078 return simd.raw(); 3073 return simd.raw();
3079 } 3074 }
3080 3075
3081 3076
3082 void RawFloat32x4::WriteTo(SnapshotWriter* writer, 3077 void RawFloat32x4::WriteTo(SnapshotWriter* writer,
(...skipping 25 matching lines...) Expand all
3108 ASSERT(reader != NULL); 3103 ASSERT(reader != NULL);
3109 // Read the values. 3104 // Read the values.
3110 uint32_t value0 = reader->Read<uint32_t>(); 3105 uint32_t value0 = reader->Read<uint32_t>();
3111 uint32_t value1 = reader->Read<uint32_t>(); 3106 uint32_t value1 = reader->Read<uint32_t>();
3112 uint32_t value2 = reader->Read<uint32_t>(); 3107 uint32_t value2 = reader->Read<uint32_t>();
3113 uint32_t value3 = reader->Read<uint32_t>(); 3108 uint32_t value3 = reader->Read<uint32_t>();
3114 3109
3115 // Create a Float32x4 object. 3110 // Create a Float32x4 object.
3116 Int32x4& simd = Int32x4::ZoneHandle(reader->zone(), Int32x4::null()); 3111 Int32x4& simd = Int32x4::ZoneHandle(reader->zone(), Int32x4::null());
3117 3112
3118 if (kind == Snapshot::kFull) { 3113 if (Snapshot::IsFull(kind)) {
3119 simd = reader->NewInt32x4(value0, value1, value2, value3); 3114 simd = reader->NewInt32x4(value0, value1, value2, value3);
3120 } else { 3115 } else {
3121 simd = Int32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind)); 3116 simd = Int32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind));
3122 } 3117 }
3123 reader->AddBackRef(object_id, &simd, kIsDeserialized); 3118 reader->AddBackRef(object_id, &simd, kIsDeserialized);
3124 return simd.raw(); 3119 return simd.raw();
3125 } 3120 }
3126 3121
3127 3122
3128 void RawInt32x4::WriteTo(SnapshotWriter* writer, 3123 void RawInt32x4::WriteTo(SnapshotWriter* writer,
(...skipping 23 matching lines...) Expand all
3152 Snapshot::Kind kind, 3147 Snapshot::Kind kind,
3153 bool as_reference) { 3148 bool as_reference) {
3154 ASSERT(reader != NULL); 3149 ASSERT(reader != NULL);
3155 // Read the values. 3150 // Read the values.
3156 double value0 = reader->Read<double>(); 3151 double value0 = reader->Read<double>();
3157 double value1 = reader->Read<double>(); 3152 double value1 = reader->Read<double>();
3158 3153
3159 // Create a Float64x2 object. 3154 // Create a Float64x2 object.
3160 Float64x2& simd = Float64x2::ZoneHandle(reader->zone(), 3155 Float64x2& simd = Float64x2::ZoneHandle(reader->zone(),
3161 Float64x2::null()); 3156 Float64x2::null());
3162 if (kind == Snapshot::kFull) { 3157 if (Snapshot::IsFull(kind)) {
3163 simd = reader->NewFloat64x2(value0, value1); 3158 simd = reader->NewFloat64x2(value0, value1);
3164 } else { 3159 } else {
3165 simd = Float64x2::New(value0, value1, HEAP_SPACE(kind)); 3160 simd = Float64x2::New(value0, value1, HEAP_SPACE(kind));
3166 } 3161 }
3167 reader->AddBackRef(object_id, &simd, kIsDeserialized); 3162 reader->AddBackRef(object_id, &simd, kIsDeserialized);
3168 return simd.raw(); 3163 return simd.raw();
3169 } 3164 }
3170 3165
3171 3166
3172 void RawFloat64x2::WriteTo(SnapshotWriter* writer, 3167 void RawFloat64x2::WriteTo(SnapshotWriter* writer,
(...skipping 24 matching lines...) Expand all
3197 RawTypedData* TypedData::ReadFrom(SnapshotReader* reader, 3192 RawTypedData* TypedData::ReadFrom(SnapshotReader* reader,
3198 intptr_t object_id, 3193 intptr_t object_id,
3199 intptr_t tags, 3194 intptr_t tags,
3200 Snapshot::Kind kind, 3195 Snapshot::Kind kind,
3201 bool as_reference) { 3196 bool as_reference) {
3202 ASSERT(reader != NULL); 3197 ASSERT(reader != NULL);
3203 3198
3204 intptr_t cid = RawObject::ClassIdTag::decode(tags); 3199 intptr_t cid = RawObject::ClassIdTag::decode(tags);
3205 intptr_t len = reader->ReadSmiValue(); 3200 intptr_t len = reader->ReadSmiValue();
3206 TypedData& result = TypedData::ZoneHandle(reader->zone(), 3201 TypedData& result = TypedData::ZoneHandle(reader->zone(),
3207 (kind == Snapshot::kFull) ? reader->NewTypedData(cid, len) 3202 (Snapshot::IsFull(kind)) ? reader->NewTypedData(cid, len)
3208 : TypedData::New(cid, len, HEAP_SPACE(kind))); 3203 : TypedData::New(cid, len, HEAP_SPACE(kind)));
3209 reader->AddBackRef(object_id, &result, kIsDeserialized); 3204 reader->AddBackRef(object_id, &result, kIsDeserialized);
3210 3205
3211 // Setup the array elements. 3206 // Setup the array elements.
3212 intptr_t element_size = ElementSizeInBytes(cid); 3207 intptr_t element_size = ElementSizeInBytes(cid);
3213 intptr_t length_in_bytes = len * element_size; 3208 intptr_t length_in_bytes = len * element_size;
3214 switch (cid) { 3209 switch (cid) {
3215 case kTypedDataInt8ArrayCid: 3210 case kTypedDataInt8ArrayCid:
3216 case kTypedDataUint8ArrayCid: 3211 case kTypedDataUint8ArrayCid:
3217 case kTypedDataUint8ClampedArrayCid: { 3212 case kTypedDataUint8ClampedArrayCid: {
(...skipping 28 matching lines...) Expand all
3246 break; 3241 break;
3247 default: 3242 default:
3248 UNREACHABLE(); 3243 UNREACHABLE();
3249 } 3244 }
3250 // If it is a canonical constant make it one. 3245 // If it is a canonical constant make it one.
3251 // When reading a full snapshot we don't need to canonicalize the object 3246 // When reading a full snapshot we don't need to canonicalize the object
3252 // as it would already be a canonical object. 3247 // as it would already be a canonical object.
3253 // When reading a script snapshot or a message snapshot we always have 3248 // When reading a script snapshot or a message snapshot we always have
3254 // to canonicalize the object. 3249 // to canonicalize the object.
3255 if (RawObject::IsCanonical(tags)) { 3250 if (RawObject::IsCanonical(tags)) {
3256 if (kind == Snapshot::kFull) { 3251 if (Snapshot::IsFull(kind)) {
3257 // Set the canonical bit. 3252 // Set the canonical bit.
3258 result.SetCanonical(); 3253 result.SetCanonical();
3259 } else { 3254 } else {
3260 result ^= result.CheckAndCanonicalize(reader->thread(), NULL); 3255 result ^= result.CheckAndCanonicalize(reader->thread(), NULL);
3261 ASSERT(!result.IsNull()); 3256 ASSERT(!result.IsNull());
3262 ASSERT(result.IsCanonical()); 3257 ASSERT(result.IsCanonical());
3263 } 3258 }
3264 } 3259 }
3265 return result.raw(); 3260 return result.raw();
3266 } 3261 }
3267 #undef TYPED_DATA_READ 3262 #undef TYPED_DATA_READ
3268 3263
3269 3264
3270 RawExternalTypedData* ExternalTypedData::ReadFrom(SnapshotReader* reader, 3265 RawExternalTypedData* ExternalTypedData::ReadFrom(SnapshotReader* reader,
3271 intptr_t object_id, 3266 intptr_t object_id,
3272 intptr_t tags, 3267 intptr_t tags,
3273 Snapshot::Kind kind, 3268 Snapshot::Kind kind,
3274 bool as_reference) { 3269 bool as_reference) {
3275 ASSERT(kind != Snapshot::kFull); 3270 ASSERT(!Snapshot::IsFull(kind));
3276 intptr_t cid = RawObject::ClassIdTag::decode(tags); 3271 intptr_t cid = RawObject::ClassIdTag::decode(tags);
3277 intptr_t length = reader->ReadSmiValue(); 3272 intptr_t length = reader->ReadSmiValue();
3278 uint8_t* data = reinterpret_cast<uint8_t*>(reader->ReadRawPointerValue()); 3273 uint8_t* data = reinterpret_cast<uint8_t*>(reader->ReadRawPointerValue());
3279 ExternalTypedData& obj = ExternalTypedData::ZoneHandle( 3274 ExternalTypedData& obj = ExternalTypedData::ZoneHandle(
3280 ExternalTypedData::New(cid, data, length)); 3275 ExternalTypedData::New(cid, data, length));
3281 reader->AddBackRef(object_id, &obj, kIsDeserialized); 3276 reader->AddBackRef(object_id, &obj, kIsDeserialized);
3282 void* peer = reinterpret_cast<void*>(reader->ReadRawPointerValue()); 3277 void* peer = reinterpret_cast<void*>(reader->ReadRawPointerValue());
3283 Dart_WeakPersistentHandleFinalizer callback = 3278 Dart_WeakPersistentHandleFinalizer callback =
3284 reinterpret_cast<Dart_WeakPersistentHandleFinalizer>( 3279 reinterpret_cast<Dart_WeakPersistentHandleFinalizer>(
3285 reader->ReadRawPointerValue()); 3280 reader->ReadRawPointerValue());
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
3475 UNREACHABLE(); 3470 UNREACHABLE();
3476 } 3471 }
3477 } 3472 }
3478 3473
3479 3474
3480 RawSendPort* SendPort::ReadFrom(SnapshotReader* reader, 3475 RawSendPort* SendPort::ReadFrom(SnapshotReader* reader,
3481 intptr_t object_id, 3476 intptr_t object_id,
3482 intptr_t tags, 3477 intptr_t tags,
3483 Snapshot::Kind kind, 3478 Snapshot::Kind kind,
3484 bool as_reference) { 3479 bool as_reference) {
3485 ASSERT(kind == Snapshot::kMessage || reader->snapshot_code()); 3480 ASSERT(kind == Snapshot::kMessage || Snapshot::IncludesCode(kind));
3486 3481
3487 uint64_t id = reader->Read<uint64_t>(); 3482 uint64_t id = reader->Read<uint64_t>();
3488 uint64_t origin_id = reader->Read<uint64_t>(); 3483 uint64_t origin_id = reader->Read<uint64_t>();
3489 3484
3490 SendPort& result = SendPort::ZoneHandle(reader->zone()); 3485 SendPort& result = SendPort::ZoneHandle(reader->zone());
3491 if (reader->snapshot_code()) { 3486 if (Snapshot::IncludesCode(kind)) {
3492 // TODO(rmacnak): Reset fields in precompiled snapshots and assert 3487 // TODO(rmacnak): Reset fields in precompiled snapshots and assert
3493 // this is unreachable. 3488 // this is unreachable.
3494 } else { 3489 } else {
3495 result = SendPort::New(id, origin_id); 3490 result = SendPort::New(id, origin_id);
3496 } 3491 }
3497 reader->AddBackRef(object_id, &result, kIsDeserialized); 3492 reader->AddBackRef(object_id, &result, kIsDeserialized);
3498 return result.raw(); 3493 return result.raw();
3499 } 3494 }
3500 3495
3501 3496
(...skipping 11 matching lines...) Expand all
3513 writer->Write<uint64_t>(ptr()->id_); 3508 writer->Write<uint64_t>(ptr()->id_);
3514 writer->Write<uint64_t>(ptr()->origin_id_); 3509 writer->Write<uint64_t>(ptr()->origin_id_);
3515 } 3510 }
3516 3511
3517 3512
3518 RawStacktrace* Stacktrace::ReadFrom(SnapshotReader* reader, 3513 RawStacktrace* Stacktrace::ReadFrom(SnapshotReader* reader,
3519 intptr_t object_id, 3514 intptr_t object_id,
3520 intptr_t tags, 3515 intptr_t tags,
3521 Snapshot::Kind kind, 3516 Snapshot::Kind kind,
3522 bool as_reference) { 3517 bool as_reference) {
3523 if (kind == Snapshot::kFull) { 3518 if (Snapshot::IsFull(kind)) {
3524 Stacktrace& result = Stacktrace::ZoneHandle(reader->zone(), 3519 Stacktrace& result = Stacktrace::ZoneHandle(reader->zone(),
3525 reader->NewStacktrace()); 3520 reader->NewStacktrace());
3526 reader->AddBackRef(object_id, &result, kIsDeserialized); 3521 reader->AddBackRef(object_id, &result, kIsDeserialized);
3527 3522
3528 bool expand_inlined = reader->Read<bool>(); 3523 bool expand_inlined = reader->Read<bool>();
3529 result.set_expand_inlined(expand_inlined); 3524 result.set_expand_inlined(expand_inlined);
3530 3525
3531 // Set all the object fields. 3526 // Set all the object fields.
3532 READ_OBJECT_FIELDS(result, 3527 READ_OBJECT_FIELDS(result,
3533 result.raw()->from(), result.raw()->to(), 3528 result.raw()->from(), result.raw()->to(),
3534 kAsReference); 3529 kAsReference);
3535 3530
3536 return result.raw(); 3531 return result.raw();
3537 } 3532 }
3538 UNREACHABLE(); // Stacktraces are not sent in a snapshot. 3533 UNREACHABLE(); // Stacktraces are not sent in a snapshot.
3539 return Stacktrace::null(); 3534 return Stacktrace::null();
3540 } 3535 }
3541 3536
3542 3537
3543 void RawStacktrace::WriteTo(SnapshotWriter* writer, 3538 void RawStacktrace::WriteTo(SnapshotWriter* writer,
3544 intptr_t object_id, 3539 intptr_t object_id,
3545 Snapshot::Kind kind, 3540 Snapshot::Kind kind,
3546 bool as_reference) { 3541 bool as_reference) {
3547 if (kind == Snapshot::kFull) { 3542 if (Snapshot::IsFull(kind)) {
3548 ASSERT(writer != NULL); 3543 ASSERT(writer != NULL);
3549 ASSERT(this == Isolate::Current()->object_store()-> 3544 ASSERT(this == Isolate::Current()->object_store()->
3550 preallocated_stack_trace()); 3545 preallocated_stack_trace());
3551 3546
3552 // Write out the serialization header value for this object. 3547 // Write out the serialization header value for this object.
3553 writer->WriteInlinedObjectHeader(object_id); 3548 writer->WriteInlinedObjectHeader(object_id);
3554 3549
3555 // Write out the class and tags information. 3550 // Write out the class and tags information.
3556 writer->WriteIndexedObject(kStacktraceCid); 3551 writer->WriteIndexedObject(kStacktraceCid);
3557 writer->WriteTags(writer->GetObjectTags(this)); 3552 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. 3705 // We do not allow objects with native fields in an isolate message.
3711 writer->SetWriteException(Exceptions::kArgument, 3706 writer->SetWriteException(Exceptions::kArgument,
3712 "Illegal argument in isolate message" 3707 "Illegal argument in isolate message"
3713 " : (object is a UserTag)"); 3708 " : (object is a UserTag)");
3714 } else { 3709 } else {
3715 UNREACHABLE(); 3710 UNREACHABLE();
3716 } 3711 }
3717 } 3712 }
3718 3713
3719 } // namespace dart 3714 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698