7#include "flutter/fml/logging.h"
8#include "third_party/dart/runtime/include/bin/dart_io_api.h"
24 mapped_isolate_snapshot_instructions;
29 bool* auto_setup_scope) {
37 return service_natives->
GetSymbol(native_function);
40#define SHUTDOWN_ON_ERROR(handle) \
41 if (Dart_IsError(handle)) { \
42 *error = strdup(Dart_GetError(handle)); \
43 FML_LOG(ERROR) << error; \
45 Dart_ShutdownIsolate(); \
59 info->name =
"dart_runner";
60 info->current_rss = -1;
63 zx_info_task_stats_t task_stats;
64 zx_handle_t
process = zx_process_self();
65 zx_status_t status = zx_object_get_info(
66 process, ZX_INFO_TASK_STATS, &task_stats,
sizeof(task_stats), NULL, NULL);
67 if (status == ZX_OK) {
69 task_stats.mem_private_bytes + task_stats.mem_shared_bytes;
81 const uint8_t *vmservice_data =
nullptr, *vmservice_instructions =
nullptr;
83#if defined(AOT_RUNTIME)
85 const char* snapshot_path =
"/pkg/data/vmservice_snapshot.so";
86 if (elf_snapshot.
Load(
nullptr, snapshot_path)) {
89 if (vmservice_data ==
nullptr || vmservice_instructions ==
nullptr) {
94 const char* snapshot_data_path =
95 "/pkg/data/vmservice_isolate_snapshot_data.bin";
96 const char* snapshot_instructions_path =
97 "/pkg/data/vmservice_isolate_snapshot_instructions.bin";
100 const char* snapshot_data_path =
"/pkg/data/isolate_core_snapshot_data.bin";
101 const char* snapshot_instructions_path =
102 "/pkg/data/isolate_core_snapshot_instructions.bin";
106 nullptr, snapshot_data_path, mapped_isolate_snapshot_data)) {
107 *
error =
strdup(
"Failed to load snapshot for service isolate");
112 nullptr, snapshot_instructions_path,
113 mapped_isolate_snapshot_instructions,
true )) {
114 *
error =
strdup(
"Failed to load snapshot for service isolate");
119 vmservice_data = mapped_isolate_snapshot_data.
address();
120 vmservice_instructions = mapped_isolate_snapshot_instructions.
address();
121#if defined(AOT_RUNTIME)
127 flags.null_safety =
true;
138 state->get()->SetIsolate(isolate);
144 {
"VMServiceIO_Shutdown",
Shutdown, 0,
true},
185 fileno(stderr), zx::channel(),
true);
191 if (*
error !=
nullptr) {
203 nullptr,
"/pkg/data/observatory.tar", vm_service_tar)) {
210 reinterpret_cast<const uint8_t*
>(vm_service_tar.
address()),
211 vm_service_tar.
size());
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
bool Load(fdio_ns_t *namespc, const std::string &path)
const uint8_t * IsolateData() const
const uint8_t * IsolateInstrs() const
static bool LoadFromNamespace(fdio_ns_t *namespc, const std::string &path, MappedResource &resource, bool executable=false)
const uint8_t * address() const
void Register(std::initializer_list< Entry > entries)
const uint8_t * GetSymbol(Dart_NativeFunction native_function)
Dart_NativeFunction GetNativeFunction(Dart_Handle name, int argument_count, bool *auto_setup_scope)
DART_EXPORT Dart_Isolate Dart_CreateIsolateGroup(const char *script_uri, const char *name, const uint8_t *isolate_snapshot_data, const uint8_t *isolate_snapshot_instructions, Dart_IsolateFlags *flags, void *isolate_group_data, void *isolate_data, char **error)
DART_EXPORT void Dart_IsolateFlagsInitialize(Dart_IsolateFlags *flags)
DART_EXPORT DART_WARN_UNUSED_RESULT char * Dart_IsolateMakeRunnable(Dart_Isolate isolate)
DART_EXPORT Dart_Handle Dart_SetNativeResolver(Dart_Handle library, Dart_NativeEntryResolver resolver, Dart_NativeEntrySymbol symbol)
DART_EXPORT void Dart_EnterScope(void)
DART_EXPORT void Dart_ExitScope(void)
DART_EXPORT void Dart_ShutdownIsolate(void)
struct _Dart_Handle * Dart_Handle
struct _Dart_Isolate * Dart_Isolate
DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url)
struct _Dart_NativeArguments * Dart_NativeArguments
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_SetField(Dart_Handle container, Dart_Handle name, Dart_Handle value)
DART_EXPORT Dart_Handle Dart_NewStringFromCString(const char *str)
void(* Dart_NativeFunction)(Dart_NativeArguments arguments)
DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value)
DART_EXPORT Dart_Handle Dart_NewBoolean(bool value)
DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate)
#define DART_VM_SERVICE_ISOLATE_NAME
DART_EXPORT void Dart_ExitIsolate(void)
DART_EXPORT Dart_Handle Dart_SetRootLibrary(Dart_Handle library)
FlutterSemanticsFlag flags
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const uint8_t uint32_t uint32_t GError ** error
#define FML_LOG(severity)
#define FML_CHECK(condition)
static void Shutdown(Dart_NativeArguments args)
void NotifyServerState(Dart_NativeArguments args)
void InitBuiltinLibrariesForIsolate(const std::string &script_uri, fdio_ns_t *namespc, int stdoutfd, int stderrfd, zx::channel directory_request, bool service_isolate)
Dart_Handle GetVMServiceAssetsArchiveCallback()
Dart_Isolate CreateServiceIsolate(const char *uri, Dart_IsolateFlags *flags_unused, char **error)
DEF_SWITCHES_START aot vmservice shared library name
static void EmbedderInformationCallback(Dart_EmbedderInformation *info)
char * strdup(const char *str1)
Dart_Handle ToDart(const T &object)
static void process(const char *inPath, const char *lexer, const char *token, const char *hPath, const char *cppPath)