Flutter Engine
The Flutter Engine
main_impl.cc
Go to the documentation of this file.
1// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#include "bin/main_impl.h"
6
7#include <stdio.h>
8#include <stdlib.h>
9#include <string.h>
10
11#include <memory>
12#include <utility>
13
14#include "bin/builtin.h"
15#include "bin/console.h"
16#include "bin/crashpad.h"
17#include "bin/dartdev_isolate.h"
18#include "bin/dartutils.h"
19#include "bin/dfe.h"
20#include "bin/error_exit.h"
21#include "bin/exe_utils.h"
22#include "bin/file.h"
23#include "bin/gzip.h"
24#include "bin/isolate_data.h"
25#include "bin/loader.h"
26#include "bin/main_options.h"
27#include "bin/platform.h"
28#include "bin/process.h"
29#include "bin/snapshot_utils.h"
30#include "bin/utils.h"
31#include "bin/vmservice_impl.h"
34#include "include/dart_api.h"
37#include "platform/globals.h"
38#include "platform/syslog.h"
39#include "platform/utils.h"
40
41extern "C" {
42extern const uint8_t kDartVmSnapshotData[];
43extern const uint8_t kDartVmSnapshotInstructions[];
44extern const uint8_t kDartCoreIsolateSnapshotData[];
45extern const uint8_t kDartCoreIsolateSnapshotInstructions[];
46}
47
48namespace dart {
49namespace bin {
50
51// Snapshot pieces we link in a snapshot.
57
58/**
59 * Global state used to control and store generation of application snapshots.
60 * An application snapshot can be generated and run using the following
61 * command
62 * dart --snapshot-kind=app-jit --snapshot=<app_snapshot_filename>
63 * <script_uri> [<script_options>]
64 * To Run the application snapshot generated above, use :
65 * dart <app_snapshot_filename> [<script_options>]
66 */
67static bool vm_run_app_snapshot = false;
68static char* app_script_uri = nullptr;
69static const uint8_t* app_isolate_snapshot_data = nullptr;
70static const uint8_t* app_isolate_snapshot_instructions = nullptr;
71static bool kernel_isolate_is_running = false;
72
73static Dart_Isolate main_isolate = nullptr;
74
75#define SAVE_ERROR_AND_EXIT(result) \
76 *error = Utils::StrDup(Dart_GetError(result)); \
77 if (Dart_IsCompilationError(result)) { \
78 *exit_code = kCompilationErrorExitCode; \
79 } else if (Dart_IsApiError(result)) { \
80 *exit_code = kApiErrorExitCode; \
81 } else { \
82 *exit_code = kErrorExitCode; \
83 } \
84 Dart_ExitScope(); \
85 Dart_ShutdownIsolate(); \
86 return nullptr;
87
88#define CHECK_RESULT(result) \
89 if (Dart_IsError(result)) { \
90 SAVE_ERROR_AND_EXIT(result); \
91 }
92
93#define CHECK_RESULT_CLEANUP(result, cleanup) \
94 if (Dart_IsError(result)) { \
95 delete (cleanup); \
96 SAVE_ERROR_AND_EXIT(result); \
97 }
98
99static void WriteDepsFile() {
100 if (Options::depfile() == nullptr) {
101 return;
102 }
103 File* file = File::Open(nullptr, Options::depfile(), File::kWriteTruncate);
104 if (file == nullptr) {
105 ErrorExit(kErrorExitCode, "Error: Unable to open snapshot depfile: %s\n\n",
106 Options::depfile());
107 }
108 bool success = true;
109 if (Options::depfile_output_filename() != nullptr) {
110 success &= file->Print("%s: ", Options::depfile_output_filename());
111 } else {
112 success &= file->Print("%s: ", Options::snapshot_filename());
113 }
117 ErrorExit(
119 "Error: Failed to fetch dependencies from kernel service: %s\n\n",
120 result.error);
121 }
122 success &= file->WriteFully(result.kernel, result.kernel_size);
123 free(result.kernel);
124 }
125 success &= file->Print("\n");
126 if (!success) {
127 ErrorExit(kErrorExitCode, "Error: Unable to write snapshot depfile: %s\n\n",
128 Options::depfile());
129 }
130 file->Release();
131}
132
133static void OnExitHook(int64_t exit_code) {
136 "A snapshot was requested, but a secondary isolate "
137 "performed a hard exit (%" Pd64 ").\n",
138 exit_code);
140 }
141 if (exit_code == 0) {
142 if (Options::gen_snapshot_kind() == kAppJIT) {
143 Snapshot::GenerateAppJIT(Options::snapshot_filename());
144 }
146 }
147}
148
150 IsolateData* isolate_data,
151 bool is_isolate_group_start,
152 bool is_kernel_isolate,
153 const char** resolved_packages_config) {
154 auto isolate_group_data = isolate_data->isolate_group_data();
155 const auto packages_file = isolate_data->packages_file();
156 const auto script_uri = isolate_group_data->script_url;
157
159
160 // Prepare builtin and other core libraries for use to resolve URIs.
161 // Set up various closures, e.g: printing, timers etc.
162 // Set up package configuration for URI resolution.
163 result = DartUtils::PrepareForScriptLoading(false, Options::trace_loading());
164 if (Dart_IsError(result)) return result;
165
166 // Setup packages config if specified.
167 result = DartUtils::SetupPackageConfig(packages_file);
168 if (Dart_IsError(result)) return result;
169 if (!Dart_IsNull(result) && resolved_packages_config != nullptr) {
170 result = Dart_StringToCString(result, resolved_packages_config);
171 if (Dart_IsError(result)) return result;
172 ASSERT(*resolved_packages_config != nullptr);
173#if !defined(DART_PRECOMPILED_RUNTIME)
174 if (is_isolate_group_start) {
175 isolate_group_data->set_resolved_packages_config(
176 *resolved_packages_config);
177 } else {
178 ASSERT(strcmp(isolate_group_data->resolved_packages_config(),
179 *resolved_packages_config) == 0);
180 }
181#endif
182 }
183
185 if (Dart_IsError(result)) return result;
186
187 // Setup the native resolver as the snapshot does not carry it.
192
193 const char* namespc = is_kernel_isolate ? nullptr : Options::namespc();
194 result =
195 DartUtils::SetupIOLibrary(namespc, script_uri, Options::exit_disabled());
196 if (Dart_IsError(result)) return result;
197
198 return Dart_Null();
199}
200
201static bool OnIsolateInitialize(void** child_callback_data, char** error) {
203 ASSERT(isolate != nullptr);
204
205 auto isolate_group_data =
207
208 auto isolate_data = new IsolateData(isolate_group_data);
209 *child_callback_data = isolate_data;
210
212 const auto script_uri = isolate_group_data->script_url;
213 const bool isolate_run_app_snapshot =
214 isolate_group_data->RunFromAppSnapshot();
215 Dart_Handle result = SetupCoreLibraries(isolate, isolate_data,
216 /*group_start=*/false,
217 /*is_kernel_isolate=*/false,
218 /*resolved_packages_config=*/nullptr);
219 if (Dart_IsError(result)) goto failed;
220
221 if (isolate_run_app_snapshot) {
222 result = Loader::InitForSnapshot(script_uri, isolate_data);
223 if (Dart_IsError(result)) goto failed;
224 } else {
226 if (Dart_IsError(result)) goto failed;
227
228 if (isolate_group_data->kernel_buffer() != nullptr) {
229 // Various core-library parts will send requests to the Loader to resolve
230 // relative URIs and perform other related tasks. We need Loader to be
231 // initialized for this to work because loading from Kernel binary
232 // bypasses normal source code loading paths that initialize it.
233 const char* resolved_script_uri = nullptr;
234 result = Dart_StringToCString(result, &resolved_script_uri);
235 if (Dart_IsError(result)) goto failed;
236 result = Loader::InitForSnapshot(resolved_script_uri, isolate_data);
237 if (Dart_IsError(result)) goto failed;
238 }
239 }
240
242 return true;
243
244failed:
247 return false;
248}
249
250static void* NativeAssetsDlopenRelative(const char* path, char** error) {
251 auto isolate_group_data =
253 const char* script_uri = isolate_group_data->script_url;
254 return NativeAssets::DlopenRelative(path, script_uri, error);
255}
256
258 bool is_main_isolate,
259 const char* script_uri,
260 const char* packages_config,
261 bool isolate_run_app_snapshot,
263 char** error,
264 int* exit_code) {
266
267 // Set up the library tag handler for the isolate group shared by all
268 // isolates in the group.
273
274 auto isolate_data = reinterpret_cast<IsolateData*>(Dart_IsolateData(isolate));
275
276 const char* resolved_packages_config = nullptr;
277 result =
278 SetupCoreLibraries(isolate, isolate_data,
279 /*is_isolate_group_start=*/true,
280 flags->is_kernel_isolate, &resolved_packages_config);
282
283#if !defined(DART_PRECOMPILED_RUNTIME)
284 auto isolate_group_data = isolate_data->isolate_group_data();
285 const uint8_t* kernel_buffer = isolate_group_data->kernel_buffer().get();
286 intptr_t kernel_buffer_size = isolate_group_data->kernel_buffer_size();
287 if (!isolate_run_app_snapshot && kernel_buffer == nullptr &&
288 !Dart_IsKernelIsolate(isolate)) {
289 if (!dfe.CanUseDartFrontend()) {
290 const char* format = "Dart frontend unavailable to compile script %s.";
291 intptr_t len = snprintf(nullptr, 0, format, script_uri) + 1;
292 *error = reinterpret_cast<char*>(malloc(len));
293 ASSERT(error != nullptr);
294 snprintf(*error, len, format, script_uri);
295 *exit_code = kErrorExitCode;
298 return nullptr;
299 }
300 uint8_t* application_kernel_buffer = nullptr;
301 intptr_t application_kernel_buffer_size = 0;
302 // Only pass snapshot = true when generating an AppJIT snapshot to avoid
303 // duplicate null-safety info messages from the frontend when generating
304 // a kernel snapshot (this flag is instead set in
305 // Snapshot::GenerateKernel()).
306 const bool for_snapshot = Options::gen_snapshot_kind() == kAppJIT;
307 // If we compile for AppJIT the sources will not be included across app-jit
308 // snapshotting, so there's no reason CFE should embed them in the kernel.
309 const bool embed_sources = Options::gen_snapshot_kind() != kAppJIT;
310 dfe.CompileAndReadScript(script_uri, &application_kernel_buffer,
311 &application_kernel_buffer_size, error, exit_code,
312 resolved_packages_config, for_snapshot,
313 embed_sources);
314 if (application_kernel_buffer == nullptr) {
317 return nullptr;
318 }
319 isolate_group_data->SetKernelBufferNewlyOwned(
320 application_kernel_buffer, application_kernel_buffer_size);
321 kernel_buffer = application_kernel_buffer;
322 kernel_buffer_size = application_kernel_buffer_size;
323 }
324 if (kernel_buffer != nullptr) {
325 Dart_Handle uri = Dart_NewStringFromCString(script_uri);
326 CHECK_RESULT(uri);
327 Dart_Handle resolved_script_uri = DartUtils::ResolveScript(uri);
328 CHECK_RESULT(resolved_script_uri);
329 result = Dart_LoadScriptFromKernel(kernel_buffer, kernel_buffer_size);
331 }
332#endif // !defined(DART_PRECOMPILED_RUNTIME)
333
334 if (isolate_run_app_snapshot) {
335 Dart_Handle result = Loader::InitForSnapshot(script_uri, isolate_data);
337#if !defined(DART_PRECOMPILED_RUNTIME)
338 if (is_main_isolate) {
339 // Find the canonical uri of the app snapshot. We'll use this to decide if
340 // other isolates should use the app snapshot or the core snapshot.
341 const char* resolved_script_uri = nullptr;
344 &resolved_script_uri);
346 ASSERT(app_script_uri == nullptr);
347 app_script_uri = Utils::StrDup(resolved_script_uri);
348 }
349#endif // !defined(DART_PRECOMPILED_RUNTIME)
350 } else {
351#if !defined(DART_PRECOMPILED_RUNTIME)
352 // Load the specified application script into the newly created isolate.
353 Dart_Handle uri =
355 CHECK_RESULT(uri);
356 if (kernel_buffer != nullptr) {
357 // relative URIs and perform other related tasks. We need Loader to be
358 // initialized for this to work because loading from Kernel binary
359 // bypasses normal source code loading paths that initialize it.
360 const char* resolved_script_uri = nullptr;
361 result = Dart_StringToCString(uri, &resolved_script_uri);
363 result = Loader::InitForSnapshot(resolved_script_uri, isolate_data);
365 }
367 Dart_GetMainPortId(), /*flow_id_count=*/0, nullptr,
369 /*argument_count=*/0, nullptr, nullptr);
370#else
371 UNREACHABLE();
372#endif // !defined(DART_PRECOMPILED_RUNTIME)
373 }
374
375 if ((Options::gen_snapshot_kind() == kAppJIT) && is_main_isolate) {
378 }
379
380#if !defined(DART_PRECOMPILED_RUNTIME)
381 // Disable pausing the DartDev isolate on start and exit.
382 const char* isolate_name = nullptr;
383 result = Dart_StringToCString(Dart_DebugName(), &isolate_name);
385 if (strstr(isolate_name, DART_DEV_ISOLATE_NAME) != nullptr) {
388 }
389#endif // !defined(DART_PRECOMPILED_RUNTIME)
390
391#if !defined(DART_PRECOMPILER)
392 NativeAssetsApi native_assets;
393 memset(&native_assets, 0, sizeof(native_assets));
399 native_assets.dlsym = &NativeAssets::Dlsym;
401#endif // !defined(DART_PRECOMPILER)
402
403 // Make the isolate runnable so that it is ready to handle messages.
407 if (*error != nullptr) {
408 Dart_EnterIsolate(isolate);
410 return nullptr;
411 }
412
413 return isolate;
414}
415
416#if !defined(EXCLUDE_CFE_AND_KERNEL_PLATFORM)
417// Returns newly created Kernel Isolate on success, nullptr on failure.
418// For now we only support the kernel isolate coming up from an
419// application snapshot or from a .dill file.
420static Dart_Isolate CreateAndSetupKernelIsolate(const char* script_uri,
421 const char* packages_config,
423 char** error,
424 int* exit_code) {
425 // Do not start a kernel isolate if we are doing a training run
426 // to create an app JIT snapshot and a kernel file is specified
427 // as the application to run.
428 if (Options::gen_snapshot_kind() == kAppJIT) {
429 const uint8_t* kernel_buffer = nullptr;
430 intptr_t kernel_buffer_size = 0;
431 dfe.application_kernel_buffer(&kernel_buffer, &kernel_buffer_size);
432 if (kernel_buffer_size != 0) {
433 return nullptr;
434 }
435 }
436 // Create and Start the kernel isolate.
437 const char* kernel_snapshot_uri = dfe.frontend_filename();
438 const char* uri =
439 kernel_snapshot_uri != nullptr ? kernel_snapshot_uri : script_uri;
440
441 if (packages_config == nullptr) {
442 packages_config = Options::packages_file();
443 }
444
445 Dart_Isolate isolate = nullptr;
446 IsolateGroupData* isolate_group_data = nullptr;
447 IsolateData* isolate_data = nullptr;
448 bool isolate_run_app_snapshot = false;
449 AppSnapshot* app_snapshot = nullptr;
450 // Kernel isolate uses an app JIT snapshot or uses the dill file.
451 if ((kernel_snapshot_uri != nullptr) &&
452 ((app_snapshot = Snapshot::TryReadAppSnapshot(
453 kernel_snapshot_uri, /*force_load_elf_from_memory=*/false,
454 /*decode_uri=*/false)) != nullptr) &&
455 app_snapshot->IsJIT()) {
456 const uint8_t* isolate_snapshot_data = nullptr;
457 const uint8_t* isolate_snapshot_instructions = nullptr;
458 const uint8_t* ignore_vm_snapshot_data;
459 const uint8_t* ignore_vm_snapshot_instructions;
460 isolate_run_app_snapshot = true;
461 app_snapshot->SetBuffers(
462 &ignore_vm_snapshot_data, &ignore_vm_snapshot_instructions,
464 isolate_group_data = new IsolateGroupData(
465 uri, packages_config, app_snapshot, isolate_run_app_snapshot);
466 isolate_data = new IsolateData(isolate_group_data);
467 isolate = Dart_CreateIsolateGroup(
470 isolate_group_data, isolate_data, error);
471 }
472 if (isolate == nullptr) {
473 // Clear error from app snapshot and re-trying from kernel file.
474 free(*error);
475 *error = nullptr;
476 delete isolate_data;
477 delete isolate_group_data;
478
479 const uint8_t* kernel_service_buffer = nullptr;
480 intptr_t kernel_service_buffer_size = 0;
481 dfe.LoadKernelService(&kernel_service_buffer, &kernel_service_buffer_size);
482 ASSERT(kernel_service_buffer != nullptr);
483 isolate_group_data = new IsolateGroupData(uri, packages_config, nullptr,
484 isolate_run_app_snapshot);
485 isolate_group_data->SetKernelBufferUnowned(
486 const_cast<uint8_t*>(kernel_service_buffer),
487 kernel_service_buffer_size);
488 isolate_data = new IsolateData(isolate_group_data);
491 kernel_service_buffer, kernel_service_buffer_size, flags,
492 isolate_group_data, isolate_data, error);
493 }
494
495 if (isolate == nullptr) {
496 Syslog::PrintErr("%s\n", *error);
497 delete isolate_data;
498 delete isolate_group_data;
499 return nullptr;
500 }
502
503 return IsolateSetupHelper(isolate, false, uri, packages_config,
504 isolate_run_app_snapshot, flags, error, exit_code);
505}
506#endif // !defined(EXCLUDE_CFE_AND_KERNEL_PLATFORM)
507
508// Returns newly created Service Isolate on success, nullptr on failure.
509// For now we only support the service isolate coming up from sources
510// which are compiled by the VM parser.
511static Dart_Isolate CreateAndSetupServiceIsolate(const char* script_uri,
512 const char* packages_config,
514 char** error,
515 int* exit_code) {
516#if !defined(PRODUCT)
517 ASSERT(script_uri != nullptr);
518 Dart_Isolate isolate = nullptr;
519 auto isolate_group_data =
520 new IsolateGroupData(script_uri, packages_config, nullptr, false);
521 ASSERT(flags != nullptr);
522
523#if defined(DART_PRECOMPILED_RUNTIME)
524 // AOT: The service isolate is included in any AOT snapshot in non-PRODUCT
525 // mode - so we launch the vm-service from the main app AOT snapshot.
527 const uint8_t* isolate_snapshot_instructions =
529 isolate = Dart_CreateIsolateGroup(
531 isolate_snapshot_instructions, flags, isolate_group_data,
532 /*isolate_data=*/nullptr, error);
533#else
534 // JIT: Service isolate uses the core libraries snapshot.
535
536 // Set flag to load and retain the vmservice library.
537 flags->load_vmservice_library = true;
538 flags->null_safety = true; // Service isolate runs in sound null safe mode.
540 const uint8_t* isolate_snapshot_instructions =
542 isolate = Dart_CreateIsolateGroup(
544 isolate_snapshot_instructions, flags, isolate_group_data,
545 /*isolate_data=*/nullptr, error);
546#endif // !defined(DART_PRECOMPILED_RUNTIME)
547 if (isolate == nullptr) {
548 delete isolate_group_data;
549 return nullptr;
550 }
551
553
558
559 // We do not spawn the external dds process in the following scenarios:
560 // - The DartDev CLI is disabled and VM service is enabled.
561 // - DDS is disabled.
562 bool wait_for_dds_to_advertise_service =
563 !(Options::disable_dart_dev() || Options::disable_dds());
564 bool serve_devtools =
565 Options::enable_devtools() || !Options::disable_devtools();
566 // Load embedder specific bits and return.
567 if (!VmService::Setup(
569 Options::vm_service_dev_mode(), Options::vm_service_auth_disabled(),
570 Options::vm_write_service_info_filename(), Options::trace_loading(),
571 Options::deterministic(), Options::enable_service_port_fallback(),
572 wait_for_dds_to_advertise_service, serve_devtools,
573 Options::enable_observatory(), Options::print_dtd())) {
575 return nullptr;
576 }
577 if (Options::compile_all()) {
580 }
585 return isolate;
586#else // !defined(PRODUCT)
587 return nullptr;
588#endif // !defined(PRODUCT)
589}
590
591#if !defined(DART_PRECOMPILED_RUNTIME)
592
593static Dart_Isolate CreateAndSetupDartDevIsolate(const char* script_uri,
594 const char* packages_config,
596 char** error,
597 int* exit_code) {
598 int64_t start = Dart_TimelineGetMicros();
599
601 if (dartdev_path.get() == nullptr) {
603 "Failed to start the Dart CLI isolate. Could not resolve DartDev "
604 "snapshot or kernel.\n");
605 if (error != nullptr && *error != nullptr) {
606 free(*error);
607 *error = nullptr;
608 }
609 return nullptr;
610 }
611
612 Dart_Isolate isolate = nullptr;
614 const uint8_t* isolate_snapshot_instructions =
616 IsolateGroupData* isolate_group_data = nullptr;
617 IsolateData* isolate_data = nullptr;
618 AppSnapshot* app_snapshot = nullptr;
619 bool isolate_run_app_snapshot = true;
620 // dartdev isolate uses an app JIT snapshot or uses the dill file.
621 if (((app_snapshot = Snapshot::TryReadAppSnapshot(
622 dartdev_path.get(), /*force_load_elf_from_memory=*/false,
623 /*decode_uri=*/false)) != nullptr) &&
624 app_snapshot->IsJIT()) {
625 const uint8_t* isolate_snapshot_data = nullptr;
626 const uint8_t* isolate_snapshot_instructions = nullptr;
627 const uint8_t* ignore_vm_snapshot_data;
628 const uint8_t* ignore_vm_snapshot_instructions;
629 app_snapshot->SetBuffers(
630 &ignore_vm_snapshot_data, &ignore_vm_snapshot_instructions,
632 isolate_group_data =
633 new IsolateGroupData(DART_DEV_ISOLATE_NAME, packages_config,
634 app_snapshot, isolate_run_app_snapshot);
635 isolate_data = new IsolateData(isolate_group_data);
636 isolate = Dart_CreateIsolateGroup(
638 isolate_snapshot_instructions, flags, isolate_group_data, isolate_data,
639 error);
640 }
641
642 if (isolate == nullptr) {
643 // dartdev_path was not an application snapshot, try it as a kernel file.
644 // Clear error from app snapshot and retry from kernel.
645 if (error != nullptr && *error != nullptr) {
646 free(*error);
647 *error = nullptr;
648 }
649 isolate_run_app_snapshot = false;
650 if (app_snapshot != nullptr) {
651 delete app_snapshot;
652 }
653 isolate_group_data =
654 new IsolateGroupData(DART_DEV_ISOLATE_NAME, packages_config, nullptr,
655 isolate_run_app_snapshot);
656 uint8_t* application_kernel_buffer = nullptr;
657 intptr_t application_kernel_buffer_size = 0;
658 dfe.ReadScript(dartdev_path.get(), nullptr, &application_kernel_buffer,
659 &application_kernel_buffer_size, /*decode_uri=*/false);
660 isolate_group_data->SetKernelBufferNewlyOwned(
661 application_kernel_buffer, application_kernel_buffer_size);
662
663 isolate_data = new IsolateData(isolate_group_data);
664 isolate = Dart_CreateIsolateGroup(
666 isolate_snapshot_instructions, flags, isolate_group_data, isolate_data,
667 error);
668 }
669
670 Dart_Isolate created_isolate =
671 IsolateSetupHelper(isolate, false, DART_DEV_ISOLATE_NAME, packages_config,
672 isolate_run_app_snapshot, flags, error, exit_code);
673
674 int64_t end = Dart_TimelineGetMicros();
675 Dart_RecordTimelineEvent("CreateAndSetupDartDevIsolate", start, end,
676 /*flow_id_count=*/0, nullptr,
678 /*argument_count=*/0, nullptr, nullptr);
679 return created_isolate;
680}
681
682#endif // !defined(DART_PRECOMPILED_RUNTIME)
683
684// Returns newly created Isolate on success, nullptr on failure.
686 bool is_main_isolate,
687 const char* script_uri,
688 const char* name,
689 const char* packages_config,
691 void* callback_data,
692 char** error,
693 int* exit_code) {
694 int64_t start = Dart_TimelineGetMicros();
695 ASSERT(script_uri != nullptr);
696 uint8_t* kernel_buffer = nullptr;
697 std::shared_ptr<uint8_t> kernel_buffer_ptr;
698 intptr_t kernel_buffer_size = 0;
699 AppSnapshot* app_snapshot = nullptr;
700
701#if defined(DART_PRECOMPILED_RUNTIME)
702 const uint8_t* isolate_snapshot_data = nullptr;
703 const uint8_t* isolate_snapshot_instructions = nullptr;
704 if (is_main_isolate) {
707 } else {
708 // AOT: All isolates need to be run from AOT compiled snapshots.
709 const bool kForceLoadElfFromMemory = false;
710 app_snapshot =
711 Snapshot::TryReadAppSnapshot(script_uri, kForceLoadElfFromMemory);
712 if (app_snapshot == nullptr || !app_snapshot->IsAOT()) {
714 "The uri(%s) provided to `Isolate.spawnUri()` does not "
715 "contain a valid AOT snapshot.",
716 script_uri);
717 return nullptr;
718 }
719
720 const uint8_t* ignore_vm_snapshot_data;
721 const uint8_t* ignore_vm_snapshot_instructions;
722 app_snapshot->SetBuffers(
723 &ignore_vm_snapshot_data, &ignore_vm_snapshot_instructions,
725 }
726
727 bool isolate_run_app_snapshot = true;
728#else
729 // JIT: Main isolate starts from the app snapshot, if any. Other isolates
730 // use the core libraries snapshot.
731 bool isolate_run_app_snapshot = false;
733 const uint8_t* isolate_snapshot_instructions =
735 if ((app_isolate_snapshot_data != nullptr) &&
736 (is_main_isolate || ((app_script_uri != nullptr) &&
737 (strcmp(script_uri, app_script_uri) == 0)))) {
738 isolate_run_app_snapshot = true;
741 } else if (!is_main_isolate) {
742 app_snapshot = Snapshot::TryReadAppSnapshot(script_uri);
743 if (app_snapshot != nullptr && app_snapshot->IsJITorAOT()) {
744 if (app_snapshot->IsAOT()) {
746 "The uri(%s) provided to `Isolate.spawnUri()` is an "
747 "AOT snapshot and the JIT VM cannot spawn an isolate using it.",
748 script_uri);
749 delete app_snapshot;
750 return nullptr;
751 }
752 isolate_run_app_snapshot = true;
753 const uint8_t* ignore_vm_snapshot_data;
754 const uint8_t* ignore_vm_snapshot_instructions;
755 app_snapshot->SetBuffers(
756 &ignore_vm_snapshot_data, &ignore_vm_snapshot_instructions,
758 }
759 }
760
761 if (kernel_buffer == nullptr && !isolate_run_app_snapshot) {
762 dfe.ReadScript(script_uri, app_snapshot, &kernel_buffer,
763 &kernel_buffer_size, /*decode_uri=*/true,
764 &kernel_buffer_ptr);
765 }
766 PathSanitizer script_uri_sanitizer(script_uri);
767 PathSanitizer packages_config_sanitizer(packages_config);
768#endif // !defined(DART_PRECOMPILED_RUNTIME)
769
770 auto isolate_group_data = new IsolateGroupData(
771 script_uri, packages_config, app_snapshot, isolate_run_app_snapshot);
772 if (kernel_buffer != nullptr) {
773 if (kernel_buffer_ptr) {
774 isolate_group_data->SetKernelBufferAlreadyOwned(
775 std::move(kernel_buffer_ptr), kernel_buffer_size);
776 } else {
777 isolate_group_data->SetKernelBufferNewlyOwned(kernel_buffer,
778 kernel_buffer_size);
779 }
780 }
781
782 Dart_Isolate isolate = nullptr;
783
784 IsolateData* isolate_data = nullptr;
785#if !defined(DART_PRECOMPILED_RUNTIME)
786 if (!isolate_run_app_snapshot && (isolate_snapshot_data == nullptr)) {
787 const uint8_t* platform_kernel_buffer = nullptr;
788 intptr_t platform_kernel_buffer_size = 0;
789 dfe.LoadPlatform(&platform_kernel_buffer, &platform_kernel_buffer_size);
790 if (platform_kernel_buffer == nullptr) {
791 platform_kernel_buffer = kernel_buffer;
792 platform_kernel_buffer_size = kernel_buffer_size;
793 }
794 if (platform_kernel_buffer == nullptr) {
795#if defined(EXCLUDE_CFE_AND_KERNEL_PLATFORM)
796 FATAL(
797 "Binary built with --exclude-kernel-service. Cannot run"
798 " from source.");
799#else
800 FATAL("platform_program cannot be nullptr.");
801#endif // defined(EXCLUDE_CFE_AND_KERNEL_PLATFORM)
802 }
803 // TODO(sivachandra): When the platform program is unavailable, check if
804 // application kernel binary is self contained or an incremental binary.
805 // Isolate should be created only if it is a self contained kernel binary.
806 isolate_data = new IsolateData(isolate_group_data);
808 script_uri, name, platform_kernel_buffer, platform_kernel_buffer_size,
809 flags, isolate_group_data, isolate_data, error);
810 } else {
811 isolate_data = new IsolateData(isolate_group_data);
814 isolate_group_data, isolate_data, error);
815 }
816#else
817 isolate_data = new IsolateData(isolate_group_data);
820 isolate_group_data, isolate_data, error);
821#endif // !defined(DART_PRECOMPILED_RUNTIME)
822
823 Dart_Isolate created_isolate = nullptr;
824 if (isolate == nullptr) {
825 delete isolate_data;
826 delete isolate_group_data;
827 } else {
828 created_isolate = IsolateSetupHelper(
829 isolate, is_main_isolate, script_uri, packages_config,
830 isolate_run_app_snapshot, flags, error, exit_code);
831 }
832 int64_t end = Dart_TimelineGetMicros();
833 Dart_RecordTimelineEvent("CreateIsolateGroupAndSetupHelper", start, end,
834 /*flow_id_count=*/0, nullptr,
836 /*argument_count=*/0, nullptr, nullptr);
837 return created_isolate;
838}
839
840#undef CHECK_RESULT
841
842static Dart_Isolate CreateIsolateGroupAndSetup(const char* script_uri,
843 const char* main,
844 const char* package_root,
845 const char* package_config,
847 void* callback_data,
848 char** error) {
849 // The VM should never call the isolate helper with a nullptr flags.
850 ASSERT(flags != nullptr);
852 ASSERT(package_root == nullptr);
853
854 if (error != nullptr) {
855 *error = nullptr;
856 }
857
858 bool dontneed_safe = true;
859#if defined(DART_HOST_OS_LINUX)
860 // This would also be true in Linux, except that Google3 overrides the default
861 // ELF interpreter to one that apparently doesn't create proper mappings.
862 dontneed_safe = false;
863#elif defined(DEBUG)
864 // If the snapshot isn't file-backed, madvise(DONT_NEED) is destructive.
865 if (Options::force_load_elf_from_memory()) {
866 dontneed_safe = false;
867 }
868#endif
869 flags->snapshot_is_dontneed_safe = dontneed_safe;
870
871 int exit_code = 0;
872#if !defined(EXCLUDE_CFE_AND_KERNEL_PLATFORM)
873 if (strcmp(script_uri, DART_KERNEL_ISOLATE_NAME) == 0) {
874 return CreateAndSetupKernelIsolate(script_uri, package_config, flags, error,
875 &exit_code);
876 }
877#endif // !defined(EXCLUDE_CFE_AND_KERNEL_PLATFORM)
878
879#if !defined(DART_PRECOMPILED_RUNTIME)
880 if (strcmp(script_uri, DART_DEV_ISOLATE_NAME) == 0) {
881 return CreateAndSetupDartDevIsolate(script_uri, package_config, flags,
882 error, &exit_code);
883 }
884#endif // !defined(DART_PRECOMPILED_RUNTIME)
885
886 if (strcmp(script_uri, DART_VM_SERVICE_ISOLATE_NAME) == 0) {
887 return CreateAndSetupServiceIsolate(script_uri, package_config, flags,
888 error, &exit_code);
889 }
890
891 bool is_main_isolate = false;
892 return CreateIsolateGroupAndSetupHelper(is_main_isolate, script_uri, main,
893 package_config, flags, callback_data,
894 error, &exit_code);
895}
896
897#if !defined(DART_PRECOMPILED_RUNTIME)
898static const char* RegisterKernelBlob(const uint8_t* kernel_buffer,
899 intptr_t kernel_buffer_size) {
900 return dfe.RegisterKernelBlob(kernel_buffer, kernel_buffer_size);
901}
902static void UnregisterKernelBlob(const char* kernel_blob_uri) {
903 dfe.UnregisterKernelBlob(kernel_blob_uri);
904}
905#endif // !defined(DART_PRECOMPILED_RUNTIME)
906
907static void OnIsolateShutdown(void* isolate_group_data, void* isolate_data) {
909 Dart_Handle sticky_error = Dart_GetStickyError();
910 if (!Dart_IsNull(sticky_error) && !Dart_IsFatalError(sticky_error)) {
911 Syslog::PrintErr("%s\n", Dart_GetError(sticky_error));
912 }
914}
915
916static void DeleteIsolateData(void* isolate_group_data, void* callback_data) {
917 auto isolate_data = reinterpret_cast<IsolateData*>(callback_data);
918 delete isolate_data;
919}
920
921static void DeleteIsolateGroupData(void* callback_data) {
922 auto isolate_group_data = reinterpret_cast<IsolateGroupData*>(callback_data);
923 delete isolate_group_data;
924}
925
926static constexpr const char* kStdoutStreamId = "Stdout";
927static constexpr const char* kStderrStreamId = "Stderr";
928
929static bool ServiceStreamListenCallback(const char* stream_id) {
930 if (strcmp(stream_id, kStdoutStreamId) == 0) {
931 SetCaptureStdout(true);
932 return true;
933 } else if (strcmp(stream_id, kStderrStreamId) == 0) {
934 SetCaptureStderr(true);
935 return true;
936 }
937 return false;
938}
939
940static void ServiceStreamCancelCallback(const char* stream_id) {
941 if (strcmp(stream_id, kStdoutStreamId) == 0) {
942 SetCaptureStdout(false);
943 } else if (strcmp(stream_id, kStderrStreamId) == 0) {
944 SetCaptureStderr(false);
945 }
946}
947
948static bool FileModifiedCallback(const char* url, int64_t since) {
949 auto path = File::UriToPath(url);
950 if (path == nullptr) {
951 // If it isn't a file on local disk, we don't know if it has been
952 // modified.
953 return true;
954 }
955 int64_t data[File::kStatSize];
956 File::Stat(nullptr, path.get(), data);
958 return true;
959 }
960 return data[File::kModifiedTime] > since;
961}
962
965 info->name = "Dart VM";
966 Process::GetRSSInformation(&(info->max_rss), &(info->current_rss));
967}
968
969#define CHECK_RESULT(result) \
970 if (Dart_IsError(result)) { \
971 const int exit_code = Dart_IsCompilationError(result) \
972 ? kCompilationErrorExitCode \
973 : kErrorExitCode; \
974 ErrorExit(exit_code, "%s\n", Dart_GetError(result)); \
975 }
976
977static void CompileAndSaveKernel(const char* script_name,
978 const char* package_config_override,
979 CommandLineOptions* dart_options) {
981 Syslog::PrintErr("Cannot create a script snapshot from an app snapshot.\n");
982 // The snapshot would contain references to the app snapshot instead of
983 // the core snapshot.
985 }
986 Snapshot::GenerateKernel(Options::snapshot_filename(), script_name,
987 package_config_override);
989}
990
991void RunMainIsolate(const char* script_name,
992 const char* package_config_override,
993 CommandLineOptions* dart_options) {
994 if (script_name != nullptr) {
995 const char* base_name = strrchr(script_name, '/');
996 if (base_name == nullptr) {
997 base_name = script_name;
998 } else {
999 base_name++; // Skip '/'.
1000 }
1001 const intptr_t kMaxNameLength = 64;
1002 char name[kMaxNameLength];
1003 Utils::SNPrint(name, kMaxNameLength, "dart:%s", base_name);
1005 }
1006
1007 // Call CreateIsolateGroupAndSetup which creates an isolate and loads up
1008 // the specified application script.
1009 char* error = nullptr;
1010 int exit_code = 0;
1013 flags.is_system_isolate = Options::mark_main_isolate_as_system_isolate();
1014 bool dontneed_safe = true;
1015#if defined(DART_HOST_OS_LINUX)
1016 // This would also be true in Linux, except that Google3 overrides the default
1017 // ELF interpreter to one that apparently doesn't create proper mappings.
1018 dontneed_safe = false;
1019#elif defined(DEBUG)
1020 // If the snapshot isn't file-backed, madvise(DONT_NEED) is destructive.
1021 if (Options::force_load_elf_from_memory()) {
1022 dontneed_safe = false;
1023 }
1024#endif
1025 flags.snapshot_is_dontneed_safe = dontneed_safe;
1026
1028 /* is_main_isolate */ true, script_name, "main",
1029 Options::packages_file() == nullptr ? package_config_override
1030 : Options::packages_file(),
1031 &flags, nullptr /* callback_data */, &error, &exit_code);
1032
1033 if (isolate == nullptr) {
1034 Syslog::PrintErr("%s\n", error);
1035 free(error);
1036 error = nullptr;
1038 error = Dart_Cleanup();
1039 if (error != nullptr) {
1040 Syslog::PrintErr("VM cleanup failed: %s\n", error);
1041 free(error);
1042 }
1044 Platform::Exit((exit_code != 0) ? exit_code : kErrorExitCode);
1045 }
1046 main_isolate = isolate;
1047
1048 Dart_EnterIsolate(isolate);
1049 ASSERT(isolate == Dart_CurrentIsolate());
1050 ASSERT(isolate != nullptr);
1052
1054
1055 // Kernel snapshots should have been handled before reaching this point.
1056 ASSERT(Options::gen_snapshot_kind() != kKernel);
1057 // Lookup the library of the root script.
1058 Dart_Handle root_lib = Dart_RootLibrary();
1059
1060#if !defined(DART_PRECOMPILED_RUNTIME)
1061 if (Options::compile_all()) {
1064 }
1065#endif // !defined(DART_PRECOMPILED_RUNTIME)
1066
1067 if (Dart_IsNull(root_lib)) {
1068 ErrorExit(kErrorExitCode, "Unable to find root library for '%s'\n",
1069 script_name);
1070 }
1071
1072 // Create a closure for the main entry point which is in the exported
1073 // namespace of the root library or invoke a getter of the same name
1074 // in the exported namespace and return the resulting closure.
1075 Dart_Handle main_closure =
1076 Dart_GetField(root_lib, Dart_NewStringFromCString("main"));
1077 CHECK_RESULT(main_closure);
1078 if (!Dart_IsClosure(main_closure)) {
1079 ErrorExit(kErrorExitCode, "Unable to find 'main' in root library '%s'\n",
1080 script_name);
1081 }
1082
1083 // Call _startIsolate in the isolate library to enable dispatching the
1084 // initial startup message.
1085 const intptr_t kNumIsolateArgs = 2;
1086 Dart_Handle isolate_args[kNumIsolateArgs];
1087 isolate_args[0] = main_closure; // entryPoint
1088 isolate_args[1] = dart_options->CreateRuntimeOptions(); // args
1089
1090 Dart_Handle isolate_lib =
1092 result =
1093 Dart_Invoke(isolate_lib, Dart_NewStringFromCString("_startMainIsolate"),
1094 kNumIsolateArgs, isolate_args);
1096
1097 // Keep handling messages until the last active receive port is closed.
1098 result = Dart_RunLoop();
1099 // Generate an app snapshot after execution if specified.
1100 if (Options::gen_snapshot_kind() == kAppJIT) {
1102 Snapshot::GenerateAppJIT(Options::snapshot_filename());
1103 }
1104 }
1106
1107 WriteDepsFile();
1108
1110
1111 // Shutdown the isolate.
1113}
1114
1115#undef CHECK_RESULT
1116
1117static bool CheckForInvalidPath(const char* path) {
1118 // TODO(zichangguo): "\\?\" is a prefix for paths on Windows.
1119 // Arguments passed are parsed as an URI. "\\?\" causes problems as a part
1120 // of URIs. This is a temporary workaround to prevent VM from crashing.
1121 // Issue: https://github.com/dart-lang/sdk/issues/42779
1122 if (strncmp(path, "\\\\?\\", 4) == 0) {
1123 Syslog::PrintErr("\\\\?\\ prefix is not supported");
1124 return false;
1125 }
1126 return true;
1127}
1128
1129// Observatory assets are not included in a product build.
1130#if !defined(PRODUCT)
1131extern unsigned int observatory_assets_archive_len;
1132extern const uint8_t* observatory_assets_archive;
1133
1135 uint8_t* decompressed = nullptr;
1136 intptr_t decompressed_len = 0;
1138 &decompressed, &decompressed_len);
1139 Dart_Handle tar_file =
1140 DartUtils::MakeUint8Array(decompressed, decompressed_len);
1141 // Free decompressed memory as it has been copied into a Dart array.
1142 free(decompressed);
1143 return tar_file;
1144}
1145#else // !defined(PRODUCT)
1147 nullptr;
1148#endif // !defined(PRODUCT)
1149
1150void main(int argc, char** argv) {
1151#if !defined(DART_HOST_OS_WINDOWS)
1152 // Very early so any crashes during startup can also be symbolized.
1154#endif
1155
1156 char* script_name = nullptr;
1157 // Allows the dartdev process to point to the desired package_config.
1158 char* package_config_override = nullptr;
1159 const int EXTRA_VM_ARGUMENTS = 10;
1160 CommandLineOptions vm_options(argc + EXTRA_VM_ARGUMENTS);
1161 CommandLineOptions dart_options(argc + EXTRA_VM_ARGUMENTS);
1162 bool print_flags_seen = false;
1163 bool verbose_debug_seen = false;
1164
1165 // Perform platform specific initialization.
1166 if (!Platform::Initialize()) {
1167 Syslog::PrintErr("Initialization failed\n");
1169 }
1170
1171 // Save the console state so we can restore it at shutdown.
1173
1174 // On Windows, the argv strings are code page encoded and not
1175 // utf8. We need to convert them to utf8.
1176 bool argv_converted = ShellUtils::GetUtf8Argv(argc, argv);
1177
1178#if !defined(DART_PRECOMPILED_RUNTIME)
1179 // Processing of some command line flags directly manipulates dfe.
1181#endif // !defined(DART_PRECOMPILED_RUNTIME)
1182
1183 // When running from the command line we assume that we are optimizing for
1184 // throughput, and therefore use a larger new gen semi space size and a faster
1185 // new gen growth factor unless others have been specified.
1186 if (kWordSize <= 4) {
1187 vm_options.AddArgument("--new_gen_semi_max_size=16");
1188 } else {
1189 vm_options.AddArgument("--new_gen_semi_max_size=32");
1190 }
1191 vm_options.AddArgument("--new_gen_growth_factor=4");
1192
1193 auto parse_arguments = [&](int argc, char** argv,
1194 CommandLineOptions* vm_options,
1195 CommandLineOptions* dart_options,
1196 bool parsing_dart_vm_options) {
1197 bool success = Options::ParseArguments(
1198 argc, argv, vm_run_app_snapshot, parsing_dart_vm_options, vm_options,
1199 &script_name, dart_options, &print_flags_seen, &verbose_debug_seen);
1200 if (!success) {
1201 if (Options::help_option()) {
1203 Platform::Exit(0);
1204 } else if (Options::version_option()) {
1206 Platform::Exit(0);
1207 } else if (print_flags_seen) {
1208 // Will set the VM flags, print them out and then we exit as no
1209 // script was specified on the command line.
1210 char* error =
1211 Dart_SetVMFlags(vm_options->count(), vm_options->arguments());
1212 if (error != nullptr) {
1213 Syslog::PrintErr("Setting VM flags failed: %s\n", error);
1214 free(error);
1216 }
1217 Platform::Exit(0);
1218 } else {
1219 // This usage error case will only be invoked when
1220 // Options::disable_dart_dev() is false.
1223 }
1224 }
1225 };
1226
1227 AppSnapshot* app_snapshot = nullptr;
1228#if defined(DART_PRECOMPILED_RUNTIME)
1229 // If the executable binary contains the runtime together with an appended
1230 // snapshot, load and run that.
1231 // Any arguments passed to such an executable are meant for the actual
1232 // application so skip all Dart VM flag parsing.
1233
1234 const size_t kPathBufSize = PATH_MAX + 1;
1235 char executable_path[kPathBufSize];
1236 if (Platform::ResolveExecutablePathInto(executable_path, kPathBufSize) > 0) {
1237 app_snapshot = Snapshot::TryReadAppendedAppSnapshotElf(executable_path);
1238 if (app_snapshot != nullptr) {
1239 script_name = argv[0];
1240
1241 // Store the executable name.
1243
1244 // Parse out options to be passed to dart main.
1245 for (int i = 1; i < argc; i++) {
1246 dart_options.AddArgument(argv[i]);
1247 }
1248
1249 // Parse DART_VM_OPTIONS options.
1250 int env_argc = 0;
1251 char** env_argv = Options::GetEnvArguments(&env_argc);
1252 if (env_argv != nullptr) {
1253 // Any Dart options that are generated based on parsing DART_VM_OPTIONS
1254 // are useless, so we'll throw them away rather than passing them along.
1255 CommandLineOptions tmp_options(env_argc + EXTRA_VM_ARGUMENTS);
1256 parse_arguments(env_argc, env_argv, &vm_options, &tmp_options,
1257 /*parsing_dart_vm_options=*/true);
1258 }
1259 }
1260 }
1261#endif
1262
1263 // Parse command line arguments.
1264 if (app_snapshot == nullptr) {
1265 parse_arguments(argc, argv, &vm_options, &dart_options,
1266 /*parsing_dart_vm_options=*/false);
1267 }
1268
1270
1271 if (Options::suppress_core_dump()) {
1273 } else {
1275 }
1276
1278
1279 auto try_load_snapshots_lambda = [&](void) -> void {
1280 if (app_snapshot == nullptr) {
1281 // For testing purposes we add a flag to debug-mode to use the
1282 // in-memory ELF loader.
1283 const bool force_load_elf_from_memory =
1284 false DEBUG_ONLY(|| Options::force_load_elf_from_memory());
1285 app_snapshot =
1286 Snapshot::TryReadAppSnapshot(script_name, force_load_elf_from_memory);
1287 }
1288 if (app_snapshot != nullptr && app_snapshot->IsJITorAOT()) {
1289 if (app_snapshot->IsAOT() && !Dart_IsPrecompiledRuntime()) {
1291 "%s is an AOT snapshot and should be run with 'dartaotruntime'\n",
1292 script_name);
1294 }
1295 vm_run_app_snapshot = true;
1296 app_snapshot->SetBuffers(&vm_snapshot_data, &vm_snapshot_instructions,
1299 }
1300 };
1301
1302 // At this point, script_name now points to a script if DartDev is disabled
1303 // or a valid file path was provided as the first non-flag argument.
1304 // Otherwise, script_name can be nullptr if DartDev should be run.
1305 if (script_name != nullptr) {
1306 if (!CheckForInvalidPath(script_name)) {
1307 Platform::Exit(0);
1308 }
1309 try_load_snapshots_lambda();
1310 }
1311
1312#if defined(DART_PRECOMPILED_RUNTIME)
1313 vm_options.AddArgument("--precompilation");
1314#endif
1315 if (Options::gen_snapshot_kind() == kAppJIT) {
1316 // App-jit snapshot can be deployed to another machine,
1317 // so generated code should not depend on the CPU features
1318 // of the system where snapshot was generated.
1319 vm_options.AddArgument("--target-unknown-cpu");
1320#if !defined(TARGET_ARCH_IA32)
1321 vm_options.AddArgument("--link_natives_lazily");
1322#endif
1323 }
1324
1325 // If we need to write an app-jit snapshot or a depfile, then add an exit
1326 // hook that writes the snapshot and/or depfile as appropriate.
1327 if ((Options::gen_snapshot_kind() == kAppJIT) ||
1328 (Options::depfile() != nullptr)) {
1330 }
1331
1332 char* error = nullptr;
1334 Syslog::PrintErr("Standalone embedder initialization failed: %s\n", error);
1335 free(error);
1337 }
1338
1339 error = Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
1340 if (error != nullptr) {
1341 Syslog::PrintErr("Setting VM flags failed: %s\n", error);
1342 free(error);
1344 }
1345
1346// Note: must read platform only *after* VM flags are parsed because
1347// they might affect how the platform is loaded.
1348#if !defined(DART_PRECOMPILED_RUNTIME)
1349 // Load vm_platform_strong.dill for dart:* source support.
1350 dfe.Init();
1352 if (script_name != nullptr) {
1353 uint8_t* application_kernel_buffer = nullptr;
1354 intptr_t application_kernel_buffer_size = 0;
1355 dfe.ReadScript(script_name, app_snapshot, &application_kernel_buffer,
1356 &application_kernel_buffer_size);
1357 if (application_kernel_buffer != nullptr) {
1358 // Since we loaded the script anyway, save it.
1359 dfe.set_application_kernel_buffer(application_kernel_buffer,
1360 application_kernel_buffer_size);
1362 }
1363 }
1364#endif
1365
1366 // Initialize the Dart VM.
1367 Dart_InitializeParams init_params;
1368 memset(&init_params, 0, sizeof(init_params));
1370 init_params.vm_snapshot_data = vm_snapshot_data;
1374 init_params.shutdown_isolate = OnIsolateShutdown;
1375 init_params.cleanup_isolate = DeleteIsolateData;
1377 init_params.file_open = DartUtils::OpenFile;
1378 init_params.file_read = DartUtils::ReadFile;
1379 init_params.file_write = DartUtils::WriteFile;
1380 init_params.file_close = DartUtils::CloseFile;
1383#if !defined(DART_PRECOMPILED_RUNTIME)
1384 init_params.start_kernel_isolate =
1386 if (init_params.start_kernel_isolate) {
1389 }
1390#else
1391 init_params.start_kernel_isolate = false;
1392#endif
1393#if defined(DART_HOST_OS_FUCHSIA)
1394#if defined(DART_PRECOMPILED_RUNTIME)
1395 init_params.vmex_resource = ZX_HANDLE_INVALID;
1396#else
1397 init_params.vmex_resource = Platform::GetVMEXResource();
1398#endif
1399#endif
1400
1401 error = Dart_Initialize(&init_params);
1402 if (error != nullptr) {
1404 Syslog::PrintErr("VM initialization failed: %s\n", error);
1405 free(error);
1407 }
1408
1413 bool ran_dart_dev = false;
1414 bool should_run_user_program = true;
1415#if !defined(DART_PRECOMPILED_RUNTIME)
1416 if (DartDevIsolate::should_run_dart_dev() && !Options::disable_dart_dev() &&
1417 Options::gen_snapshot_kind() == SnapshotKind::kNone) {
1419 CreateIsolateGroupAndSetup, &package_config_override, &script_name,
1420 &dart_options);
1422 ran_dart_dev = true;
1423 should_run_user_program =
1424 (dartdev_result == DartDevIsolate::DartDev_Result_Run);
1425 if (should_run_user_program) {
1426 try_load_snapshots_lambda();
1427 }
1428 } else if (script_name == nullptr &&
1429 Options::gen_snapshot_kind() != SnapshotKind::kNone) {
1431 "Snapshot generation should be done using the 'dart compile' "
1432 "command.\n");
1434 }
1435#endif // !defined(DART_PRECOMPILED_RUNTIME)
1436
1437 if (should_run_user_program) {
1438 if (Options::gen_snapshot_kind() == kKernel) {
1439 CompileAndSaveKernel(script_name, package_config_override, &dart_options);
1440 } else {
1441 // Run the main isolate until we aren't told to restart.
1442 RunMainIsolate(script_name, package_config_override, &dart_options);
1443 }
1444 }
1445
1446 // Terminate process exit-code handler.
1448
1449 error = Dart_Cleanup();
1450 if (error != nullptr) {
1451 Syslog::PrintErr("VM cleanup failed: %s\n", error);
1452 free(error);
1453 }
1454 const intptr_t global_exit_code = Process::GlobalExitCode();
1456
1457 delete app_snapshot;
1458 free(app_script_uri);
1459 if (ran_dart_dev && script_name != nullptr) {
1460 free(script_name);
1461 }
1462
1463 // Free copied argument strings if converted.
1464 if (argv_converted) {
1465 for (int i = 0; i < argc; i++) {
1466 free(argv[i]);
1467 }
1468 }
1469
1470 // Free environment if any.
1472
1473 Platform::Exit(global_exit_code);
1474}
1475
1476} // namespace bin
1477} // namespace dart
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
static std::string base_name(const std::string &path)
Definition: SkSLMinify.cpp:46
#define UNREACHABLE()
Definition: assert.h:248
static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static int SNPrint(char *str, size_t size, const char *format,...) PRINTF_ATTRIBUTE(3
static char * StrDup(const char *s)
static char * SCreate(const char *format,...) PRINTF_ATTRIBUTE(1
Definition: utils.cc:231
virtual void SetBuffers(const uint8_t **vm_data_buffer, const uint8_t **vm_instructions_buffer, const uint8_t **isolate_data_buffer, const uint8_t **isolate_instructions_buffer)=0
static void SetNativeResolver(BuiltinLibraryId id)
Definition: builtin.cc:28
Dart_Handle CreateRuntimeOptions()
Definition: dartutils.cc:58
static void SaveConfig()
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)
Definition: dfe.cc:204
bool CanUseDartFrontend() const
Definition: dfe.cc:143
void set_use_dfe(bool value=true)
Definition: dfe.h:41
void set_verbosity(Dart_KernelCompilationVerbosityLevel verbosity)
Definition: dfe.h:49
void set_application_kernel_buffer(uint8_t *buffer, intptr_t size)
Definition: dfe.h:60
bool UseDartFrontend() const
Definition: dfe.h:42
void LoadPlatform(const uint8_t **kernel_buffer, intptr_t *kernel_buffer_size)
Definition: dfe.cc:137
const char * RegisterKernelBlob(const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
Definition: dfe.cc:482
void Init()
Definition: dfe.cc:88
void application_kernel_buffer(const uint8_t **buffer, intptr_t *size) const
Definition: dfe.h:64
void UnregisterKernelBlob(const char *uri)
Definition: dfe.cc:531
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)
Definition: dfe.cc:241
void LoadKernelService(const uint8_t **kernel_service_buffer, intptr_t *kernel_service_buffer_size)
Definition: dfe.cc:131
char * frontend_filename() const
Definition: dfe.h:32
static bool should_run_dart_dev()
static CStringUniquePtr TryResolveDartDevSnapshotPath()
static DartDev_Result RunDartDev(Dart_IsolateGroupCreateCallback create_isolate, char **packages_file, char **script, CommandLineOptions *dart_options)
static Dart_Handle SetupPackageConfig(const char *packages_file)
Definition: dartutils.cc:555
static void ReadFile(uint8_t **data, intptr_t *file_len, void *stream)
Definition: dartutils.cc:273
static Dart_Handle MakeUint8Array(const void *buffer, intptr_t length)
Definition: dartutils.cc:360
static Dart_Handle SetupIOLibrary(const char *namespc_path, const char *script_uri, bool disable_exit)
Definition: dartutils.cc:617
static bool EntropySource(uint8_t *buffer, intptr_t length)
Definition: dartutils.cc:308
static Dart_Handle EnvironmentCallback(Dart_Handle name)
Definition: dartutils.cc:835
static Dart_Handle PrepareForScriptLoading(bool is_service_isolate, bool trace_loading)
Definition: dartutils.cc:570
static void SetEnvironment(dart::SimpleHashMap *environment)
Definition: dartutils.cc:831
static void CloseFile(void *stream)
Definition: dartutils.cc:303
static void * OpenFile(const char *name, bool write)
Definition: dartutils.cc:261
static Dart_Handle ResolveScript(Dart_Handle url)
Definition: dartutils.cc:386
static void WriteFile(const void *buffer, intptr_t num_bytes, void *stream)
Definition: dartutils.cc:294
static void LoadDartProfilerSymbols(const char *exepath)
Definition: exe_utils.cc:129
static CStringUniquePtr UriToPath(const char *uri)
@ kModifiedTime
Definition: file.h:100
@ kDoesNotExist
Definition: file.h:81
static void Stat(Namespace *namespc, const char *path, int64_t *data)
static File * Open(Namespace *namespc, const char *path, FileOpenMode mode)
@ kWriteTruncate
Definition: file.h:60
const char * packages_file() const
Definition: isolate_data.h:149
IsolateGroupData * isolate_group_data() const
Definition: isolate_data.h:128
void SetKernelBufferNewlyOwned(uint8_t *buffer, intptr_t size)
Definition: isolate_data.h:63
void SetKernelBufferUnowned(uint8_t *buffer, intptr_t size)
Definition: isolate_data.h:54
static Dart_Handle InitForSnapshot(const char *snapshot_uri, IsolateData *isolate_data)
Definition: loader.cc:28
static Dart_Handle DeferredLoadHandler(intptr_t loading_unit_id)
Definition: loader.cc:144
static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, Dart_Handle library, Dart_Handle url)
Definition: loader.cc:69
static void InitOnce()
Definition: loader.cc:182
static void * DlopenSystem(const char *path, char **error)
static void * DlopenExecutable(char **error)
static void * DlopenProcess(char **error)
static void * DlopenRelative(const char *path, const char *script_uri, char **error)
static void * Dlsym(void *handle, const char *symbol, char **error)
static void * DlopenAbsolute(const char *path, char **error)
static void Cleanup()
static void PrintVersion()
static void set_dfe(DFE *dfe)
Definition: main_options.h:164
static DFE * dfe()
Definition: main_options.h:163
static void PrintUsage()
static Dart_KernelCompilationVerbosityLevel verbosity_level()
Definition: main_options.h:159
static bool ParseArguments(int argc, char **argv, bool vm_run_app_snapshot, bool parsing_dart_vm_options, CommandLineOptions *vm_options, char **script_name, CommandLineOptions *dart_options, bool *print_flags_seen, bool *verbose_debug_seen)
static const char * vm_service_server_ip()
Definition: main_options.h:148
static int vm_service_server_port()
Definition: main_options.h:149
static dart::SimpleHashMap * environment()
Definition: main_options.h:145
static void SetExecutableName(const char *executable_name)
Definition: platform.h:71
static void SetProcessName(const char *name)
static DART_NORETURN void Exit(int exit_code)
static bool Initialize()
static intptr_t ResolveExecutablePathInto(char *result, size_t result_size)
static void SetCoreDumpResourceLimit(int value)
static void GetRSSInformation(int64_t *max_rss, int64_t *current_rss)
Definition: process.cc:393
static void TerminateExitCodeHandler()
static int GlobalExitCode()
Definition: process.h:124
static void SetExitHook(ExitHook hook)
Definition: process.h:135
static bool GetUtf8Argv(int argc, char **argv)
static AppSnapshot * TryReadAppSnapshot(const char *script_uri, bool force_load_elf_from_memory=false, bool decode_uri=true)
static AppSnapshot * TryReadAppendedAppSnapshotElf(const char *container_path)
static void GenerateKernel(const char *snapshot_filename, const char *script_name, const char *package_config)
static void GenerateAppJIT(const char *snapshot_filename)
static const char * GetErrorMessage()
static void SetNativeResolver()
static bool Setup(const char *server_ip, intptr_t server_port, bool dev_mode_server, bool auth_codes_disabled, const char *write_service_info_filename, bool trace_loading, bool deterministic, bool enable_service_port_fallback, bool wait_for_dds_to_advertise_service, bool serve_devtools, bool serve_observatory, bool print_dtd)
#define DART_FLAGS_CURRENT_VERSION
Definition: dart_api.h:582
#define DART_INITIALIZE_PARAMS_CURRENT_VERSION
Definition: dart_api.h:840
@ Dart_KernelCompilationStatus_Ok
Definition: dart_api.h:3785
#define DART_KERNEL_ISOLATE_NAME
Definition: dart_api.h:3880
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
struct _Dart_Isolate * Dart_Isolate
Definition: dart_api.h:88
Dart_Handle(* Dart_GetVMServiceAssetsArchive)(void)
Definition: dart_api.h:834
#define DART_VM_SERVICE_ISOLATE_NAME
Definition: dart_api.h:3888
@ Dart_Timeline_Event_Async_End
@ Dart_Timeline_Event_Duration
#define DART_EMBEDDER_INFORMATION_CURRENT_VERSION
#define DART_DEV_ISOLATE_NAME
#define ASSERT(E)
#define FATAL(error)
FlutterSemanticsFlag flags
glong glong end
const uint8_t uint32_t uint32_t GError ** error
GAsyncResult * result
uint32_t uint32_t * format
char ** argv
Definition: library.h:9
#define CHECK_RESULT(result)
Definition: main_impl.cc:969
const uint8_t kDartVmSnapshotData[]
const uint8_t kDartVmSnapshotInstructions[]
const uint8_t kDartCoreIsolateSnapshotInstructions[]
const uint8_t kDartCoreIsolateSnapshotData[]
static bool FileModifiedCallback(const char *url, int64_t since)
Definition: main_impl.cc:948
const uint8_t * isolate_snapshot_data
Definition: gen_snapshot.cc:69
unsigned int observatory_assets_archive_len
static void DeleteIsolateGroupData(void *callback_data)
Definition: main_impl.cc:921
static const char * RegisterKernelBlob(const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
Definition: main_impl.cc:898
void SetCaptureStdout(bool value)
Definition: file_support.cc:25
static Dart_Isolate IsolateSetupHelper(Dart_Isolate isolate, bool is_main_isolate, const char *script_uri, const char *packages_config, bool isolate_run_app_snapshot, Dart_IsolateFlags *flags, char **error, int *exit_code)
Definition: main_impl.cc:257
static constexpr const char * kStderrStreamId
Definition: main_impl.cc:927
static void UnregisterKernelBlob(const char *kernel_blob_uri)
Definition: main_impl.cc:902
static void CompileAndSaveKernel(const char *script_name, const char *package_config_override, CommandLineOptions *dart_options)
Definition: main_impl.cc:977
static void * NativeAssetsDlopenRelative(const char *path, char **error)
Definition: main_impl.cc:250
static Dart_Isolate CreateAndSetupServiceIsolate(const char *script_uri, const char *packages_config, Dart_IsolateFlags *flags, char **error, int *exit_code)
Definition: main_impl.cc:511
const uint8_t * vm_snapshot_data
Definition: main_impl.cc:52
static Dart_Isolate CreateAndSetupDartDevIsolate(const char *script_uri, const char *packages_config, Dart_IsolateFlags *flags, char **error, int *exit_code)
Definition: main_impl.cc:593
static bool OnIsolateInitialize(void **child_callback_data, char **error)
Definition: main_impl.cc:201
DFE dfe
Definition: dfe.cc:59
const uint8_t * vm_snapshot_instructions
Definition: main_impl.cc:53
void RunMainIsolate(const char *script_name, const char *package_config_override, CommandLineOptions *dart_options)
Definition: main_impl.cc:991
static void ServiceStreamCancelCallback(const char *stream_id)
Definition: main_impl.cc:940
static void WriteDepsFile()
Definition: main_impl.cc:99
const uint8_t * core_isolate_snapshot_data
Definition: main_impl.cc:54
static bool vm_run_app_snapshot
Definition: main_impl.cc:67
static char * app_script_uri
Definition: main_impl.cc:68
static constexpr const char * kStdoutStreamId
Definition: main_impl.cc:926
int main(int argc, char **argv)
static void DeleteIsolateData(void *isolate_group_data, void *callback_data)
Definition: main_impl.cc:916
const uint8_t * observatory_assets_archive
constexpr int kErrorExitCode
Definition: error_exit.h:18
static Dart_Isolate main_isolate
Definition: main_impl.cc:73
Dart_Handle GetVMServiceAssetsArchiveCallback()
Definition: main_impl.cc:1134
static Dart_Handle SetupCoreLibraries(Dart_Isolate isolate, IsolateData *isolate_data, bool is_isolate_group_start, bool is_kernel_isolate, const char **resolved_packages_config)
Definition: main_impl.cc:149
static bool ServiceStreamListenCallback(const char *stream_id)
Definition: main_impl.cc:929
static bool kernel_isolate_is_running
Definition: main_impl.cc:71
const uint8_t * core_isolate_snapshot_instructions
Definition: main_impl.cc:55
static void OnExitHook(int64_t exit_code)
Definition: main_impl.cc:133
static Dart_Isolate CreateIsolateGroupAndSetup(const char *script_uri, const char *main, const char *package_root, const char *package_config, Dart_IsolateFlags *flags, void *callback_data, char **error)
Definition: main_impl.cc:842
void InitializeCrashpadClient()
Definition: crashpad.cc:77
void SetCaptureStderr(bool value)
Definition: file_support.cc:29
static const uint8_t * app_isolate_snapshot_data
Definition: main_impl.cc:69
static const uint8_t * app_isolate_snapshot_instructions
Definition: main_impl.cc:70
void ErrorExit(int exit_code, const char *format,...)
Definition: error_exit.cc:18
static void OnIsolateShutdown(void *isolate_group_data, void *isolate_data)
Definition: main_impl.cc:907
static void EmbedderInformationCallback(Dart_EmbedderInformation *info)
Definition: main_impl.cc:963
void Decompress(const uint8_t *input, intptr_t input_len, uint8_t **output, intptr_t *output_length)
Definition: gzip.cc:15
static Dart_Isolate CreateIsolateGroupAndSetupHelper(bool is_main_isolate, const char *script_uri, const char *name, const char *packages_config, Dart_IsolateFlags *flags, void *callback_data, char **error, int *exit_code)
Definition: main_impl.cc:685
static Dart_Isolate CreateAndSetupKernelIsolate(const char *script_uri, const char *packages_config, Dart_IsolateFlags *flags, char **error, int *exit_code)
Definition: main_impl.cc:420
Dart_ShutdownIsolate()
const uint8_t * isolate_snapshot_instructions
Definition: gen_snapshot.cc:70
static bool CheckForInvalidPath(const char *path)
Definition: main_impl.cc:1117
bool InitOnce(char **error)
Definition: dart_vm.cc:33
DART_EXPORT bool Dart_IsCompilationError(Dart_Handle object)
DART_EXPORT void Dart_EnterScope()
const char *const name
DART_EXPORT Dart_Port Dart_GetMainPortId()
DART_EXPORT Dart_Handle Dart_GetStickyError()
DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate)
DART_EXPORT Dart_Handle Dart_DebugName()
DART_EXPORT char * Dart_SetServiceStreamCallbacks(Dart_ServiceStreamListenCallback listen_callback, Dart_ServiceStreamCancelCallback cancel_callback)
DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target, Dart_Handle name, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT Dart_Handle Dart_RootLibrary()
DART_EXPORT void Dart_SetEmbedderInformationCallback(Dart_EmbedderInformationCallback callback)
void * malloc(size_t size)
Definition: allocation.cc:19
DART_EXPORT void Dart_SetShouldPauseOnExit(bool should_pause)
DART_EXPORT void Dart_IsolateFlagsInitialize(Dart_IsolateFlags *flags)
DART_EXPORT Dart_Handle Dart_SetDeferredLoadHandler(Dart_DeferredLoadHandler handler)
DART_EXPORT const char * Dart_GetError(Dart_Handle handle)
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 char * Dart_SetFileModifiedCallback(Dart_FileModifiedCallback file_modified_callback)
DART_EXPORT char * Dart_Initialize(Dart_InitializeParams *params)
DART_EXPORT Dart_Handle Dart_GetField(Dart_Handle container, Dart_Handle name)
DART_EXPORT void Dart_InitializeNativeAssetsResolver(NativeAssetsApi *native_assets_api)
DART_EXPORT Dart_Isolate Dart_CurrentIsolate()
DART_EXPORT bool Dart_IsKernelIsolate(Dart_Isolate isolate)
DART_EXPORT char * Dart_Cleanup()
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
DART_EXPORT void Dart_ExitIsolate()
DART_EXPORT void * Dart_IsolateData(Dart_Isolate isolate)
DART_EXPORT char * Dart_IsolateMakeRunnable(Dart_Isolate isolate)
DART_EXPORT Dart_Isolate Dart_CreateIsolateGroup(const char *script_uri, const char *name, const uint8_t *snapshot_data, const uint8_t *snapshot_instructions, Dart_IsolateFlags *flags, void *isolate_group_data, void *isolate_data, char **error)
DART_EXPORT Dart_Handle Dart_RunLoop()
DART_EXPORT void * Dart_CurrentIsolateGroupData()
DART_EXPORT bool Dart_IsPrecompiledRuntime()
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 char * Dart_SetVMFlags(int argc, const char **argv)
DART_EXPORT Dart_KernelCompilationResult Dart_KernelListDependencies()
DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler(Dart_LibraryTagHandler handler)
DART_EXPORT Dart_Handle Dart_SortClasses()
DART_EXPORT Dart_Handle Dart_CompileAll()
constexpr intptr_t kWordSize
Definition: globals.h:509
DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url)
DART_EXPORT Dart_Handle Dart_LoadScriptFromKernel(const uint8_t *buffer, intptr_t buffer_size)
DART_EXPORT int64_t Dart_TimelineGetMicros()
DART_EXPORT bool Dart_IsNull(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_SetEnvironmentCallback(Dart_EnvironmentCallback callback)
DART_EXPORT Dart_Handle Dart_Null()
static int8_t data[kExtLength]
DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle object, const char **cstr)
DART_EXPORT bool Dart_IsClosure(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_NewStringFromCString(const char *str)
DART_EXPORT bool Dart_IsFatalError(Dart_Handle object)
DART_EXPORT void Dart_SetShouldPauseOnStart(bool should_pause)
@ kNone
Definition: layer.h:53
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
Definition: switches.h:57
Definition: main.py:1
#define DEBUG_ONLY(code)
Definition: globals.h:141
#define Pd64
Definition: globals.h:416
#define PATH_MAX
Definition: globals.h:708
Dart_IsolateGroupCreateCallback create_group
Definition: dart_api.h:925
Dart_InitializeIsolateCallback initialize_isolate
Definition: dart_api.h:932
Dart_IsolateGroupCleanupCallback cleanup_group
Definition: dart_api.h:950
Dart_FileReadCallback file_read
Definition: dart_api.h:955
const uint8_t * vm_snapshot_data
Definition: dart_api.h:911
Dart_GetVMServiceAssetsArchive get_service_assets
Definition: dart_api.h:964
Dart_FileOpenCallback file_open
Definition: dart_api.h:954
Dart_IsolateShutdownCallback shutdown_isolate
Definition: dart_api.h:938
Dart_UnregisterKernelBlobCallback unregister_kernel_blob
Definition: dart_api.h:982
Dart_FileWriteCallback file_write
Definition: dart_api.h:956
Dart_EntropySource entropy_source
Definition: dart_api.h:958
Dart_RegisterKernelBlobCallback register_kernel_blob
Definition: dart_api.h:977
Dart_IsolateCleanupCallback cleanup_isolate
Definition: dart_api.h:944
const uint8_t * vm_snapshot_instructions
Definition: dart_api.h:919
Dart_FileCloseCallback file_close
Definition: dart_api.h:957
Dart_NativeAssetsDlopenCallback dlopen_system
Definition: dart_api.h:3394
Dart_NativeAssetsDlopenCallback dlopen_absolute
Definition: dart_api.h:3392
Dart_NativeAssetsDlopenCallbackNoPath dlopen_process
Definition: dart_api.h:3395
Dart_NativeAssetsDlopenCallback dlopen_relative
Definition: dart_api.h:3393
Dart_NativeAssetsDlsymCallback dlsym
Definition: dart_api.h:3397
Dart_NativeAssetsDlopenCallbackNoPath dlopen_executable
Definition: dart_api.h:3396