Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
dart::Deserializer Class Reference
Inheritance diagram for dart::Deserializer:
dart::ThreadStackResource dart::StackResource

Classes

class  Local
 

Public Member Functions

 Deserializer (Thread *thread, Snapshot::Kind kind, const uint8_t *buffer, intptr_t size, const uint8_t *data_buffer, const uint8_t *instructions_buffer, bool is_non_root_unit, intptr_t offset=0)
 
 ~Deserializer ()
 
ApiErrorPtr VerifyImageAlignment ()
 
ObjectPtr Allocate (intptr_t size)
 
template<typename T >
T Read ()
 
intptr_t ReadRefId ()
 
intptr_t ReadUnsigned ()
 
uint64_t ReadUnsigned64 ()
 
void ReadBytes (uint8_t *addr, intptr_t len)
 
uword ReadWordWith32BitReads ()
 
intptr_t position () const
 
void set_position (intptr_t p)
 
const uint8_t * AddressOfCurrentPosition () const
 
void Advance (intptr_t value)
 
void Align (intptr_t alignment, intptr_t offset=0)
 
void AddBaseObject (ObjectPtr base_object)
 
void AssignRef (ObjectPtr object)
 
ObjectPtr Ref (intptr_t index) const
 
CodePtr GetCodeByIndex (intptr_t code_index, uword *entry_point) const
 
uword GetEntryPointByCodeIndex (intptr_t code_index) const
 
ObjectPtr ReadRef ()
 
TokenPosition ReadTokenPosition ()
 
intptr_t ReadCid ()
 
void ReadInstructions (CodePtr code, bool deferred)
 
void EndInstructions ()
 
ObjectPtr GetObjectAt (uint32_t offset) const
 
void Deserialize (DeserializationRoots *roots)
 
DeserializationClusterReadCluster ()
 
void ReadDispatchTable ()
 
void ReadDispatchTable (ReadStream *stream, bool deferred, const InstructionsTable &root_instruction_table, intptr_t deferred_code_start_index, intptr_t deferred_code_end_index)
 
intptr_t next_index () const
 
Heapheap () const
 
Zonezone () const
 
Snapshot::Kind kind () const
 
bool is_non_root_unit () const
 
void set_code_start_index (intptr_t value)
 
intptr_t code_start_index () const
 
void set_code_stop_index (intptr_t value)
 
intptr_t code_stop_index () const
 
const InstructionsTableinstructions_table () const
 
intptr_t num_base_objects () const
 
- Public Member Functions inherited from dart::ThreadStackResource
 ThreadStackResource (Thread *T)
 
 ~ThreadStackResource ()
 
Threadthread () const
 
Isolateisolate () const
 
IsolateGroupisolate_group () const
 
- Public Member Functions inherited from dart::StackResource
 StackResource (ThreadState *thread)
 
virtual ~StackResource ()
 
ThreadStatethread () const
 

Static Public Member Functions

static void InitializeHeader (ObjectPtr raw, intptr_t cid, intptr_t size, bool is_canonical=false)
 
static void InitializeHeader (ObjectPtr raw, intptr_t cid, intptr_t size, bool is_canonical, bool is_immutable)
 
static intptr_t CodeIndexToClusterIndex (const InstructionsTable &table, intptr_t code_index)
 
- Static Public Member Functions inherited from dart::StackResource
static void Unwind (ThreadState *thread)
 
static void UnwindAbove (ThreadState *thread, StackResource *new_top)
 

Detailed Description

Definition at line 665 of file app_snapshot.cc.

Constructor & Destructor Documentation

◆ Deserializer()

dart::Deserializer::Deserializer ( Thread thread,
Snapshot::Kind  kind,
const uint8_t *  buffer,
intptr_t  size,
const uint8_t *  data_buffer,
const uint8_t *  instructions_buffer,
bool  is_non_root_unit,
intptr_t  offset = 0 
)

Definition at line 8922 of file app_snapshot.cc.

8931 heap_(thread->isolate_group()->heap()),
8932 old_space_(heap_->old_space()),
8933 freelist_(old_space_->DataFreeList()),
8934 zone_(thread->zone()),
8935 kind_(kind),
8936 stream_(buffer, size),
8937 image_reader_(nullptr),
8938 refs_(nullptr),
8939 next_ref_index_(kFirstReference),
8940 clusters_(nullptr),
8941 is_non_root_unit_(is_non_root_unit),
8942 instructions_table_(InstructionsTable::Handle(thread->zone())) {
8944 ASSERT(instructions_buffer != nullptr);
8945 ASSERT(data_buffer != nullptr);
8946 image_reader_ = new (zone_) ImageReader(data_buffer, instructions_buffer);
8947 }
8948 stream_.SetPosition(offset);
8949}
bool is_non_root_unit() const
Snapshot::Kind kind() const
PageSpace * old_space()
Definition heap.h:63
Heap * heap() const
Definition isolate.h:295
static Object & Handle()
Definition object.h:407
FreeList * DataFreeList(intptr_t i=0)
Definition pages.h:296
void SetPosition(intptr_t value)
Definition datastream.h:128
static bool IncludesCode(Kind kind)
Definition snapshot.h:67
Zone * zone() const
IsolateGroup * isolate_group() const
Definition thread.h:540
#define ASSERT(E)
static const uint8_t buffer[]
static constexpr intptr_t kFirstReference
Point offset

◆ ~Deserializer()

dart::Deserializer::~Deserializer ( )

Definition at line 8951 of file app_snapshot.cc.

8951 {
8952 delete[] clusters_;
8953}

Member Function Documentation

◆ AddBaseObject()

void dart::Deserializer::AddBaseObject ( ObjectPtr  base_object)
inline

Definition at line 721 of file app_snapshot.cc.

721{ AssignRef(base_object); }
void AssignRef(ObjectPtr object)

◆ AddressOfCurrentPosition()

const uint8_t * dart::Deserializer::AddressOfCurrentPosition ( ) const
inline

Definition at line 712 of file app_snapshot.cc.

712 {
713 return stream_.AddressOfCurrentPosition();
714 }
const uint8_t * AddressOfCurrentPosition() const
Definition datastream.h:140

◆ Advance()

void dart::Deserializer::Advance ( intptr_t  value)
inline

Definition at line 716 of file app_snapshot.cc.

716{ stream_.Advance(value); }
void Advance(intptr_t value)
Definition datastream.h:142

◆ Align()

void dart::Deserializer::Align ( intptr_t  alignment,
intptr_t  offset = 0 
)
inline

Definition at line 717 of file app_snapshot.cc.

717 {
718 stream_.Align(alignment, offset);
719 }
void Align(intptr_t alignment, intptr_t offset=0)
Definition datastream.h:133

◆ Allocate()

DART_FORCE_INLINE ObjectPtr dart::Deserializer::Allocate ( intptr_t  size)

Definition at line 878 of file app_snapshot.cc.

878 {
880 old_space_->AllocateSnapshotLocked(freelist_, size));
881}
DART_FORCE_INLINE uword AllocateSnapshotLocked(FreeList *freelist, intptr_t size)
Definition pages.h:161
static ObjectPtr FromAddr(uword addr)
Definition raw_object.h:495

◆ AssignRef()

void dart::Deserializer::AssignRef ( ObjectPtr  object)
inline

Definition at line 723 of file app_snapshot.cc.

723 {
724 ASSERT(next_ref_index_ <= num_objects_);
725 refs_->untag()->data()[next_ref_index_] = object;
726 next_ref_index_++;
727 }

◆ code_start_index()

intptr_t dart::Deserializer::code_start_index ( ) const
inline

Definition at line 786 of file app_snapshot.cc.

786{ return code_start_index_; }

◆ code_stop_index()

intptr_t dart::Deserializer::code_stop_index ( ) const
inline

Definition at line 788 of file app_snapshot.cc.

788{ return code_stop_index_; }

◆ CodeIndexToClusterIndex()

intptr_t dart::Deserializer::CodeIndexToClusterIndex ( const InstructionsTable table,
intptr_t  code_index 
)
static

Definition at line 1859 of file app_snapshot.cc.

1860 {
1861 // Note: code indices we are interpreting here originate from the root
1862 // loading unit which means base is equal to 0.
1863 // See comments which clarify the connection between code_index and
1864 // index into the Code cluster.
1865 ASSERT(FLAG_precompiled_mode);
1866 const intptr_t first_entry_with_code = table.rodata()->first_entry_with_code;
1867 return code_index - 1 - first_entry_with_code;
1868}
SI F table(const skcms_Curve *curve, F v)

◆ Deserialize()

void dart::Deserializer::Deserialize ( DeserializationRoots roots)

Definition at line 9468 of file app_snapshot.cc.

9468 {
9469 const void* clustered_start = AddressOfCurrentPosition();
9470
9471 Array& refs = Array::Handle(zone_);
9472 num_base_objects_ = ReadUnsigned();
9473 num_objects_ = ReadUnsigned();
9474 num_clusters_ = ReadUnsigned();
9475 const intptr_t instructions_table_len = ReadUnsigned();
9476 const uint32_t instruction_table_data_offset = ReadUnsigned();
9477 USE(instruction_table_data_offset);
9478
9479 clusters_ = new DeserializationCluster*[num_clusters_];
9480 refs = Array::New(num_objects_ + kFirstReference, Heap::kOld);
9481
9482#if defined(DART_PRECOMPILED_RUNTIME)
9483 if (instructions_table_len > 0) {
9484 ASSERT(FLAG_precompiled_mode);
9485 const uword start_pc = image_reader_->GetBareInstructionsAt(0);
9486 const uword end_pc = image_reader_->GetBareInstructionsEnd();
9487 uword instruction_table_data = 0;
9488 if (instruction_table_data_offset != 0) {
9489 // NoSafepointScope to satisfy assertion in DataStart. InstructionsTable
9490 // data resides in RO memory and is immovable and immortal making it
9491 // safe to use DataStart result outside of NoSafepointScope.
9492 NoSafepointScope no_safepoint;
9493 instruction_table_data = reinterpret_cast<uword>(
9494 OneByteString::DataStart(String::Handle(static_cast<StringPtr>(
9495 image_reader_->GetObjectAt(instruction_table_data_offset)))));
9496 }
9497 instructions_table_ = InstructionsTable::New(
9498 instructions_table_len, start_pc, end_pc, instruction_table_data);
9499 }
9500#else
9501 ASSERT(instructions_table_len == 0);
9502#endif // defined(DART_PRECOMPILED_RUNTIME)
9503
9504 {
9505 // The deserializer initializes objects without using the write barrier,
9506 // partly for speed since we know all the deserialized objects will be
9507 // long-lived and partly because the target objects can be not yet
9508 // initialized at the time of the write. To make this safe, we must ensure
9509 // there are no other threads mutating this heap, and that incremental
9510 // marking is not in progress. This is normally the case anyway for the
9511 // main snapshot being deserialized at isolate load, but needs checks for
9512 // loading secondary snapshots are part of deferred loading.
9513 HeapIterationScope iter(thread());
9514 // For bump-pointer allocation in old-space.
9515 HeapLocker hl(thread(), heap_->old_space());
9516 // Must not perform any other type of allocation, which might trigger GC
9517 // while there are still uninitialized objects.
9518 NoSafepointScope no_safepoint;
9519 refs_ = refs.ptr();
9520
9521 roots->AddBaseObjects(this);
9522
9523 if (num_base_objects_ != (next_ref_index_ - kFirstReference)) {
9524 FATAL("Snapshot expects %" Pd
9525 " base objects, but deserializer provided %" Pd,
9526 num_base_objects_, next_ref_index_ - kFirstReference);
9527 }
9528
9529 {
9530 TIMELINE_DURATION(thread(), Isolate, "ReadAlloc");
9531 for (intptr_t i = 0; i < num_clusters_; i++) {
9532 clusters_[i] = ReadCluster();
9533 clusters_[i]->ReadAlloc(this);
9534#if defined(DEBUG)
9535 intptr_t serializers_next_ref_index_ = Read<int32_t>();
9536 ASSERT_EQUAL(serializers_next_ref_index_, next_ref_index_);
9537#endif
9538 }
9539 }
9540
9541 // We should have completely filled the ref array.
9542 ASSERT_EQUAL(next_ref_index_ - kFirstReference, num_objects_);
9543
9544 {
9545 TIMELINE_DURATION(thread(), Isolate, "ReadFill");
9546 for (intptr_t i = 0; i < num_clusters_; i++) {
9547 clusters_[i]->ReadFill(this);
9548#if defined(DEBUG)
9549 int32_t section_marker = Read<int32_t>();
9550 ASSERT(section_marker == kSectionMarker);
9551#endif
9552 }
9553 }
9554
9555 roots->ReadRoots(this);
9556
9557#if defined(DEBUG)
9558 int32_t section_marker = Read<int32_t>();
9559 ASSERT(section_marker == kSectionMarker);
9560#endif
9561
9562 refs_ = nullptr;
9563 }
9564
9565 roots->PostLoad(this, refs);
9566
9568#if defined(DEBUG)
9569 isolate_group->ValidateClassTable();
9570 if (isolate_group != Dart::vm_isolate()->group()) {
9571 isolate_group->heap()->Verify("Deserializer::Deserialize");
9572 }
9573#endif
9574
9575 {
9576 TIMELINE_DURATION(thread(), Isolate, "PostLoad");
9577 for (intptr_t i = 0; i < num_clusters_; i++) {
9578 clusters_[i]->PostLoad(this, refs);
9579 }
9580 }
9581
9582 if (isolate_group->snapshot_is_dontneed_safe()) {
9583 size_t clustered_length =
9584 reinterpret_cast<uword>(AddressOfCurrentPosition()) -
9585 reinterpret_cast<uword>(clustered_start);
9586 VirtualMemory::DontNeed(const_cast<void*>(clustered_start),
9587 clustered_length);
9588 }
9589}
#define ASSERT_EQUAL(expected, actual)
Definition assert.h:309
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition object.h:10933
static Isolate * vm_isolate()
Definition dart.h:68
virtual void ReadFill(Deserializer *deserializer)=0
virtual void PostLoad(Deserializer *deserializer, const Array &refs)
virtual void ReadAlloc(Deserializer *deserializer)=0
intptr_t ReadUnsigned()
const uint8_t * AddressOfCurrentPosition() const
DeserializationCluster * ReadCluster()
@ kOld
Definition heap.h:39
bool Verify(const char *msg, MarkExpectation mark_expectation=kForbidMarked)
Definition heap.cc:760
ObjectPtr GetObjectAt(uint32_t offset) const
static InstructionsTablePtr New(intptr_t length, uword start_pc, uword end_pc, uword rodata)
Definition object.cc:15565
IsolateGroup * isolate_group() const
static void DontNeed(void *address, intptr_t size)
#define FATAL(error)
uintptr_t uword
Definition globals.h:501
static void USE(T &&)
Definition globals.h:618
#define Pd
Definition globals.h:408
#define TIMELINE_DURATION(thread, stream, name)
Definition timeline.h:39

◆ EndInstructions()

void dart::Deserializer::EndInstructions ( )

Definition at line 9413 of file app_snapshot.cc.

9413 {
9414#if defined(DART_PRECOMPILED_RUNTIME)
9415 if (instructions_table_.IsNull()) {
9416 ASSERT(instructions_index_ == 0);
9417 return;
9418 }
9419
9420 const auto& code_objects =
9421 Array::Handle(instructions_table_.ptr()->untag()->code_objects());
9422 ASSERT(code_objects.Length() == instructions_index_);
9423
9424 uword previous_end = image_reader_->GetBareInstructionsEnd();
9425 for (intptr_t i = instructions_index_ - 1; i >= 0; --i) {
9426 CodePtr code = Code::RawCast(code_objects.At(i));
9428 ASSERT(start <= previous_end);
9429 code->untag()->instructions_length_ = previous_end - start;
9430 previous_end = start;
9431 }
9432
9433 ObjectStore* object_store = IsolateGroup::Current()->object_store();
9434 GrowableObjectArray& tables =
9435 GrowableObjectArray::Handle(zone_, object_store->instructions_tables());
9436 if (tables.IsNull()) {
9438 object_store->set_instructions_tables(tables);
9439 }
9440 if ((tables.Length() == 0) ||
9441 (tables.At(tables.Length() - 1) != instructions_table_.ptr())) {
9442 ASSERT((!is_non_root_unit_ && tables.Length() == 0) ||
9443 (is_non_root_unit_ && tables.Length() > 0));
9444 tables.Add(instructions_table_, Heap::kOld);
9445 }
9446#endif
9447}
static uword PayloadStartOf(const CodePtr code)
Definition object.h:6824
static GrowableObjectArrayPtr New(Heap::Space space=Heap::kNew)
Definition object.h:11118
ObjectStore * object_store() const
Definition isolate.h:505
static IsolateGroup * Current()
Definition isolate.h:534
UntaggedObject * untag() const
ObjectPtr ptr() const
Definition object.h:332
bool IsNull() const
Definition object.h:363
static ObjectPtr RawCast(ObjectPtr obj)
Definition object.h:325

◆ GetCodeByIndex()

CodePtr dart::Deserializer::GetCodeByIndex ( intptr_t  code_index,
uword entry_point 
) const

Definition at line 1842 of file app_snapshot.cc.

1843 {
1844 // See Serializer::GetCodeIndex for how code_index is encoded.
1845 if (code_index == 0) {
1846 return StubCode::LazyCompile().ptr();
1847 } else if (FLAG_precompiled_mode) {
1849 /*need_entry_point_for_non_discarded=*/false>(this, code_index,
1850 entry_point);
1851 } else {
1852 // -1 below because 0 is reserved for LazyCompile stub.
1853 const intptr_t ref = code_start_index_ + code_index - 1;
1854 ASSERT(code_start_index_ <= ref && ref < code_stop_index_);
1855 return static_cast<CodePtr>(Ref(ref));
1856 }
1857}
ObjectPtr Ref(intptr_t index) const
static DART_FORCE_INLINE CodePtr GetCodeAndEntryPointByIndex(const Deserializer *d, intptr_t code_index, uword *entry_point)

◆ GetEntryPointByCodeIndex()

uword dart::Deserializer::GetEntryPointByCodeIndex ( intptr_t  code_index) const

Definition at line 1870 of file app_snapshot.cc.

1870 {
1871 // See Deserializer::GetCodeByIndex which this code repeats.
1872 ASSERT(FLAG_precompiled_mode);
1873 uword entry_point = 0;
1874 GetCodeAndEntryPointByIndex</*need_entry_point_for_non_discarded=*/true>(
1875 this, code_index, &entry_point);
1876 return entry_point;
1877}

◆ GetObjectAt()

ObjectPtr dart::Deserializer::GetObjectAt ( uint32_t  offset) const

Definition at line 9449 of file app_snapshot.cc.

9449 {
9450 return image_reader_->GetObjectAt(offset);
9451}

◆ heap()

Heap * dart::Deserializer::heap ( ) const
inline

Definition at line 775 of file app_snapshot.cc.

775{ return heap_; }

◆ InitializeHeader() [1/2]

void dart::Deserializer::InitializeHeader ( ObjectPtr  raw,
intptr_t  cid,
intptr_t  size,
bool  is_canonical,
bool  is_immutable 
)
static

Definition at line 883 of file app_snapshot.cc.

887 {
889 uword tags = 0;
890 tags = UntaggedObject::ClassIdTag::update(class_id, tags);
891 tags = UntaggedObject::SizeTag::update(size, tags);
892 tags = UntaggedObject::CanonicalBit::update(is_canonical, tags);
893 tags = UntaggedObject::AlwaysSetBit::update(true, tags);
894 tags = UntaggedObject::NotMarkedBit::update(true, tags);
896 tags = UntaggedObject::NewBit::update(false, tags);
897 tags = UntaggedObject::ImmutableBit::update(is_immutable, tags);
898 raw->untag()->tags_ = tags;
899}
static constexpr uword update(ClassIdTagType value, uword original)
Definition bitfield.h:190
static constexpr uword update(intptr_t size, uword tag)
Definition raw_object.h:209
static constexpr bool IsAligned(T x, uintptr_t alignment, uintptr_t offset=0)
Definition utils.h:77
static constexpr intptr_t kObjectAlignment

◆ InitializeHeader() [2/2]

static void dart::Deserializer::InitializeHeader ( ObjectPtr  raw,
intptr_t  cid,
intptr_t  size,
bool  is_canonical = false 
)
inlinestatic

Definition at line 684 of file app_snapshot.cc.

687 {
688 InitializeHeader(raw, cid, size, is_canonical,
690 }
static void InitializeHeader(ObjectPtr raw, intptr_t cid, intptr_t size, bool is_canonical=false)
bool ShouldHaveImmutabilityBitSetCid(intptr_t predefined_cid)
Definition class_id.h:507
const intptr_t cid

◆ instructions_table()

const InstructionsTable & dart::Deserializer::instructions_table ( ) const
inline

Definition at line 789 of file app_snapshot.cc.

789 {
790 return instructions_table_;
791 }

◆ is_non_root_unit()

bool dart::Deserializer::is_non_root_unit ( ) const
inline

Definition at line 784 of file app_snapshot.cc.

784{ return is_non_root_unit_; }

◆ kind()

Snapshot::Kind dart::Deserializer::kind ( ) const
inline

Definition at line 777 of file app_snapshot.cc.

777 {
778#if defined(DART_PRECOMPILED_RUNTIME)
779 return Snapshot::kFullAOT;
780#else
781 return kind_;
782#endif
783 }

◆ next_index()

intptr_t dart::Deserializer::next_index ( ) const
inline

Definition at line 774 of file app_snapshot.cc.

774{ return next_ref_index_; }

◆ num_base_objects()

intptr_t dart::Deserializer::num_base_objects ( ) const
inline

Definition at line 792 of file app_snapshot.cc.

792{ return num_base_objects_; }

◆ position()

intptr_t dart::Deserializer::position ( ) const
inline

Definition at line 710 of file app_snapshot.cc.

710{ return stream_.Position(); }
intptr_t Position() const
Definition datastream.h:127

◆ Read()

template<typename T >
T dart::Deserializer::Read ( )
inline

Definition at line 700 of file app_snapshot.cc.

700 {
701 return ReadStream::Raw<sizeof(T), T>::Read(&stream_);
702 }
#define T

◆ ReadBytes()

void dart::Deserializer::ReadBytes ( uint8_t *  addr,
intptr_t  len 
)
inline

Definition at line 706 of file app_snapshot.cc.

706{ stream_.ReadBytes(addr, len); }
void ReadBytes(void *addr, intptr_t len)
Definition datastream.h:90

◆ ReadCid()

intptr_t dart::Deserializer::ReadCid ( )
inline

Definition at line 751 of file app_snapshot.cc.

751 {
753 return Read<int32_t>();
754 }
#define COMPILE_ASSERT(expr)
Definition assert.h:339

◆ ReadCluster()

DeserializationCluster * dart::Deserializer::ReadCluster ( )

Definition at line 8955 of file app_snapshot.cc.

8955 {
8956 const uint32_t tags = Read<uint32_t>();
8957 const intptr_t cid = UntaggedObject::ClassIdTag::decode(tags);
8958 const bool is_canonical = UntaggedObject::CanonicalBit::decode(tags);
8959 const bool is_immutable = UntaggedObject::ImmutableBit::decode(tags);
8960 Zone* Z = zone_;
8961 if (cid >= kNumPredefinedCids || cid == kInstanceCid) {
8962 return new (Z) InstanceDeserializationCluster(
8963 cid, is_canonical, is_immutable, !is_non_root_unit_);
8964 }
8966 ASSERT(!is_canonical);
8967 return new (Z) TypedDataViewDeserializationCluster(cid);
8968 }
8970 ASSERT(!is_canonical);
8971 return new (Z) ExternalTypedDataDeserializationCluster(cid);
8972 }
8973 if (IsTypedDataClassId(cid)) {
8974 ASSERT(!is_canonical);
8975 return new (Z) TypedDataDeserializationCluster(cid);
8976 }
8977
8978#if !defined(DART_COMPRESSED_POINTERS)
8979 if (Snapshot::IncludesCode(kind_)) {
8980 switch (cid) {
8981 case kPcDescriptorsCid:
8982 case kCodeSourceMapCid:
8983 case kCompressedStackMapsCid:
8984 return new (Z)
8985 RODataDeserializationCluster(cid, is_canonical, !is_non_root_unit_);
8986 case kOneByteStringCid:
8987 case kTwoByteStringCid:
8988 case kStringCid:
8989 if (!is_non_root_unit_) {
8990 return new (Z) RODataDeserializationCluster(cid, is_canonical,
8991 !is_non_root_unit_);
8992 }
8993 break;
8994 }
8995 }
8996#endif
8997
8998 switch (cid) {
8999 case kClassCid:
9000 ASSERT(!is_canonical);
9001 return new (Z) ClassDeserializationCluster();
9002 case kTypeParametersCid:
9003 return new (Z) TypeParametersDeserializationCluster();
9004 case kTypeArgumentsCid:
9005 return new (Z)
9006 TypeArgumentsDeserializationCluster(is_canonical, !is_non_root_unit_);
9007 case kPatchClassCid:
9008 ASSERT(!is_canonical);
9009 return new (Z) PatchClassDeserializationCluster();
9010 case kFunctionCid:
9011 ASSERT(!is_canonical);
9012 return new (Z) FunctionDeserializationCluster();
9013 case kClosureDataCid:
9014 ASSERT(!is_canonical);
9015 return new (Z) ClosureDataDeserializationCluster();
9016 case kFfiTrampolineDataCid:
9017 ASSERT(!is_canonical);
9018 return new (Z) FfiTrampolineDataDeserializationCluster();
9019 case kFieldCid:
9020 ASSERT(!is_canonical);
9021 return new (Z) FieldDeserializationCluster();
9022 case kScriptCid:
9023 ASSERT(!is_canonical);
9024 return new (Z) ScriptDeserializationCluster();
9025 case kLibraryCid:
9026 ASSERT(!is_canonical);
9027 return new (Z) LibraryDeserializationCluster();
9028 case kNamespaceCid:
9029 ASSERT(!is_canonical);
9030 return new (Z) NamespaceDeserializationCluster();
9031#if !defined(DART_PRECOMPILED_RUNTIME)
9032 case kKernelProgramInfoCid:
9033 ASSERT(!is_canonical);
9034 return new (Z) KernelProgramInfoDeserializationCluster();
9035#endif // !DART_PRECOMPILED_RUNTIME
9036 case kCodeCid:
9037 ASSERT(!is_canonical);
9038 return new (Z) CodeDeserializationCluster();
9039 case kObjectPoolCid:
9040 ASSERT(!is_canonical);
9041 return new (Z) ObjectPoolDeserializationCluster();
9042 case kPcDescriptorsCid:
9043 ASSERT(!is_canonical);
9044 return new (Z) PcDescriptorsDeserializationCluster();
9045 case kCodeSourceMapCid:
9046 ASSERT(!is_canonical);
9047 return new (Z) CodeSourceMapDeserializationCluster();
9048 case kCompressedStackMapsCid:
9049 ASSERT(!is_canonical);
9050 return new (Z) CompressedStackMapsDeserializationCluster();
9051 case kExceptionHandlersCid:
9052 ASSERT(!is_canonical);
9053 return new (Z) ExceptionHandlersDeserializationCluster();
9054 case kContextCid:
9055 ASSERT(!is_canonical);
9056 return new (Z) ContextDeserializationCluster();
9057 case kContextScopeCid:
9058 ASSERT(!is_canonical);
9059 return new (Z) ContextScopeDeserializationCluster();
9060 case kUnlinkedCallCid:
9061 ASSERT(!is_canonical);
9062 return new (Z) UnlinkedCallDeserializationCluster();
9063 case kICDataCid:
9064 ASSERT(!is_canonical);
9065 return new (Z) ICDataDeserializationCluster();
9066 case kMegamorphicCacheCid:
9067 ASSERT(!is_canonical);
9068 return new (Z) MegamorphicCacheDeserializationCluster();
9069 case kSubtypeTestCacheCid:
9070 ASSERT(!is_canonical);
9071 return new (Z) SubtypeTestCacheDeserializationCluster();
9072 case kLoadingUnitCid:
9073 ASSERT(!is_canonical);
9074 return new (Z) LoadingUnitDeserializationCluster();
9075 case kLanguageErrorCid:
9076 ASSERT(!is_canonical);
9077 return new (Z) LanguageErrorDeserializationCluster();
9078 case kUnhandledExceptionCid:
9079 ASSERT(!is_canonical);
9080 return new (Z) UnhandledExceptionDeserializationCluster();
9081 case kLibraryPrefixCid:
9082 ASSERT(!is_canonical);
9083 return new (Z) LibraryPrefixDeserializationCluster();
9084 case kTypeCid:
9085 return new (Z)
9086 TypeDeserializationCluster(is_canonical, !is_non_root_unit_);
9087 case kFunctionTypeCid:
9088 return new (Z)
9089 FunctionTypeDeserializationCluster(is_canonical, !is_non_root_unit_);
9090 case kRecordTypeCid:
9091 return new (Z)
9092 RecordTypeDeserializationCluster(is_canonical, !is_non_root_unit_);
9093 case kTypeParameterCid:
9094 return new (Z)
9095 TypeParameterDeserializationCluster(is_canonical, !is_non_root_unit_);
9096 case kClosureCid:
9097 return new (Z)
9098 ClosureDeserializationCluster(is_canonical, !is_non_root_unit_);
9099 case kMintCid:
9100 return new (Z)
9101 MintDeserializationCluster(is_canonical, !is_non_root_unit_);
9102 case kDoubleCid:
9103 return new (Z)
9104 DoubleDeserializationCluster(is_canonical, !is_non_root_unit_);
9105 case kInt32x4Cid:
9106 case kFloat32x4Cid:
9107 case kFloat64x2Cid:
9108 return new (Z)
9109 Simd128DeserializationCluster(cid, is_canonical, !is_non_root_unit_);
9110 case kGrowableObjectArrayCid:
9111 ASSERT(!is_canonical);
9112 return new (Z) GrowableObjectArrayDeserializationCluster();
9113 case kRecordCid:
9114 return new (Z)
9115 RecordDeserializationCluster(is_canonical, !is_non_root_unit_);
9116 case kStackTraceCid:
9117 ASSERT(!is_canonical);
9118 return new (Z) StackTraceDeserializationCluster();
9119 case kRegExpCid:
9120 ASSERT(!is_canonical);
9121 return new (Z) RegExpDeserializationCluster();
9122 case kWeakPropertyCid:
9123 ASSERT(!is_canonical);
9124 return new (Z) WeakPropertyDeserializationCluster();
9125 case kMapCid:
9126 // We do not have mutable hash maps in snapshots.
9127 UNREACHABLE();
9128 case kConstMapCid:
9129 return new (Z) MapDeserializationCluster(kConstMapCid, is_canonical,
9130 !is_non_root_unit_);
9131 case kSetCid:
9132 // We do not have mutable hash sets in snapshots.
9133 UNREACHABLE();
9134 case kConstSetCid:
9135 return new (Z) SetDeserializationCluster(kConstSetCid, is_canonical,
9136 !is_non_root_unit_);
9137 case kArrayCid:
9138 return new (Z) ArrayDeserializationCluster(kArrayCid, is_canonical,
9139 !is_non_root_unit_);
9140 case kImmutableArrayCid:
9141 return new (Z) ArrayDeserializationCluster(
9142 kImmutableArrayCid, is_canonical, !is_non_root_unit_);
9143 case kWeakArrayCid:
9144 return new (Z) WeakArrayDeserializationCluster();
9145 case kStringCid:
9146 return new (Z) StringDeserializationCluster(
9147 is_canonical,
9148 !is_non_root_unit_ && isolate_group() != Dart::vm_isolate_group());
9149#define CASE_FFI_CID(name) case kFfi##name##Cid:
9151#undef CASE_FFI_CID
9152 return new (Z) InstanceDeserializationCluster(
9153 cid, is_canonical, is_immutable, !is_non_root_unit_);
9154 case kDeltaEncodedTypedDataCid:
9155 return new (Z) DeltaEncodedTypedDataDeserializationCluster();
9156 default:
9157 break;
9158 }
9159 FATAL("No cluster defined for cid %" Pd, cid);
9160 return nullptr;
9161}
#define CASE_FFI_CID(name)
#define UNREACHABLE()
Definition assert.h:248
#define Z
#define CLASS_LIST_FFI_TYPE_MARKER(V)
Definition class_id.h:165
static IsolateGroup * vm_isolate_group()
Definition dart.h:69
bool IsTypedDataViewClassId(intptr_t index)
Definition class_id.h:439
bool IsTypedDataClassId(intptr_t index)
Definition class_id.h:433
@ kNumPredefinedCids
Definition class_id.h:257
bool IsExternalTypedDataClassId(intptr_t index)
Definition class_id.h:447

◆ ReadDispatchTable() [1/2]

void dart::Deserializer::ReadDispatchTable ( )
inline

Definition at line 764 of file app_snapshot.cc.

764 {
765 ReadDispatchTable(&stream_, /*deferred=*/false, InstructionsTable::Handle(),
766 -1, -1);
767 }

◆ ReadDispatchTable() [2/2]

void dart::Deserializer::ReadDispatchTable ( ReadStream stream,
bool  deferred,
const InstructionsTable root_instruction_table,
intptr_t  deferred_code_start_index,
intptr_t  deferred_code_end_index 
)

Definition at line 9163 of file app_snapshot.cc.

9168 {
9169#if defined(DART_PRECOMPILED_RUNTIME)
9170 const uint8_t* table_snapshot_start = stream->AddressOfCurrentPosition();
9171 const intptr_t length = stream->ReadUnsigned();
9172 if (length == 0) return;
9173
9174 const intptr_t first_code_id = stream->ReadUnsigned();
9175 deferred_code_start_index -= first_code_id;
9176 deferred_code_end_index -= first_code_id;
9177
9178 auto const IG = isolate_group();
9179 auto code = IG->object_store()->dispatch_table_null_error_stub();
9180 ASSERT(code != Code::null());
9181 uword null_entry = Code::EntryPointOf(code);
9182
9183 DispatchTable* table;
9184 if (deferred) {
9185 table = IG->dispatch_table();
9186 ASSERT(table != nullptr && table->length() == length);
9187 } else {
9188 ASSERT(IG->dispatch_table() == nullptr);
9189 table = new DispatchTable(length);
9190 }
9191 auto const array = table->array();
9192 uword value = 0;
9193 uword recent[kDispatchTableRecentCount] = {0};
9194 intptr_t recent_index = 0;
9195 intptr_t repeat_count = 0;
9196 for (intptr_t i = 0; i < length; i++) {
9197 if (repeat_count > 0) {
9198 array[i] = value;
9199 repeat_count--;
9200 continue;
9201 }
9202 auto const encoded = stream->Read<intptr_t>();
9203 if (encoded == 0) {
9204 value = null_entry;
9205 } else if (encoded < 0) {
9206 intptr_t r = ~encoded;
9207 ASSERT(r < kDispatchTableRecentCount);
9208 value = recent[r];
9209 } else if (encoded <= kDispatchTableMaxRepeat) {
9210 repeat_count = encoded - 1;
9211 } else {
9212 const intptr_t code_index = encoded - kDispatchTableIndexBase;
9213 if (deferred) {
9214 const intptr_t code_id =
9215 CodeIndexToClusterIndex(root_instruction_table, code_index);
9216 if ((deferred_code_start_index <= code_id) &&
9217 (code_id < deferred_code_end_index)) {
9218 auto code = static_cast<CodePtr>(Ref(first_code_id + code_id));
9219 value = Code::EntryPointOf(code);
9220 } else {
9221 // Reuse old value from the dispatch table.
9222 value = array[i];
9223 }
9224 } else {
9225 value = GetEntryPointByCodeIndex(code_index);
9226 }
9227 recent[recent_index] = value;
9228 recent_index = (recent_index + 1) & kDispatchTableRecentMask;
9229 }
9230 array[i] = value;
9231 }
9232 ASSERT(repeat_count == 0);
9233
9234 if (!deferred) {
9235 IG->set_dispatch_table(table);
9236 intptr_t table_snapshot_size =
9237 stream->AddressOfCurrentPosition() - table_snapshot_start;
9238 IG->set_dispatch_table_snapshot(table_snapshot_start);
9239 IG->set_dispatch_table_snapshot_size(table_snapshot_size);
9240 }
9241#endif
9242}
#define IG
static uword EntryPointOf(const CodePtr code)
Definition object.h:6838
uword GetEntryPointByCodeIndex(intptr_t code_index) const
static intptr_t CodeIndexToClusterIndex(const InstructionsTable &table, intptr_t code_index)
static ObjectPtr null()
Definition object.h:433
uint8_t value
size_t length

◆ ReadInstructions()

void dart::Deserializer::ReadInstructions ( CodePtr  code,
bool  deferred 
)

Definition at line 9361 of file app_snapshot.cc.

9361 {
9362#if defined(DART_PRECOMPILED_RUNTIME)
9363 if (deferred) {
9364 uword entry_point = StubCode::NotLoaded().EntryPoint();
9365 code->untag()->entry_point_ = entry_point;
9366 code->untag()->unchecked_entry_point_ = entry_point;
9367 code->untag()->monomorphic_entry_point_ = entry_point;
9368 code->untag()->monomorphic_unchecked_entry_point_ = entry_point;
9369 code->untag()->instructions_length_ = 0;
9370 return;
9371 }
9372
9373 const uword payload_start = instructions_table_.EntryPointAt(
9374 instructions_table_.rodata()->first_entry_with_code +
9375 instructions_index_);
9376 const uint32_t payload_info = ReadUnsigned();
9377 const uint32_t unchecked_offset = payload_info >> 1;
9378 const bool has_monomorphic_entrypoint = (payload_info & 0x1) == 0x1;
9379
9380 const uword entry_offset =
9381 has_monomorphic_entrypoint ? Instructions::kPolymorphicEntryOffsetAOT : 0;
9382 const uword monomorphic_entry_offset =
9383 has_monomorphic_entrypoint ? Instructions::kMonomorphicEntryOffsetAOT : 0;
9384
9385 const uword entry_point = payload_start + entry_offset;
9386 const uword monomorphic_entry_point =
9387 payload_start + monomorphic_entry_offset;
9388
9389 instructions_table_.SetCodeAt(instructions_index_++, code);
9390
9391 // There are no serialized RawInstructions objects in this mode.
9392 code->untag()->instructions_ = Instructions::null();
9393 code->untag()->entry_point_ = entry_point;
9394 code->untag()->unchecked_entry_point_ = entry_point + unchecked_offset;
9395 code->untag()->monomorphic_entry_point_ = monomorphic_entry_point;
9396 code->untag()->monomorphic_unchecked_entry_point_ =
9397 monomorphic_entry_point + unchecked_offset;
9398#else
9399 ASSERT(!deferred);
9400 InstructionsPtr instr = image_reader_->GetInstructionsAt(Read<uint32_t>());
9401 uint32_t unchecked_offset = ReadUnsigned();
9402 code->untag()->instructions_ = instr;
9403 code->untag()->unchecked_offset_ = unchecked_offset;
9405 const uint32_t active_offset = Read<uint32_t>();
9406 instr = image_reader_->GetInstructionsAt(active_offset);
9407 unchecked_offset = ReadUnsigned();
9408 code->untag()->active_instructions_ = instr;
9409 Code::InitializeCachedEntryPointsFrom(code, instr, unchecked_offset);
9410#endif // defined(DART_PRECOMPILED_RUNTIME)
9411}
InstructionsPtr GetInstructionsAt(uint32_t offset) const
void SetCodeAt(intptr_t index, CodePtr code) const
Definition object.cc:15586
const UntaggedInstructionsTable::Data * rodata() const
Definition object.h:5962
uword EntryPointAt(intptr_t index) const
Definition object.cc:15688

◆ ReadRef()

ObjectPtr dart::Deserializer::ReadRef ( )
inline

Definition at line 745 of file app_snapshot.cc.

745{ return Ref(ReadRefId()); }

◆ ReadRefId()

intptr_t dart::Deserializer::ReadRefId ( )
inline

Definition at line 703 of file app_snapshot.cc.

703{ return stream_.ReadRefId(); }
intptr_t ReadRefId()
Definition datastream.h:103

◆ ReadTokenPosition()

TokenPosition dart::Deserializer::ReadTokenPosition ( )
inline

Definition at line 747 of file app_snapshot.cc.

747 {
748 return TokenPosition::Deserialize(Read<int32_t>());
749 }
static TokenPosition Deserialize(int32_t value)

◆ ReadUnsigned()

intptr_t dart::Deserializer::ReadUnsigned ( )
inline

Definition at line 704 of file app_snapshot.cc.

704{ return stream_.ReadUnsigned(); }

◆ ReadUnsigned64()

uint64_t dart::Deserializer::ReadUnsigned64 ( )
inline

Definition at line 705 of file app_snapshot.cc.

705{ return stream_.ReadUnsigned<uint64_t>(); }

◆ ReadWordWith32BitReads()

uword dart::Deserializer::ReadWordWith32BitReads ( )
inline

Definition at line 708 of file app_snapshot.cc.

708{ return stream_.ReadWordWith32BitReads(); }
uword ReadWordWith32BitReads()
Definition datastream.h:157

◆ Ref()

ObjectPtr dart::Deserializer::Ref ( intptr_t  index) const
inline

Definition at line 729 of file app_snapshot.cc.

729 {
730 ASSERT(index > 0);
731 ASSERT(index <= num_objects_);
732 return refs_->untag()->element(index);
733 }

◆ set_code_start_index()

void dart::Deserializer::set_code_start_index ( intptr_t  value)
inline

Definition at line 785 of file app_snapshot.cc.

785{ code_start_index_ = value; }

◆ set_code_stop_index()

void dart::Deserializer::set_code_stop_index ( intptr_t  value)
inline

Definition at line 787 of file app_snapshot.cc.

787{ code_stop_index_ = value; }

◆ set_position()

void dart::Deserializer::set_position ( intptr_t  p)
inline

Definition at line 711 of file app_snapshot.cc.

711{ stream_.SetPosition(p); }

◆ VerifyImageAlignment()

ApiErrorPtr dart::Deserializer::VerifyImageAlignment ( )

Definition at line 9244 of file app_snapshot.cc.

9244 {
9245 if (image_reader_ != nullptr) {
9246 return image_reader_->VerifyAlignment();
9247 }
9248 return ApiError::null();
9249}
ApiErrorPtr VerifyAlignment() const

◆ zone()

Zone * dart::Deserializer::zone ( ) const
inline

Definition at line 776 of file app_snapshot.cc.

776{ return zone_; }

The documentation for this class was generated from the following file: