20#if !defined(EXCLUDE_CFE_AND_KERNEL_PLATFORM)
41#if defined(EXCLUDE_CFE_AND_KERNEL_PLATFORM) || \
42 (defined(DART_PRECOMPILER) && defined(TARGET_ARCH_X64))
50#if defined(EXCLUDE_CFE_AND_KERNEL_PLATFORM)
58#if !defined(DART_PRECOMPILED_RUNTIME)
67 use_incremental_compiler_(
false),
68 frontend_filename_(nullptr),
69 application_kernel_buffer_(nullptr),
70 application_kernel_buffer_size_(0),
72 kernel_blobs_lock_() {}
75 if (frontend_filename_ !=
nullptr) {
76 free(frontend_filename_);
78 frontend_filename_ =
nullptr;
80 free(application_kernel_buffer_);
81 application_kernel_buffer_ =
nullptr;
82 application_kernel_buffer_size_ = 0;
93 InitKernelServiceAndPlatformDills();
98void DFE::InitKernelServiceAndPlatformDills() {
99 if (frontend_filename_ !=
nullptr) {
112 free(frontend_filename_);
113 frontend_filename_ =
nullptr;
123 free(frontend_filename_);
124 frontend_filename_ =
nullptr;
132 intptr_t* kernel_service_buffer_size) {
138 intptr_t* kernel_buffer_size) {
149#if defined(DART_HOST_OS_WINDOWS)
159 if (
path ==
nullptr) {
163 char* uri =
reinterpret_cast<char*
>(
new char[
len + 1 + 1]);
164 if (uri ==
nullptr) {
168 if (
len > 2 &&
path[1] ==
':') {
171 for (
const char*
p =
path; *
p !=
'\0'; ++
p, ++
s) {
172 *
s = *
p ==
'\\' ?
'/' : *
p;
175 sanitized_uri_ = std::unique_ptr<char[]>(uri);
177 sanitized_uri_ =
path;
182#if defined(DART_HOST_OS_WINDOWS)
183 return sanitized_uri_.get();
185 return sanitized_uri_;
191 const char* package_config,
193 bool embed_sources) {
201 incremental, for_snapshot, embed_sources, package_config,
verbosity());
205 uint8_t** kernel_buffer,
206 intptr_t* kernel_buffer_size,
209 const char* package_config,
211 bool embed_sources) {
214 for_snapshot, embed_sources);
217 *kernel_buffer =
result.kernel;
218 *kernel_buffer_size =
result.kernel_size;
243 uint8_t** kernel_buffer,
244 intptr_t* kernel_buffer_size,
246 std::shared_ptr<uint8_t>* kernel_blob_ptr) {
249 kernel_buffer_size, decode_uri, kernel_blob_ptr)) {
253 if (kernel_blob_ptr !=
nullptr && *kernel_blob_ptr) {
254 *kernel_blob_ptr =
nullptr;
256 free(*kernel_buffer);
258 *kernel_buffer =
nullptr;
259 *kernel_buffer_size = -1;
264 0,
nullptr,
nullptr);
273 uint8_t** p_kernel_ir,
274 intptr_t* p_kernel_ir_size) {
286 *p_kernel_ir =
nullptr;
287 *p_kernel_ir_size = -1;
298 bool decode_uri =
true) {
301 if (script_file ==
nullptr) {
306 return *
buffer !=
nullptr;
312 : kernel_ir_(kernel_ir), kernel_size_(kernel_size) {}
319 if (*p_head ==
nullptr) {
322 (*p_tail)->next_ = node;
333 *p_bytes =
reinterpret_cast<uint8_t*
>(
malloc(
size));
334 uint8_t*
p = *p_bytes;
336 while (node !=
nullptr) {
337 memmove(
p, node->kernel_ir_, node->kernel_size_);
338 p += node->kernel_size_;
347 while (node !=
nullptr) {
356 intptr_t kernel_size_;
368 const char*
c_str() {
return c_str_; }
389 intptr_t* kernel_ir_size) {
391 if (strcmp(kernel_list_dirname, script_uri) == 0) {
392 kernel_list_dirname =
"";
400 char*
tail =
reinterpret_cast<char*
>(memchr(filename,
'\n', filename_size));
401 while (
tail !=
nullptr) {
403 intptr_t this_kernel_size;
404 uint8_t* this_buffer;
411 &this_kernel_size)) {
415 uint8_t* this_kernel_ir;
417 &this_kernel_size)) {
420 *kernel_ir =
nullptr;
421 *kernel_ir_size = -1;
426 filename_size -=
tail + 1 - filename;
428 tail =
reinterpret_cast<char*
>(memchr(filename,
'\n', filename_size));
440 intptr_t* kernel_ir_size,
442 std::shared_ptr<uint8_t>* kernel_blob_ptr) {
443 *kernel_ir =
nullptr;
444 *kernel_ir_size = -1;
446 if (decode_uri && kernel_blob_ptr !=
nullptr) {
448 if (*kernel_blob_ptr) {
449 *kernel_ir = kernel_blob_ptr->get();
455 if (app_snapshot ==
nullptr || app_snapshot->
IsKernel() ||
462 if (app_snapshot ==
nullptr) {
464 }
else if (app_snapshot->
IsKernel()) {
475 kernel_ir, kernel_ir_size);
483 intptr_t kernel_buffer_size) {
486 uint8_t* buffer_copy =
reinterpret_cast<uint8_t*
>(
malloc(kernel_buffer_size));
487 if (buffer_copy ==
nullptr) {
490 memmove(buffer_copy, kernel_buffer, kernel_buffer_size);
493 ++kernel_blob_counter_;
509 intptr_t* kernel_length) {
513 if (kernel_blob_counter_ == 0) {
518 void*
key =
const_cast<char*
>(uri);
522 if (entry ==
nullptr) {
527 *kernel_length = blob->
size();
535 void*
key =
const_cast<char*
>(uri);
539 if (entry ==
nullptr) {
544 entry->
value =
nullptr;
static uint32_t buffer_size(uint32_t offset, uint32_t maxAlignment)
static float next(float f)
static uint32_t hash(const SkShaderBase::GradientInfo &v)
void Clear(ClearFun clear=nullptr)
Entry * Lookup(void *key, uint32_t hash, bool insert)
void Remove(void *key, uint32_t hash)
static uint32_t StringHash(const char *key)
static char * StrDup(const char *s)
static char * SCreate(const char *format,...) PRINTF_ATTRIBUTE(1
bool IsKernelList() const
bool TryReadKernelFile(const char *script_uri, const AppSnapshot *app_snapshot, uint8_t **kernel_buffer, intptr_t *kernel_buffer_size, bool decode_uri=true, std::shared_ptr< uint8_t > *kernel_blob_ptr=nullptr)
void CompileAndReadScript(const char *script_uri, uint8_t **kernel_buffer, intptr_t *kernel_buffer_size, char **error, int *exit_code, const char *package_config, bool for_snapshot, bool embed_sources)
bool CanUseDartFrontend() const
std::shared_ptr< uint8_t > TryFindKernelBlob(const char *uri, intptr_t *kernel_length)
Dart_KernelCompilationVerbosityLevel verbosity() const
bool use_incremental_compiler() const
void LoadPlatform(const uint8_t **kernel_buffer, intptr_t *kernel_buffer_size)
const char * RegisterKernelBlob(const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
Dart_KernelCompilationResult CompileScript(const char *script_uri, bool incremental, const char *package_config, bool for_snapshot, bool embedd_sources)
bool KernelServiceDillAvailable() const
void UnregisterKernelBlob(const char *uri)
void ReadScript(const char *script_uri, const AppSnapshot *app_snapshot, uint8_t **kernel_buffer, intptr_t *kernel_buffer_size, bool decode_uri=true, std::shared_ptr< uint8_t > *kernel_blob_ptr=nullptr)
void LoadKernelService(const uint8_t **kernel_service_buffer, intptr_t *kernel_service_buffer_size)
char * frontend_filename() const
static char * DirName(const char *url)
static void ReadFile(uint8_t **data, intptr_t *file_len, void *stream)
static void * OpenFileUri(const char *uri, bool write)
static void CloseFile(void *stream)
static MagicNumber SniffForMagicNumber(const char *filename)
static void * OpenFile(const char *name, bool write)
static CStringUniquePtr GetDirectoryPrefixFromResolvedExeName()
static bool IsAbsolutePath(const char *path)
static const char * PathSeparator()
static bool Exists(Namespace *namespc, const char *path)
std::shared_ptr< uint8_t > buffer()
static void Merge(KernelIRNode *head, uint8_t **p_bytes, intptr_t *p_size)
static void Add(KernelIRNode **p_head, KernelIRNode **p_tail, KernelIRNode *node)
static void Delete(KernelIRNode *head)
KernelIRNode(uint8_t *kernel_ir, intptr_t kernel_size)
const char * sanitized_uri() const
PathSanitizer(const char *path)
StringPointer(char *c_str)
@ Dart_KernelCompilationStatus_MsgFailed
@ Dart_KernelCompilationStatus_Error
@ Dart_KernelCompilationStatus_Crash
@ Dart_KernelCompilationStatus_Unknown
@ Dart_KernelCompilationStatus_Ok
const uint8_t kPlatformStrongDill[]
intptr_t kKernelServiceDillSize
intptr_t kPlatformStrongDillSize
const uint8_t kKernelServiceDill[]
const uint8_t uint32_t uint32_t GError ** error
constexpr int kCompilationErrorExitCode
const char kKernelServiceSnapshot[]
static bool TryReadKernelListBuffer(const char *script_uri, uint8_t *buffer, intptr_t buffer_size, uint8_t **kernel_ir, intptr_t *kernel_ir_size)
MagicNumberData kernel_list_magic_number
constexpr int kErrorExitCode
static bool TryReadSimpleKernelBuffer(uint8_t *buffer, uint8_t **p_kernel_ir, intptr_t *p_kernel_ir_size)
constexpr int kDartFrontendErrorExitCode
const intptr_t kernel_service_dill_size
const char kSnapshotsDirectory[]
const intptr_t platform_strong_dill_size
static bool TryReadFile(const char *script_uri, uint8_t **buffer, intptr_t *size, bool decode_uri=true)
const uint8_t * platform_strong_dill
const uint8_t * kernel_service_dill
DART_EXPORT bool Dart_IsKernel(const uint8_t *buffer, intptr_t buffer_size)
void * malloc(size_t size)
DART_EXPORT void Dart_RecordTimelineEvent(const char *label, int64_t timestamp0, int64_t timestamp1_or_id, intptr_t flow_id_count, const int64_t *flow_ids, Dart_Timeline_Event_Type type, intptr_t argument_count, const char **argument_names, const char **argument_values)
DART_EXPORT Dart_KernelCompilationResult Dart_CompileToKernel(const char *script_uri, const uint8_t *platform_kernel, intptr_t platform_kernel_size, bool incremental_compile, bool for_snapshot, bool embed_sources, const char *package_config, Dart_KernelCompilationVerbosityLevel verbosity)
DART_EXPORT void Dart_SetDartLibrarySourcesKernel(const uint8_t *platform_kernel, const intptr_t platform_kernel_size)
DART_EXPORT int64_t Dart_TimelineGetMicros()
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
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
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