Flutter Engine
The Flutter Engine
dartutils.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/dartutils.h"
6
7#include "bin/crypto.h"
8#include "bin/directory.h"
9#include "bin/file.h"
10#include "bin/io_buffer.h"
12#include "bin/utils.h"
13#include "include/dart_api.h"
15#include "platform/assert.h"
16#include "platform/globals.h"
17#include "platform/utils.h"
18
19// Return the error from the containing function if handle is in error handle.
20#define RETURN_IF_ERROR(handle) \
21 { \
22 Dart_Handle __handle = handle; \
23 if (Dart_IsError((__handle))) { \
24 return __handle; \
25 } \
26 }
27
28namespace dart {
29namespace bin {
30
31const char* DartUtils::original_working_directory = nullptr;
32
33dart::SimpleHashMap* DartUtils::environment_ = nullptr;
34
35MagicNumberData appjit_magic_number = {8, {0xdc, 0xdc, 0xf6, 0xf6, 0, 0, 0, 0}};
36MagicNumberData aotelf_magic_number = {4, {0x7F, 0x45, 0x4C, 0x46, 0x0}};
37MagicNumberData aotmacho32_magic_number = {4, {0xFE, 0xED, 0xFA, 0xCE}};
38MagicNumberData aotmacho64_magic_number = {4, {0xFE, 0xED, 0xFA, 0xCF}};
39MagicNumberData aotmacho64_arm64_magic_number = {4, {0xCF, 0xFA, 0xED, 0xFE}};
44MagicNumberData kernel_magic_number = {4, {0x90, 0xab, 0xcd, 0xef}};
46 7,
47 {0x23, 0x40, 0x64, 0x69, 0x6c, 0x6c, 0x0a}}; // #@dill\n
48MagicNumberData gzip_magic_number = {2, {0x1f, 0x8b, 0, 0}};
49
50static bool IsWindowsHost() {
51#if defined(DART_HOST_OS_WINDOWS)
52 return true;
53#else // defined(DART_HOST_OS_WINDOWS)
54 return false;
55#endif // defined(DART_HOST_OS_WINDOWS)
56}
57
59 Dart_Handle string_type = DartUtils::GetDartType("dart:core", "String");
60 if (Dart_IsError(string_type)) {
61 return string_type;
62 }
63 Dart_Handle dart_arguments =
64 Dart_NewListOfTypeFilled(string_type, Dart_EmptyString(), count_);
65 if (Dart_IsError(dart_arguments)) {
66 return dart_arguments;
67 }
68 for (int i = 0; i < count_; i++) {
70 if (Dart_IsError(argument_value)) {
71 return argument_value;
72 }
73 Dart_Handle result = Dart_ListSetAt(dart_arguments, i, argument_value);
74 if (Dart_IsError(result)) {
75 return result;
76 }
77 }
78 return dart_arguments;
79}
80
82 int64_t value = 0;
84 if (Dart_IsError(result)) {
86 }
87 return value;
88}
89
91 int64_t lower,
92 int64_t upper) {
93 int64_t value = DartUtils::GetIntegerValue(value_obj);
94 if (value < lower || upper < value) {
95 Dart_PropagateError(Dart_NewApiError("Value outside expected range"));
96 }
97 return value;
98}
99
101 int64_t value = 0;
103 if (Dart_IsError(result)) {
105 }
106 if (value < kIntptrMin || kIntptrMax < value) {
107 Dart_PropagateError(Dart_NewApiError("Value outside intptr_t range"));
108 }
109 return static_cast<intptr_t>(value);
110}
111
112bool DartUtils::GetInt64Value(Dart_Handle value_obj, int64_t* value) {
113 bool valid = Dart_IsInteger(value_obj);
114 if (valid) {
115 Dart_Handle result = Dart_IntegerFitsIntoInt64(value_obj, &valid);
116 if (Dart_IsError(result)) {
118 }
119 }
120 if (!valid) return false;
122 if (Dart_IsError(result)) {
124 }
125 return true;
126}
127
129 const char* cstring = nullptr;
130 Dart_Handle result = Dart_StringToCString(str_obj, &cstring);
131 if (Dart_IsError(result)) {
133 }
134 return cstring;
135}
136
138 bool value = false;
140 if (Dart_IsError(result)) {
142 }
143 return value;
144}
145
147 intptr_t index) {
148 bool value = false;
150 if (Dart_IsError(result)) {
152 }
153 return value;
154}
155
157 intptr_t index) {
158 int64_t value = 0;
160 if (Dart_IsError(result)) {
162 }
163 return value;
164}
165
167 intptr_t index) {
168 int64_t value = GetNativeIntegerArgument(args, index);
169 if (value < kIntptrMin || kIntptrMax < value) {
170 Dart_PropagateError(Dart_NewApiError("Value outside intptr_t range"));
171 }
172 return static_cast<intptr_t>(value);
173}
174
176 intptr_t index) {
177 char* tmp = nullptr;
179 Dart_GetNativeStringArgument(args, index, reinterpret_cast<void**>(&tmp));
180 if (Dart_IsError(result)) {
182 }
183 if (tmp != nullptr) {
184 return tmp;
185 }
186 const char* cstring = nullptr;
188 if (Dart_IsError(result)) {
190 }
191 ASSERT(cstring != nullptr);
192 return cstring;
193}
194
196 intptr_t index) {
197 Dart_Handle handle = Dart_GetNativeArgument(args, index);
198 TypedDataScope data(handle);
200 return data.GetScopedCString();
201}
202
204 const char* name,
205 int64_t val) {
206 return Dart_SetField(handle, NewString(name), Dart_NewInteger(val));
207}
208
210 const char* name,
211 const char* val) {
212 return Dart_SetField(handle, NewString(name), NewString(val));
213}
214
215bool DartUtils::IsDartSchemeURL(const char* url_name) {
216 static const intptr_t kDartSchemeLen = strlen(kDartScheme);
217 // If the URL starts with "dart:" then it is considered as a special
218 // library URL which is handled differently from other URLs.
219 return (strncmp(url_name, kDartScheme, kDartSchemeLen) == 0);
220}
221
222bool DartUtils::IsHttpSchemeURL(const char* url_name) {
223 static const intptr_t kHttpSchemeLen = strlen(kHttpScheme);
224 return (strncmp(url_name, kHttpScheme, kHttpSchemeLen) == 0);
225}
226
227bool DartUtils::IsDartIOLibURL(const char* url_name) {
228 return (strcmp(url_name, kIOLibURL) == 0);
229}
230
231bool DartUtils::IsDartCLILibURL(const char* url_name) {
232 return (strcmp(url_name, kCLILibURL) == 0);
233}
234
235bool DartUtils::IsDartHttpLibURL(const char* url_name) {
236 return (strcmp(url_name, kHttpLibURL) == 0);
237}
238
239bool DartUtils::IsDartBuiltinLibURL(const char* url_name) {
240 return (strcmp(url_name, kBuiltinLibURL) == 0);
241}
242
243const char* DartUtils::RemoveScheme(const char* url) {
244 const char* colon = strchr(url, ':');
245 if (colon == nullptr) {
246 return url;
247 } else {
248 return colon + 1;
249 }
250}
251
252char* DartUtils::DirName(const char* url) {
253 const char* slash = strrchr(url, File::PathSeparator()[0]);
254 if (slash == nullptr) {
255 return Utils::StrDup(url);
256 } else {
257 return Utils::StrNDup(url, slash - url + 1);
258 }
259}
260
261void* DartUtils::OpenFile(const char* name, bool write) {
262 File* file =
264 return reinterpret_cast<void*>(file);
265}
266
267void* DartUtils::OpenFileUri(const char* uri, bool write) {
268 File* file =
270 return reinterpret_cast<void*>(file);
271}
272
273void DartUtils::ReadFile(uint8_t** data, intptr_t* len, void* stream) {
274 ASSERT(data != nullptr);
275 ASSERT(len != nullptr);
276 ASSERT(stream != nullptr);
277 File* file_stream = reinterpret_cast<File*>(stream);
278 int64_t file_len = file_stream->Length();
279 if ((file_len < 0) || (file_len > kIntptrMax)) {
280 *data = nullptr;
281 *len = -1; // Indicates read was not successful.
282 return;
283 }
284 *len = static_cast<intptr_t>(file_len);
285 *data = reinterpret_cast<uint8_t*>(malloc(*len));
286 if (!file_stream->ReadFully(*data, *len)) {
287 free(*data);
288 *data = nullptr;
289 *len = -1; // Indicates read was not successful.
290 return;
291 }
292}
293
295 intptr_t num_bytes,
296 void* stream) {
297 ASSERT(stream != nullptr);
298 File* file_stream = reinterpret_cast<File*>(stream);
299 bool bytes_written = file_stream->WriteFully(buffer, num_bytes);
300 ASSERT(bytes_written);
301}
302
304 File* file = reinterpret_cast<File*>(stream);
305 file->Release();
306}
307
308bool DartUtils::EntropySource(uint8_t* buffer, intptr_t length) {
310}
311
313 const char* method,
314 Dart_Handle arg) {
315 const int kNumArgs = 1;
316 Dart_Handle dart_args[kNumArgs];
317 dart_args[0] = arg;
318 return Dart_Invoke(lib, DartUtils::NewString(method), kNumArgs, dart_args);
319}
320
321// TODO(iposva): Allocate from the zone instead of leaking error string
322// here. On the other hand the binary is about to exit anyway.
323#define SET_ERROR_MSG(error_msg, format, ...) \
324 intptr_t len = snprintf(nullptr, 0, format, __VA_ARGS__); \
325 char* msg = reinterpret_cast<char*>(malloc(len + 1)); \
326 snprintf(msg, len + 1, format, __VA_ARGS__); \
327 *error_msg = msg
328
329static uint8_t* ReadFileFully(const char* filename,
330 intptr_t* file_len,
331 const char** error_msg) {
332 *file_len = -1;
333 void* stream = DartUtils::OpenFile(filename, false);
334 if (stream == nullptr) {
335 SET_ERROR_MSG(error_msg, "Unable to open file: %s", filename);
336 return nullptr;
337 }
338 uint8_t* text_buffer = nullptr;
339 DartUtils::ReadFile(&text_buffer, file_len, stream);
340 if (text_buffer == nullptr || *file_len == -1) {
341 *error_msg = "Unable to read file contents";
342 text_buffer = nullptr;
343 }
345 return text_buffer;
346}
347
349 const char* error_msg = nullptr;
350 intptr_t len;
351 uint8_t* text_buffer = ReadFileFully(filename, &len, &error_msg);
352 if (text_buffer == nullptr) {
353 return Dart_NewApiError(error_msg);
354 }
355 Dart_Handle str = Dart_NewStringFromUTF8(text_buffer, len);
356 free(text_buffer);
357 return str;
358}
359
362 RETURN_IF_ERROR(array);
363 {
364 Dart_TypedData_Type td_type;
365 void* td_data;
366 intptr_t td_len;
368 Dart_TypedDataAcquireData(array, &td_type, &td_data, &td_len);
370 ASSERT(td_type == Dart_TypedData_kUint8);
371 ASSERT(td_len == len);
372 ASSERT(td_data != nullptr);
373 memmove(td_data, buffer, td_len);
376 }
377 return array;
378}
379
380Dart_Handle DartUtils::SetWorkingDirectory() {
382 return SingleArgDart_Invoke(LookupBuiltinLib(), "_setWorkingDirectory",
383 directory);
384}
385
387 const int kNumArgs = 1;
388 Dart_Handle dart_args[kNumArgs];
389 dart_args[0] = url;
391 NewString("_resolveScriptUri"), kNumArgs, dart_args);
392}
393
394static bool CheckMagicNumber(const uint8_t* buffer,
395 intptr_t buffer_length,
396 const MagicNumberData& magic_number) {
397 if ((buffer_length >= magic_number.length)) {
398 return memcmp(buffer, magic_number.bytes, magic_number.length) == 0;
399 }
400 return false;
401}
402
417 if (File::GetType(nullptr, filename, true) == File::kIsFile) {
418 File* file = File::Open(nullptr, filename, File::kRead);
419 if (file != nullptr) {
422 if (file->ReadFully(&header, kMaxMagicNumberSize)) {
423 magic_number = DartUtils::SniffForMagicNumber(header, sizeof(header));
424 }
425 }
426 }
427 return magic_number;
428}
429
431 intptr_t buffer_length) {
432 if (CheckMagicNumber(buffer, buffer_length, appjit_magic_number)) {
433 return kAppJITMagicNumber;
434 }
435
436 if (CheckMagicNumber(buffer, buffer_length, kernel_magic_number)) {
437 return kKernelMagicNumber;
438 }
439
440 if (CheckMagicNumber(buffer, buffer_length, kernel_list_magic_number)) {
442 }
443
444 if (CheckMagicNumber(buffer, buffer_length, gzip_magic_number)) {
445 return kGzipMagicNumber;
446 }
447
448 if (CheckMagicNumber(buffer, buffer_length, gzip_magic_number)) {
449 return kGzipMagicNumber;
450 }
451
452 if (CheckMagicNumber(buffer, buffer_length, aotelf_magic_number)) {
453 return kAotELFMagicNumber;
454 }
455
456 if (CheckMagicNumber(buffer, buffer_length, aotmacho32_magic_number)) {
458 }
459
460 if (CheckMagicNumber(buffer, buffer_length, aotmacho64_magic_number)) {
462 }
463
466 }
467
470 }
471
474 }
475
478 }
479
482 }
483
484 return kUnknownMagicNumber;
485}
486
487Dart_Handle DartUtils::PrepareBuiltinLibrary(Dart_Handle builtin_lib,
488 Dart_Handle internal_lib,
489 bool is_service_isolate,
490 bool trace_loading) {
491 // Setup the internal library's 'internalPrint' function.
493 Dart_Invoke(builtin_lib, NewString("_getPrintClosure"), 0, nullptr);
496 Dart_SetField(internal_lib, NewString("_printClosure"), print);
498
499 if (!is_service_isolate) {
500 if (IsWindowsHost()) {
501 result = Dart_SetField(builtin_lib, NewString("_isWindows"), Dart_True());
503 }
504 if (trace_loading) {
505 result =
506 Dart_SetField(builtin_lib, NewString("_traceLoading"), Dart_True());
508 }
509 // Set current working directory.
510 result = SetWorkingDirectory();
512 }
513 return Dart_True();
514}
515
516Dart_Handle DartUtils::PrepareCoreLibrary(Dart_Handle core_lib,
517 Dart_Handle io_lib,
518 bool is_service_isolate) {
519 if (!is_service_isolate) {
520 // Setup the 'Uri.base' getter in dart:core.
521 Dart_Handle uri_base =
522 Dart_Invoke(io_lib, NewString("_getUriBaseClosure"), 0, nullptr);
523 RETURN_IF_ERROR(uri_base);
525 Dart_SetField(core_lib, NewString("_uriBaseClosure"), uri_base);
527 }
528 return Dart_True();
529}
530
531Dart_Handle DartUtils::PrepareAsyncLibrary(Dart_Handle async_lib,
532 Dart_Handle isolate_lib) {
533 Dart_Handle schedule_immediate_closure =
534 Dart_Invoke(isolate_lib, NewString("_getIsolateScheduleImmediateClosure"),
535 0, nullptr);
536 RETURN_IF_ERROR(schedule_immediate_closure);
537 Dart_Handle args[1];
538 args[0] = schedule_immediate_closure;
539 return Dart_Invoke(async_lib, NewString("_setScheduleImmediateClosure"), 1,
540 args);
541}
542
543Dart_Handle DartUtils::PrepareIOLibrary(Dart_Handle io_lib) {
544 return Dart_Invoke(io_lib, NewString("_setupHooks"), 0, nullptr);
545}
546
547Dart_Handle DartUtils::PrepareIsolateLibrary(Dart_Handle isolate_lib) {
548 return Dart_Invoke(isolate_lib, NewString("_setupHooks"), 0, nullptr);
549}
550
551Dart_Handle DartUtils::PrepareCLILibrary(Dart_Handle cli_lib) {
552 return Dart_Null();
553}
554
555Dart_Handle DartUtils::SetupPackageConfig(const char* packages_config) {
557
558 if (packages_config != nullptr) {
559 result = NewString(packages_config);
561 const int kNumArgs = 1;
562 Dart_Handle dart_args[kNumArgs];
563 dart_args[0] = result;
565 NewString("_setPackagesMap"), kNumArgs, dart_args);
566 }
567 return result;
568}
569
571 bool trace_loading) {
572 // First ensure all required libraries are available.
574 RETURN_IF_ERROR(url);
575 Dart_Handle core_lib = Dart_LookupLibrary(url);
576 RETURN_IF_ERROR(core_lib);
577 url = NewString(kAsyncLibURL);
578 RETURN_IF_ERROR(url);
579 Dart_Handle async_lib = Dart_LookupLibrary(url);
580 RETURN_IF_ERROR(async_lib);
582 RETURN_IF_ERROR(url);
583 Dart_Handle isolate_lib = Dart_LookupLibrary(url);
584 RETURN_IF_ERROR(isolate_lib);
586 RETURN_IF_ERROR(url);
587 Dart_Handle internal_lib = Dart_LookupLibrary(url);
588 RETURN_IF_ERROR(internal_lib);
589 Dart_Handle builtin_lib =
591 RETURN_IF_ERROR(builtin_lib);
594 RETURN_IF_ERROR(io_lib);
597 RETURN_IF_ERROR(cli_lib);
599
600 // We need to ensure that all the scripts loaded so far are finalized
601 // as we are about to invoke some Dart code below to setup closures.
604
605 result = PrepareBuiltinLibrary(builtin_lib, internal_lib, is_service_isolate,
606 trace_loading);
608
609 RETURN_IF_ERROR(PrepareAsyncLibrary(async_lib, isolate_lib));
610 RETURN_IF_ERROR(PrepareCoreLibrary(core_lib, io_lib, is_service_isolate));
611 RETURN_IF_ERROR(PrepareIsolateLibrary(isolate_lib));
612 RETURN_IF_ERROR(PrepareIOLibrary(io_lib));
613 RETURN_IF_ERROR(PrepareCLILibrary(cli_lib));
614 return result;
615}
616
617Dart_Handle DartUtils::SetupIOLibrary(const char* namespc_path,
618 const char* script_uri,
619 bool disable_exit) {
620 Dart_Handle io_lib_url = NewString(kIOLibURL);
621 RETURN_IF_ERROR(io_lib_url);
622 Dart_Handle io_lib = Dart_LookupLibrary(io_lib_url);
623 RETURN_IF_ERROR(io_lib);
624
625 if (namespc_path != nullptr) {
626 Dart_Handle namespc_type = GetDartType(DartUtils::kIOLibURL, "_Namespace");
627 RETURN_IF_ERROR(namespc_type);
628 Dart_Handle args[1];
629 args[0] = NewString(namespc_path);
632 Dart_Invoke(namespc_type, NewString("_setupNamespace"), 1, args);
634 }
635
636 if (disable_exit) {
637 Dart_Handle embedder_config_type =
638 GetDartType(DartUtils::kIOLibURL, "_EmbedderConfig");
639 RETURN_IF_ERROR(embedder_config_type);
640 Dart_Handle result = Dart_SetField(embedder_config_type,
641 NewString("_mayExit"), Dart_False());
643 }
644
645 Dart_Handle platform_type = GetDartType(DartUtils::kIOLibURL, "_Platform");
646 RETURN_IF_ERROR(platform_type);
647 Dart_Handle script_name = NewString("_nativeScript");
648 RETURN_IF_ERROR(script_name);
649 Dart_Handle dart_script = NewString(script_uri);
650 RETURN_IF_ERROR(dart_script);
651 Dart_Handle set_script_name =
652 Dart_SetField(platform_type, script_name, dart_script);
653 RETURN_IF_ERROR(set_script_name);
654
655#if !defined(PRODUCT)
656 Dart_Handle network_profiling_type =
657 GetDartType(DartUtils::kIOLibURL, "_NetworkProfiling");
658 RETURN_IF_ERROR(network_profiling_type);
660 Dart_Invoke(network_profiling_type,
661 NewString("_registerServiceExtension"), 0, nullptr);
663#endif // !defined(PRODUCT)
664 return Dart_Null();
665}
666
668 // Post a message with just the null object.
669 return Dart_PostCObject(port_id, CObject::Null()->AsApiCObject());
670}
671
672bool DartUtils::PostInt32(Dart_Port port_id, int32_t value) {
673 // Post a message with the integer value.
674 int32_t min = 0xc0000000; // -1073741824
675 int32_t max = 0x3fffffff; // 1073741823
676 ASSERT(min <= value && value < max);
677 Dart_CObject object;
678 object.type = Dart_CObject_kInt32;
679 object.value.as_int32 = value;
680 return Dart_PostCObject(port_id, &object);
681}
682
683bool DartUtils::PostInt64(Dart_Port port_id, int64_t value) {
684 // Post a message with the integer value.
685 Dart_CObject object;
686 object.type = Dart_CObject_kInt64;
687 object.value.as_int64 = value;
688 return Dart_PostCObject(port_id, &object);
689}
690
691bool DartUtils::PostString(Dart_Port port_id, const char* value) {
693 return Dart_PostCObject(port_id, object);
694}
695
696Dart_Handle DartUtils::GetDartType(const char* library_url,
697 const char* class_name) {
699 NewString(class_name), 0, nullptr);
700}
701
703 // Extract the current OS error.
704 OSError os_error;
705 return NewDartOSError(&os_error);
706}
707
709 // Create a dart:io OSError object with the information retrieved from the OS.
712 Dart_Handle args[2];
713 args[0] = NewString(os_error->message());
714 args[1] = Dart_NewInteger(os_error->code());
715 return Dart_New(type, Dart_Null(), 2, args);
716}
717
719 const char* exception_name,
720 const char* message,
721 Dart_Handle os_error) {
722 // Create a Dart Exception object with a message and an OSError.
723 Dart_Handle type = GetDartType(library_url, exception_name);
725 Dart_Handle args[2];
726 args[0] = NewString(message);
727 args[1] = os_error;
728 return Dart_New(type, Dart_Null(), 2, args);
729}
730
732 const char* exception_name,
733 const char* message) {
734 // Create a Dart Exception object with a message.
735 Dart_Handle type = GetDartType(library_url, exception_name);
737 if (message != nullptr) {
738 Dart_Handle args[1];
739 args[0] = NewString(message);
740 return Dart_New(type, Dart_Null(), 1, args);
741 } else {
742 return Dart_New(type, Dart_Null(), 0, nullptr);
743 }
744}
745
747 return NewDartExceptionWithMessage(kCoreLibURL, "ArgumentError", message);
748}
749
751 return NewDartExceptionWithMessage(kCoreLibURL, "FormatException", message);
752}
753
755 return NewDartExceptionWithMessage(kCoreLibURL, "UnsupportedError", message);
756}
757
759 const char* message,
760 Dart_Handle os_error) {
761 // Create a dart:io exception object of the given type.
762 return NewDartExceptionWithOSError(kIOLibURL, exception_name, message,
763 os_error);
764}
765
767 va_list measure_args;
768 va_start(measure_args, format);
769 intptr_t len = Utils::VSNPrint(nullptr, 0, format, measure_args);
770 va_end(measure_args);
771
772 char* buffer = reinterpret_cast<char*>(Dart_ScopeAllocate(len + 1));
773 va_list print_args;
774 va_start(print_args, format);
775 Utils::VSNPrint(buffer, (len + 1), format, print_args);
776 va_end(print_args);
777
778 return Dart_NewApiError(buffer);
779}
780
782 return NewDartExceptionWithMessage(kCoreLibURL, "_InternalError", message);
783}
784
786 va_list args;
789 va_end(args);
790 return NewString(result);
791}
792
793char* DartUtils::ScopedCStringVFormatted(const char* format, va_list args) {
794 va_list measure_args;
795 va_copy(measure_args, args);
796 intptr_t len = Utils::VSNPrint(nullptr, 0, format, measure_args);
797 if (len < 0) {
798 return nullptr;
799 }
800 va_end(measure_args);
801
802 char* buffer = ScopedCString(len + 1);
803 va_list print_args;
804 va_copy(print_args, args);
805 len = Utils::VSNPrint(buffer, (len + 1), format, print_args);
806 if (len < 0) {
807 return nullptr;
808 }
809 va_end(print_args);
810 return buffer;
811}
812
814 va_list args;
817 va_end(args);
818 return result;
819}
820
822 // If we happen to re-initialize the Dart VM multiple times, make sure to free
823 // the old string (allocated by getcwd()) before setting a new one.
824 if (original_working_directory != nullptr) {
825 free(const_cast<char*>(original_working_directory));
826 }
828 return original_working_directory != nullptr;
829}
830
832 environment_ = environment;
833}
834
836 uint8_t* utf8_array;
837 intptr_t utf8_len;
839 Dart_Handle handle = Dart_StringToUTF8(name, &utf8_array, &utf8_len);
840 if (Dart_IsError(handle)) {
841 handle = Dart_ThrowException(
843 } else {
844 char* name_chars = reinterpret_cast<char*>(malloc(utf8_len + 1));
845 memmove(name_chars, utf8_array, utf8_len);
846 name_chars[utf8_len] = '\0';
847 const char* value = nullptr;
848 if (environment_ != nullptr) {
849 SimpleHashMap::Entry* entry =
850 environment_->Lookup(GetHashmapKeyFromString(name_chars),
851 SimpleHashMap::StringHash(name_chars), false);
852 if (entry != nullptr) {
853 value = reinterpret_cast<char*>(entry->value);
854 }
855 }
856 if (value != nullptr) {
857 result = Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(value),
858 strlen(value));
859 if (Dart_IsError(result)) {
860 result = Dart_Null();
861 }
862 }
863 free(name_chars);
864 }
865 return result;
866}
867
868// Statically allocated Dart_CObject instances for immutable
869// objects. As these will be used by different threads the use of
870// these depends on the fact that the marking internally in the
871// Dart_CObject structure is not marking simple value objects.
872Dart_CObject CObject::api_null_ = {Dart_CObject_kNull, {false}};
873Dart_CObject CObject::api_true_ = {Dart_CObject_kBool, {true}};
874Dart_CObject CObject::api_false_ = {Dart_CObject_kBool, {false}};
875CObject CObject::null_(&api_null_);
876CObject CObject::true_(&api_true_);
877CObject CObject::false_(&api_false_);
878
880 return &null_;
881}
882
884 return &true_;
885}
886
888 return &false_;
889}
890
892 return value ? &true_ : &false_;
893}
894
895Dart_CObject* CObject::New(Dart_CObject_Type type, int additional_bytes) {
896 Dart_CObject* cobject = reinterpret_cast<Dart_CObject*>(
897 Dart_ScopeAllocate(sizeof(Dart_CObject) + additional_bytes));
898 cobject->type = type;
899 return cobject;
900}
901
903 Dart_CObject* cobject = New(Dart_CObject_kInt32);
904 cobject->value.as_int32 = value;
905 return cobject;
906}
907
909 Dart_CObject* cobject = New(Dart_CObject_kInt64);
910 cobject->value.as_int64 = value;
911 return cobject;
912}
913
915 // Pointer values passed as intptr_t are always send as int64_t.
916 Dart_CObject* cobject = New(Dart_CObject_kInt64);
917 cobject->value.as_int64 = value;
918 return cobject;
919}
920
922 Dart_CObject* cobject = New(Dart_CObject_kDouble);
923 cobject->value.as_double = value;
924 return cobject;
925}
926
928 intptr_t length = strlen(str);
929 Dart_CObject* cobject = New(Dart_CObject_kString, length + 1);
930 char* payload = reinterpret_cast<char*>(cobject + 1);
931 memmove(payload, str, length + 1);
932 cobject->value.as_string = payload;
933 return cobject;
934}
935
937 Dart_CObject* cobject =
938 New(Dart_CObject_kArray, length * sizeof(Dart_CObject*)); // NOLINT
939 cobject->value.as_array.length = length;
940 cobject->value.as_array.values =
941 reinterpret_cast<Dart_CObject**>(cobject + 1);
942 return cobject;
943}
944
947 memmove(reinterpret_cast<uint8_t*>(cobject + 1), data, length);
949 cobject->value.as_typed_data.length = length;
950 cobject->value.as_typed_data.values =
951 reinterpret_cast<const uint8_t*>(cobject + 1);
952 return cobject;
953}
954
956 uint8_t* data,
957 void* peer,
963 cobject->value.as_external_typed_data.peer = peer;
965 return cobject;
966}
967
969 intptr_t size,
972 cobject->value.as_native_pointer.ptr = ptr;
973 cobject->value.as_native_pointer.size = size;
975 return cobject;
976}
977
979 // Make sure that we do not have an integer overflow here. Actual check
980 // against max elements will be done at the time of writing, as the constant
981 // is not part of the public API.
982 if ((length < 0) || (length > kIntptrMax)) {
983 return nullptr;
984 }
985 uint8_t* data = IOBuffer::Allocate(static_cast<intptr_t>(length));
986 if (data == nullptr) {
987 return nullptr;
988 }
989 return NewExternalUint8Array(static_cast<intptr_t>(length), data, data,
991}
992
993void CObject::ShrinkIOBuffer(Dart_CObject* cobject, int64_t new_length) {
994 if (cobject == nullptr) return;
996
997 const auto old_data = cobject->value.as_external_typed_data.data;
998 const auto old_length = cobject->value.as_external_typed_data.length;
999
1000 // We only shrink IOBuffers, never grow them.
1001 ASSERT(0 <= new_length && new_length <= old_length);
1002
1003 // We only reallocate if we think the freed space is worth reallocating.
1004 // We consider it worthwhile when freed space is >=25% and we have at
1005 // least 100 free bytes.
1006 const auto free_memory = old_length - new_length;
1007 if ((old_length >> 2) <= free_memory && 100 <= free_memory) {
1008 const auto new_data = IOBuffer::Reallocate(old_data, new_length);
1009 if (new_data != nullptr) {
1010 cobject->value.as_external_typed_data.data = new_data;
1011 cobject->value.as_external_typed_data.peer = new_data;
1012 }
1013 }
1014
1015 // The typed data object always has to have the shranken length.
1016 cobject->value.as_external_typed_data.length = new_length;
1017}
1018
1022 nullptr, cobject->value.as_external_typed_data.peer);
1023 cobject->value.as_external_typed_data.data = nullptr;
1024}
1025
1029 return result;
1030}
1031
1035 return result;
1036}
1037
1039 OSError os_error;
1040 return NewOSError(&os_error);
1041}
1042
1044 CObject* error_message =
1045 new CObjectString(CObject::NewString(os_error->message()));
1048 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
1049 result->SetAt(2, error_message);
1050 return result;
1051}
1052
1053} // namespace bin
1054} // namespace dart
GLenum type
Entry * Lookup(void *key, uint32_t hash, bool insert)
Definition: hashmap.cc:20
static uint32_t StringHash(const char *key)
Definition: hashmap.h:26
static char * StrDup(const char *s)
static int static int VSNPrint(char *str, size_t size, const char *format, va_list args)
static char * StrNDup(const char *s, intptr_t n)
static Dart_Handle LoadAndCheckLibrary(BuiltinLibraryId id)
Definition: builtin.cc:43
static void SetNativeResolver(BuiltinLibraryId id)
Definition: builtin.cc:28
Dart_CObject_Type type()
Definition: dartutils.h:338
static Dart_CObject * NewString(const char *str)
Definition: dartutils.cc:927
static CObject * IllegalArgumentError()
Definition: dartutils.cc:1026
static CObject * FileClosedError()
Definition: dartutils.cc:1032
static Dart_CObject * NewExternalUint8Array(intptr_t length, uint8_t *data, void *peer, Dart_HandleFinalizer callback)
Definition: dartutils.cc:955
static void FreeIOBufferData(Dart_CObject *object)
Definition: dartutils.cc:1019
static Dart_CObject * NewIntptr(intptr_t value)
Definition: dartutils.cc:914
static constexpr int kOSError
Definition: dartutils.h:334
static constexpr int kFileClosedError
Definition: dartutils.h:335
static Dart_CObject * NewIOBuffer(int64_t length)
Definition: dartutils.cc:978
static CObject * Bool(bool value)
Definition: dartutils.cc:891
static Dart_CObject * NewArray(intptr_t length)
Definition: dartutils.cc:936
static CObject * True()
Definition: dartutils.cc:883
static Dart_CObject * NewUint8Array(const void *data, intptr_t length)
Definition: dartutils.cc:945
static constexpr int kArgumentError
Definition: dartutils.h:333
static Dart_CObject * NewNativePointer(intptr_t ptr, intptr_t size, Dart_HandleFinalizer callback)
Definition: dartutils.cc:968
static Dart_CObject * NewInt32(int32_t value)
Definition: dartutils.cc:902
static Dart_CObject * NewInt64(int64_t value)
Definition: dartutils.cc:908
static Dart_CObject * NewDouble(double value)
Definition: dartutils.cc:921
static CObject * NewOSError()
Definition: dartutils.cc:1038
static void ShrinkIOBuffer(Dart_CObject *cobject, int64_t new_length)
Definition: dartutils.cc:993
static CObject * Null()
Definition: dartutils.cc:879
static CObject * False()
Definition: dartutils.cc:887
Dart_Handle CreateRuntimeOptions()
Definition: dartutils.cc:58
const char * GetArgument(int index) const
Definition: dartutils.h:65
static bool GetRandomBytes(intptr_t count, uint8_t *buffer)
static constexpr const char * kDartScheme
Definition: dartutils.h:290
static constexpr const char * kCLILibURL
Definition: dartutils.h:299
static int64_t GetNativeIntegerArgument(Dart_NativeArguments args, intptr_t index)
Definition: dartutils.cc:156
static Dart_Handle NewDartFormatException(const char *message)
Definition: dartutils.cc:750
static char static char * ScopedCStringVFormatted(const char *format, va_list args)
Definition: dartutils.cc:793
static int64_t GetIntegerValue(Dart_Handle value_obj)
Definition: dartutils.cc:81
static Dart_Handle SetupPackageConfig(const char *packages_file)
Definition: dartutils.cc:555
static int64_t GetInt64ValueCheckRange(Dart_Handle value_obj, int64_t lower, int64_t upper)
Definition: dartutils.cc:90
static Dart_Handle NewDartExceptionWithMessage(const char *library_url, const char *exception_name, const char *message)
Definition: dartutils.cc:731
static Dart_Handle LookupBuiltinLib()
Definition: dartutils.h:248
static constexpr const char * kIOLibURL
Definition: dartutils.h:297
static const char * GetNativeTypedDataArgument(Dart_NativeArguments args, intptr_t index)
Definition: dartutils.cc:195
static Dart_Handle NewDartOSError()
Definition: dartutils.cc:702
static constexpr const char * kAsyncLibURL
Definition: dartutils.h:291
static constexpr const char * kIsolateLibURL
Definition: dartutils.h:295
static char * DirName(const char *url)
Definition: dartutils.cc:252
static void ReadFile(uint8_t **data, intptr_t *file_len, void *stream)
Definition: dartutils.cc:273
static Dart_Handle ReadStringFromFile(const char *filename)
Definition: dartutils.cc:348
static bool GetBooleanValue(Dart_Handle bool_obj)
Definition: dartutils.cc:137
static bool GetInt64Value(Dart_Handle value_obj, int64_t *value)
Definition: dartutils.cc:112
static bool IsHttpSchemeURL(const char *url_name)
Definition: dartutils.cc:222
static const char * GetStringValue(Dart_Handle str_obj)
Definition: dartutils.cc:128
static void * OpenFileUri(const char *uri, bool write)
Definition: dartutils.cc:267
static Dart_Handle NewDartExceptionWithOSError(const char *library_url, const char *exception_name, const char *message, Dart_Handle os_error)
Definition: dartutils.cc:718
static Dart_Handle MakeUint8Array(const void *buffer, intptr_t length)
Definition: dartutils.cc:360
static bool IsDartBuiltinLibURL(const char *url_name)
Definition: dartutils.cc:239
static constexpr const char * kInternalLibURL
Definition: dartutils.h:294
static Dart_Handle SetupIOLibrary(const char *namespc_path, const char *script_uri, bool disable_exit)
Definition: dartutils.cc:617
static bool PostInt32(Dart_Port port_id, int32_t value)
Definition: dartutils.cc:672
static Dart_Handle NewStringFormatted(const char *format,...)
Definition: dartutils.cc:785
static const char * original_working_directory
Definition: dartutils.h:288
static bool SetOriginalWorkingDirectory()
Definition: dartutils.cc:821
static bool PostNull(Dart_Port port_id)
Definition: dartutils.cc:667
static Dart_Handle NewError(const char *format,...)
Definition: dartutils.cc:766
static char * ScopedCStringFormatted(const char *format,...) PRINTF_ATTRIBUTE(1
Definition: dartutils.cc:813
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 NewDartIOException(const char *exception_name, const char *message, Dart_Handle os_error)
Definition: dartutils.cc:758
static bool PostString(Dart_Port port_id, const char *value)
Definition: dartutils.cc:691
static constexpr const char * kHttpLibURL
Definition: dartutils.h:296
static constexpr const char * kCoreLibURL
Definition: dartutils.h:293
static bool PostInt64(Dart_Port port_id, int64_t value)
Definition: dartutils.cc:683
static Dart_Handle NewDartUnsupportedError(const char *message)
Definition: dartutils.cc:754
static intptr_t GetNativeIntptrArgument(Dart_NativeArguments args, intptr_t index)
Definition: dartutils.cc:166
static char * ScopedCString(intptr_t length)
Definition: dartutils.h:224
static Dart_Handle NewString(const char *str)
Definition: dartutils.h:214
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 Dart_Handle SetIntegerField(Dart_Handle handle, const char *name, int64_t val)
Definition: dartutils.cc:203
static void CloseFile(void *stream)
Definition: dartutils.cc:303
static Dart_Handle NewDartArgumentError(const char *message)
Definition: dartutils.cc:746
static MagicNumber SniffForMagicNumber(const char *filename)
Definition: dartutils.cc:403
static void * OpenFile(const char *name, bool write)
Definition: dartutils.cc:261
static Dart_Handle NewInternalError(const char *message)
Definition: dartutils.cc:781
static const char * RemoveScheme(const char *url)
Definition: dartutils.cc:243
static bool IsDartCLILibURL(const char *url_name)
Definition: dartutils.cc:231
static constexpr const char * kBuiltinLibURL
Definition: dartutils.h:292
static bool IsDartSchemeURL(const char *url_name)
Definition: dartutils.cc:215
static Dart_Handle SetStringField(Dart_Handle handle, const char *name, const char *val)
Definition: dartutils.cc:209
static bool IsDartHttpLibURL(const char *url_name)
Definition: dartutils.cc:235
static constexpr int64_t kMaxMagicNumberSize
Definition: dartutils.h:271
static Dart_Handle ResolveScript(Dart_Handle url)
Definition: dartutils.cc:386
static bool IsDartIOLibURL(const char *url_name)
Definition: dartutils.cc:227
static Dart_Handle GetDartType(const char *library_url, const char *class_name)
Definition: dartutils.cc:696
static intptr_t GetIntptrValue(Dart_Handle value_obj)
Definition: dartutils.cc:100
static constexpr const char * kHttpScheme
Definition: dartutils.h:302
static const char * GetNativeStringArgument(Dart_NativeArguments args, intptr_t index)
Definition: dartutils.cc:175
static void WriteFile(const void *buffer, intptr_t num_bytes, void *stream)
Definition: dartutils.cc:294
static bool GetNativeBooleanArgument(Dart_NativeArguments args, intptr_t index)
Definition: dartutils.cc:146
static char * CurrentNoScope()
static File * OpenUri(Namespace *namespc, const char *uri, FileOpenMode mode)
static const char * PathSeparator()
bool WriteFully(const void *buffer, int64_t num_bytes)
Definition: file_support.cc:55
bool ReadFully(void *buffer, int64_t num_bytes)
Definition: file_support.cc:41
static File * Open(Namespace *namespc, const char *path, FileOpenMode mode)
int64_t Length()
@ kWriteTruncate
Definition: file.h:60
static Type GetType(Namespace *namespc, const char *path, bool follow_links)
static void Finalizer(void *isolate_callback_data, void *buffer)
Definition: io_buffer.h:31
static Dart_Handle Allocate(intptr_t size, uint8_t **buffer)
Definition: io_buffer.cc:12
static uint8_t * Reallocate(uint8_t *buffer, intptr_t new_size)
Definition: io_buffer.cc:34
char * message()
Definition: utils.h:36
int64_t Dart_Port
Definition: dart_api.h:1525
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
void(* Dart_HandleFinalizer)(void *isolate_callback_data, void *peer)
Definition: dart_api.h:265
struct _Dart_NativeArguments * Dart_NativeArguments
Definition: dart_api.h:3019
Dart_TypedData_Type
Definition: dart_api.h:2612
@ Dart_TypedData_kUint8
Definition: dart_api.h:2615
Dart_CObject_Type
@ Dart_CObject_kInt64
@ Dart_CObject_kNativePointer
@ Dart_CObject_kDouble
@ Dart_CObject_kTypedData
@ Dart_CObject_kString
@ Dart_CObject_kArray
@ Dart_CObject_kNull
@ Dart_CObject_kExternalTypedData
@ Dart_CObject_kInt32
@ Dart_CObject_kBool
#define SET_ERROR_MSG(error_msg, format,...)
Definition: dartutils.cc:323
#define RETURN_IF_ERROR(handle)
Definition: dartutils.cc:20
#define ASSERT(E)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
uint8_t value
GAsyncResult * result
uint32_t uint32_t * format
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static float min(float r, float g, float b)
Definition: hsl.cpp:48
size_t length
Win32Message message
MagicNumberData gzip_magic_number
Definition: dartutils.cc:48
MagicNumberData aotcoff_riscv32_magic_number
Definition: dartutils.cc:42
MagicNumberData appjit_magic_number
Definition: dartutils.cc:35
static void * GetHashmapKeyFromString(char *key)
Definition: dartutils.h:38
va_start(args, format)
MagicNumberData aotmacho32_magic_number
Definition: dartutils.cc:37
static uint8_t * ReadFileFully(const char *filename, intptr_t *file_len, const char **error_msg)
Definition: dartutils.cc:329
CObject CObject::false_ & api_false_
Definition: dartutils.cc:877
MagicNumberData aotmacho64_magic_number
Definition: dartutils.cc:38
static Dart_Handle SingleArgDart_Invoke(Dart_Handle lib, const char *method, Dart_Handle arg)
Definition: dartutils.cc:312
MagicNumberData kernel_list_magic_number
Definition: dartutils.cc:45
va_end(args)
MagicNumberData aotelf_magic_number
Definition: dartutils.cc:36
CObject CObject::true_ & api_true_
Definition: dartutils.cc:876
static bool CheckMagicNumber(const uint8_t *buffer, intptr_t buffer_length, const MagicNumberData &magic_number)
Definition: dartutils.cc:394
MagicNumberData aotcoff_riscv64_magic_number
Definition: dartutils.cc:43
CObject CObject::null_ & api_null_
Definition: dartutils.cc:875
MagicNumberData kernel_magic_number
Definition: dartutils.cc:44
static bool IsWindowsHost()
Definition: dartutils.cc:50
MagicNumberData aotcoff_arm64_magic_number
Definition: dartutils.cc:41
MagicNumberData aotcoff_arm32_magic_number
Definition: dartutils.cc:40
MagicNumberData aotmacho64_arm64_magic_number
Definition: dartutils.cc:39
static dart::SimpleHashMap * environment
Definition: gen_snapshot.cc:59
Definition: dart_vm.cc:33
DART_EXPORT Dart_Handle Dart_StringToUTF8(Dart_Handle str, uint8_t **utf8_array, intptr_t *length)
DART_EXPORT Dart_Handle Dart_GetNativeStringArgument(Dart_NativeArguments args, int arg_index, void **peer)
const char *const name
DART_EXPORT Dart_Handle Dart_FinalizeLoading(bool complete_futures)
DART_EXPORT Dart_Handle Dart_False()
DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target, Dart_Handle name, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT Dart_Handle Dart_True()
void * malloc(size_t size)
Definition: allocation.cc:19
const char *const class_name
constexpr intptr_t kIntptrMin
Definition: globals.h:556
DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value)
DART_EXPORT Dart_Handle Dart_BooleanValue(Dart_Handle boolean_obj, bool *value)
DART_EXPORT Dart_Handle Dart_NewStringFromUTF8(const uint8_t *utf8_array, intptr_t length)
DART_EXPORT void Dart_PropagateError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_GetNonNullableType(Dart_Handle library, Dart_Handle class_name, intptr_t number_of_type_arguments, Dart_Handle *type_arguments)
DART_EXPORT const char * Dart_GetError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_NewTypedData(Dart_TypedData_Type type, intptr_t length)
DART_EXPORT uint8_t * Dart_ScopeAllocate(intptr_t size)
DART_EXPORT Dart_Handle Dart_TypedDataAcquireData(Dart_Handle object, Dart_TypedData_Type *type, void **data, intptr_t *len)
DART_EXPORT Dart_Handle Dart_NewListOfTypeFilled(Dart_Handle element_type, Dart_Handle fill_object, intptr_t length)
DART_EXPORT Dart_Handle Dart_ListSetAt(Dart_Handle list, intptr_t index, Dart_Handle value)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_EmptyString()
DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, int index)
DART_EXPORT Dart_Handle Dart_SetField(Dart_Handle container, Dart_Handle name, Dart_Handle value)
DART_EXPORT Dart_Handle Dart_TypedDataReleaseData(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer, bool *fits)
DART_EXPORT Dart_Handle Dart_NewApiError(const char *error)
DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url)
DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception)
DART_EXPORT Dart_Handle Dart_GetNativeIntegerArgument(Dart_NativeArguments args, int index, int64_t *value)
DART_EXPORT bool Dart_IsInteger(Dart_Handle object)
DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject *message)
DART_EXPORT Dart_Handle Dart_Null()
DART_EXPORT Dart_Handle Dart_New(Dart_Handle type, Dart_Handle constructor_name, int number_of_arguments, Dart_Handle *arguments)
static int8_t data[kExtLength]
DART_EXPORT Dart_Handle Dart_GetNativeBooleanArgument(Dart_NativeArguments args, int index, bool *value)
DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle object, const char **cstr)
constexpr intptr_t kIntptrMax
Definition: globals.h:557
DART_EXPORT Dart_Handle Dart_IntegerToInt64(Dart_Handle integer, int64_t *value)
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
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
Definition: switches.h:259
def print(*args, **kwargs)
Definition: run_tests.py:49
static const char header[]
Definition: skpbench.cpp:88
void write(SkWStream *wStream, const T &text)
Definition: skqp.cpp:188
Dart_HandleFinalizer callback
union _Dart_CObject::@86 value
Dart_CObject_Type type
uint8_t * data
struct _Dart_CObject::@86::@90 as_typed_data
const char * as_string
struct _Dart_CObject::@86::@91 as_external_typed_data
struct _Dart_CObject::@86::@89 as_array
struct _Dart_CObject ** values
struct _Dart_CObject::@86::@92 as_native_pointer
const uint8_t bytes[kMaxLength]
Definition: dartutils.h:657