Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dart::FullSnapshotReader Class Reference

#include <app_snapshot.h>

Public Member Functions

 FullSnapshotReader (const Snapshot *snapshot, const uint8_t *instructions_buffer, Thread *thread)
 
 ~FullSnapshotReader ()
 
ApiErrorPtr ReadVMSnapshot ()
 
ApiErrorPtr ReadProgramSnapshot ()
 
ApiErrorPtr ReadUnitSnapshot (const LoadingUnit &unit)
 

Detailed Description

Definition at line 161 of file app_snapshot.h.

Constructor & Destructor Documentation

◆ FullSnapshotReader()

dart::FullSnapshotReader::FullSnapshotReader ( const Snapshot snapshot,
const uint8_t *  instructions_buffer,
Thread thread 
)

Definition at line 9776 of file app_snapshot.cc.

9779 : kind_(snapshot->kind()),
9780 thread_(thread),
9781 buffer_(snapshot->Addr()),
9782 size_(snapshot->length()),
9783 data_image_(snapshot->DataImage()),
9784 instructions_image_(instructions_buffer) {}

◆ ~FullSnapshotReader()

dart::FullSnapshotReader::~FullSnapshotReader ( )
inline

Definition at line 166 of file app_snapshot.h.

166{}

Member Function Documentation

◆ ReadProgramSnapshot()

ApiErrorPtr dart::FullSnapshotReader::ReadProgramSnapshot ( )

Definition at line 9933 of file app_snapshot.cc.

9933 {
9934 SnapshotHeaderReader header_reader(kind_, buffer_, size_);
9935 intptr_t offset = 0;
9936 char* error =
9937 header_reader.VerifyVersionAndFeatures(thread_->isolate_group(), &offset);
9938 if (error != nullptr) {
9939 return ConvertToApiError(error);
9940 }
9941
9942 // Even though there's no concurrent threads we have to guard agains, some
9943 // logic we do in deserialization triggers common code that asserts the
9944 // program lock is held.
9945 SafepointWriteRwLocker ml(thread_, isolate_group()->program_lock());
9946
9947 Deserializer deserializer(thread_, kind_, buffer_, size_, data_image_,
9948 instructions_image_, /*is_non_root_unit=*/false,
9949 offset);
9950 ApiErrorPtr api_error = deserializer.VerifyImageAlignment();
9951 if (api_error != ApiError::null()) {
9952 return api_error;
9953 }
9954
9955 if (Snapshot::IncludesCode(kind_)) {
9956 ASSERT(data_image_ != nullptr);
9957 thread_->isolate_group()->SetupImagePage(data_image_,
9958 /* is_executable */ false);
9959 ASSERT(instructions_image_ != nullptr);
9960 thread_->isolate_group()->SetupImagePage(instructions_image_,
9961 /* is_executable */ true);
9962 }
9963
9964 ProgramDeserializationRoots roots(thread_->isolate_group()->object_store());
9965 deserializer.Deserialize(&roots);
9966
9967 if (Snapshot::IncludesCode(kind_)) {
9968 const auto& units = Array::Handle(
9969 thread_->isolate_group()->object_store()->loading_units());
9970 if (!units.IsNull()) {
9971 const auto& unit = LoadingUnit::Handle(
9973 // Unlike other units, we don't explicitly load the root loading unit,
9974 // so we mark it as loaded here, setting the instructions image as well.
9975 unit.set_load_outstanding();
9976 unit.set_instructions_image(instructions_image_);
9977 unit.set_loaded(true);
9978 }
9979 }
9980
9981 InitializeBSS();
9982
9983 return ApiError::null();
9984}
ObjectStore * object_store() const
Definition isolate.h:505
void SetupImagePage(const uint8_t *snapshot_buffer, bool is_executable)
Definition isolate.cc:1917
static constexpr intptr_t kRootId
Definition object.h:7940
static ObjectPtr null()
Definition object.h:433
static Object & Handle()
Definition object.h:407
static ObjectPtr RawCast(ObjectPtr obj)
Definition object.h:325
static bool IncludesCode(Kind kind)
Definition snapshot.h:67
IsolateGroup * isolate_group() const
Definition thread.h:540
#define ASSERT(E)
const uint8_t uint32_t uint32_t GError ** error
Point offset

◆ ReadUnitSnapshot()

ApiErrorPtr dart::FullSnapshotReader::ReadUnitSnapshot ( const LoadingUnit unit)

Definition at line 9986 of file app_snapshot.cc.

9986 {
9987 SnapshotHeaderReader header_reader(kind_, buffer_, size_);
9988 intptr_t offset = 0;
9989 char* error =
9990 header_reader.VerifyVersionAndFeatures(thread_->isolate_group(), &offset);
9991 if (error != nullptr) {
9992 return ConvertToApiError(error);
9993 }
9994
9995 Deserializer deserializer(
9996 thread_, kind_, buffer_, size_, data_image_, instructions_image_,
9997 /*is_non_root_unit=*/unit.id() != LoadingUnit::kRootId, offset);
9998 ApiErrorPtr api_error = deserializer.VerifyImageAlignment();
9999 if (api_error != ApiError::null()) {
10000 return api_error;
10001 }
10002 {
10003 Array& units =
10004 Array::Handle(isolate_group()->object_store()->loading_units());
10005 uint32_t main_program_hash = Smi::Value(Smi::RawCast(units.At(0)));
10006 uint32_t unit_program_hash = deserializer.Read<uint32_t>();
10007 if (main_program_hash != unit_program_hash) {
10008 return ApiError::New(String::Handle(
10009 String::New("Deferred loading unit is from a different "
10010 "program than the main loading unit")));
10011 }
10012 }
10013
10014 if (Snapshot::IncludesCode(kind_)) {
10015 ASSERT(data_image_ != nullptr);
10016 thread_->isolate_group()->SetupImagePage(data_image_,
10017 /* is_executable */ false);
10018 ASSERT(instructions_image_ != nullptr);
10019 thread_->isolate_group()->SetupImagePage(instructions_image_,
10020 /* is_executable */ true);
10021 unit.set_instructions_image(instructions_image_);
10022 }
10023
10024 UnitDeserializationRoots roots(unit);
10025 deserializer.Deserialize(&roots);
10026
10027 InitializeBSS();
10028
10029 return ApiError::null();
10030}
intptr_t Value() const
Definition object.h:9969
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
Definition object.cc:23777

◆ ReadVMSnapshot()

ApiErrorPtr dart::FullSnapshotReader::ReadVMSnapshot ( )

Definition at line 9886 of file app_snapshot.cc.

9886 {
9887 SnapshotHeaderReader header_reader(kind_, buffer_, size_);
9888
9889 intptr_t offset = 0;
9890 char* error = header_reader.VerifyVersionAndFeatures(
9891 /*isolate_group=*/nullptr, &offset);
9892 if (error != nullptr) {
9893 return ConvertToApiError(error);
9894 }
9895
9896 // Even though there's no concurrent threads we have to guard agains, some
9897 // logic we do in deserialization triggers common code that asserts the
9898 // program lock is held.
9899 SafepointWriteRwLocker ml(thread_, isolate_group()->program_lock());
9900
9901 Deserializer deserializer(thread_, kind_, buffer_, size_, data_image_,
9902 instructions_image_, /*is_non_root_unit=*/false,
9903 offset);
9904 ApiErrorPtr api_error = deserializer.VerifyImageAlignment();
9905 if (api_error != ApiError::null()) {
9906 return api_error;
9907 }
9908
9909 if (Snapshot::IncludesCode(kind_)) {
9910 ASSERT(data_image_ != nullptr);
9911 thread_->isolate_group()->SetupImagePage(data_image_,
9912 /* is_executable */ false);
9913 ASSERT(instructions_image_ != nullptr);
9914 thread_->isolate_group()->SetupImagePage(instructions_image_,
9915 /* is_executable */ true);
9916 }
9917
9918 VMDeserializationRoots roots;
9919 deserializer.Deserialize(&roots);
9920
9921#if defined(DART_PRECOMPILED_RUNTIME)
9922 // Initialize entries in the VM portion of the BSS segment.
9924 Image image(instructions_image_);
9925 if (auto const bss = image.bss()) {
9926 BSS::Initialize(thread_, bss, /*vm=*/true);
9927 }
9928#endif // defined(DART_PRECOMPILED_RUNTIME)
9929
9930 return ApiError::null();
9931}
static void Initialize(Thread *current, uword *bss, bool vm)
Definition bss_relocs.cc:30
sk_sp< SkImage > image
Definition examples.cpp:29
CanvasImage Image
Definition dart_ui.cc:55

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