Flutter Engine
The Flutter Engine
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 8954 of file app_snapshot.cc.

8963 heap_(thread->isolate_group()->heap()),
8964 old_space_(heap_->old_space()),
8965 freelist_(old_space_->DataFreeList()),
8966 zone_(thread->zone()),
8967 kind_(kind),
8968 stream_(buffer, size),
8969 image_reader_(nullptr),
8970 refs_(nullptr),
8971 next_ref_index_(kFirstReference),
8972 clusters_(nullptr),
8973 is_non_root_unit_(is_non_root_unit),
8974 instructions_table_(InstructionsTable::Handle(thread->zone())) {
8976 ASSERT(instructions_buffer != nullptr);
8977 ASSERT(data_buffer != nullptr);
8978 image_reader_ = new (zone_) ImageReader(data_buffer, instructions_buffer);
8979 }
8980 stream_.SetPosition(offset);
8981}
bool is_non_root_unit() const
Snapshot::Kind kind() const
PageSpace * old_space()
Definition: heap.h:63
Heap * heap() const
Definition: isolate.h:296
static Object & Handle()
Definition: object.h:407
FreeList * DataFreeList(intptr_t i=0)
Definition: pages.h:301
void SetPosition(intptr_t value)
Definition: datastream.h:128
static bool IncludesCode(Kind kind)
Definition: snapshot.h:67
Zone * zone() const
Definition: thread_state.h:37
IsolateGroup * isolate_group() const
Definition: thread.h:541
#define ASSERT(E)
static constexpr intptr_t kFirstReference
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
SeparatedVector2 offset

◆ ~Deserializer()

dart::Deserializer::~Deserializer ( )

Definition at line 8983 of file app_snapshot.cc.

8983 {
8984 delete[] clusters_;
8985}

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
uint8_t value

◆ 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:516

◆ 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 9520 of file app_snapshot.cc.

9520 {
9521 const void* clustered_start = AddressOfCurrentPosition();
9522
9523 Array& refs = Array::Handle(zone_);
9524 num_base_objects_ = ReadUnsigned();
9525 num_objects_ = ReadUnsigned();
9526 num_clusters_ = ReadUnsigned();
9527 const intptr_t instructions_table_len = ReadUnsigned();
9528 const uint32_t instruction_table_data_offset = ReadUnsigned();
9529 USE(instruction_table_data_offset);
9530
9531 clusters_ = new DeserializationCluster*[num_clusters_];
9532 refs = Array::New(num_objects_ + kFirstReference, Heap::kOld);
9533
9534#if defined(DART_PRECOMPILED_RUNTIME)
9535 if (instructions_table_len > 0) {
9536 ASSERT(FLAG_precompiled_mode);
9537 const uword start_pc = image_reader_->GetBareInstructionsAt(0);
9538 const uword end_pc = image_reader_->GetBareInstructionsEnd();
9539 uword instruction_table_data = 0;
9540 if (instruction_table_data_offset != 0) {
9541 // NoSafepointScope to satisfy assertion in DataStart. InstructionsTable
9542 // data resides in RO memory and is immovable and immortal making it
9543 // safe to use DataStart result outside of NoSafepointScope.
9544 NoSafepointScope no_safepoint;
9545 instruction_table_data = reinterpret_cast<uword>(
9546 OneByteString::DataStart(String::Handle(static_cast<StringPtr>(
9547 image_reader_->GetObjectAt(instruction_table_data_offset)))));
9548 }
9549 instructions_table_ = InstructionsTable::New(
9550 instructions_table_len, start_pc, end_pc, instruction_table_data);
9551 }
9552#else
9553 ASSERT(instructions_table_len == 0);
9554#endif // defined(DART_PRECOMPILED_RUNTIME)
9555
9556 {
9557 // The deserializer initializes objects without using the write barrier,
9558 // partly for speed since we know all the deserialized objects will be
9559 // long-lived and partly because the target objects can be not yet
9560 // initialized at the time of the write. To make this safe, we must ensure
9561 // there are no other threads mutating this heap, and that incremental
9562 // marking is not in progress. This is normally the case anyway for the
9563 // main snapshot being deserialized at isolate load, but needs checks for
9564 // loading secondary snapshots are part of deferred loading.
9565 HeapIterationScope iter(thread());
9566 // For bump-pointer allocation in old-space.
9567 HeapLocker hl(thread(), heap_->old_space());
9568 // Must not perform any other type of allocation, which might trigger GC
9569 // while there are still uninitialized objects.
9570 NoSafepointScope no_safepoint;
9571 refs_ = refs.ptr();
9572
9573 roots->AddBaseObjects(this);
9574
9575 if (num_base_objects_ != (next_ref_index_ - kFirstReference)) {
9576 FATAL("Snapshot expects %" Pd
9577 " base objects, but deserializer provided %" Pd,
9578 num_base_objects_, next_ref_index_ - kFirstReference);
9579 }
9580
9581 {
9582 TIMELINE_DURATION(thread(), Isolate, "ReadAlloc");
9583 for (intptr_t i = 0; i < num_clusters_; i++) {
9584 clusters_[i] = ReadCluster();
9585 clusters_[i]->ReadAlloc(this);
9586#if defined(DEBUG)
9587 intptr_t serializers_next_ref_index_ = Read<int32_t>();
9588 ASSERT_EQUAL(serializers_next_ref_index_, next_ref_index_);
9589#endif
9590 }
9591 }
9592
9593 // We should have completely filled the ref array.
9594 ASSERT_EQUAL(next_ref_index_ - kFirstReference, num_objects_);
9595
9596 {
9597 TIMELINE_DURATION(thread(), Isolate, "ReadFill");
9598 for (intptr_t i = 0; i < num_clusters_; i++) {
9599 clusters_[i]->ReadFill(this);
9600#if defined(DEBUG)
9601 int32_t section_marker = Read<int32_t>();
9602 ASSERT(section_marker == kSectionMarker);
9603#endif
9604 }
9605 }
9606
9607 roots->ReadRoots(this);
9608
9609#if defined(DEBUG)
9610 int32_t section_marker = Read<int32_t>();
9611 ASSERT(section_marker == kSectionMarker);
9612#endif
9613
9614 refs_ = nullptr;
9615 }
9616
9617 roots->PostLoad(this, refs);
9618
9620#if defined(DEBUG)
9621 isolate_group->ValidateClassTable();
9622 if (isolate_group != Dart::vm_isolate()->group()) {
9623 isolate_group->heap()->Verify("Deserializer::Deserialize");
9624 }
9625#endif
9626
9627 {
9628 TIMELINE_DURATION(thread(), Isolate, "PostLoad");
9629 for (intptr_t i = 0; i < num_clusters_; i++) {
9630 clusters_[i]->PostLoad(this, refs);
9631 }
9632 }
9633
9634 if (isolate_group->snapshot_is_dontneed_safe()) {
9635 size_t clustered_length =
9636 reinterpret_cast<uword>(AddressOfCurrentPosition()) -
9637 reinterpret_cast<uword>(clustered_start);
9638 VirtualMemory::DontNeed(const_cast<void*>(clustered_start),
9639 clustered_length);
9640 }
9641}
#define ASSERT_EQUAL(expected, actual)
Definition: assert.h:309
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition: object.h:10959
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:771
ObjectPtr GetObjectAt(uint32_t offset) const
static InstructionsTablePtr New(intptr_t length, uword start_pc, uword end_pc, uword rodata)
Definition: object.cc:15518
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 9465 of file app_snapshot.cc.

9465 {
9466#if defined(DART_PRECOMPILED_RUNTIME)
9467 if (instructions_table_.IsNull()) {
9468 ASSERT(instructions_index_ == 0);
9469 return;
9470 }
9471
9472 const auto& code_objects =
9473 Array::Handle(instructions_table_.ptr()->untag()->code_objects());
9474 ASSERT(code_objects.Length() == instructions_index_);
9475
9476 uword previous_end = image_reader_->GetBareInstructionsEnd();
9477 for (intptr_t i = instructions_index_ - 1; i >= 0; --i) {
9478 CodePtr code = Code::RawCast(code_objects.At(i));
9480 ASSERT(start <= previous_end);
9481 code->untag()->instructions_length_ = previous_end - start;
9482 previous_end = start;
9483 }
9484
9485 ObjectStore* object_store = IsolateGroup::Current()->object_store();
9486 GrowableObjectArray& tables =
9487 GrowableObjectArray::Handle(zone_, object_store->instructions_tables());
9488 if (tables.IsNull()) {
9490 object_store->set_instructions_tables(tables);
9491 }
9492 if ((tables.Length() == 0) ||
9493 (tables.At(tables.Length() - 1) != instructions_table_.ptr())) {
9494 ASSERT((!is_non_root_unit_ && tables.Length() == 0) ||
9495 (is_non_root_unit_ && tables.Length() > 0));
9496 tables.Add(instructions_table_, Heap::kOld);
9497 }
9498#endif
9499}
static uword PayloadStartOf(const CodePtr code)
Definition: object.h:6851
static GrowableObjectArrayPtr New(Heap::Space space=Heap::kNew)
Definition: object.h:11144
ObjectStore * object_store() const
Definition: isolate.h:510
static IsolateGroup * Current()
Definition: isolate.h:539
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 9501 of file app_snapshot.cc.

9501 {
9502 return image_reader_->GetObjectAt(offset);
9503}

◆ 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);
892 tags = UntaggedObject::CanonicalBit::update(is_canonical, tags);
893 tags = UntaggedObject::AlwaysSetBit::update(true, tags);
894 tags = UntaggedObject::NotMarkedBit::update(true, 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:188
static constexpr uword update(intptr_t size, uword tag)
Definition: raw_object.h:212
static constexpr bool IsAligned(T x, uintptr_t alignment, uintptr_t offset=0)
Definition: utils.h:92
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
Definition: precompiler.cc:65

◆ 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 }
COMPILE_ASSERT(kUnreachableReference==WeakTable::kNoValue)

◆ ReadCluster()

DeserializationCluster * dart::Deserializer::ReadCluster ( )

Definition at line 8987 of file app_snapshot.cc.

8987 {
8988 const uint32_t tags = Read<uint32_t>();
8989 const intptr_t cid = UntaggedObject::ClassIdTag::decode(tags);
8990 const bool is_canonical = UntaggedObject::CanonicalBit::decode(tags);
8991 const bool is_immutable = UntaggedObject::ImmutableBit::decode(tags);
8992 Zone* Z = zone_;
8993 if (cid >= kNumPredefinedCids || cid == kInstanceCid) {
8994 return new (Z) InstanceDeserializationCluster(
8995 cid, is_canonical, is_immutable, !is_non_root_unit_);
8996 }
8998 ASSERT(!is_canonical);
8999 return new (Z) TypedDataViewDeserializationCluster(cid);
9000 }
9002 ASSERT(!is_canonical);
9003 return new (Z) ExternalTypedDataDeserializationCluster(cid);
9004 }
9005 if (IsTypedDataClassId(cid)) {
9006 ASSERT(!is_canonical);
9007 return new (Z) TypedDataDeserializationCluster(cid);
9008 }
9009
9010#if !defined(DART_COMPRESSED_POINTERS)
9011 if (Snapshot::IncludesCode(kind_)) {
9012 switch (cid) {
9013 case kPcDescriptorsCid:
9014 case kCodeSourceMapCid:
9015 case kCompressedStackMapsCid:
9016 return new (Z)
9017 RODataDeserializationCluster(cid, is_canonical, !is_non_root_unit_);
9018 case kOneByteStringCid:
9019 case kTwoByteStringCid:
9020 case kStringCid:
9021 if (!is_non_root_unit_) {
9022 return new (Z) RODataDeserializationCluster(cid, is_canonical,
9023 !is_non_root_unit_);
9024 }
9025 break;
9026 }
9027 }
9028#endif
9029
9030 switch (cid) {
9031 case kClassCid:
9032 ASSERT(!is_canonical);
9033 return new (Z) ClassDeserializationCluster();
9034 case kTypeParametersCid:
9035 return new (Z) TypeParametersDeserializationCluster();
9036 case kTypeArgumentsCid:
9037 return new (Z)
9038 TypeArgumentsDeserializationCluster(is_canonical, !is_non_root_unit_);
9039 case kPatchClassCid:
9040 ASSERT(!is_canonical);
9041 return new (Z) PatchClassDeserializationCluster();
9042 case kFunctionCid:
9043 ASSERT(!is_canonical);
9044 return new (Z) FunctionDeserializationCluster();
9045 case kClosureDataCid:
9046 ASSERT(!is_canonical);
9047 return new (Z) ClosureDataDeserializationCluster();
9048 case kFfiTrampolineDataCid:
9049 ASSERT(!is_canonical);
9050 return new (Z) FfiTrampolineDataDeserializationCluster();
9051 case kFieldCid:
9052 ASSERT(!is_canonical);
9053 return new (Z) FieldDeserializationCluster();
9054 case kScriptCid:
9055 ASSERT(!is_canonical);
9056 return new (Z) ScriptDeserializationCluster();
9057 case kLibraryCid:
9058 ASSERT(!is_canonical);
9059 return new (Z) LibraryDeserializationCluster();
9060 case kNamespaceCid:
9061 ASSERT(!is_canonical);
9062 return new (Z) NamespaceDeserializationCluster();
9063#if !defined(DART_PRECOMPILED_RUNTIME)
9064 case kKernelProgramInfoCid:
9065 ASSERT(!is_canonical);
9066 return new (Z) KernelProgramInfoDeserializationCluster();
9067#endif // !DART_PRECOMPILED_RUNTIME
9068 case kCodeCid:
9069 ASSERT(!is_canonical);
9070 return new (Z) CodeDeserializationCluster();
9071 case kObjectPoolCid:
9072 ASSERT(!is_canonical);
9073 return new (Z) ObjectPoolDeserializationCluster();
9074 case kPcDescriptorsCid:
9075 ASSERT(!is_canonical);
9076 return new (Z) PcDescriptorsDeserializationCluster();
9077 case kCodeSourceMapCid:
9078 ASSERT(!is_canonical);
9079 return new (Z) CodeSourceMapDeserializationCluster();
9080 case kCompressedStackMapsCid:
9081 ASSERT(!is_canonical);
9082 return new (Z) CompressedStackMapsDeserializationCluster();
9083 case kExceptionHandlersCid:
9084 ASSERT(!is_canonical);
9085 return new (Z) ExceptionHandlersDeserializationCluster();
9086 case kContextCid:
9087 ASSERT(!is_canonical);
9088 return new (Z) ContextDeserializationCluster();
9089 case kContextScopeCid:
9090 ASSERT(!is_canonical);
9091 return new (Z) ContextScopeDeserializationCluster();
9092 case kUnlinkedCallCid:
9093 ASSERT(!is_canonical);
9094 return new (Z) UnlinkedCallDeserializationCluster();
9095 case kICDataCid:
9096 ASSERT(!is_canonical);
9097 return new (Z) ICDataDeserializationCluster();
9098 case kMegamorphicCacheCid:
9099 ASSERT(!is_canonical);
9100 return new (Z) MegamorphicCacheDeserializationCluster();
9101 case kSubtypeTestCacheCid:
9102 ASSERT(!is_canonical);
9103 return new (Z) SubtypeTestCacheDeserializationCluster();
9104 case kLoadingUnitCid:
9105 ASSERT(!is_canonical);
9106 return new (Z) LoadingUnitDeserializationCluster();
9107 case kLanguageErrorCid:
9108 ASSERT(!is_canonical);
9109 return new (Z) LanguageErrorDeserializationCluster();
9110 case kUnhandledExceptionCid:
9111 ASSERT(!is_canonical);
9112 return new (Z) UnhandledExceptionDeserializationCluster();
9113 case kLibraryPrefixCid:
9114 ASSERT(!is_canonical);
9115 return new (Z) LibraryPrefixDeserializationCluster();
9116 case kTypeCid:
9117 return new (Z)
9118 TypeDeserializationCluster(is_canonical, !is_non_root_unit_);
9119 case kFunctionTypeCid:
9120 return new (Z)
9121 FunctionTypeDeserializationCluster(is_canonical, !is_non_root_unit_);
9122 case kRecordTypeCid:
9123 return new (Z)
9124 RecordTypeDeserializationCluster(is_canonical, !is_non_root_unit_);
9125 case kTypeParameterCid:
9126 return new (Z)
9127 TypeParameterDeserializationCluster(is_canonical, !is_non_root_unit_);
9128 case kClosureCid:
9129 return new (Z)
9130 ClosureDeserializationCluster(is_canonical, !is_non_root_unit_);
9131 case kMintCid:
9132 return new (Z)
9133 MintDeserializationCluster(is_canonical, !is_non_root_unit_);
9134 case kDoubleCid:
9135 return new (Z)
9136 DoubleDeserializationCluster(is_canonical, !is_non_root_unit_);
9137 case kInt32x4Cid:
9138 case kFloat32x4Cid:
9139 case kFloat64x2Cid:
9140 return new (Z)
9141 Simd128DeserializationCluster(cid, is_canonical, !is_non_root_unit_);
9142 case kGrowableObjectArrayCid:
9143 ASSERT(!is_canonical);
9144 return new (Z) GrowableObjectArrayDeserializationCluster();
9145 case kRecordCid:
9146 return new (Z)
9147 RecordDeserializationCluster(is_canonical, !is_non_root_unit_);
9148 case kStackTraceCid:
9149 ASSERT(!is_canonical);
9150 return new (Z) StackTraceDeserializationCluster();
9151 case kRegExpCid:
9152 ASSERT(!is_canonical);
9153 return new (Z) RegExpDeserializationCluster();
9154 case kWeakPropertyCid:
9155 ASSERT(!is_canonical);
9156 return new (Z) WeakPropertyDeserializationCluster();
9157 case kMapCid:
9158 // We do not have mutable hash maps in snapshots.
9159 UNREACHABLE();
9160 case kConstMapCid:
9161 return new (Z) MapDeserializationCluster(kConstMapCid, is_canonical,
9162 !is_non_root_unit_);
9163 case kSetCid:
9164 // We do not have mutable hash sets in snapshots.
9165 UNREACHABLE();
9166 case kConstSetCid:
9167 return new (Z) SetDeserializationCluster(kConstSetCid, is_canonical,
9168 !is_non_root_unit_);
9169 case kArrayCid:
9170 return new (Z) ArrayDeserializationCluster(kArrayCid, is_canonical,
9171 !is_non_root_unit_);
9172 case kImmutableArrayCid:
9173 return new (Z) ArrayDeserializationCluster(
9174 kImmutableArrayCid, is_canonical, !is_non_root_unit_);
9175 case kWeakArrayCid:
9176 return new (Z) WeakArrayDeserializationCluster();
9177 case kStringCid:
9178 return new (Z) StringDeserializationCluster(
9179 is_canonical,
9180 !is_non_root_unit_ && isolate_group() != Dart::vm_isolate_group());
9181#define CASE_FFI_CID(name) case kFfi##name##Cid:
9183#undef CASE_FFI_CID
9184 return new (Z) InstanceDeserializationCluster(
9185 cid, is_canonical, is_immutable, !is_non_root_unit_);
9186 case kDeltaEncodedTypedDataCid:
9187 return new (Z) DeltaEncodedTypedDataDeserializationCluster();
9188 default:
9189 break;
9190 }
9191 FATAL("No cluster defined for cid %" Pd, cid);
9192 return nullptr;
9193}
#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 constexpr ClassIdTagType decode(uword value)
Definition: bitfield.h:171
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 9195 of file app_snapshot.cc.

9200 {
9201#if defined(DART_PRECOMPILED_RUNTIME)
9202 const uint8_t* table_snapshot_start = stream->AddressOfCurrentPosition();
9203 const intptr_t length = stream->ReadUnsigned();
9204 if (length == 0) return;
9205
9206 const intptr_t first_code_id = stream->ReadUnsigned();
9207 deferred_code_start_index -= first_code_id;
9208 deferred_code_end_index -= first_code_id;
9209
9210 auto const IG = isolate_group();
9211 auto code = IG->object_store()->dispatch_table_null_error_stub();
9212 ASSERT(code != Code::null());
9213 uword null_entry = Code::EntryPointOf(code);
9214
9215 DispatchTable* table;
9216 if (deferred) {
9217 table = IG->dispatch_table();
9218 ASSERT(table != nullptr && table->length() == length);
9219 } else {
9220 ASSERT(IG->dispatch_table() == nullptr);
9221 table = new DispatchTable(length);
9222 }
9223 auto const array = table->array();
9224 uword value = 0;
9225 uword recent[kDispatchTableRecentCount] = {0};
9226 intptr_t recent_index = 0;
9227 intptr_t repeat_count = 0;
9228 for (intptr_t i = 0; i < length; i++) {
9229 if (repeat_count > 0) {
9230 array[i] = value;
9231 repeat_count--;
9232 continue;
9233 }
9234 auto const encoded = stream->Read<intptr_t>();
9235 if (encoded == 0) {
9236 value = null_entry;
9237 } else if (encoded < 0) {
9238 intptr_t r = ~encoded;
9239 ASSERT(r < kDispatchTableRecentCount);
9240 value = recent[r];
9241 } else if (encoded <= kDispatchTableMaxRepeat) {
9242 repeat_count = encoded - 1;
9243 } else {
9244 const intptr_t code_index = encoded - kDispatchTableIndexBase;
9245 if (deferred) {
9246 const intptr_t code_id =
9247 CodeIndexToClusterIndex(root_instruction_table, code_index);
9248 if ((deferred_code_start_index <= code_id) &&
9249 (code_id < deferred_code_end_index)) {
9250 auto code = static_cast<CodePtr>(Ref(first_code_id + code_id));
9252 } else {
9253 // Reuse old value from the dispatch table.
9254 value = array[i];
9255 }
9256 } else {
9257 value = GetEntryPointByCodeIndex(code_index);
9258 }
9259 recent[recent_index] = value;
9260 recent_index = (recent_index + 1) & kDispatchTableRecentMask;
9261 }
9262 array[i] = value;
9263 }
9264 ASSERT(repeat_count == 0);
9265
9266 if (!deferred) {
9267 IG->set_dispatch_table(table);
9268 intptr_t table_snapshot_size =
9269 stream->AddressOfCurrentPosition() - table_snapshot_start;
9270 IG->set_dispatch_table_snapshot(table_snapshot_start);
9271 IG->set_dispatch_table_snapshot_size(table_snapshot_size);
9272 }
9273#endif
9274}
#define IG
static uword EntryPointOf(const CodePtr code)
Definition: object.h:6865
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
size_t length

◆ ReadInstructions()

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

Definition at line 9413 of file app_snapshot.cc.

9413 {
9414#if defined(DART_PRECOMPILED_RUNTIME)
9415 if (deferred) {
9416 uword entry_point = StubCode::NotLoaded().EntryPoint();
9417 code->untag()->entry_point_ = entry_point;
9418 code->untag()->unchecked_entry_point_ = entry_point;
9419 code->untag()->monomorphic_entry_point_ = entry_point;
9420 code->untag()->monomorphic_unchecked_entry_point_ = entry_point;
9421 code->untag()->instructions_length_ = 0;
9422 return;
9423 }
9424
9425 const uword payload_start = instructions_table_.EntryPointAt(
9426 instructions_table_.rodata()->first_entry_with_code +
9427 instructions_index_);
9428 const uint32_t payload_info = ReadUnsigned();
9429 const uint32_t unchecked_offset = payload_info >> 1;
9430 const bool has_monomorphic_entrypoint = (payload_info & 0x1) == 0x1;
9431
9432 const uword entry_offset =
9433 has_monomorphic_entrypoint ? Instructions::kPolymorphicEntryOffsetAOT : 0;
9434 const uword monomorphic_entry_offset =
9435 has_monomorphic_entrypoint ? Instructions::kMonomorphicEntryOffsetAOT : 0;
9436
9437 const uword entry_point = payload_start + entry_offset;
9438 const uword monomorphic_entry_point =
9439 payload_start + monomorphic_entry_offset;
9440
9441 instructions_table_.SetCodeAt(instructions_index_++, code);
9442
9443 // There are no serialized RawInstructions objects in this mode.
9444 code->untag()->instructions_ = Instructions::null();
9445 code->untag()->entry_point_ = entry_point;
9446 code->untag()->unchecked_entry_point_ = entry_point + unchecked_offset;
9447 code->untag()->monomorphic_entry_point_ = monomorphic_entry_point;
9448 code->untag()->monomorphic_unchecked_entry_point_ =
9449 monomorphic_entry_point + unchecked_offset;
9450#else
9451 ASSERT(!deferred);
9452 InstructionsPtr instr = image_reader_->GetInstructionsAt(Read<uint32_t>());
9453 uint32_t unchecked_offset = ReadUnsigned();
9454 code->untag()->instructions_ = instr;
9455 code->untag()->unchecked_offset_ = unchecked_offset;
9457 const uint32_t active_offset = Read<uint32_t>();
9458 instr = image_reader_->GetInstructionsAt(active_offset);
9459 unchecked_offset = ReadUnsigned();
9460 code->untag()->active_instructions_ = instr;
9461 Code::InitializeCachedEntryPointsFrom(code, instr, unchecked_offset);
9462#endif // defined(DART_PRECOMPILED_RUNTIME)
9463}
InstructionsPtr GetInstructionsAt(uint32_t offset) const
void SetCodeAt(intptr_t index, CodePtr code) const
Definition: object.cc:15539
const UntaggedInstructionsTable::Data * rodata() const
Definition: object.h:5991
uword EntryPointAt(intptr_t index) const
Definition: object.cc:15641

◆ ReadRef()

ObjectPtr dart::Deserializer::ReadRef ( )
inline

Definition at line 745 of file app_snapshot.cc.

745{ return Ref(ReadRefId()); }
intptr_t 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.

◆ VerifyImageAlignment()

ApiErrorPtr dart::Deserializer::VerifyImageAlignment ( )

Definition at line 9276 of file app_snapshot.cc.

9276 {
9277 if (image_reader_ != nullptr) {
9278 return image_reader_->VerifyAlignment();
9279 }
9280 return ApiError::null();
9281}
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: