4#if !defined(DART_PRECOMPILED_RUNTIME)
26#define CASE(Name, value) \
38 const intptr_t start_offset =
offset();
41 intptr_t max_start = 0;
42 for (intptr_t i = 0; i < line_start_count; ++i) {
47 const intptr_t
cid = (max_start <=
kMaxUint16) ? kTypedDataUint16ArrayCid
48 : kTypedDataUint32ArrayCid;
53 intptr_t current_start = 0;
54 for (intptr_t i = 0; i < line_start_count; ++i) {
56 current_start += delta;
57 if (
cid == kTypedDataUint16ArrayCid) {
58 line_starts_data.SetUint16(i << 1,
static_cast<uint16_t
>(current_start));
60 line_starts_data.SetUint32(i << 2, current_start);
64 return line_starts_data.
ptr();
68 "File size is too small to be a valid kernel file";
71 "Invalid kernel binary format version";
73 "Invalid kernel binary: Indicated size is invalid";
88std::unique_ptr<Program> Program::ReadFrom(Reader* reader,
const char**
error) {
89 if (reader->size() < 70) {
105 if (
error !=
nullptr) {
111 uint32_t
magic = reader->ReadUInt32();
113 if (
error !=
nullptr) {
119 const uint32_t format_version = reader->ReadUInt32();
121 if (
error !=
nullptr) {
128 if (
error !=
nullptr) {
135 std::unique_ptr<Program> program(
new Program(reader->typed_data()));
139 int subprogram_count = 0;
140 reader->set_offset(reader->size() - 4);
141 while (reader->offset() > 0) {
142 intptr_t
size = reader->ReadUInt32();
143 intptr_t
start = reader->offset() -
size;
144 if (
start < 0 || size <= 0) {
145 if (
error !=
nullptr) {
151 if (subprogram_count > 1)
break;
152 reader->set_offset(
start - 4);
154 program->single_program_ = subprogram_count == 1;
157 program->library_count_ = reader->ReadFromIndexNoReset(
159 intptr_t count_from_first_library_offset =
161 program->source_table_offset_ = reader->ReadFromIndexNoReset(
164 count_from_first_library_offset,
166 program->constant_table_offset_ = reader->ReadUInt32();
167 reader->ReadUInt32();
168 program->name_table_offset_ = reader->ReadUInt32();
169 program->metadata_payloads_offset_ = reader->ReadUInt32();
170 program->metadata_mappings_offset_ = reader->ReadUInt32();
171 program->string_table_offset_ = reader->ReadUInt32();
174 program->component_index_offset_ = reader->ReadUInt32();
176 program->main_method_reference_ = NameIndex(reader->ReadUInt32() - 1);
177 reader->ReadUInt32();
182std::unique_ptr<Program> Program::ReadFromFile(
183 const char* script_uri,
184 const char**
error ) {
186 auto isolate_group = thread->isolate_group();
187 if (script_uri ==
nullptr) {
190 if (!isolate_group->HasTagHandler()) {
193 std::unique_ptr<kernel::Program> kernel_program;
198 if (ret.IsExternalTypedData()) {
199 const auto& typed_data = ExternalTypedData::Cast(ret);
200 kernel_program = kernel::Program::ReadFromTypedData(typed_data);
201 return kernel_program;
202 }
else if (
error !=
nullptr) {
203 Api::Scope api_scope(thread);
206 TransitionVMToNative transition(thread);
210 return kernel_program;
213std::unique_ptr<Program> Program::ReadFromBuffer(
const uint8_t*
buffer,
214 intptr_t buffer_length,
215 const char**
error) {
219 kExternalTypedDataUint8ArrayCid,
const_cast<uint8_t*
>(
buffer),
221 kernel::Reader reader(binary);
222 return kernel::Program::ReadFrom(&reader,
error);
225std::unique_ptr<Program> Program::ReadFromTypedData(
226 const ExternalTypedData& typed_data,
227 const char**
error) {
228 kernel::Reader reader(typed_data);
229 return kernel::Program::ReadFrom(&reader,
error);
static Dart_Handle NewHandle(Thread *thread, ObjectPtr raw)
static ExternalTypedDataPtr New(intptr_t class_id, uint8_t *data, intptr_t len, Heap::Space space=Heap::kNew, bool perform_eager_msan_initialization_check=true)
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
static Thread * Current()
static TypedDataPtr New(intptr_t class_id, intptr_t len, Heap::Space space=Heap::kNew)
static const char * SdkHash()
void set_offset(intptr_t offset)
TypedDataPtr ReadLineStartsData(intptr_t line_start_count)
static const char * TagName(Tag tag)
struct _Dart_Handle * Dart_Handle
static const uint8_t buffer[]
const uint8_t uint32_t uint32_t GError ** error
#define CASE(Arity, Mask, Name, Args, Result)
#define KERNEL_TAG_LIST(V)
bool IsValidSdkHash(const uint8_t *sdk_hash)
const char * kKernelInvalidMagicIdentifier
const char * kKernelInvalidSdkHash
const int kSdkHashSizeInBytes
const char * kKernelInvalidSizeIndicated
const char * kKernelInvalidBinaryFormatVersion
const char * kKernelInvalidFilesize
static const uint32_t kMagicProgramFile
static constexpr int SourceTableFieldCountFromFirstLibraryOffset
static constexpr int LibraryCountFieldCountFromEnd
static const uint32_t kSupportedKernelFormatVersion
const char * kSdkHashNull
DART_EXPORT const char * Dart_GetError(Dart_Handle handle)
constexpr uint16_t kMaxUint16
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