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

#include <app_snapshot.h>

Public Member Functions

 SnapshotHeaderReader (const Snapshot *snapshot)
 
 SnapshotHeaderReader (Snapshot::Kind kind, const uint8_t *buffer, intptr_t size)
 
char * VerifyVersionAndFeatures (IsolateGroup *isolate_group, intptr_t *offset)
 

Static Public Member Functions

static char * InitializeGlobalVMFlagsFromSnapshot (const Snapshot *snapshot)
 

Detailed Description

Definition at line 72 of file app_snapshot.h.

Constructor & Destructor Documentation

◆ SnapshotHeaderReader() [1/2]

dart::SnapshotHeaderReader::SnapshotHeaderReader ( const Snapshot snapshot)
inlineexplicit

Definition at line 76 of file app_snapshot.h.

77 : SnapshotHeaderReader(snapshot->kind(),
78 snapshot->Addr(),
79 snapshot->length()) {}
SnapshotHeaderReader(const Snapshot *snapshot)

◆ SnapshotHeaderReader() [2/2]

dart::SnapshotHeaderReader::SnapshotHeaderReader ( Snapshot::Kind  kind,
const uint8_t *  buffer,
intptr_t  size 
)
inline

Definition at line 81 of file app_snapshot.h.

84 : kind_(kind), stream_(buffer, size) {
86 }
void SetPosition(intptr_t value)
Definition datastream.h:128
static constexpr intptr_t kHeaderSize
Definition snapshot.h:43
static const uint8_t buffer[]

Member Function Documentation

◆ InitializeGlobalVMFlagsFromSnapshot()

char * dart::SnapshotHeaderReader::InitializeGlobalVMFlagsFromSnapshot ( const Snapshot snapshot)
static

Definition at line 9786 of file app_snapshot.cc.

9787 {
9788 SnapshotHeaderReader header_reader(snapshot);
9789
9790 char* error = header_reader.VerifyVersion();
9791 if (error != nullptr) {
9792 return error;
9793 }
9794
9795 const char* features = nullptr;
9796 intptr_t features_length = 0;
9797 error = header_reader.ReadFeatures(&features, &features_length);
9798 if (error != nullptr) {
9799 return error;
9800 }
9801
9802 ASSERT(features[features_length] == '\0');
9803 const char* cursor = features;
9804 while (*cursor != '\0') {
9805 while (*cursor == ' ') {
9806 cursor++;
9807 }
9808
9809 const char* end = strstr(cursor, " ");
9810 if (end == nullptr) {
9811 end = features + features_length;
9812 }
9813
9814#define SET_FLAG(name) \
9815 if (strncmp(cursor, #name, end - cursor) == 0) { \
9816 FLAG_##name = true; \
9817 cursor = end; \
9818 continue; \
9819 } \
9820 if (strncmp(cursor, "no-" #name, end - cursor) == 0) { \
9821 FLAG_##name = false; \
9822 cursor = end; \
9823 continue; \
9824 }
9825
9826#define CHECK_FLAG(name, mode) \
9827 if (strncmp(cursor, #name, end - cursor) == 0) { \
9828 if (!FLAG_##name) { \
9829 return header_reader.BuildError("Flag " #name \
9830 " is true in snapshot, " \
9831 "but " #name \
9832 " is always false in " mode); \
9833 } \
9834 cursor = end; \
9835 continue; \
9836 } \
9837 if (strncmp(cursor, "no-" #name, end - cursor) == 0) { \
9838 if (FLAG_##name) { \
9839 return header_reader.BuildError("Flag " #name \
9840 " is false in snapshot, " \
9841 "but " #name \
9842 " is always true in " mode); \
9843 } \
9844 cursor = end; \
9845 continue; \
9846 }
9847
9848#define SET_P(name, T, DV, C) SET_FLAG(name)
9849
9850#if defined(PRODUCT)
9851#define SET_OR_CHECK_R(name, PV, T, DV, C) CHECK_FLAG(name, "product mode")
9852#else
9853#define SET_OR_CHECK_R(name, PV, T, DV, C) SET_FLAG(name)
9854#endif
9855
9856#if defined(PRODUCT)
9857#define SET_OR_CHECK_C(name, PCV, PV, T, DV, C) CHECK_FLAG(name, "product mode")
9858#elif defined(DART_PRECOMPILED_RUNTIME)
9859#define SET_OR_CHECK_C(name, PCV, PV, T, DV, C) \
9860 CHECK_FLAG(name, "the precompiled runtime")
9861#else
9862#define SET_OR_CHECK_C(name, PV, T, DV, C) SET_FLAG(name)
9863#endif
9864
9865#if !defined(DEBUG)
9866#define SET_OR_CHECK_D(name, T, DV, C) CHECK_FLAG(name, "non-debug mode")
9867#else
9868#define SET_OR_CHECK_D(name, T, DV, C) SET_FLAG(name)
9869#endif
9870
9872
9873#undef SET_OR_CHECK_D
9874#undef SET_OR_CHECK_C
9875#undef SET_OR_CHECK_R
9876#undef SET_P
9877#undef CHECK_FLAG
9878#undef SET_FLAG
9879
9880 cursor = end;
9881 }
9882
9883 return nullptr;
9884}
#define SET_OR_CHECK_R(name, PV, T, DV, C)
#define SET_P(name, T, DV, C)
#define SET_OR_CHECK_C(name, PV, T, DV, C)
#define SET_OR_CHECK_D(name, T, DV, C)
#define ASSERT(E)
glong glong end
const uint8_t uint32_t uint32_t GError ** error
#define VM_GLOBAL_FLAG_LIST(P, R, C, D)
Definition flag_list.h:58

◆ VerifyVersionAndFeatures()

char * dart::SnapshotHeaderReader::VerifyVersionAndFeatures ( IsolateGroup isolate_group,
intptr_t *  offset 
)

Definition at line 9251 of file app_snapshot.cc.

9253 {
9254 char* error = VerifyVersion();
9255 if (error == nullptr) {
9256 error = VerifyFeatures(isolate_group);
9257 }
9258 if (error == nullptr) {
9259 *offset = stream_.Position();
9260 }
9261 return error;
9262}
intptr_t Position() const
Definition datastream.h:127
Point offset

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