Flutter Engine
The Flutter Engine
Classes | Functions
dart::embedder Namespace Reference

Classes

struct  IsolateCreationData
 
struct  VmServiceConfiguration
 

Functions

static char * MallocFormatedString (const char *format,...)
 
bool InitOnce (char **error)
 
void Cleanup ()
 
Dart_Isolate CreateKernelServiceIsolate (const IsolateCreationData &data, const uint8_t *buffer, intptr_t buffer_size, char **error)
 
Dart_Isolate CreateVmServiceIsolate (const IsolateCreationData &data, const VmServiceConfiguration &config, const uint8_t *isolate_data, const uint8_t *isolate_instr, char **error)
 
Dart_Isolate CreateVmServiceIsolateFromKernel (const IsolateCreationData &data, const VmServiceConfiguration &config, const uint8_t *kernel_buffer, intptr_t kernel_buffer_size, char **error)
 

Function Documentation

◆ Cleanup()

void dart::embedder::Cleanup ( )

Definition at line 49 of file dart_embedder_api_impl.cc.

49 {
50 bin::Process::ClearAllSignalHandlers();
51
52 bin::EventHandler::Stop();
53#if !defined(DART_IO_SECURE_SOCKET_DISABLED)
55#endif
57}

◆ CreateKernelServiceIsolate()

DART_WARN_UNUSED_RESULT Dart_Isolate dart::embedder::CreateKernelServiceIsolate ( const IsolateCreationData data,
const uint8_t *  buffer,
intptr_t  buffer_size,
char **  error 
)

Definition at line 59 of file dart_embedder_api_impl.cc.

62 {
64 data.script_uri, data.main, buffer, buffer_size, data.flags,
65 data.isolate_group_data, data.isolate_data, error);
66 if (kernel_isolate == nullptr) {
67 return nullptr;
68 }
69
72 if (Dart_IsError(result)) {
73 *error = Utils::StrDup(Dart_GetError(result));
76 return nullptr;
77 }
78 result = bin::DartUtils::PrepareForScriptLoading(/*is_service_isolate=*/false,
79 /*trace_loading=*/false);
82 return kernel_isolate;
83}
static uint32_t buffer_size(uint32_t offset, uint32_t maxAlignment)
DART_EXPORT void Dart_EnterScope(void)
DART_EXPORT void Dart_ExitScope(void)
DART_EXPORT void Dart_ShutdownIsolate(void)
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
struct _Dart_Isolate * Dart_Isolate
Definition: dart_api.h:88
DART_EXPORT Dart_Isolate Dart_CreateIsolateGroupFromKernel(const char *script_uri, const char *name, const uint8_t *kernel_buffer, intptr_t kernel_buffer_size, Dart_IsolateFlags *flags, void *isolate_group_data, void *isolate_data, char **error)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_LoadScriptFromKernel(const uint8_t *kernel_buffer, intptr_t kernel_size)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
DART_EXPORT void Dart_ExitIsolate(void)
DART_EXPORT const char * Dart_GetError(Dart_Handle handle)
const uint8_t uint32_t uint32_t GError ** error
GAsyncResult * result
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
Definition: switches.h:126
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ CreateVmServiceIsolate()

DART_WARN_UNUSED_RESULT Dart_Isolate dart::embedder::CreateVmServiceIsolate ( const IsolateCreationData data,
const VmServiceConfiguration config,
const uint8_t *  isolate_data,
const uint8_t *  isolate_instr,
char **  error 
)

Definition at line 85 of file dart_embedder_api_impl.cc.

89 {
90 if (data.flags == nullptr) {
91 *error = Utils::StrDup("Expected non-null flags");
92 return nullptr;
93 }
94 data.flags->load_vmservice_library = true;
95
96 Dart_Isolate service_isolate = Dart_CreateIsolateGroup(
97 data.script_uri, data.main, isolate_data, isolate_instr, data.flags,
98 data.isolate_group_data, data.isolate_data, error);
99 if (service_isolate == nullptr) {
100 return nullptr;
101 }
102
104 // Load embedder specific bits and return.
105 if (!bin::VmService::Setup(config.ip, config.port, config.dev_mode,
106 config.disable_auth_codes,
108 /*trace_loading=*/false, config.deterministic,
109 /*enable_service_port_fallback=*/false,
110 /*wait_for_dds_to_advertise_service=*/false,
111 /*serve_devtools=*/false,
112 /*serve_observatory=*/true,
113 /*print_dtd=*/false)) {
114 *error = Utils::StrDup(bin::VmService::GetErrorMessage());
115 return nullptr;
116 }
117
120 return service_isolate;
121}
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)

◆ CreateVmServiceIsolateFromKernel()

DART_WARN_UNUSED_RESULT Dart_Isolate dart::embedder::CreateVmServiceIsolateFromKernel ( const IsolateCreationData data,
const VmServiceConfiguration config,
const uint8_t *  kernel_buffer,
intptr_t  kernel_buffer_size,
char **  error 
)

Definition at line 123 of file dart_embedder_api_impl.cc.

128 {
129 if (data.flags == nullptr) {
130 *error = Utils::StrDup("Expected non-null flags");
131 return nullptr;
132 }
133 data.flags->load_vmservice_library = true;
134
136 data.script_uri, data.main, kernel_buffer, kernel_buffer_size, data.flags,
137 data.isolate_group_data, data.isolate_data, error);
138 if (service_isolate == nullptr) {
139 return nullptr;
140 }
141
143 // Load embedder specific bits and return.
144 if (!bin::VmService::Setup(config.ip, config.port, config.dev_mode,
145 config.disable_auth_codes,
147 /*trace_loading=*/false, config.deterministic,
148 /*enable_service_port_fallback=*/false,
149 /*wait_for_dds_to_advertise_service=*/false,
150 /*serve_devtools=*/false,
151 /*serve_observatory=*/true,
152 /*print_dtd=*/false)) {
153 *error = Utils::StrDup(bin::VmService::GetErrorMessage());
154 return nullptr;
155 }
156
159 return service_isolate;
160}

◆ InitOnce()

DART_WARN_UNUSED_RESULT bool dart::embedder::InitOnce ( char **  error)

Definition at line 33 of file dart_embedder_api_impl.cc.

33 {
34 if (!bin::DartUtils::SetOriginalWorkingDirectory()) {
35 bin::OSError err;
36 *error = MallocFormatedString("Error determining current directory: %s\n",
37 err.message());
38 return false;
39 }
42#if !defined(DART_IO_SECURE_SOCKET_DISABLED)
44#endif
45 bin::EventHandler::Start();
46 return true;
47}
char * message()
Definition: utils.h:36
void Init()
static char * MallocFormatedString(const char *format,...)
bool InitOnce(char **error)

◆ MallocFormatedString()

static char * dart::embedder::MallocFormatedString ( const char *  format,
  ... 
)
static

Definition at line 19 of file dart_embedder_api_impl.cc.

19 {
20 va_list measure_args;
21 va_start(measure_args, format);
22 intptr_t len = Utils::VSNPrint(nullptr, 0, format, measure_args);
23 va_end(measure_args);
24
25 char* buffer = reinterpret_cast<char*>(malloc(len + 1));
26 va_list print_args;
27 va_start(print_args, format);
28 Utils::VSNPrint(buffer, (len + 1), format, print_args);
29 va_end(print_args);
30 return buffer;
31}
uint32_t uint32_t * format
va_start(args, format)
va_end(args)
void * malloc(size_t size)
Definition: allocation.cc:19