Flutter Engine
The Flutter Engine
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
dart::bin Namespace Reference

Namespaces

namespace  elf
 
namespace  test
 

Classes

class  AddressList
 
class  AppSnapshot
 
class  AsyncDirectoryListing
 
class  BufferListBase
 
class  Builtin
 
class  CallbackOptionProcessor
 
class  CircularLinkedList
 
class  ClientSocket
 
class  CObject
 
class  CObjectArray
 
class  CObjectBool
 
class  CObjectDouble
 
class  CObjectExternalUint8Array
 
class  CObjectInt32
 
class  CObjectInt64
 
class  CObjectIntptr
 
class  CObjectNativePointer
 
class  CObjectSendPort
 
class  CObjectString
 
class  CObjectTypedData
 
class  CObjectUint8Array
 
class  CommandLineOptions
 
class  Console
 
class  Crypto
 
class  DartDevIsolate
 
class  DartUtils
 
class  DatagramSocket
 
class  DescriptorInfo
 
class  DescriptorInfoBase
 
class  DescriptorInfoMultiple
 
class  DescriptorInfoMultipleMixin
 
class  DescriptorInfoSingle
 
class  DescriptorInfoSingleMixin
 
class  DFE
 
class  Directory
 
class  DirectoryListing
 
class  DirectoryListingEntry
 
class  DirectoryWatchHandle
 
class  DummySnapshot
 
class  EventHandler
 
class  EventHandlerImplementation
 
class  EXEUtils
 
class  FDUtils
 
class  File
 
class  FileHandle
 
class  FileSystemWatcher
 
class  Filter
 
class  Handle
 
class  InterfaceSocketAddress
 
class  InterruptMessage
 
class  IOBuffer
 
class  IOHandle
 
class  IOService
 
class  IsolateData
 
class  IsolateGroupData
 
class  KernelBlob
 
class  KernelIRNode
 
class  ListeningSocketRegistry
 
class  ListenSocket
 
class  Loader
 
struct  MagicNumberData
 
class  MappedAppSnapshot
 
class  MappedMemory
 
class  Monitor
 
class  MonitorData
 
class  MonitorLocker
 
class  Mutex
 
class  MutexData
 
class  MutexLocker
 
class  Namespace
 
class  NamespaceImpl
 
class  NamespaceScope
 
class  NativeAssets
 
struct  NativeEntries
 
class  OptionProcessor
 
class  Options
 
class  OSError
 
class  OverlappedBuffer
 
class  PathBuffer
 
class  PathSanitizer
 
class  Platform
 
class  Process
 
class  ProcessResult
 
union  RawAddr
 
class  RefCntReleaseScope
 
class  ReferenceCounted
 
class  RetainedPointer
 
class  ScopedBlockingCall
 
class  ScopedMemBIO
 
class  ScopedSSLStackType
 
class  ScopedSSLType
 
class  SecureSocketUtils
 
class  ServerSocket
 
class  ShellUtils
 
class  SignalInfo
 
class  Snapshot
 
class  Socket
 
class  SocketAddress
 
class  SocketBase
 
class  SocketControlMessage
 
class  SocketHandle
 
class  SSLCertContext
 
class  SSLFilter
 
class  StdHandle
 
class  Stdin
 
class  Stdout
 
class  StringPointer
 
class  StringUtils
 
class  StringUtilsWin
 
class  SyncDirectoryListing
 
class  SynchronousSocket
 
class  Thread
 
class  TimeoutQueue
 
class  TimerUtils
 
class  TypedDataScope
 
class  UriDecoder
 
class  VirtualMemory
 
class  VmService
 
struct  VmServiceIONativeEntry
 
class  WideToUtf8Scope
 
class  X509Helper
 
class  X509TrustState
 
class  ZLibDeflateFilter
 
class  ZLibInflateFilter
 

Typedefs

typedef bool(* OptionProcessorCallback) (const char *arg, CommandLineOptions *vm_options)
 
typedef void(* sa_handler_t) (int)
 
typedef ScopedSSLType< PKCS12, PKCS12_free > ScopedPKCS12
 
typedef ScopedSSLType< X509, X509_free > ScopedX509
 
typedef ScopedSSLStackType< STACK_OF(X509), X509, X509_free > ScopedX509Stack
 
typedef void(* TrustEvaluateHandlerFunc) (Dart_Port dest_port_id, Dart_CObject *message)
 
typedef pthread_t ThreadId
 

Enumerations

enum  ListType {
  kListFile = 0 , kListDirectory = 1 , kListLink = 2 , kListError = 3 ,
  kListDone = 4
}
 
enum  MessageFlags {
  kInEvent = 0 , kOutEvent = 1 , kErrorEvent = 2 , kCloseEvent = 3 ,
  kDestroyedEvent = 4 , kCloseCommand = 8 , kShutdownReadCommand = 9 , kShutdownWriteCommand = 10 ,
  kReturnTokenCommand = 11 , kSetEventMaskCommand = 12 , kListeningSocket = 16 , kPipe = 17 ,
  kSignalSocket = 18
}
 
enum  SnapshotKind {
  kCore , kApp , kAppJIT , kAppAOTAssembly ,
  kAppAOTElf , kVMAOTAssembly , kNone , kKernel ,
  kAppJIT
}
 
enum  SnapshotKind {
  kCore , kApp , kAppJIT , kAppAOTAssembly ,
  kAppAOTElf , kVMAOTAssembly , kNone , kKernel ,
  kAppJIT
}
 
enum  VerbosityLevel { kError , kWarning , kInfo , kAll }
 
enum  ProcessSignals {
  kSighup = 1 , kSigint = 2 , kSigquit = 3 , kSigill = 4 ,
  kSigtrap = 5 , kSigabrt = 6 , kSigbus = 7 , kSigfpe = 8 ,
  kSigkill = 9 , kSigusr1 = 10 , kSigsegv = 11 , kSigusr2 = 12 ,
  kSigpipe = 13 , kSigalrm = 14 , kSigterm = 15 , kSigchld = 17 ,
  kSigcont = 18 , kSigstop = 19 , kSigtstp = 20 , kSigttin = 21 ,
  kSigttou = 22 , kSigurg = 23 , kSigxcpu = 24 , kSigxfsz = 25 ,
  kSigvtalrm = 26 , kSigprof = 27 , kSigwinch = 28 , kSigpoll = 29 ,
  kSigsys = 31 , kLastSignal = kSigsys
}
 
enum  ProcessStartMode { kNormal = 0 , kInheritStdio = 1 , kDetached = 2 , kDetachedWithStdio = 3 }
 
enum  _RawSocketOptions : int64_t {
  DART_SOL_SOCKET = 0 , DART_IPPROTO_IP = 1 , DART_IP_MULTICAST_IF = 2 , DART_IPPROTO_IPV6 = 3 ,
  DART_IPV6_MULTICAST_IF = 4 , DART_IPPROTO_TCP = 5 , DART_IPPROTO_UDP = 6
}
 

Functions

 BUILTIN_NATIVE_LIST (DECLARE_FUNCTION)
 
void FUNCTION_NAME() Builtin_PrintString (Dart_NativeArguments args)
 
void Builtin_DummyNative (Dart_NativeArguments args)
 
void InitializeCrashpadClient ()
 
void FUNCTION_NAME() Crypto_GetRandomBytes (Dart_NativeArguments args)
 
 TEST_CASE (GetRandomBytes)
 
void BootstrapDartIo ()
 
void CleanupDartIo ()
 
void SetSystemTempDirectory (const char *system_temp)
 
void SetExecutableName (const char *executable_name)
 
void SetExecutableArguments (int script_index, char **argv)
 
void GetIOEmbedderInformation (Dart_EmbedderInformation *info)
 
void * OpenFile (const char *name, bool write)
 
void ReadFile (uint8_t **data, intptr_t *file_len, void *stream)
 
void WriteFile (const void *buffer, intptr_t num_bytes, void *stream)
 
void CloseFile (void *stream)
 
bool GetEntropy (uint8_t *buffer, intptr_t length)
 
Dart_NativeFunction LookupIONative (Dart_Handle name, int argument_count, bool *auto_setup_scope)
 
const uint8_t * LookupIONativeSymbol (Dart_NativeFunction nf)
 
static Dart_CObjectGetArrayItem (Dart_CObject *message, intptr_t index)
 
static bool IsWindowsHost ()
 
static Dart_Handle SingleArgDart_Invoke (Dart_Handle lib, const char *method, Dart_Handle arg)
 
static uint8_t * ReadFileFully (const char *filename, intptr_t *file_len, const char **error_msg)
 
static bool CheckMagicNumber (const uint8_t *buffer, intptr_t buffer_length, const MagicNumberData &magic_number)
 
static Dart_Handle ThrowIfError (Dart_Handle handle)
 
static void * GetHashmapKeyFromString (char *key)
 
static bool TryReadSimpleKernelBuffer (uint8_t *buffer, uint8_t **p_kernel_ir, intptr_t *p_kernel_ir_size)
 
static bool TryReadFile (const char *script_uri, uint8_t **buffer, intptr_t *size, bool decode_uri=true)
 
static bool TryReadKernelListBuffer (const char *script_uri, uint8_t *buffer, intptr_t buffer_size, uint8_t **kernel_ir, intptr_t *kernel_ir_size)
 
void FUNCTION_NAME() Directory_Current (Dart_NativeArguments args)
 
void FUNCTION_NAME() Directory_SetCurrent (Dart_NativeArguments args)
 
void FUNCTION_NAME() Directory_Exists (Dart_NativeArguments args)
 
void FUNCTION_NAME() Directory_Create (Dart_NativeArguments args)
 
void FUNCTION_NAME() Directory_SystemTemp (Dart_NativeArguments args)
 
void FUNCTION_NAME() Directory_CreateTemp (Dart_NativeArguments args)
 
void FUNCTION_NAME() Directory_Delete (Dart_NativeArguments args)
 
void FUNCTION_NAME() Directory_Rename (Dart_NativeArguments args)
 
void FUNCTION_NAME() Directory_FillWithDirectoryListing (Dart_NativeArguments args)
 
void FUNCTION_NAME() Directory_GetAsyncDirectoryListerPointer (Dart_NativeArguments args)
 
static void ReleaseListing (void *isolate_callback_data, void *peer)
 
void FUNCTION_NAME() Directory_SetAsyncDirectoryListerPointer (Dart_NativeArguments args)
 
static NamespaceCObjectToNamespacePointer (CObject *cobject)
 
static CObjectCreateIllegalArgumentError ()
 
static bool ListNext (DirectoryListing *listing)
 
void ErrorExit (int exit_code, const char *format,...)
 
void FUNCTION_NAME() EventHandler_SendData (Dart_NativeArguments args)
 
void FUNCTION_NAME() EventHandler_TimerMillisecondClock (Dart_NativeArguments args)
 
 VM_UNIT_TEST_CASE (CircularLinkedList)
 
static bool StartsWithPathSeparator (const char *path, const char *sep, intptr_t sep_length)
 
static char * GetDirectoryFromPath (const char *path, char *dir)
 
static const char * GetFileNameFromPath (const char *path)
 
static bool IsFile (Dart_Handle file_obj)
 
static FileGetFile (Dart_NativeArguments args)
 
static void SetFile (Dart_Handle dart_this, intptr_t file_pointer)
 
void FUNCTION_NAME() File_GetPointer (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_GetFD (Dart_NativeArguments args)
 
static void ReleaseFile (void *isolate_callback_data, void *peer)
 
void FUNCTION_NAME() File_SetPointer (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_Open (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_Exists (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_Close (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_ReadByte (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_WriteByte (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_Read (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_ReadInto (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_WriteFrom (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_Position (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_SetPosition (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_Truncate (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_Length (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_LengthFromPath (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_LastModified (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_SetLastModified (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_LastAccessed (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_SetLastAccessed (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_Flush (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_Lock (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_Create (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_CreateLink (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_CreatePipe (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_LinkTarget (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_Delete (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_DeleteLink (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_Rename (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_RenameLink (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_Copy (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_ResolveSymbolicLinks (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_OpenStdio (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_GetStdioHandleType (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_GetType (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_Stat (Dart_NativeArguments args)
 
void FUNCTION_NAME() File_AreIdentical (Dart_NativeArguments args)
 
static int64_t CObjectInt32OrInt64ToInt64 (CObject *cobject)
 
static FileCObjectToFilePointer (CObject *cobject)
 
static NamespaceCObjectToNamespacePointer (CObject *cobject)
 
static int SizeInBytes (Dart_TypedData_Type type)
 
void SetCaptureStdout (bool value)
 
void SetCaptureStderr (bool value)
 
bool ShouldCaptureStdout ()
 
bool ShouldCaptureStderr ()
 
void FUNCTION_NAME() FileSystemWatcher_IsSupported (Dart_NativeArguments args)
 
void FUNCTION_NAME() FileSystemWatcher_InitWatcher (Dart_NativeArguments args)
 
void FUNCTION_NAME() FileSystemWatcher_CloseWatcher (Dart_NativeArguments args)
 
void FUNCTION_NAME() FileSystemWatcher_WatchPath (Dart_NativeArguments args)
 
void FUNCTION_NAME() FileSystemWatcher_UnwatchPath (Dart_NativeArguments args)
 
void FUNCTION_NAME() FileSystemWatcher_ReadEvents (Dart_NativeArguments args)
 
void FUNCTION_NAME() FileSystemWatcher_GetSocketId (Dart_NativeArguments args)
 
std::unique_ptr< wchar_t[]> ToWinAPIDirectoryPath (const char *path, bool force_long_prefix=false)
 
static Dart_Handle GetFilter (Dart_Handle filter_obj, Filter **filter)
 
static Dart_Handle CopyDictionary (Dart_Handle dictionary_obj, uint8_t **dictionary)
 
void FUNCTION_NAME() Filter_CreateZLibInflate (Dart_NativeArguments args)
 
void FUNCTION_NAME() Filter_CreateZLibDeflate (Dart_NativeArguments args)
 
void FUNCTION_NAME() Filter_Process (Dart_NativeArguments args)
 
void FUNCTION_NAME() Filter_Processed (Dart_NativeArguments args)
 
static void DeleteFilter (void *isolate_data, void *filter_pointer)
 
static bool ProcessEnvironmentOption (const char *arg, CommandLineOptions *vm_options)
 
 DEFINE_ENUM_OPTION (snapshot_kind, SnapshotKind, snapshot_kind)
 
 DEFINE_CB_OPTION (ProcessEnvironmentOption)
 
static bool IsSnapshottingForPrecompilation ()
 
static void PrintUsage ()
 
static int ParseArguments (int argc, char **argv, CommandLineOptions *vm_options, CommandLineOptions *inputs)
 
 PRINTF_ATTRIBUTE (1, 2) static void PrintErrAndExit(const char *format
 
 va_start (args, format)
 
 va_end (args)
 
 Dart_ExitScope ()
 
 Dart_ShutdownIsolate ()
 
 exit (kErrorExitCode)
 
static FileOpenFile (const char *filename)
 
static void WriteFile (const char *filename, const uint8_t *buffer, const intptr_t size)
 
static void ReadFile (const char *filename, uint8_t **buffer, intptr_t *size)
 
static void MallocFinalizer (void *isolate_callback_data, void *peer)
 
static void MaybeLoadExtraInputs (const CommandLineOptions &inputs)
 
static void MaybeLoadCode ()
 
static void CreateAndWriteCoreSnapshot ()
 
static std::unique_ptr< MappedMemoryMapFile (const char *filename, File::MapType type, const uint8_t **buffer)
 
static void CreateAndWriteAppSnapshot ()
 
static void CreateAndWriteAppJITSnapshot ()
 
static void StreamingWriteCallback (void *callback_data, const uint8_t *buffer, intptr_t size)
 
static void StreamingCloseCallback (void *callback_data)
 
static FileOpenLoadingUnitManifest ()
 
static void WriteLoadingUnitManifest (File *manifest_file, intptr_t id, const char *path, const char *debug_path=nullptr)
 
static void CloseLoadingUnitManifest (File *manifest_file)
 
static void NextLoadingUnit (void *callback_data, intptr_t loading_unit_id, void **write_callback_data, void **write_debug_callback_data, const char *main_filename, const char *suffix)
 
static void NextAsmCallback (void *callback_data, intptr_t loading_unit_id, void **write_callback_data, void **write_debug_callback_data)
 
static void NextElfCallback (void *callback_data, intptr_t loading_unit_id, void **write_callback_data, void **write_debug_callback_data)
 
static void CreateAndWritePrecompiledSnapshot ()
 
static int CreateIsolateAndSnapshot (const CommandLineOptions &inputs)
 
int main (int argc, char **argv)
 
void Decompress (const uint8_t *input, intptr_t input_len, uint8_t **output, intptr_t *output_length)
 
 IO_NATIVE_LIST (DECLARE_FUNCTION)
 
Dart_NativeFunction IONativeLookup (Dart_Handle name, int argument_count, bool *auto_setup_scope)
 
const uint8_t * IONativeSymbol (Dart_NativeFunction nf)
 
void IOServiceCallback (Dart_Port dest_port_id, Dart_CObject *message)
 
void FUNCTION_NAME() IOService_NewServicePort (Dart_NativeArguments args)
 
static void MallocFinalizer (void *isolate_callback_data, void *peer)
 
static Dart_Handle WrapMallocedKernelBuffer (uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
 
static void WriteDepsFile ()
 
static void OnExitHook (int64_t exit_code)
 
static Dart_Handle SetupCoreLibraries (Dart_Isolate isolate, IsolateData *isolate_data, bool is_isolate_group_start, bool is_kernel_isolate, const char **resolved_packages_config)
 
static bool OnIsolateInitialize (void **child_callback_data, char **error)
 
static void * NativeAssetsDlopenRelative (const char *path, char **error)
 
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)
 
static Dart_Isolate CreateAndSetupKernelIsolate (const char *script_uri, const char *packages_config, Dart_IsolateFlags *flags, char **error, int *exit_code)
 
static Dart_Isolate CreateAndSetupServiceIsolate (const char *script_uri, const char *packages_config, Dart_IsolateFlags *flags, char **error, int *exit_code)
 
static Dart_Isolate CreateAndSetupDartDevIsolate (const char *script_uri, const char *packages_config, Dart_IsolateFlags *flags, char **error, int *exit_code)
 
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)
 
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)
 
static const char * RegisterKernelBlob (const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
 
static void UnregisterKernelBlob (const char *kernel_blob_uri)
 
static void OnIsolateShutdown (void *isolate_group_data, void *isolate_data)
 
static void DeleteIsolateData (void *isolate_group_data, void *callback_data)
 
static void DeleteIsolateGroupData (void *callback_data)
 
static bool ServiceStreamListenCallback (const char *stream_id)
 
static void ServiceStreamCancelCallback (const char *stream_id)
 
static bool FileModifiedCallback (const char *url, int64_t since)
 
static void EmbedderInformationCallback (Dart_EmbedderInformation *info)
 
static void CompileAndSaveKernel (const char *script_name, const char *package_config_override, CommandLineOptions *dart_options)
 
void RunMainIsolate (const char *script_name, const char *package_config_override, CommandLineOptions *dart_options)
 
static bool CheckForInvalidPath (const char *path)
 
Dart_Handle GetVMServiceAssetsArchiveCallback ()
 
 DEFINE_STRING_OPTION_CB (dfe, { Options::dfe() ->set_frontend_filename(value);})
 
static void hot_reload_test_mode_callback (CommandLineOptions *vm_options)
 
 DEFINE_BOOL_OPTION_CB (hot_reload_test_mode, hot_reload_test_mode_callback)
 
static void hot_reload_rollback_test_mode_callback (CommandLineOptions *vm_options)
 
 DEFINE_BOOL_OPTION_CB (hot_reload_rollback_test_mode, hot_reload_rollback_test_mode_callback)
 
static bool IsOption (const char *arg, const char *option)
 
static void ReleaseNamespace (void *isolate_callback_data, void *peer)
 
void FUNCTION_NAME() Namespace_Create (Dart_NativeArguments args)
 
void FUNCTION_NAME() Namespace_GetDefault (Dart_NativeArguments args)
 
void FUNCTION_NAME() Namespace_GetPointer (Dart_NativeArguments args)
 
CStringUniquePtr CleanScriptUri (const char *script_uri)
 
static void * LoadDynamicLibrary (const char *library_file, char **error=nullptr)
 
static void WrapError (const char *path, char **error)
 
static void WrapErrorRelative (const char *path, const char *script_uri, char **error)
 
static void * ResolveSymbol (void *handle, const char *symbol, char **error)
 
static bool IsPrefix (const char *prefix, size_t prefix_len, const char *str)
 
void FUNCTION_NAME() Platform_NumberOfProcessors (Dart_NativeArguments args)
 
void FUNCTION_NAME() Platform_OperatingSystem (Dart_NativeArguments args)
 
void FUNCTION_NAME() Platform_OperatingSystemVersion (Dart_NativeArguments args)
 
void FUNCTION_NAME() Platform_PathSeparator (Dart_NativeArguments args)
 
void FUNCTION_NAME() Platform_LocalHostname (Dart_NativeArguments args)
 
void FUNCTION_NAME() Platform_ExecutableName (Dart_NativeArguments args)
 
void FUNCTION_NAME() Platform_ResolvedExecutableName (Dart_NativeArguments args)
 
void FUNCTION_NAME() Platform_ExecutableArguments (Dart_NativeArguments args)
 
void FUNCTION_NAME() Platform_Environment (Dart_NativeArguments args)
 
void FUNCTION_NAME() Platform_GetVersion (Dart_NativeArguments args)
 
void FUNCTION_NAME() Platform_LocaleName (Dart_NativeArguments args)
 
char * ExtractsOSVersionFromString (char *str)
 
std::string NSProcessInfoOperatingSystemVersionString ()
 
static char ** ExtractCStringList (Dart_Handle strings, Dart_Handle status_handle, const char *error_msg, intptr_t *length)
 
void FUNCTION_NAME() Process_Start (Dart_NativeArguments args)
 
void FUNCTION_NAME() Process_Wait (Dart_NativeArguments args)
 
void FUNCTION_NAME() Process_KillPid (Dart_NativeArguments args)
 
void FUNCTION_NAME() Process_Exit (Dart_NativeArguments args)
 
void FUNCTION_NAME() Process_SetExitCode (Dart_NativeArguments args)
 
void FUNCTION_NAME() Process_GetExitCode (Dart_NativeArguments args)
 
void FUNCTION_NAME() Process_Sleep (Dart_NativeArguments args)
 
void FUNCTION_NAME() Process_Pid (Dart_NativeArguments args)
 
void FUNCTION_NAME() Process_SetSignalHandler (Dart_NativeArguments args)
 
void FUNCTION_NAME() Process_ClearSignalHandler (Dart_NativeArguments args)
 
void FUNCTION_NAME() SystemEncodingToString (Dart_NativeArguments args)
 
void FUNCTION_NAME() StringToSystemEncoding (Dart_NativeArguments args)
 
void FUNCTION_NAME() ProcessInfo_CurrentRSS (Dart_NativeArguments args)
 
void FUNCTION_NAME() ProcessInfo_MaxRSS (Dart_NativeArguments args)
 
static SSLFilterGetFilter (Dart_NativeArguments args)
 
static void DeleteFilter (void *isolate_data, void *context_pointer)
 
static Dart_Handle SetFilter (Dart_NativeArguments args, SSLFilter *filter)
 
void FUNCTION_NAME() SecureSocket_Init (Dart_NativeArguments args)
 
void FUNCTION_NAME() SecureSocket_Connect (Dart_NativeArguments args)
 
void FUNCTION_NAME() SecureSocket_Destroy (Dart_NativeArguments args)
 
void FUNCTION_NAME() SecureSocket_Handshake (Dart_NativeArguments args)
 
void FUNCTION_NAME() SecureSocket_MarkAsTrusted (Dart_NativeArguments args)
 
void FUNCTION_NAME() SecureSocket_NewX509CertificateWrapper (Dart_NativeArguments args)
 
void FUNCTION_NAME() SecureSocket_GetSelectedProtocol (Dart_NativeArguments args)
 
void FUNCTION_NAME() SecureSocket_RegisterHandshakeCompleteCallback (Dart_NativeArguments args)
 
void FUNCTION_NAME() SecureSocket_RegisterBadCertificateCallback (Dart_NativeArguments args)
 
void FUNCTION_NAME() SecureSocket_RegisterKeyLogPort (Dart_NativeArguments args)
 
void FUNCTION_NAME() SecureSocket_PeerCertificate (Dart_NativeArguments args)
 
void FUNCTION_NAME() SecureSocket_FilterPointer (Dart_NativeArguments args)
 
 TEST_CASE (SecureSocketUtils_CertNotYetValid)
 
 TEST_CASE (SecureSocketUtils_CertValid)
 
 TEST_CASE (SecureSocketUtils_CertAlreadyExpired)
 
static void DeleteSecurityContext (void *isolate_data, void *context_pointer)
 
static Dart_Handle SetSecurityContext (Dart_NativeArguments args, SSLCertContext *context)
 
static void ReleaseCertificate (void *isolate_data, void *context_pointer)
 
static intptr_t EstimateX509Size (X509 *certificate)
 
static int SetTrustedCertificatesBytesPKCS12 (SSL_CTX *context, ScopedMemBIO *bio, const char *password)
 
static int SetTrustedCertificatesBytesPEM (SSL_CTX *context, BIO *bio)
 
static int SetClientAuthoritiesPKCS12 (SSL_CTX *context, ScopedMemBIO *bio, const char *password)
 
static int SetClientAuthoritiesPEM (SSL_CTX *context, BIO *bio)
 
static int SetClientAuthorities (SSL_CTX *context, ScopedMemBIO *bio, const char *password)
 
int PasswordCallback (char *buf, int size, int rwflag, void *userdata)
 
static EVP_PKEY * GetPrivateKeyPKCS12 (BIO *bio, const char *password)
 
static EVP_PKEY * GetPrivateKey (BIO *bio, const char *password)
 
int AlpnCallback (SSL *ssl, const uint8_t **out, uint8_t *outlen, const uint8_t *in, unsigned int inlen, void *arg)
 
static int UseChainBytesPKCS12 (SSL_CTX *context, ScopedMemBIO *bio, const char *password)
 
static int UseChainBytesPEM (SSL_CTX *context, BIO *bio)
 
static int UseChainBytes (SSL_CTX *context, ScopedMemBIO *bio, const char *password)
 
static X509 * GetX509Certificate (Dart_NativeArguments args)
 
static Dart_Handle ASN1TimeToMilliseconds (ASN1_TIME *aTime)
 
void FUNCTION_NAME() SecurityContext_UsePrivateKeyBytes (Dart_NativeArguments args)
 
void FUNCTION_NAME() SecurityContext_Allocate (Dart_NativeArguments args)
 
void FUNCTION_NAME() SecurityContext_SetTrustedCertificatesBytes (Dart_NativeArguments args)
 
void FUNCTION_NAME() SecurityContext_SetClientAuthoritiesBytes (Dart_NativeArguments args)
 
void FUNCTION_NAME() SecurityContext_UseCertificateChainBytes (Dart_NativeArguments args)
 
void FUNCTION_NAME() SecurityContext_TrustBuiltinRoots (Dart_NativeArguments args)
 
void FUNCTION_NAME() SecurityContext_SetAllowTlsRenegotiation (Dart_NativeArguments args)
 
void FUNCTION_NAME() X509_Der (Dart_NativeArguments args)
 
void FUNCTION_NAME() X509_Pem (Dart_NativeArguments args)
 
void FUNCTION_NAME() X509_Sha1 (Dart_NativeArguments args)
 
void FUNCTION_NAME() X509_Subject (Dart_NativeArguments args)
 
void FUNCTION_NAME() X509_Issuer (Dart_NativeArguments args)
 
void FUNCTION_NAME() X509_StartValidity (Dart_NativeArguments args)
 
void FUNCTION_NAME() X509_EndValidity (Dart_NativeArguments args)
 
void FUNCTION_NAME() SecurityContext_SetAlpnProtocols (Dart_NativeArguments args)
 
static AppSnapshotTryReadAppSnapshotBlobs (const char *script_name, File *file)
 
static void WriteSnapshotFile (const char *filename, const uint8_t *buffer, const intptr_t size)
 
static bool WriteInt64 (File *file, int64_t size)
 
static void StreamingWriteCallback (void *callback_data, const uint8_t *buffer, intptr_t size)
 
void FUNCTION_NAME() Socket_CreateConnect (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_CreateBindConnect (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_CreateUnixDomainBindConnect (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_CreateUnixDomainConnect (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_CreateBindDatagram (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_Available (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_Read (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_RecvFrom (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_ReceiveMessage (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_HasPendingWrite (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_WriteList (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_SendMessage (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_SendTo (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_GetPort (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_GetRemotePeer (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_GetError (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_Fatal (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_GetFD (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_GetType (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_GetStdioHandle (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_GetSocketId (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_SetSocketId (Dart_NativeArguments args)
 
void FUNCTION_NAME() ServerSocket_CreateBindListen (Dart_NativeArguments args)
 
void FUNCTION_NAME() ServerSocket_CreateUnixDomainBindListen (Dart_NativeArguments args)
 
void FUNCTION_NAME() ServerSocket_Accept (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_GetOption (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_SetOption (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_SetRawOption (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_GetRawOption (Dart_NativeArguments args)
 
void FUNCTION_NAME() RawSocketOption_GetOptionValue (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_JoinMulticast (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_LeaveMulticast (Dart_NativeArguments args)
 
void FUNCTION_NAME() Socket_AvailableDatagram (Dart_NativeArguments args)
 
static void NormalSocketFinalizer (void *isolate_data, void *data)
 
static void ListeningSocketFinalizer (void *isolate_data, void *data)
 
static void StdioSocketFinalizer (void *isolate_data, void *data)
 
static void SignalSocketFinalizer (void *isolate_data, void *data)
 
void FUNCTION_NAME() SocketControlMessage_fromHandles (Dart_NativeArguments args)
 
void FUNCTION_NAME() SocketControlMessageImpl_extractHandles (Dart_NativeArguments args)
 
void FUNCTION_NAME() ResourceHandleImpl_toFile (Dart_NativeArguments args)
 
void FUNCTION_NAME() ResourceHandleImpl_toSocket (Dart_NativeArguments args)
 
void FUNCTION_NAME() ResourceHandleImpl_toRawSocket (Dart_NativeArguments args)
 
void FUNCTION_NAME() ResourceHandleImpl_toRawDatagramSocket (Dart_NativeArguments args)
 
void FUNCTION_NAME() InternetAddress_Parse (Dart_NativeArguments args)
 
void FUNCTION_NAME() InternetAddress_ParseScopedLinkLocalAddress (Dart_NativeArguments args)
 
void FUNCTION_NAME() InternetAddress_RawAddrToString (Dart_NativeArguments args)
 
void FUNCTION_NAME() SocketBase_IsBindError (Dart_NativeArguments args)
 
static bool GetIntptrArgument (Dart_NativeArguments args, intptr_t idx, intptr_t *value)
 
void FUNCTION_NAME() Stdin_ReadByte (Dart_NativeArguments args)
 
void FUNCTION_NAME() Stdin_GetEchoMode (Dart_NativeArguments args)
 
void FUNCTION_NAME() Stdin_SetEchoMode (Dart_NativeArguments args)
 
void FUNCTION_NAME() Stdin_GetEchoNewlineMode (Dart_NativeArguments args)
 
void FUNCTION_NAME() Stdin_SetEchoNewlineMode (Dart_NativeArguments args)
 
void FUNCTION_NAME() Stdin_GetLineMode (Dart_NativeArguments args)
 
void FUNCTION_NAME() Stdin_SetLineMode (Dart_NativeArguments args)
 
void FUNCTION_NAME() Stdin_AnsiSupported (Dart_NativeArguments args)
 
void FUNCTION_NAME() Stdout_GetTerminalSize (Dart_NativeArguments args)
 
void FUNCTION_NAME() Stdout_AnsiSupported (Dart_NativeArguments args)
 
void FUNCTION_NAME() SynchronousSocket_LookupRequest (Dart_NativeArguments args)
 
void FUNCTION_NAME() SynchronousSocket_CreateConnectSync (Dart_NativeArguments args)
 
void FUNCTION_NAME() SynchronousSocket_WriteList (Dart_NativeArguments args)
 
void FUNCTION_NAME() SynchronousSocket_ReadList (Dart_NativeArguments args)
 
void FUNCTION_NAME() SynchronousSocket_Available (Dart_NativeArguments args)
 
void FUNCTION_NAME() SynchronousSocket_CloseSync (Dart_NativeArguments args)
 
void FUNCTION_NAME() SynchronousSocket_Read (Dart_NativeArguments args)
 
void FUNCTION_NAME() SynchronousSocket_ShutdownRead (Dart_NativeArguments args)
 
void FUNCTION_NAME() SynchronousSocket_ShutdownWrite (Dart_NativeArguments args)
 
void FUNCTION_NAME() SynchronousSocket_GetPort (Dart_NativeArguments args)
 
void FUNCTION_NAME() SynchronousSocket_GetRemotePeer (Dart_NativeArguments args)
 
static void SynchronousSocketFinalizer (void *isolate_data, void *data)
 
void FUNCTION_NAME() OSError_inProgressErrorCode (Dart_NativeArguments args)
 
void FormatMessageIntoBuffer (DWORD code, wchar_t *buffer, int buffer_length)
 
FILETIME GetFiletimeFromMillis (int64_t millis)
 
std::unique_ptr< wchar_t[]> Utf8ToWideChar (const char *path)
 
void NotifyServerState (Dart_NativeArguments args)
 
static void Shutdown (Dart_NativeArguments args)
 
static Dart_NativeFunction VmServiceIONativeResolver (Dart_Handle name, int num_arguments, bool *auto_setup_scope)
 
const uint8_t * VmServiceIONativeSymbol (Dart_NativeFunction nf)
 

Variables

static struct dart::bin::NativeEntries BuiltinEntries [] = {BUILTIN_NATIVE_LIST(REGISTER_FUNCTION)}
 
static struct dart::bin::NativeEntries BuiltinEntries [] = {BUILTIN_NATIVE_LIST(REGISTER_FUNCTION)}
 
MagicNumberData appjit_magic_number = {8, {0xdc, 0xdc, 0xf6, 0xf6, 0, 0, 0, 0}}
 
MagicNumberData aotelf_magic_number = {4, {0x7F, 0x45, 0x4C, 0x46, 0x0}}
 
MagicNumberData aotmacho32_magic_number = {4, {0xFE, 0xED, 0xFA, 0xCE}}
 
MagicNumberData aotmacho64_magic_number = {4, {0xFE, 0xED, 0xFA, 0xCF}}
 
MagicNumberData aotmacho64_arm64_magic_number = {4, {0xCF, 0xFA, 0xED, 0xFE}}
 
MagicNumberData aotcoff_arm32_magic_number = {2, {0x01, 0xC0}}
 
MagicNumberData aotcoff_arm64_magic_number = {2, {0xAA, 0x64}}
 
MagicNumberData aotcoff_riscv32_magic_number = {2, {0x50, 0x32}}
 
MagicNumberData aotcoff_riscv64_magic_number = {2, {0x50, 0x64}}
 
MagicNumberData kernel_magic_number = {4, {0x90, 0xab, 0xcd, 0xef}}
 
MagicNumberData kernel_list_magic_number
 
MagicNumberData gzip_magic_number = {2, {0x1f, 0x8b, 0, 0}}
 
CObject CObject::null_ & api_null_
 
CObject CObject::true_ & api_true_
 
CObject CObject::false_ & api_false_
 
const uint8_t * kernel_service_dill = kKernelServiceDill
 
const intptr_t kernel_service_dill_size = kKernelServiceDillSize
 
const uint8_t * platform_strong_dill = kPlatformStrongDill
 
const intptr_t platform_strong_dill_size = kPlatformStrongDillSize
 
DFE dfe
 
const char kKernelServiceSnapshot [] = "kernel-service.dart.snapshot"
 
const char kSnapshotsDirectory [] = "snapshots"
 
static constexpr int kAsyncDirectoryListerFieldIndex = 0
 
constexpr int kDartFrontendErrorExitCode = 252
 
constexpr int kApiErrorExitCode = 253
 
constexpr int kCompilationErrorExitCode = 254
 
constexpr int kErrorExitCode = 255
 
static EventHandlerevent_handler = nullptr
 
static Monitorshutdown_monitor = nullptr
 
static constexpr intptr_t kInterruptMessageSize = sizeof(InterruptMessage)
 
static constexpr intptr_t kInfinityTimeout = -1
 
static constexpr intptr_t kTimerId = -1
 
static constexpr intptr_t kShutdownId = -2
 
static constexpr int kFileNativeFieldIndex = 0
 
static bool capture_stdout = false
 
static bool capture_stderr = false
 
const int kZLibFlagUseGZipHeader = 16
 
const int kZLibFlagAcceptAnyHeader = 32
 
static constexpr int kFilterPointerNativeField = 0
 
static dart::SimpleHashMapenvironment = nullptr
 
const uint8_t * isolate_snapshot_data = nullptr
 
const uint8_t * isolate_snapshot_instructions = nullptr
 
static SnapshotKind snapshot_kind = kCore
 
static const char *const kSnapshotKindNames []
 
static const struct dart::bin::NativeEntries IOEntries [] = {IO_NATIVE_LIST(REGISTER_FUNCTION)}
 
const uint8_t * vm_snapshot_data = kDartVmSnapshotData
 
const uint8_t * vm_snapshot_instructions = kDartVmSnapshotInstructions
 
const uint8_t * core_isolate_snapshot_data = kDartCoreIsolateSnapshotData
 
const uint8_t * core_isolate_snapshot_instructions
 
static bool vm_run_app_snapshot = false
 
static char * app_script_uri = nullptr
 
static const uint8_t * app_isolate_snapshot_data = nullptr
 
static const uint8_t * app_isolate_snapshot_instructions = nullptr
 
static bool kernel_isolate_is_running = false
 
static Dart_Isolate main_isolate = nullptr
 
static constexpr const char * kStdoutStreamId = "Stdout"
 
static constexpr const char * kStderrStreamId = "Stderr"
 
unsigned int observatory_assets_archive_len = 0
 
const uint8_t * observatory_assets_archive = observatory_assets_archive_
 
static const char *const kSnapshotKindNames []
 
static const char *const kVerbosityLevelNames []
 
static constexpr const char * DEFAULT_VM_SERVICE_SERVER_IP = "localhost"
 
static constexpr int DEFAULT_VM_SERVICE_SERVER_PORT = 8181
 
static constexpr int INVALID_VM_SERVICE_SERVER_PORT = -1
 
static constexpr int kNamespaceNativeFieldIndex = 0
 
const char * file_schema = "file://"
 
const int file_schema_length = 7
 
static const uint8_t observatory_assets_archive_ [] = {'\0'}
 
static constexpr int kProcessIdNativeField = 0
 
const unsigned char * root_certificates_pem = root_certificates_pem_
 
unsigned int root_certificates_pem_length = 219488
 
const bool SSL_LOG_STATUS = false
 
const bool SSL_LOG_DATA = false
 
const bool SSL_LOG_CERTS = false
 
static constexpr int64_t kAppSnapshotHeaderSize = 2 * kInt64Size
 
static constexpr int64_t kAppSnapshotPageSize = 64 * KB
 
static const char kMachOAppSnapshotNoteName[] DART_UNUSED = "__dart_app_snap"
 
static constexpr int kSocketIdNativeField = 0
 
ListeningSocketRegistryglobalTcpListeningSocketRegistry = nullptr
 
static constexpr int kSocketIdNativeField = 0
 
static constexpr const char * kVMServiceIOLibraryUri = "dart:vmservice_io"
 
static VmServiceIONativeEntry _VmServiceIONativeEntries []
 
const unsigned char root_certificates_pem_ []
 

Typedef Documentation

◆ OptionProcessorCallback

typedef bool(* dart::bin::OptionProcessorCallback) (const char *arg, CommandLineOptions *vm_options)

Definition at line 16 of file options.h.

◆ sa_handler_t

typedef void(* dart::bin::sa_handler_t) (int)

Definition at line 173 of file process.h.

◆ ScopedPKCS12

typedef ScopedSSLType<PKCS12, PKCS12_free> dart::bin::ScopedPKCS12

Definition at line 181 of file secure_socket_utils.h.

◆ ScopedX509

typedef ScopedSSLType<X509, X509_free> dart::bin::ScopedX509

Definition at line 182 of file secure_socket_utils.h.

◆ ScopedX509Stack

typedef ScopedSSLStackType<STACK_OF(X509), X509, X509_free> dart::bin::ScopedX509Stack

Definition at line 183 of file secure_socket_utils.h.

◆ ThreadId

Definition at line 21 of file thread_absl.h.

◆ TrustEvaluateHandlerFunc

typedef void(* dart::bin::TrustEvaluateHandlerFunc) (Dart_Port dest_port_id, Dart_CObject *message)

Definition at line 21 of file security_context.h.

Enumeration Type Documentation

◆ _RawSocketOptions

Enumerator
DART_SOL_SOCKET 
DART_IPPROTO_IP 
DART_IP_MULTICAST_IF 
DART_IPPROTO_IPV6 
DART_IPV6_MULTICAST_IF 
DART_IPPROTO_TCP 
DART_IPPROTO_UDP 

Definition at line 1333 of file socket.cc.

1333 : int64_t {
1334 DART_SOL_SOCKET = 0,
1335 DART_IPPROTO_IP = 1,
1339 DART_IPPROTO_TCP = 5,
1341};
@ DART_IPV6_MULTICAST_IF
Definition: socket.cc:1338
@ DART_IPPROTO_UDP
Definition: socket.cc:1340
@ DART_IPPROTO_IPV6
Definition: socket.cc:1337
@ DART_IPPROTO_TCP
Definition: socket.cc:1339
@ DART_IPPROTO_IP
Definition: socket.cc:1335
@ DART_IP_MULTICAST_IF
Definition: socket.cc:1336
@ DART_SOL_SOCKET
Definition: socket.cc:1334

◆ ListType

Enumerator
kListFile 
kListDirectory 
kListLink 
kListError 
kListDone 

Definition at line 18 of file directory.h.

18 {
19 kListFile = 0,
21 kListLink = 2,
22 kListError = 3,
23 kListDone = 4
24};
@ kListDone
Definition: directory.h:23
@ kListFile
Definition: directory.h:19
@ kListDirectory
Definition: directory.h:20
@ kListError
Definition: directory.h:22
@ kListLink
Definition: directory.h:21

◆ MessageFlags

Enumerator
kInEvent 
kOutEvent 
kErrorEvent 
kCloseEvent 
kDestroyedEvent 
kCloseCommand 
kShutdownReadCommand 
kShutdownWriteCommand 
kReturnTokenCommand 
kSetEventMaskCommand 
kListeningSocket 
kPipe 
kSignalSocket 

Definition at line 22 of file eventhandler.h.

22 {
23 kInEvent = 0,
24 kOutEvent = 1,
25 kErrorEvent = 2,
26 kCloseEvent = 3,
28 kCloseCommand = 8,
34 kPipe = 17,
35 kSignalSocket = 18,
36};
@ kShutdownWriteCommand
Definition: eventhandler.h:30
@ kListeningSocket
Definition: eventhandler.h:33
@ kReturnTokenCommand
Definition: eventhandler.h:31
@ kShutdownReadCommand
Definition: eventhandler.h:29
@ kDestroyedEvent
Definition: eventhandler.h:27
@ kSetEventMaskCommand
Definition: eventhandler.h:32

◆ ProcessSignals

Enumerator
kSighup 
kSigint 
kSigquit 
kSigill 
kSigtrap 
kSigabrt 
kSigbus 
kSigfpe 
kSigkill 
kSigusr1 
kSigsegv 
kSigusr2 
kSigpipe 
kSigalrm 
kSigterm 
kSigchld 
kSigcont 
kSigstop 
kSigtstp 
kSigttin 
kSigttou 
kSigurg 
kSigxcpu 
kSigxfsz 
kSigvtalrm 
kSigprof 
kSigwinch 
kSigpoll 
kSigsys 
kLastSignal 

Definition at line 47 of file process.h.

47 {
48 kSighup = 1,
49 kSigint = 2,
50 kSigquit = 3,
51 kSigill = 4,
52 kSigtrap = 5,
53 kSigabrt = 6,
54 kSigbus = 7,
55 kSigfpe = 8,
56 kSigkill = 9,
57 kSigusr1 = 10,
58 kSigsegv = 11,
59 kSigusr2 = 12,
60 kSigpipe = 13,
61 kSigalrm = 14,
62 kSigterm = 15,
63 kSigchld = 17,
64 kSigcont = 18,
65 kSigstop = 19,
66 kSigtstp = 20,
67 kSigttin = 21,
68 kSigttou = 22,
69 kSigurg = 23,
70 kSigxcpu = 24,
71 kSigxfsz = 25,
72 kSigvtalrm = 26,
73 kSigprof = 27,
74 kSigwinch = 28,
75 kSigpoll = 29,
76 kSigsys = 31,
78};
@ kSigtrap
Definition: process.h:52
@ kSigtstp
Definition: process.h:66
@ kSigstop
Definition: process.h:65
@ kSigbus
Definition: process.h:54
@ kSighup
Definition: process.h:48
@ kSigpoll
Definition: process.h:75
@ kSigttin
Definition: process.h:67
@ kSigxcpu
Definition: process.h:70
@ kSigkill
Definition: process.h:56
@ kSigquit
Definition: process.h:50
@ kSigusr1
Definition: process.h:57
@ kSigvtalrm
Definition: process.h:72
@ kSigabrt
Definition: process.h:53
@ kSigcont
Definition: process.h:64
@ kSigterm
Definition: process.h:62
@ kSigusr2
Definition: process.h:59
@ kSigfpe
Definition: process.h:55
@ kSigxfsz
Definition: process.h:71
@ kSigchld
Definition: process.h:63
@ kSigsegv
Definition: process.h:58
@ kSigill
Definition: process.h:51
@ kLastSignal
Definition: process.h:77
@ kSigwinch
Definition: process.h:74
@ kSigprof
Definition: process.h:73
@ kSigttou
Definition: process.h:68
@ kSigalrm
Definition: process.h:61
@ kSigint
Definition: process.h:49
@ kSigsys
Definition: process.h:76
@ kSigurg
Definition: process.h:69
@ kSigpipe
Definition: process.h:60

◆ ProcessStartMode

Enumerator
kNormal 
kInheritStdio 
kDetached 
kDetachedWithStdio 

Definition at line 81 of file process.h.

81 {
82 kNormal = 0,
83 kInheritStdio = 1,
84 kDetached = 2,
86};
@ kDetached
Definition: process.h:84
@ kInheritStdio
Definition: process.h:83
@ kNormal
Definition: process.h:82
@ kDetachedWithStdio
Definition: process.h:85

◆ SnapshotKind [1/2]

Enumerator
kCore 
kApp 
kAppJIT 
kAppAOTAssembly 
kAppAOTElf 
kVMAOTAssembly 
kNone 
kKernel 
kAppJIT 

Definition at line 75 of file gen_snapshot.cc.

◆ SnapshotKind [2/2]

Enumerator
kCore 
kApp 
kAppJIT 
kAppAOTAssembly 
kAppAOTElf 
kVMAOTAssembly 
kNone 
kKernel 
kAppJIT 

Definition at line 83 of file main_options.h.

83 {
84 kNone,
85 kKernel,
86 kAppJIT,
87};

◆ VerbosityLevel

Enumerator
kError 
kWarning 
kInfo 
kAll 

Definition at line 90 of file main_options.h.

90 {
91 kError,
93 kInfo,
94 kAll,
95};

Function Documentation

◆ AlpnCallback()

int dart::bin::AlpnCallback ( SSL *  ssl,
const uint8_t **  out,
uint8_t *  outlen,
const uint8_t *  in,
unsigned int  inlen,
void *  arg 
)

Definition at line 451 of file security_context.cc.

456 {
457 // 'in' and 'arg' are sequences of (length, data) strings with 1-byte lengths.
458 // 'arg' is 0-terminated. Finds the first string in 'arg' that is in 'in'.
459 uint8_t* server_list = static_cast<uint8_t*>(arg);
460 while (*server_list != 0) {
461 uint8_t protocol_length = *server_list++;
462 const uint8_t* client_list = in;
463 while (client_list < in + inlen) {
464 uint8_t client_protocol_length = *client_list++;
465 if (client_protocol_length == protocol_length) {
466 if (0 == memcmp(server_list, client_list, protocol_length)) {
467 *out = client_list;
468 *outlen = client_protocol_length;
469 return SSL_TLSEXT_ERR_OK; // Success
470 }
471 }
472 client_list += client_protocol_length;
473 }
474 server_list += protocol_length;
475 }
476 // TODO(23580): Make failure send a fatal alert instead of ignoring ALPN.
477 return SSL_TLSEXT_ERR_NOACK;
478}

◆ ASN1TimeToMilliseconds()

static Dart_Handle dart::bin::ASN1TimeToMilliseconds ( ASN1_TIME *  aTime)
static

Definition at line 771 of file security_context.cc.

771 {
772 ASN1_UTCTIME* epoch_start = ASN1_UTCTIME_new();
773 ASN1_UTCTIME_set_string(epoch_start, "700101000000Z");
774 int days;
775 int seconds;
776 int result = ASN1_TIME_diff(&days, &seconds, epoch_start, aTime);
777 ASN1_UTCTIME_free(epoch_start);
778 if (result != 1) {
779 // TODO(whesse): Propagate an error to Dart.
780 Syslog::PrintErr("ASN1Time error %d\n", result);
781 }
782 return Dart_NewInteger((86400LL * days + seconds) * 1000LL);
783}
DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value)
GAsyncResult * result

◆ BootstrapDartIo()

void dart::bin::BootstrapDartIo ( )

Definition at line 22 of file dart_io_api_impl.cc.

22 {
23 // Bootstrap 'dart:io' event handler.
26#if !defined(DART_IO_SECURE_SOCKET_DISABLED)
28#endif
29 EventHandler::Start();
30}
void Init()
bool InitOnce(char **error)

◆ Builtin_DummyNative()

void dart::bin::Builtin_DummyNative ( Dart_NativeArguments  args)

Definition at line 38 of file builtin_natives.cc.

38 {
40}
#define UNREACHABLE()
Definition: assert.h:248

◆ BUILTIN_NATIVE_LIST()

dart::bin::BUILTIN_NATIVE_LIST ( DECLARE_FUNCTION  )

◆ Builtin_PrintString()

void FUNCTION_NAME() dart::bin::Builtin_PrintString ( Dart_NativeArguments  args)

Definition at line 63 of file builtin_gen_snapshot.cc.

63 {
65 intptr_t length = 0;
66 uint8_t* chars = nullptr;
69 if (Dart_IsError(result)) {
70 // TODO(turnidge): Consider propagating some errors here. What if
71 // an isolate gets interrupted by the embedder in the middle of
72 // Dart_StringToUTF8? We need to make sure not to swallow the
73 // interrupt.
74 fputs(Dart_GetError(result), stdout);
75 } else {
76 fwrite(chars, sizeof(*chars), length, stdout);
77 }
78 fputc('\n', stdout);
79 fflush(stdout);
81}
DART_EXPORT void Dart_EnterScope(void)
DART_EXPORT void Dart_ExitScope(void)
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, int index)
DART_EXPORT Dart_Handle Dart_StringToUTF8(Dart_Handle str, uint8_t **utf8_array, intptr_t *length)
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
DART_EXPORT const char * Dart_GetError(Dart_Handle handle)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
size_t length

◆ CheckForInvalidPath()

static bool dart::bin::CheckForInvalidPath ( const char *  path)
static

Definition at line 1117 of file main_impl.cc.

1117 {
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}
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

◆ CheckMagicNumber()

static bool dart::bin::CheckMagicNumber ( const uint8_t *  buffer,
intptr_t  buffer_length,
const MagicNumberData magic_number 
)
static

Definition at line 394 of file dartutils.cc.

396 {
397 if ((buffer_length >= magic_number.length)) {
398 return memcmp(buffer, magic_number.bytes, magic_number.length) == 0;
399 }
400 return false;
401}
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
const uint8_t bytes[kMaxLength]
Definition: dartutils.h:657

◆ CleanScriptUri()

CStringUniquePtr dart::bin::CleanScriptUri ( const char *  script_uri)

Definition at line 49 of file native_assets_api_impl.cc.

49 {
51
52 if (strlen(script_uri) > file_schema_length &&
53 strncmp(script_uri, file_schema, file_schema_length) == 0) {
54 // Isolate.spawnUri sets a `source` including the file schema,
55 // e.g. Isolate.spawnUri may make the embedder pass a file:// uri.
56 script_path = File::UriToPath(script_uri);
57 } else {
58 // Dart and Flutter embedders set a source without a file schema.
59 script_path = CStringUniquePtr(strdup(script_uri));
60 }
61
62 // Resolve symlinks.
63 char canon_path[PATH_MAX];
64 File::GetCanonicalPath(nullptr, script_path.get(), canon_path, PATH_MAX);
65
66 // Convert path to Uri. Inspired by sdk/lib/core/uri.dart _makeFileUri.
67 // Only has a single case, the path is always absolute and always a file.
68 const intptr_t len = strlen(canon_path);
69 char* path_copy =
70 reinterpret_cast<char*>(malloc(file_schema_length + len + 1));
71 snprintf(path_copy, len + 1, "%s%s", file_schema, canon_path);
72#if defined(DART_TARGET_OS_WINDOWS)
73 // Replace backward slashes with forward slashes.
74 ReplaceBackSlashes(path_copy);
75#endif
77}
const char * file_schema
const int file_schema_length
CAllocUniquePtr< char > CStringUniquePtr
Definition: utils.h:31
void * malloc(size_t size)
Definition: allocation.cc:19
char * strdup(const char *str1)
SKWASM_EXPORT SkPath * path_copy(SkPath *path)
Definition: path.cpp:20
#define PATH_MAX
Definition: globals.h:708

◆ CleanupDartIo()

void dart::bin::CleanupDartIo ( )

Definition at line 32 of file dart_io_api_impl.cc.

32 {
33 EventHandler::Stop();
34 Process::TerminateExitCodeHandler();
35#if !defined(DART_IO_SECURE_SOCKET_DISABLED)
37#endif
39}

◆ CloseFile()

void dart::bin::CloseFile ( void *  stream)

Definition at line 69 of file dart_io_api_impl.cc.

◆ CloseLoadingUnitManifest()

static void dart::bin::CloseLoadingUnitManifest ( File manifest_file)
static

Definition at line 540 of file gen_snapshot.cc.

540 {
541 if (!manifest_file->Print("]}\n")) {
542 PrintErrAndExit("Error: Unable to write file: %s\n\n",
543 loading_unit_manifest_filename);
544 }
545 manifest_file->Release();
546}
bool Print(const char *format,...) PRINTF_ATTRIBUTE(2

◆ CObjectInt32OrInt64ToInt64()

static int64_t dart::bin::CObjectInt32OrInt64ToInt64 ( CObject cobject)
static

Definition at line 728 of file file.cc.

728 {
729 ASSERT(cobject->IsInt32OrInt64());
730 int64_t result;
731 if (cobject->IsInt32()) {
732 CObjectInt32 value(cobject);
733 result = value.Value();
734 } else {
735 CObjectInt64 value(cobject);
736 result = value.Value();
737 }
738 return result;
739}
bool IsInt32OrInt64()
Definition: dartutils.h:349
#define ASSERT(E)
uint8_t value

◆ CObjectToFilePointer()

static File * dart::bin::CObjectToFilePointer ( CObject cobject)
static

Definition at line 741 of file file.cc.

741 {
742 CObjectIntptr value(cobject);
743 return reinterpret_cast<File*>(value.Value());
744}

◆ CObjectToNamespacePointer() [1/2]

static Namespace * dart::bin::CObjectToNamespacePointer ( CObject cobject)
static

Definition at line 197 of file directory.cc.

197 {
198 CObjectIntptr value(cobject);
199 return reinterpret_cast<Namespace*>(value.Value());
200}

◆ CObjectToNamespacePointer() [2/2]

static Namespace * dart::bin::CObjectToNamespacePointer ( CObject cobject)
static

Definition at line 746 of file file.cc.

746 {
747 CObjectIntptr value(cobject);
748 return reinterpret_cast<Namespace*>(value.Value());
749}

◆ CompileAndSaveKernel()

static void dart::bin::CompileAndSaveKernel ( const char *  script_name,
const char *  package_config_override,
CommandLineOptions dart_options 
)
static

Definition at line 977 of file main_impl.cc.

979 {
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.
984 Platform::Exit(kErrorExitCode);
985 }
986 Snapshot::GenerateKernel(Options::snapshot_filename(), script_name,
987 package_config_override);
989}
static void WriteDepsFile()
Definition: main_impl.cc:99
static bool vm_run_app_snapshot
Definition: main_impl.cc:67
constexpr int kErrorExitCode
Definition: error_exit.h:18

◆ CopyDictionary()

static Dart_Handle dart::bin::CopyDictionary ( Dart_Handle  dictionary_obj,
uint8_t **  dictionary 
)
static

Definition at line 35 of file filter.cc.

36 {
37 ASSERT(dictionary != nullptr);
38 uint8_t* src = nullptr;
39 intptr_t size;
41
42 Dart_Handle err = Dart_ListLength(dictionary_obj, &size);
43 if (Dart_IsError(err)) {
44 return err;
45 }
46
47 uint8_t* result = new uint8_t[size];
48 if (result == nullptr) {
49 return Dart_NewApiError("Could not allocate new dictionary");
50 }
51
52 err = Dart_TypedDataAcquireData(dictionary_obj, &type,
53 reinterpret_cast<void**>(&src), &size);
54 if (!Dart_IsError(err)) {
55 memmove(result, src, size);
56 Dart_TypedDataReleaseData(dictionary_obj);
57 } else {
58 err = Dart_ListGetAsBytes(dictionary_obj, 0, result, size);
59 if (Dart_IsError(err)) {
60 delete[] result;
61 return err;
62 }
63 }
64
65 *dictionary = result;
66 return Dart_Null();
67}
GLenum type
DART_EXPORT Dart_Handle Dart_TypedDataReleaseData(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_ListGetAsBytes(Dart_Handle list, intptr_t offset, uint8_t *native_array, intptr_t length)
DART_EXPORT Dart_Handle Dart_TypedDataAcquireData(Dart_Handle object, Dart_TypedData_Type *type, void **data, intptr_t *len)
Dart_TypedData_Type
Definition: dart_api.h:2612
DART_EXPORT Dart_Handle Dart_NewApiError(const char *error)
DART_EXPORT Dart_Handle Dart_Null(void)
DART_EXPORT Dart_Handle Dart_ListLength(Dart_Handle list, intptr_t *length)
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

◆ CreateAndSetupDartDevIsolate()

static Dart_Isolate dart::bin::CreateAndSetupDartDevIsolate ( const char *  script_uri,
const char *  packages_config,
Dart_IsolateFlags flags,
char **  error,
int exit_code 
)
static

Definition at line 593 of file main_impl.cc.

597 {
598 int64_t start = Dart_TimelineGetMicros();
599
600 auto dartdev_path = DartDevIsolate::TryResolveDartDevSnapshotPath();
601 if (dartdev_path.get() == nullptr) {
602 Syslog::PrintErr(
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}
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
DART_EXPORT Dart_Isolate Dart_CreateIsolateGroup(const char *script_uri, const char *name, const uint8_t *isolate_snapshot_data, const uint8_t *isolate_snapshot_instructions, Dart_IsolateFlags *flags, void *isolate_group_data, void *isolate_data, char **error)
struct _Dart_Isolate * Dart_Isolate
Definition: dart_api.h:88
DART_EXPORT int64_t Dart_TimelineGetMicros()
@ Dart_Timeline_Event_Duration
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)
#define DART_DEV_ISOLATE_NAME
FlutterSemanticsFlag flags
glong glong end
const uint8_t uint32_t uint32_t GError ** error
const uint8_t * isolate_snapshot_data
Definition: gen_snapshot.cc:69
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
DFE dfe
Definition: dfe.cc:59
const uint8_t * core_isolate_snapshot_data
Definition: main_impl.cc:54
const uint8_t * core_isolate_snapshot_instructions
Definition: main_impl.cc:55
const uint8_t * isolate_snapshot_instructions
Definition: gen_snapshot.cc:70

◆ CreateAndSetupKernelIsolate()

static Dart_Isolate dart::bin::CreateAndSetupKernelIsolate ( const char *  script_uri,
const char *  packages_config,
Dart_IsolateFlags flags,
char **  error,
int exit_code 
)
static

Definition at line 420 of file main_impl.cc.

424 {
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}
void application_kernel_buffer(const uint8_t **buffer, intptr_t *size) const
Definition: dfe.h:64
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
#define DART_KERNEL_ISOLATE_NAME
Definition: dart_api.h:3880
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)
static bool kernel_isolate_is_running
Definition: main_impl.cc:71

◆ CreateAndSetupServiceIsolate()

static Dart_Isolate dart::bin::CreateAndSetupServiceIsolate ( const char *  script_uri,
const char *  packages_config,
Dart_IsolateFlags flags,
char **  error,
int exit_code 
)
static

Definition at line 511 of file main_impl.cc.

515 {
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
556 result = Dart_SetDeferredLoadHandler(Loader::DeferredLoadHandler);
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(
568 Options::vm_service_server_ip(), Options::vm_service_server_port(),
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())) {
574 *error = Utils::StrDup(VmService::GetErrorMessage());
575 return nullptr;
576 }
577 if (Options::compile_all()) {
580 }
581 result = Dart_SetEnvironmentCallback(DartUtils::EnvironmentCallback);
585 return isolate;
586#else // !defined(PRODUCT)
587 return nullptr;
588#endif // !defined(PRODUCT)
589}
DART_EXPORT Dart_Handle Dart_SetDeferredLoadHandler(Dart_DeferredLoadHandler handler)
DART_EXPORT Dart_Handle Dart_SetEnvironmentCallback(Dart_EnvironmentCallback callback)
#define DART_VM_SERVICE_ISOLATE_NAME
Definition: dart_api.h:3888
DART_EXPORT void Dart_ExitIsolate(void)
DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler(Dart_LibraryTagHandler handler)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CompileAll(void)
#define CHECK_RESULT(result)
Definition: main_impl.cc:969
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
static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, Dart_Handle library, Dart_Handle url)
Definition: unit_test.cc:375

◆ CreateAndWriteAppJITSnapshot()

static void dart::bin::CreateAndWriteAppJITSnapshot ( )
static

Definition at line 457 of file gen_snapshot.cc.

457 {
459 ASSERT(isolate_snapshot_data_filename != nullptr);
460 ASSERT(isolate_snapshot_instructions_filename != nullptr);
461
463 uint8_t* isolate_snapshot_data_buffer = nullptr;
464 intptr_t isolate_snapshot_data_size = 0;
465 uint8_t* isolate_snapshot_instructions_buffer = nullptr;
466 intptr_t isolate_snapshot_instructions_size = 0;
467
469 &isolate_snapshot_data_buffer, &isolate_snapshot_data_size,
470 &isolate_snapshot_instructions_buffer,
471 &isolate_snapshot_instructions_size);
473
474 WriteFile(isolate_snapshot_data_filename, isolate_snapshot_data_buffer,
475 isolate_snapshot_data_size);
476 WriteFile(isolate_snapshot_instructions_filename,
477 isolate_snapshot_instructions_buffer,
478 isolate_snapshot_instructions_size);
479}
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CreateAppJITSnapshotAsBlobs(uint8_t **isolate_snapshot_data_buffer, intptr_t *isolate_snapshot_data_size, uint8_t **isolate_snapshot_instructions_buffer, intptr_t *isolate_snapshot_instructions_size)
#define CHECK_RESULT(result)
Definition: gen_snapshot.cc:42
static void WriteFile(const char *filename, const uint8_t *buffer, const intptr_t size)
static SnapshotKind snapshot_kind
Definition: gen_snapshot.cc:83

◆ CreateAndWriteAppSnapshot()

static void dart::bin::CreateAndWriteAppSnapshot ( )
static

Definition at line 437 of file gen_snapshot.cc.

437 {
439 ASSERT(isolate_snapshot_data_filename != nullptr);
440
442 uint8_t* isolate_snapshot_data_buffer = nullptr;
443 intptr_t isolate_snapshot_data_size = 0;
444
445 result = Dart_CreateSnapshot(nullptr, nullptr, &isolate_snapshot_data_buffer,
446 &isolate_snapshot_data_size, /*is_core=*/false);
448
449 WriteFile(isolate_snapshot_data_filename, isolate_snapshot_data_buffer,
450 isolate_snapshot_data_size);
451 if (isolate_snapshot_instructions_filename != nullptr) {
452 // Create empty file for the convenience of build systems.
453 WriteFile(isolate_snapshot_instructions_filename, nullptr, 0);
454 }
455}
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CreateSnapshot(uint8_t **vm_snapshot_data_buffer, intptr_t *vm_snapshot_data_size, uint8_t **isolate_snapshot_data_buffer, intptr_t *isolate_snapshot_data_size, bool is_core)

◆ CreateAndWriteCoreSnapshot()

static void dart::bin::CreateAndWriteCoreSnapshot ( )
static

Definition at line 379 of file gen_snapshot.cc.

379 {
381 ASSERT(vm_snapshot_data_filename != nullptr);
382 ASSERT(isolate_snapshot_data_filename != nullptr);
383
385 uint8_t* vm_snapshot_data_buffer = nullptr;
386 intptr_t vm_snapshot_data_size = 0;
387 uint8_t* isolate_snapshot_data_buffer = nullptr;
388 intptr_t isolate_snapshot_data_size = 0;
389
390 // First create a snapshot.
391 result = Dart_CreateSnapshot(&vm_snapshot_data_buffer, &vm_snapshot_data_size,
392 &isolate_snapshot_data_buffer,
393 &isolate_snapshot_data_size,
394 /*is_core=*/true);
396
397 // Now write the vm isolate and isolate snapshots out to the
398 // specified file and exit.
399 WriteFile(vm_snapshot_data_filename, vm_snapshot_data_buffer,
400 vm_snapshot_data_size);
401 if (vm_snapshot_instructions_filename != nullptr) {
402 // Create empty file for the convenience of build systems.
403 WriteFile(vm_snapshot_instructions_filename, nullptr, 0);
404 }
405 WriteFile(isolate_snapshot_data_filename, isolate_snapshot_data_buffer,
406 isolate_snapshot_data_size);
407 if (isolate_snapshot_instructions_filename != nullptr) {
408 // Create empty file for the convenience of build systems.
409 WriteFile(isolate_snapshot_instructions_filename, nullptr, 0);
410 }
411}

◆ CreateAndWritePrecompiledSnapshot()

static void dart::bin::CreateAndWritePrecompiledSnapshot ( )
static

Definition at line 595 of file gen_snapshot.cc.

595 {
598
599 // Precompile with specified embedder entry points
602
603 // Create a precompiled snapshot.
605 if (strip && (debugging_info_filename == nullptr)) {
606 Syslog::PrintErr(
607 "Warning: Generating assembly code without DWARF debugging"
608 " information.\n");
609 }
610 if (loading_unit_manifest_filename == nullptr) {
611 File* file = OpenFile(assembly_filename);
612 RefCntReleaseScope<File> rs(file);
613 File* debug_file = nullptr;
614 if (debugging_info_filename != nullptr) {
615 debug_file = OpenFile(debugging_info_filename);
616 }
618 strip, debug_file);
619 if (debug_file != nullptr) debug_file->Release();
621 } else {
622 File* manifest_file = OpenLoadingUnitManifest();
624 NextAsmCallback, manifest_file, strip, StreamingWriteCallback,
627 CloseLoadingUnitManifest(manifest_file);
628 }
629 if (obfuscate && !strip) {
630 Syslog::PrintErr(
631 "Warning: The generated assembly code contains unobfuscated DWARF "
632 "debugging information.\n"
633 " To avoid this, use --strip to remove it.\n");
634 }
635 } else if (snapshot_kind == kAppAOTElf) {
636 if (strip && (debugging_info_filename == nullptr)) {
637 Syslog::PrintErr(
638 "Warning: Generating ELF library without DWARF debugging"
639 " information.\n");
640 }
641 if (loading_unit_manifest_filename == nullptr) {
642 File* file = OpenFile(elf_filename);
643 RefCntReleaseScope<File> rs(file);
644 File* debug_file = nullptr;
645 if (debugging_info_filename != nullptr) {
646 debug_file = OpenFile(debugging_info_filename);
647 }
649 strip, debug_file);
650 if (debug_file != nullptr) debug_file->Release();
652 } else {
653 File* manifest_file = OpenLoadingUnitManifest();
658 CloseLoadingUnitManifest(manifest_file);
659 }
660 if (obfuscate && !strip) {
661 Syslog::PrintErr(
662 "Warning: The generated ELF library contains unobfuscated DWARF "
663 "debugging information.\n"
664 " To avoid this, use --strip to remove it and "
665 "--save-debugging-info=<...> to save it to a separate file.\n");
666 }
667 } else {
668 UNREACHABLE();
669 }
670
671 // Serialize obfuscation map if requested.
672 if (obfuscation_map_filename != nullptr) {
673 ASSERT(obfuscate);
674 uint8_t* buffer = nullptr;
675 intptr_t size = 0;
678 WriteFile(obfuscation_map_filename, buffer, size);
679 }
680}
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CreateAppAOTSnapshotAsElf(Dart_StreamingWriteCallback callback, void *callback_data, bool stripped, void *debug_callback_data)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CreateAppAOTSnapshotAsAssemblies(Dart_CreateLoadingUnitCallback next_callback, void *next_callback_data, bool stripped, Dart_StreamingWriteCallback write_callback, Dart_StreamingCloseCallback close_callback)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CreateAppAOTSnapshotAsElfs(Dart_CreateLoadingUnitCallback next_callback, void *next_callback_data, bool stripped, Dart_StreamingWriteCallback write_callback, Dart_StreamingCloseCallback close_callback)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CreateAppAOTSnapshotAsAssembly(Dart_StreamingWriteCallback callback, void *callback_data, bool stripped, void *debug_callback_data)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_GetObfuscationMap(uint8_t **buffer, intptr_t *buffer_length)
DART_EXPORT Dart_Handle Dart_Precompile(void)
static void CloseLoadingUnitManifest(File *manifest_file)
static bool IsSnapshottingForPrecompilation()
static File * OpenLoadingUnitManifest()
static void StreamingWriteCallback(void *callback_data, const uint8_t *buffer, intptr_t size)
static File * OpenFile(const char *filename)
static void StreamingCloseCallback(void *callback_data)
static void NextAsmCallback(void *callback_data, intptr_t loading_unit_id, void **write_callback_data, void **write_debug_callback_data)
static void NextElfCallback(void *callback_data, intptr_t loading_unit_id, void **write_callback_data, void **write_debug_callback_data)

◆ CreateIllegalArgumentError()

static CObject * dart::bin::CreateIllegalArgumentError ( )
static

Definition at line 278 of file directory.cc.

278 {
279 // Respond with an illegal argument list error message.
280 CObjectArray* error = new CObjectArray(CObject::NewArray(3));
281 error->SetAt(0, new CObjectInt32(
282 CObject::NewInt32(AsyncDirectoryListing::kListError)));
283 error->SetAt(1, CObject::Null());
284 error->SetAt(2, CObject::IllegalArgumentError());
285 return error;
286}
SK_API sk_sp< SkSurface > Null(int width, int height)

◆ CreateIsolateAndSnapshot()

static int dart::bin::CreateIsolateAndSnapshot ( const CommandLineOptions inputs)
static

Definition at line 682 of file gen_snapshot.cc.

682 {
683 uint8_t* kernel_buffer = nullptr;
684 intptr_t kernel_buffer_size = 0;
685 ReadFile(inputs.GetArgument(0), &kernel_buffer, &kernel_buffer_size);
686
687 Dart_IsolateFlags isolate_flags;
688 Dart_IsolateFlagsInitialize(&isolate_flags);
690 isolate_flags.obfuscate = obfuscate;
691 }
692
693 auto isolate_group_data = std::unique_ptr<IsolateGroupData>(
694 new IsolateGroupData(nullptr, nullptr, nullptr, false));
695 Dart_Isolate isolate;
696 char* error = nullptr;
697
698 bool loading_kernel_failed = false;
699 if (isolate_snapshot_data == nullptr) {
700 // We need to capture the vmservice library in the core snapshot, so load it
701 // in the main isolate as well.
702 isolate_flags.load_vmservice_library = true;
704 nullptr, nullptr, kernel_buffer, kernel_buffer_size, &isolate_flags,
705 isolate_group_data.get(), /*isolate_data=*/nullptr, &error);
706 loading_kernel_failed = (isolate == nullptr);
707 } else {
708 isolate = Dart_CreateIsolateGroup(nullptr, nullptr, isolate_snapshot_data,
710 &isolate_flags, isolate_group_data.get(),
711 /*isolate_data=*/nullptr, &error);
712 }
713 if (isolate == nullptr) {
714 Syslog::PrintErr("%s\n", error);
715 free(error);
716 free(kernel_buffer);
717 // The only real reason when `gen_snapshot` fails to create an isolate from
718 // a valid kernel file is if loading the kernel results in a "compile-time"
719 // error.
720 //
721 // There are other possible reasons, like memory allocation failures, but
722 // those are very uncommon.
723 //
724 // The Dart API doesn't allow us to distinguish the different error cases,
725 // so we'll use [kCompilationErrorExitCode] for failed kernel loading, since
726 // a compile-time error is the most probable cause.
727 return loading_kernel_failed ? kCompilationErrorExitCode : kErrorExitCode;
728 }
729
732 Dart_SetEnvironmentCallback(DartUtils::EnvironmentCallback);
734
735 // The root library has to be set to generate AOT snapshots, and sometimes we
736 // set one for the core snapshot too.
737 // If the input dill file has a root library, then Dart_LoadScript will
738 // ignore this dummy uri and set the root library to the one reported in
739 // the dill file. Since dill files are not dart script files,
740 // trying to resolve the root library URI based on the dill file name
741 // would not help.
742 //
743 // If the input dill file does not have a root library, then
744 // Dart_LoadScript will error.
745 //
746 // TODO(kernel): Dart_CreateIsolateGroupFromKernel should respect the root
747 // library in the kernel file, though this requires auditing the other
748 // loading paths in the embedders that had to work around this.
750 Dart_LoadLibraryFromKernel(kernel_buffer, kernel_buffer_size));
752
754
756
757 switch (snapshot_kind) {
758 case kCore:
760 break;
761 case kApp:
763 break;
764 case kAppJIT:
766 break;
767 case kAppAOTAssembly:
768 case kAppAOTElf:
770 break;
771 case kVMAOTAssembly: {
772 File* file = OpenFile(assembly_filename);
773 RefCntReleaseScope<File> rs(file);
776 break;
777 }
778 default:
779 UNREACHABLE();
780 }
781
784
785 free(kernel_buffer);
786 return 0;
787}
DART_EXPORT void Dart_IsolateFlagsInitialize(Dart_IsolateFlags *flags)
DART_EXPORT void Dart_ShutdownIsolate(void)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_CreateVMAOTSnapshotAsAssembly(Dart_StreamingWriteCallback callback, void *callback_data)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_LoadLibraryFromKernel(const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
DART_EXPORT Dart_Handle Dart_SetRootLibrary(Dart_Handle library)
constexpr int kCompilationErrorExitCode
Definition: error_exit.h:16
static void CreateAndWritePrecompiledSnapshot()
static void MaybeLoadCode()
static void CreateAndWriteCoreSnapshot()
static void ReadFile(const char *filename, uint8_t **buffer, intptr_t *size)
static void MaybeLoadExtraInputs(const CommandLineOptions &inputs)
static void CreateAndWriteAppJITSnapshot()
static void CreateAndWriteAppSnapshot()
bool load_vmservice_library
Definition: dart_api.h:590

◆ CreateIsolateGroupAndSetup()

static Dart_Isolate dart::bin::CreateIsolateGroupAndSetup ( const char *  script_uri,
const char *  main,
const char *  package_root,
const char *  package_config,
Dart_IsolateFlags flags,
void *  callback_data,
char **  error 
)
static

Definition at line 842 of file main_impl.cc.

848 {
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}
#define DART_FLAGS_CURRENT_VERSION
Definition: dart_api.h:582
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
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 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
Definition: main.py:1

◆ CreateIsolateGroupAndSetupHelper()

static Dart_Isolate dart::bin::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 
)
static

Definition at line 685 of file main_impl.cc.

693 {
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()) {
713 *error = Utils::SCreate(
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()) {
745 *error = Utils::SCreate(
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}
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
void LoadPlatform(const uint8_t **kernel_buffer, intptr_t *kernel_buffer_size)
Definition: dfe.cc:137
#define FATAL(error)
static char * app_script_uri
Definition: main_impl.cc:68
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ Crypto_GetRandomBytes()

void FUNCTION_NAME() dart::bin::Crypto_GetRandomBytes ( Dart_NativeArguments  args)

Definition at line 13 of file crypto.cc.

13 {
15 const int64_t kMaxRandomBytes = 4096;
16 int64_t count64 = 0;
17 if (!DartUtils::GetInt64Value(count_obj, &count64) || (count64 < 0) ||
18 (count64 > kMaxRandomBytes)) {
20 "Invalid argument: count must be a positive int "
21 "less than or equal to 4096.");
23 }
24 intptr_t count = static_cast<intptr_t>(count64);
26 ASSERT(buffer != nullptr);
27 if (!Crypto::GetRandomBytes(count, buffer)) {
28 Dart_ThrowException(DartUtils::NewDartOSError());
30 }
32 if (Dart_IsError(result)) {
33 Dart_Handle error = DartUtils::NewString("Failed to allocate storage.");
36 }
39}
int count
Definition: FontMgrTest.cpp:50
DART_EXPORT Dart_Handle Dart_ListSetAsBytes(Dart_Handle list, intptr_t offset, const uint8_t *native_array, intptr_t length)
DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception)
@ Dart_TypedData_kUint8
Definition: dart_api.h:2615
DART_EXPORT Dart_Handle Dart_NewTypedData(Dart_TypedData_Type type, intptr_t length)
DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args, Dart_Handle retval)
DART_EXPORT uint8_t * Dart_ScopeAllocate(intptr_t size)
Dart_Handle NewString(const char *str)
Definition: unit_test.h:229

◆ Dart_ExitScope()

dart::bin::Dart_ExitScope ( )

◆ Dart_ShutdownIsolate()

dart::bin::Dart_ShutdownIsolate ( )

◆ Decompress()

void dart::bin::Decompress ( const uint8_t *  input,
intptr_t  input_len,
uint8_t **  output,
intptr_t *  output_length 
)

Definition at line 15 of file gzip.cc.

18 {
19 ASSERT(input != nullptr);
20 ASSERT(input_len > 0);
21 ASSERT(output != nullptr);
22 ASSERT(output_length != nullptr);
23
24 const intptr_t kChunkSize = 256 * 1024;
25
26 // Initialize output.
27 intptr_t output_capacity = input_len * 2;
28 if (output_capacity < kChunkSize) {
29 output_capacity = kChunkSize;
30 }
31 *output = reinterpret_cast<uint8_t*>(malloc(output_capacity));
32
33 uint8_t* chunk_out = reinterpret_cast<uint8_t*>(malloc(kChunkSize));
34 z_stream strm;
35 strm.zalloc = Z_NULL;
36 strm.zfree = Z_NULL;
37 strm.opaque = Z_NULL;
38 strm.avail_in = 0;
39 strm.next_in = Z_NULL;
40 int ret = inflateInit2(&strm, 32 + MAX_WBITS);
41 ASSERT(ret == Z_OK);
42
43 intptr_t input_cursor = 0;
44 intptr_t output_cursor = 0;
45 do {
46 // Setup input.
47 intptr_t size_in = input_len - input_cursor;
48 if (size_in > kChunkSize) {
49 size_in = kChunkSize;
50 }
51 strm.avail_in = size_in;
52 strm.next_in = const_cast<uint8_t*>(&input[input_cursor]);
53
54 // Inflate until we've exhausted the current input chunk.
55 do {
56 // Setup output.
57 strm.avail_out = kChunkSize;
58 strm.next_out = &chunk_out[0];
59 // Inflate.
60 ret = inflate(&strm, Z_SYNC_FLUSH);
61 // We either hit the end of the stream or made forward progress.
62 ASSERT((ret == Z_STREAM_END) || (ret == Z_OK));
63 // Grow output buffer size.
64 intptr_t size_out = kChunkSize - strm.avail_out;
65 if (size_out > (output_capacity - output_cursor)) {
66 output_capacity *= 2;
67 ASSERT(size_out <= (output_capacity - output_cursor));
68 *output = reinterpret_cast<uint8_t*>(realloc(*output, output_capacity));
69 }
70 // Copy output.
71 memmove(&((*output)[output_cursor]), &chunk_out[0], size_out);
72 output_cursor += size_out;
73 } while (strm.avail_out == 0);
74
75 // We've processed size_in bytes.
76 input_cursor += size_in;
77
78 // We're finished decompressing when zlib tells us.
79 } while (ret != Z_STREAM_END);
80
81 inflateEnd(&strm);
82
83 *output_length = output_cursor;
84 free(chunk_out);
85}
void * realloc(void *ptr, size_t size)
Definition: allocation.cc:27

◆ DEFINE_BOOL_OPTION_CB() [1/2]

dart::bin::DEFINE_BOOL_OPTION_CB ( hot_reload_rollback_test_mode  ,
hot_reload_rollback_test_mode_callback   
)

◆ DEFINE_BOOL_OPTION_CB() [2/2]

dart::bin::DEFINE_BOOL_OPTION_CB ( hot_reload_test_mode  ,
hot_reload_test_mode_callback   
)

◆ DEFINE_CB_OPTION()

dart::bin::DEFINE_CB_OPTION ( ProcessEnvironmentOption  )

◆ DEFINE_ENUM_OPTION()

dart::bin::DEFINE_ENUM_OPTION ( snapshot_kind  ,
SnapshotKind  ,
snapshot_kind   
)

◆ DEFINE_STRING_OPTION_CB()

dart::bin::DEFINE_STRING_OPTION_CB ( dfe  ,
{ Options::dfe() ->set_frontend_filename(value);}   
)

◆ DeleteFilter() [1/2]

static void dart::bin::DeleteFilter ( void *  isolate_data,
void *  context_pointer 
)
static

Definition at line 67 of file secure_socket_filter.cc.

67 {
68 SSLFilter* filter = reinterpret_cast<SSLFilter*>(context_pointer);
69 filter->Release();
70}

◆ DeleteFilter() [2/2]

static void dart::bin::DeleteFilter ( void *  isolate_data,
void *  filter_pointer 
)
static

Definition at line 259 of file filter.cc.

259 {
260 Filter* filter = reinterpret_cast<Filter*>(filter_pointer);
261 delete filter;
262}

◆ DeleteIsolateData()

static void dart::bin::DeleteIsolateData ( void *  isolate_group_data,
void *  callback_data 
)
static

Definition at line 916 of file main_impl.cc.

916 {
917 auto isolate_data = reinterpret_cast<IsolateData*>(callback_data);
918 delete isolate_data;
919}

◆ DeleteIsolateGroupData()

static void dart::bin::DeleteIsolateGroupData ( void *  callback_data)
static

Definition at line 921 of file main_impl.cc.

921 {
922 auto isolate_group_data = reinterpret_cast<IsolateGroupData*>(callback_data);
923 delete isolate_group_data;
924}

◆ DeleteSecurityContext()

static void dart::bin::DeleteSecurityContext ( void *  isolate_data,
void *  context_pointer 
)
static

Definition at line 109 of file security_context.cc.

109 {
110 SSLCertContext* context = static_cast<SSLCertContext*>(context_pointer);
111 context->Release();
112}

◆ Directory_Create()

void FUNCTION_NAME() dart::bin::Directory_Create ( Dart_NativeArguments  args)

Definition at line 61 of file directory.cc.

61 {
62 Namespace* namespc = Namespace::GetNamespace(args, 0);
63 const char* name = DartUtils::GetNativeTypedDataArgument(args, 1);
64 bool result = Directory::Create(namespc, name);
65 if (result) {
67 } else {
68 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
69 }
70}
static sk_sp< Effect > Create()
Definition: RefCntTest.cpp:117
DART_EXPORT void Dart_SetBooleanReturnValue(Dart_NativeArguments args, bool retval)

◆ Directory_CreateTemp()

void FUNCTION_NAME() dart::bin::Directory_CreateTemp ( Dart_NativeArguments  args)

Definition at line 79 of file directory.cc.

79 {
80 Namespace* namespc = Namespace::GetNamespace(args, 0);
81 const char* name = DartUtils::GetNativeTypedDataArgument(args, 1);
82 const char* result = Directory::CreateTemp(namespc, name);
83 if (result != nullptr) {
86 } else {
87 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
88 }
89}
static Dart_Handle ThrowIfError(Dart_Handle handle)
Definition: dartutils.h:31

◆ Directory_Current()

void FUNCTION_NAME() dart::bin::Directory_Current ( Dart_NativeArguments  args)

Definition at line 24 of file directory.cc.

24 {
25 Namespace* namespc = Namespace::GetNamespace(args, 0);
26 const char* current = Directory::Current(namespc);
27 if (current != nullptr) {
30 } else {
31 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
32 }
33}

◆ Directory_Delete()

void FUNCTION_NAME() dart::bin::Directory_Delete ( Dart_NativeArguments  args)

Definition at line 91 of file directory.cc.

91 {
92 Namespace* namespc = Namespace::GetNamespace(args, 0);
93 const char* name = DartUtils::GetNativeTypedDataArgument(args, 1);
94 bool result = Directory::Delete(namespc, name,
95 DartUtils::GetNativeBooleanArgument(args, 2));
96 if (result) {
98 } else {
99 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
100 }
101}

◆ Directory_Exists()

void FUNCTION_NAME() dart::bin::Directory_Exists ( Dart_NativeArguments  args)

Definition at line 46 of file directory.cc.

46 {
47 const int kExists = 1;
48 const int kDoesNotExist = 0;
49 Namespace* namespc = Namespace::GetNamespace(args, 0);
50 const char* name = DartUtils::GetNativeTypedDataArgument(args, 1);
51 Directory::ExistsResult result = Directory::Exists(namespc, name);
52 if (result == Directory::EXISTS) {
54 } else if (result == Directory::DOES_NOT_EXIST) {
55 Dart_SetIntegerReturnValue(args, kDoesNotExist);
56 } else {
57 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
58 }
59}
DART_EXPORT void Dart_SetIntegerReturnValue(Dart_NativeArguments args, int64_t retval)

◆ Directory_FillWithDirectoryListing()

void FUNCTION_NAME() dart::bin::Directory_FillWithDirectoryListing ( Dart_NativeArguments  args)

Definition at line 115 of file directory.cc.

116 {
117 Namespace* namespc = Namespace::GetNamespace(args, 0);
118 // The list that we should fill.
121 Dart_Handle dart_error;
122 const char* name;
123 {
126 // We need to release our typed data before creating SyncDirectoryListing
127 // since it allocates objects which require us to not be holding typed data
128 // that has been acquired.
129 name = data.GetScopedCString();
130 }
131 {
132 // Pass the list that should hold the directory listing to the
133 // SyncDirectoryListing object, which adds elements to it.
134 SyncDirectoryListing sync_listing(
135 results, namespc, name, DartUtils::GetNativeBooleanArgument(args, 3),
136 DartUtils::GetNativeBooleanArgument(args, 4));
137 Directory::List(&sync_listing);
138 dart_error = sync_listing.dart_error();
139 }
140 if (Dart_IsError(dart_error)) {
141 Dart_PropagateError(dart_error);
142 } else if (!Dart_IsNull(dart_error)) {
143 Dart_ThrowException(dart_error);
144 }
145}
SkIDChangeListener::List List
DART_EXPORT void Dart_PropagateError(Dart_Handle handle)
DART_EXPORT bool Dart_IsNull(Dart_Handle object)
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ Directory_GetAsyncDirectoryListerPointer()

void FUNCTION_NAME() dart::bin::Directory_GetAsyncDirectoryListerPointer ( Dart_NativeArguments  args)

Definition at line 149 of file directory.cc.

150 {
151 AsyncDirectoryListing* listing;
153 ASSERT(Dart_IsInstance(dart_this));
156 reinterpret_cast<intptr_t*>(&listing)));
157 if (listing != nullptr) {
158 intptr_t listing_pointer = reinterpret_cast<intptr_t>(listing);
159 // Increment the listing's reference count. This native should only be
160 // be called when we are about to send the AsyncDirectoryListing* to the
161 // IO service.
162 listing->Retain();
163 Dart_SetReturnValue(args, Dart_NewInteger(listing_pointer));
164 }
165}
DART_EXPORT bool Dart_IsInstance(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_GetNativeInstanceField(Dart_Handle obj, int index, intptr_t *value)
static constexpr int kAsyncDirectoryListerFieldIndex
Definition: directory.cc:147

◆ Directory_Rename()

void FUNCTION_NAME() dart::bin::Directory_Rename ( Dart_NativeArguments  args)

Definition at line 103 of file directory.cc.

103 {
104 Namespace* namespc = Namespace::GetNamespace(args, 0);
105 const char* name = DartUtils::GetNativeTypedDataArgument(args, 1);
106 bool result = Directory::Rename(namespc, name,
108 if (result) {
110 } else {
111 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
112 }
113}
static bool GetNativeStringArgument(NativeArguments *arguments, int arg_index, Dart_Handle *str, void **peer)

◆ Directory_SetAsyncDirectoryListerPointer()

void FUNCTION_NAME() dart::bin::Directory_SetAsyncDirectoryListerPointer ( Dart_NativeArguments  args)

Definition at line 173 of file directory.cc.

174 {
176 intptr_t listing_pointer =
177 DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1));
178 AsyncDirectoryListing* listing =
179 reinterpret_cast<AsyncDirectoryListing*>(listing_pointer);
180 Dart_NewFinalizableHandle(dart_this, reinterpret_cast<void*>(listing),
181 sizeof(*listing), ReleaseListing);
183 dart_this, kAsyncDirectoryListerFieldIndex, listing_pointer);
185}
DART_EXPORT Dart_FinalizableHandle Dart_NewFinalizableHandle(Dart_Handle object, void *peer, intptr_t external_allocation_size, Dart_HandleFinalizer callback)
DART_EXPORT Dart_Handle Dart_SetNativeInstanceField(Dart_Handle obj, int index, intptr_t value)
static void ReleaseListing(void *isolate_callback_data, void *peer)
Definition: directory.cc:167

◆ Directory_SetCurrent()

void FUNCTION_NAME() dart::bin::Directory_SetCurrent ( Dart_NativeArguments  args)

Definition at line 35 of file directory.cc.

35 {
36 Namespace* namespc = Namespace::GetNamespace(args, 0);
37 const char* name = DartUtils::GetNativeTypedDataArgument(args, 1);
38 bool result = Directory::SetCurrent(namespc, name);
39 if (result) {
41 } else {
42 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
43 }
44}

◆ Directory_SystemTemp()

void FUNCTION_NAME() dart::bin::Directory_SystemTemp ( Dart_NativeArguments  args)

Definition at line 72 of file directory.cc.

72 {
73 Namespace* namespc = Namespace::GetNamespace(args, 0);
74 const char* result = Directory::SystemTemp(namespc);
77}

◆ EmbedderInformationCallback()

static void dart::bin::EmbedderInformationCallback ( Dart_EmbedderInformation info)
static

Definition at line 963 of file main_impl.cc.

963 {
965 info->name = "Dart VM";
966 Process::GetRSSInformation(&(info->max_rss), &(info->current_rss));
967}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
#define DART_EMBEDDER_INFORMATION_CURRENT_VERSION

◆ ErrorExit()

void dart::bin::ErrorExit ( int  exit_code,
const char *  format,
  ... 
)

Definition at line 18 of file error_exit.cc.

18 {
19 va_list arguments;
20 va_start(arguments, format);
21 Syslog::VPrintErr(format, arguments);
22 va_end(arguments);
23
24 // Sometimes ErrorExit is called even before we have entered an isolate.
25 // We need to shutdown the isolate only if one exists.
26 if (Dart_CurrentIsolate() != nullptr) {
28 }
29
30 // Terminate process exit-code handler.
31 Process::TerminateExitCodeHandler();
32
33 char* error = Dart_Cleanup();
34 if (error != nullptr) {
35 Syslog::PrintErr("VM cleanup failed: %s\n", error);
36 free(error);
37 }
38
39 Process::ClearAllSignalHandlers();
40 EventHandler::Stop();
41 Platform::Exit(exit_code);
42}
DART_EXPORT Dart_Isolate Dart_CurrentIsolate(void)
DART_EXPORT DART_WARN_UNUSED_RESULT char * Dart_Cleanup(void)
uint32_t uint32_t * format
va_start(args, format)
va_end(args)

◆ EstimateX509Size()

static intptr_t dart::bin::EstimateX509Size ( X509 *  certificate)
static

Definition at line 134 of file security_context.cc.

134 {
135 intptr_t length = i2d_X509(certificate, nullptr);
136 length = length > 0 ? length : 0;
137 // An X509 is a tree of structures, which are either opaque or will be opaque
138 // in the future. Estimate the overhead to 512 bytes by rounding up
139 // sizeof(X509) + sizeof(X509_CINF).
140 return length + 512;
141}

◆ EventHandler_SendData()

void FUNCTION_NAME() dart::bin::EventHandler_SendData ( Dart_NativeArguments  args)

Definition at line 79 of file eventhandler.cc.

79 {
80 // Get the id out of the send port. If the handle is not a send port
81 // we will get an error and propagate that out.
83 Dart_Port dart_port;
84 handle = Dart_SendPortGetId(handle, &dart_port);
85 if (Dart_IsError(handle)) {
86 Dart_PropagateError(handle);
88 }
90 intptr_t id;
91 if (Dart_IsNull(sender)) {
92 id = kTimerId;
93 } else {
94 Socket* socket = Socket::GetSocketIdNativeField(sender);
95 ASSERT(dart_port != ILLEGAL_PORT);
96 socket->set_port(dart_port);
97 socket->Retain(); // inc refcount before sending to the eventhandler.
98 id = reinterpret_cast<intptr_t>(socket);
99 }
100 int64_t data = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2));
101 event_handler->SendData(id, dart_port, data);
102}
void SendData(intptr_t id, Dart_Port dart_port, int64_t data)
Definition: eventhandler.h:606
#define ILLEGAL_PORT
Definition: dart_api.h:1535
int64_t Dart_Port
Definition: dart_api.h:1525
DART_EXPORT Dart_Handle Dart_SendPortGetId(Dart_Handle port, Dart_Port *port_id)
static constexpr intptr_t kTimerId
Definition: eventhandler.h:109
static EventHandler * event_handler
Definition: eventhandler.cc:18
const uintptr_t id

◆ EventHandler_TimerMillisecondClock()

void FUNCTION_NAME() dart::bin::EventHandler_TimerMillisecondClock ( Dart_NativeArguments  args)

Definition at line 104 of file eventhandler.cc.

105 {
106 int64_t now = TimerUtils::GetCurrentMonotonicMillis();
108}

◆ exit()

dart::bin::exit ( kErrorExitCode  )

◆ ExtractCStringList()

static char ** dart::bin::ExtractCStringList ( Dart_Handle  strings,
Dart_Handle  status_handle,
const char *  error_msg,
intptr_t *  length 
)
static

Definition at line 23 of file process.cc.

26 {
27 static constexpr intptr_t kMaxArgumentListLength = 1024 * 1024;
28 ASSERT(Dart_IsList(strings));
29 intptr_t len = 0;
32 // Protect against user-defined list implementations that can have
33 // arbitrary length.
34 if ((len < 0) || (len > kMaxArgumentListLength)) {
35 result = DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
37 result = DartUtils::SetStringField(status_handle, "_errorMessage",
38 "Max argument list length exceeded");
40 return nullptr;
41 }
42 *length = len;
43 char** string_args;
44 string_args =
45 reinterpret_cast<char**>(Dart_ScopeAllocate(len * sizeof(*string_args)));
46 for (int i = 0; i < len; i++) {
47 Dart_Handle arg = Dart_ListGetAt(strings, i);
48 ThrowIfError(arg);
49 if (!Dart_IsString(arg)) {
50 result = DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
52 result =
53 DartUtils::SetStringField(status_handle, "_errorMessage", error_msg);
55 return nullptr;
56 }
57 string_args[i] = const_cast<char*>(DartUtils::GetStringValue(arg));
58 }
59 return string_args;
60}
DART_EXPORT Dart_Handle Dart_ListGetAt(Dart_Handle list, intptr_t index)
DART_EXPORT bool Dart_IsString(Dart_Handle object)
DART_EXPORT bool Dart_IsList(Dart_Handle object)

◆ ExtractsOSVersionFromString()

char * dart::bin::ExtractsOSVersionFromString ( char *  str)

◆ File_AreIdentical()

void FUNCTION_NAME() dart::bin::File_AreIdentical ( Dart_NativeArguments  args)

Definition at line 634 of file file.cc.

634 {
635 Namespace* namespc = Namespace::GetNamespace(args, 0);
636 const char* path_1 = DartUtils::GetNativeStringArgument(args, 1);
637 const char* path_2 = DartUtils::GetNativeStringArgument(args, 2);
638 File::Identical result = File::AreIdentical(namespc, path_1, namespc, path_2);
639 if (result == File::kError) {
640 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
641 } else {
642 Dart_SetBooleanReturnValue(args, result == File::kIdentical);
643 }
644}

◆ File_Close()

void FUNCTION_NAME() dart::bin::File_Close ( Dart_NativeArguments  args)

Definition at line 115 of file file.cc.

115 {
116 // TODO(zra): The bots are hitting a crash in this function, so we include
117 // some checks here that are normally only in a Debug build. When the crash
118 // is gone, this can go back to using GetFile and SetFile.
120#if !defined(PRODUCT)
121 if (!IsFile(dart_this)) {
122 Dart_PropagateError(DartUtils::NewInternalError(
123 "File_Close expects the receiver to be a _RandomAccessFileOpsImpl."));
124 }
125#endif
126 File* file;
128 reinterpret_cast<intptr_t*>(&file)));
129 if (file == nullptr) {
131 return;
132 }
133 file->Close();
134 file->DeleteFinalizableHandle(Dart_CurrentIsolate(), dart_this);
135 file->Release();
136
140}
static bool IsFile(Dart_Handle file_obj)
Definition: file.cc:25
static constexpr int kFileNativeFieldIndex
Definition: file.cc:22

◆ File_Copy()

void FUNCTION_NAME() dart::bin::File_Copy ( Dart_NativeArguments  args)

Definition at line 558 of file file.cc.

558 {
559 Namespace* namespc = Namespace::GetNamespace(args, 0);
560 const char* old_path = DartUtils::GetNativeTypedDataArgument(args, 1);
561 const char* new_path = DartUtils::GetNativeStringArgument(args, 2);
562 bool result = File::Copy(namespc, old_path, new_path);
563 if (result) {
565 } else {
566 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
567 }
568}

◆ File_Create()

void FUNCTION_NAME() dart::bin::File_Create ( Dart_NativeArguments  args)

Definition at line 458 of file file.cc.

458 {
459 Namespace* namespc = Namespace::GetNamespace(args, 0);
460 Dart_Handle exclusive_handle = Dart_GetNativeArgument(args, 2);
461 const char* path = DartUtils::GetNativeTypedDataArgument(args, 1);
462 bool exclusive = DartUtils::GetBooleanValue(exclusive_handle);
463 bool result = File::Create(namespc, path, exclusive);
464 if (result) {
466 } else {
467 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
468 }
469}

◆ File_CreateLink()

void FUNCTION_NAME() dart::bin::File_CreateLink ( Dart_NativeArguments  args)

Definition at line 471 of file file.cc.

471 {
472 Namespace* namespc = Namespace::GetNamespace(args, 0);
473 const char* name = DartUtils::GetNativeTypedDataArgument(args, 1);
475 bool result = File::CreateLink(namespc, name, target);
476 if (!result) {
477 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
478 }
479}
uint32_t * target

◆ File_CreatePipe()

void FUNCTION_NAME() dart::bin::File_CreatePipe ( Dart_NativeArguments  args)

Definition at line 481 of file file.cc.

481 {
482 Namespace* namespc = Namespace::GetNamespace(args, 0);
483
484 File* readPipe;
485 File* writePipe;
486 if (File::CreatePipe(namespc, &readPipe, &writePipe)) {
488 Dart_Handle readHandle =
489 ThrowIfError(Dart_NewInteger(reinterpret_cast<intptr_t>(readPipe)));
490 Dart_Handle writeHandle =
491 ThrowIfError(Dart_NewInteger(reinterpret_cast<intptr_t>(writePipe)));
492 ThrowIfError(Dart_ListSetAt(pipes, 0, readHandle));
493 ThrowIfError(Dart_ListSetAt(pipes, 1, writeHandle));
495 } else {
496 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
497 }
498}
DART_EXPORT Dart_Handle Dart_NewList(intptr_t length)
DART_EXPORT Dart_Handle Dart_ListSetAt(Dart_Handle list, intptr_t index, Dart_Handle value)

◆ File_Delete()

void FUNCTION_NAME() dart::bin::File_Delete ( Dart_NativeArguments  args)

Definition at line 512 of file file.cc.

512 {
513 Namespace* namespc = Namespace::GetNamespace(args, 0);
514 const char* path = DartUtils::GetNativeTypedDataArgument(args, 1);
515 bool result = File::Delete(namespc, path);
516 if (result) {
518 } else {
519 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
520 }
521}

◆ File_DeleteLink()

void FUNCTION_NAME() dart::bin::File_DeleteLink ( Dart_NativeArguments  args)

Definition at line 523 of file file.cc.

523 {
524 Namespace* namespc = Namespace::GetNamespace(args, 0);
525 const char* path = DartUtils::GetNativeTypedDataArgument(args, 1);
526 bool result = File::DeleteLink(namespc, path);
527 if (result) {
529 } else {
530 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
531 }
532}

◆ File_Exists()

void FUNCTION_NAME() dart::bin::File_Exists ( Dart_NativeArguments  args)

Definition at line 108 of file file.cc.

108 {
109 Namespace* namespc = Namespace::GetNamespace(args, 0);
110 const char* filename = DartUtils::GetNativeTypedDataArgument(args, 1);
111 bool exists = File::Exists(namespc, filename);
113}

◆ File_Flush()

void FUNCTION_NAME() dart::bin::File_Flush ( Dart_NativeArguments  args)

Definition at line 425 of file file.cc.

425 {
426 File* file = GetFile(args);
427 ASSERT(file != nullptr);
428 if (file->Flush()) {
430 } else {
431 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
432 }
433}
static File * GetFile(Dart_NativeArguments args)
Definition: file.cc:37

◆ File_GetFD()

void FUNCTION_NAME() dart::bin::File_GetFD ( Dart_NativeArguments  args)

Definition at line 70 of file file.cc.

70 {
72}

◆ File_GetPointer()

void FUNCTION_NAME() dart::bin::File_GetPointer ( Dart_NativeArguments  args)

Definition at line 58 of file file.cc.

58 {
60 // If the file is already closed, GetFile() will return nullptr.
61 if (file != nullptr) {
62 // Increment file's reference count. File_GetPointer() should only be called
63 // when we are about to send the File* to the IO Service.
64 file->Retain();
65 }
66 intptr_t file_pointer = reinterpret_cast<intptr_t>(file);
67 Dart_SetIntegerReturnValue(args, file_pointer);
68}

◆ File_GetStdioHandleType()

void FUNCTION_NAME() dart::bin::File_GetStdioHandleType ( Dart_NativeArguments  args)

Definition at line 589 of file file.cc.

589 {
591 ASSERT((fd == STDIN_FILENO) || (fd == STDOUT_FILENO) ||
592 (fd == STDERR_FILENO));
593 File::StdioHandleType type = File::GetStdioHandleType(static_cast<int>(fd));
594 if (type == File::StdioHandleType::kTypeError) {
595 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
596 } else {
598 }
599}
static bool GetNativeIntegerArgument(NativeArguments *arguments, int arg_index, int64_t *value)

◆ File_GetType()

void FUNCTION_NAME() dart::bin::File_GetType ( Dart_NativeArguments  args)

Definition at line 601 of file file.cc.

601 {
602 Namespace* namespc = Namespace::GetNamespace(args, 0);
603 const char* path = DartUtils::GetNativeTypedDataArgument(args, 1);
604 bool follow_links = DartUtils::GetNativeBooleanArgument(args, 2);
605 File::Type type = File::GetType(namespc, path, follow_links);
606 Dart_SetIntegerReturnValue(args, static_cast<int>(type));
607}
static Dart_TypedData_Type GetType(intptr_t class_id)

◆ File_LastAccessed()

void FUNCTION_NAME() dart::bin::File_LastAccessed ( Dart_NativeArguments  args)

Definition at line 400 of file file.cc.

400 {
401 Namespace* namespc = Namespace::GetNamespace(args, 0);
402 const char* name = DartUtils::GetNativeTypedDataArgument(args, 1);
403 int64_t return_value = File::LastAccessed(namespc, name);
404 if (return_value >= 0) {
406 } else {
407 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
408 }
409}
constexpr intptr_t kMillisecondsPerSecond
Definition: globals.h:560

◆ File_LastModified()

void FUNCTION_NAME() dart::bin::File_LastModified ( Dart_NativeArguments  args)

Definition at line 375 of file file.cc.

375 {
376 Namespace* namespc = Namespace::GetNamespace(args, 0);
377 const char* raw_name = DartUtils::GetNativeTypedDataArgument(args, 1);
378 int64_t return_value = File::LastModified(namespc, raw_name);
379 if (return_value >= 0) {
381 } else {
382 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
383 }
384}

◆ File_Length()

void FUNCTION_NAME() dart::bin::File_Length ( Dart_NativeArguments  args)

Definition at line 353 of file file.cc.

353 {
354 File* file = GetFile(args);
355 ASSERT(file != nullptr);
356 int64_t return_value = file->Length();
357 if (return_value >= 0) {
358 Dart_SetIntegerReturnValue(args, return_value);
359 } else {
360 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
361 }
362}

◆ File_LengthFromPath()

void FUNCTION_NAME() dart::bin::File_LengthFromPath ( Dart_NativeArguments  args)

Definition at line 364 of file file.cc.

364 {
365 Namespace* namespc = Namespace::GetNamespace(args, 0);
366 const char* path = DartUtils::GetNativeTypedDataArgument(args, 1);
367 int64_t return_value = File::LengthFromPath(namespc, path);
368 if (return_value >= 0) {
369 Dart_SetIntegerReturnValue(args, return_value);
370 } else {
371 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
372 }
373}

◆ File_LinkTarget()

void FUNCTION_NAME() dart::bin::File_LinkTarget ( Dart_NativeArguments  args)

Definition at line 500 of file file.cc.

500 {
501 Namespace* namespc = Namespace::GetNamespace(args, 0);
502 const char* name = DartUtils::GetNativeTypedDataArgument(args, 1);
503 const char* target = File::LinkTarget(namespc, name);
504 if (target == nullptr) {
505 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
506 } else {
509 }
510}

◆ File_Lock()

void FUNCTION_NAME() dart::bin::File_Lock ( Dart_NativeArguments  args)

Definition at line 435 of file file.cc.

435 {
436 File* file = GetFile(args);
437 ASSERT(file != nullptr);
438 int64_t lock;
439 int64_t start;
440 int64_t end;
441 if (DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 1), &lock) &&
442 DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 2), &start) &&
443 DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 3), &end)) {
444 if ((lock >= File::kLockMin) && (lock <= File::kLockMax) && (start >= 0) &&
445 (end == -1 || end > start)) {
446 if (file->Lock(static_cast<File::LockType>(lock), start, end)) {
448 } else {
449 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
450 }
451 return;
452 }
453 }
454 OSError os_error(-1, "Invalid argument", OSError::kUnknown);
455 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
456}

◆ File_Open()

void FUNCTION_NAME() dart::bin::File_Open ( Dart_NativeArguments  args)

Definition at line 89 of file file.cc.

89 {
90 Namespace* namespc = Namespace::GetNamespace(args, 0);
91 const char* filename = DartUtils::GetNativeTypedDataArgument(args, 1);
93 File::DartFileOpenMode dart_file_mode =
94 static_cast<File::DartFileOpenMode>(mode);
95 File::FileOpenMode file_mode = File::DartModeToFileMode(dart_file_mode);
96 // Check that the file exists before opening it only for
97 // reading. This is to prevent the opening of directories as
98 // files. Directories can be opened for reading using the posix
99 // 'open' call.
100 File* file = File::Open(namespc, filename, file_mode);
101 if (file != nullptr) {
102 Dart_SetIntegerReturnValue(args, reinterpret_cast<intptr_t>(file));
103 } else {
104 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
105 }
106}
DartFileOpenMode
Definition: file.h:67
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 mode
Definition: switches.h:228

◆ File_OpenStdio()

void FUNCTION_NAME() dart::bin::File_OpenStdio ( Dart_NativeArguments  args)

Definition at line 583 of file file.cc.

583 {
584 const int64_t fd = DartUtils::GetNativeIntegerArgument(args, 0);
585 File* file = File::OpenStdio(static_cast<int>(fd));
586 Dart_SetIntegerReturnValue(args, reinterpret_cast<intptr_t>(file));
587}

◆ File_Position()

void FUNCTION_NAME() dart::bin::File_Position ( Dart_NativeArguments  args)

Definition at line 310 of file file.cc.

310 {
311 File* file = GetFile(args);
312 ASSERT(file != nullptr);
313 intptr_t return_value = file->Position();
314 if (return_value >= 0) {
315 Dart_SetIntegerReturnValue(args, return_value);
316 } else {
317 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
318 }
319}

◆ File_Read()

void FUNCTION_NAME() dart::bin::File_Read ( Dart_NativeArguments  args)

Definition at line 174 of file file.cc.

174 {
175 File* file = GetFile(args);
176 ASSERT(file != nullptr);
177 Dart_Handle length_object = Dart_GetNativeArgument(args, 1);
178 int64_t length = 0;
179 if (!DartUtils::GetInt64Value(length_object, &length) || (length < 0)) {
180 OSError os_error(-1, "Invalid argument", OSError::kUnknown);
181 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
182 return;
183 }
184 uint8_t* buffer = nullptr;
185 Dart_Handle external_array = IOBuffer::Allocate(length, &buffer);
186 if (Dart_IsNull(external_array)) {
187 OSError os_error(-1, "Failed to allocate buffer", OSError::kUnknown);
188 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
189 return;
190 }
191 int64_t bytes_read = file->Read(reinterpret_cast<void*>(buffer), length);
192 if (bytes_read < 0) {
193 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
194 return;
195 }
196 if (bytes_read < length) {
197 const int kNumArgs = 3;
198 Dart_Handle dart_args[kNumArgs];
199 dart_args[0] = external_array;
200 dart_args[1] = Dart_NewInteger(0);
201 dart_args[2] = Dart_NewInteger(bytes_read);
202 // TODO(sgjesse): Cache the _makeUint8ListView function somewhere.
204 ThrowIfError(io_lib);
205 Dart_Handle array_view =
206 Dart_Invoke(io_lib, DartUtils::NewString("_makeUint8ListView"),
207 kNumArgs, dart_args);
208 Dart_SetReturnValue(args, array_view);
209 } else {
210 Dart_SetReturnValue(args, external_array);
211 }
212}
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_Invoke(Dart_Handle target, Dart_Handle name, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url)
static void * Allocate(uword size, Zone *zone)
Definition: allocation.cc:14

◆ File_ReadByte()

void FUNCTION_NAME() dart::bin::File_ReadByte ( Dart_NativeArguments  args)

Definition at line 142 of file file.cc.

142 {
143 File* file = GetFile(args);
144 ASSERT(file != nullptr);
145 uint8_t buffer;
146 int64_t bytes_read = file->Read(reinterpret_cast<void*>(&buffer), 1);
147 if (bytes_read == 1) {
149 } else if (bytes_read == 0) {
151 } else {
152 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
153 }
154}

◆ File_ReadInto()

void FUNCTION_NAME() dart::bin::File_ReadInto ( Dart_NativeArguments  args)

Definition at line 214 of file file.cc.

214 {
215 File* file = GetFile(args);
216 ASSERT(file != nullptr);
217 Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1);
218 ASSERT(Dart_IsList(buffer_obj));
219 // start and end arguments are checked in Dart code to be
220 // integers and have the property that end <=
221 // list.length. Therefore, it is safe to extract their value as
222 // intptr_t.
223 intptr_t start = DartUtils::GetNativeIntptrArgument(args, 2);
224 intptr_t end = DartUtils::GetNativeIntptrArgument(args, 3);
225 intptr_t length = end - start;
226 intptr_t array_len = 0;
227 Dart_Handle result = Dart_ListLength(buffer_obj, &array_len);
229 ASSERT(end <= array_len);
230
231 uint8_t* buffer;
232 bool is_byte_data = false;
233
234 if (Dart_IsTypedData(buffer_obj)) {
235 // Avoid a memory copy if the input List<int> is an UInt8List.
236 Dart_TypedData_Type data_type;
237 intptr_t bytes_count;
238 ThrowIfError(Dart_TypedDataAcquireData(buffer_obj, &data_type,
239 reinterpret_cast<void**>(&buffer),
240 &bytes_count));
241 if (data_type == Dart_TypedData_kUint8) {
242 is_byte_data = true;
243 buffer += start;
244 ASSERT(bytes_count == array_len);
245 } else {
247 }
248 }
249
250 if (!is_byte_data) {
252 }
253
254 int64_t bytes_read = file->Read(reinterpret_cast<void*>(buffer), length);
255 if (is_byte_data) {
257 }
258 if (bytes_read >= 0) {
259 if (!is_byte_data) {
260 ThrowIfError(Dart_ListSetAsBytes(buffer_obj, start, buffer, bytes_read));
261 }
262 Dart_SetIntegerReturnValue(args, bytes_read);
263 } else {
264 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
265 }
266}
DART_EXPORT bool Dart_IsTypedData(Dart_Handle object)

◆ File_Rename()

void FUNCTION_NAME() dart::bin::File_Rename ( Dart_NativeArguments  args)

Definition at line 534 of file file.cc.

534 {
535 Namespace* namespc = Namespace::GetNamespace(args, 0);
536 const char* old_path = DartUtils::GetNativeTypedDataArgument(args, 1);
537 const char* new_path = DartUtils::GetNativeStringArgument(args, 2);
538 bool result = File::Rename(namespc, old_path, new_path);
539 if (result) {
541 } else {
542 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
543 }
544}

◆ File_RenameLink()

void FUNCTION_NAME() dart::bin::File_RenameLink ( Dart_NativeArguments  args)

Definition at line 546 of file file.cc.

546 {
547 Namespace* namespc = Namespace::GetNamespace(args, 0);
548 const char* old_path = DartUtils::GetNativeTypedDataArgument(args, 1);
549 const char* new_path = DartUtils::GetNativeStringArgument(args, 2);
550 bool result = File::RenameLink(namespc, old_path, new_path);
551 if (result) {
553 } else {
554 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
555 }
556}

◆ File_ResolveSymbolicLinks()

void FUNCTION_NAME() dart::bin::File_ResolveSymbolicLinks ( Dart_NativeArguments  args)

Definition at line 570 of file file.cc.

570 {
571 Namespace* namespc = Namespace::GetNamespace(args, 0);
572 const char* path = nullptr;
573 const char* str = DartUtils::GetNativeTypedDataArgument(args, 1);
574 path = File::GetCanonicalPath(namespc, str);
575 if (path != nullptr) {
578 } else {
579 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
580 }
581}

◆ File_SetLastAccessed()

void FUNCTION_NAME() dart::bin::File_SetLastAccessed ( Dart_NativeArguments  args)

Definition at line 411 of file file.cc.

411 {
412 Namespace* namespc = Namespace::GetNamespace(args, 0);
413 int64_t millis;
414 if (!DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 2), &millis)) {
415 Dart_ThrowException(DartUtils::NewDartArgumentError(
416 "The second argument must be a 64-bit int."));
417 }
418 const char* name = DartUtils::GetNativeTypedDataArgument(args, 1);
419 bool result = File::SetLastAccessed(namespc, name, millis);
420 if (!result) {
421 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
422 }
423}

◆ File_SetLastModified()

void FUNCTION_NAME() dart::bin::File_SetLastModified ( Dart_NativeArguments  args)

Definition at line 386 of file file.cc.

386 {
387 Namespace* namespc = Namespace::GetNamespace(args, 0);
388 int64_t millis;
389 if (!DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 2), &millis)) {
390 Dart_ThrowException(DartUtils::NewDartArgumentError(
391 "The second argument must be a 64-bit int."));
392 }
393 const char* name = DartUtils::GetNativeTypedDataArgument(args, 1);
394 bool result = File::SetLastModified(namespc, name, millis);
395 if (!result) {
396 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
397 }
398}

◆ File_SetPointer()

void FUNCTION_NAME() dart::bin::File_SetPointer ( Dart_NativeArguments  args)

Definition at line 79 of file file.cc.

79 {
81 intptr_t file_pointer = DartUtils::GetNativeIntptrArgument(args, 1);
82 File* file = reinterpret_cast<File*>(file_pointer);
84 dart_this, reinterpret_cast<void*>(file), sizeof(*file), ReleaseFile);
85 file->SetFinalizableHandle(handle);
86 SetFile(dart_this, file_pointer);
87}
struct _Dart_FinalizableHandle * Dart_FinalizableHandle
Definition: dart_api.h:261
static void ReleaseFile(void *isolate_callback_data, void *peer)
Definition: file.cc:74
static void SetFile(Dart_Handle dart_this, intptr_t file_pointer)
Definition: file.cc:51

◆ File_SetPosition()

void FUNCTION_NAME() dart::bin::File_SetPosition ( Dart_NativeArguments  args)

Definition at line 321 of file file.cc.

321 {
322 File* file = GetFile(args);
323 ASSERT(file != nullptr);
324 int64_t position = 0;
325 if (DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 1), &position)) {
326 if (file->SetPosition(position)) {
328 } else {
329 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
330 }
331 } else {
332 OSError os_error(-1, "Invalid argument", OSError::kUnknown);
333 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
334 }
335}

◆ File_Stat()

void FUNCTION_NAME() dart::bin::File_Stat ( Dart_NativeArguments  args)

Definition at line 609 of file file.cc.

609 {
610 Namespace* namespc = Namespace::GetNamespace(args, 0);
612
613 int64_t stat_data[File::kStatSize];
614 File::Stat(namespc, path, stat_data);
615 if (stat_data[File::kType] == File::kDoesNotExist) {
616 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
617 return;
618 }
619 Dart_Handle returned_data =
621 ThrowIfError(returned_data);
622 Dart_TypedData_Type data_type_unused;
623 void* data_location;
624 intptr_t data_length_unused;
626 returned_data, &data_type_unused, &data_location, &data_length_unused);
627 ThrowIfError(status);
628 memmove(data_location, stat_data, File::kStatSize * sizeof(int64_t));
629 status = Dart_TypedDataReleaseData(returned_data);
630 ThrowIfError(status);
631 Dart_SetReturnValue(args, returned_data);
632}
@ Dart_TypedData_kInt64
Definition: dart_api.h:2621

◆ File_Truncate()

void FUNCTION_NAME() dart::bin::File_Truncate ( Dart_NativeArguments  args)

Definition at line 337 of file file.cc.

337 {
338 File* file = GetFile(args);
339 ASSERT(file != nullptr);
340 int64_t length = 0;
341 if (DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 1), &length)) {
342 if (file->Truncate(length)) {
344 } else {
345 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
346 }
347 } else {
348 OSError os_error(-1, "Invalid argument", OSError::kUnknown);
349 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
350 }
351}

◆ File_WriteByte()

void FUNCTION_NAME() dart::bin::File_WriteByte ( Dart_NativeArguments  args)

Definition at line 156 of file file.cc.

156 {
157 File* file = GetFile(args);
158 ASSERT(file != nullptr);
159 int64_t byte = 0;
160 if (DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 1), &byte)) {
161 uint8_t buffer = static_cast<uint8_t>(byte & 0xff);
162 bool success = file->WriteFully(reinterpret_cast<void*>(&buffer), 1);
163 if (success) {
165 } else {
166 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
167 }
168 } else {
169 OSError os_error(-1, "Invalid argument", OSError::kUnknown);
170 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
171 }
172}

◆ File_WriteFrom()

void FUNCTION_NAME() dart::bin::File_WriteFrom ( Dart_NativeArguments  args)

Definition at line 268 of file file.cc.

268 {
269 File* file = GetFile(args);
270 ASSERT(file != nullptr);
271
272 Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1);
273
274 // Offset and length arguments are checked in Dart code to be
275 // integers and have the property that (offset + length) <=
276 // list.length. Therefore, it is safe to extract their value as
277 // intptr_t.
278 intptr_t start = DartUtils::GetNativeIntptrArgument(args, 2);
279 intptr_t end = DartUtils::GetNativeIntptrArgument(args, 3);
280
281 // The buffer object passed in has to be an Int8List or Uint8List object.
282 // Acquire a direct pointer to the data area of the buffer object.
284 intptr_t length = end - start;
285 intptr_t buffer_len = 0;
286 void* buffer = nullptr;
288 Dart_TypedDataAcquireData(buffer_obj, &type, &buffer, &buffer_len);
290
292 ASSERT(end <= buffer_len);
293 ASSERT(buffer != nullptr);
294
295 // Write all the data out into the file.
296 char* byte_buffer = reinterpret_cast<char*>(buffer);
297 bool success = file->WriteFully(byte_buffer + start, length);
298 OSError os_error; // capture error if any
299
300 // Release the direct pointer acquired above.
302
303 if (!success) {
304 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
305 } else {
307 }
308}
@ Dart_TypedData_kInt8
Definition: dart_api.h:2614

◆ FileModifiedCallback()

static bool dart::bin::FileModifiedCallback ( const char *  url,
int64_t  since 
)
static

Definition at line 948 of file main_impl.cc.

948 {
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);
957 if (data[File::kType] == File::kDoesNotExist) {
958 return true;
959 }
960 return data[File::kModifiedTime] > since;
961}

◆ FileSystemWatcher_CloseWatcher()

void FUNCTION_NAME() dart::bin::FileSystemWatcher_CloseWatcher ( Dart_NativeArguments  args)

Definition at line 32 of file file_system_watcher.cc.

32 {
33 intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0));
35}
void Close(PathBuilder *builder)
Definition: tessellator.cc:38

◆ FileSystemWatcher_GetSocketId()

void FUNCTION_NAME() dart::bin::FileSystemWatcher_GetSocketId ( Dart_NativeArguments  args)

Definition at line 65 of file file_system_watcher.cc.

65 {
66 intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0));
67 intptr_t path_id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1));
68 int socket_id = FileSystemWatcher::GetSocketId(id, path_id);
70}

◆ FileSystemWatcher_InitWatcher()

void FUNCTION_NAME() dart::bin::FileSystemWatcher_InitWatcher ( Dart_NativeArguments  args)

Definition at line 23 of file file_system_watcher.cc.

23 {
24 intptr_t id = FileSystemWatcher::Init();
25 if (id >= 0) {
27 } else {
28 Dart_ThrowException(DartUtils::NewDartOSError());
29 }
30}

◆ FileSystemWatcher_IsSupported()

void FUNCTION_NAME() dart::bin::FileSystemWatcher_IsSupported ( Dart_NativeArguments  args)

Definition at line 19 of file file_system_watcher.cc.

19 {
21}
bool IsSupported(const SkMaskFilter *maskfilter)

◆ FileSystemWatcher_ReadEvents()

void FUNCTION_NAME() dart::bin::FileSystemWatcher_ReadEvents ( Dart_NativeArguments  args)

Definition at line 57 of file file_system_watcher.cc.

57 {
58 intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0));
59 intptr_t path_id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1));
60 Dart_Handle handle = FileSystemWatcher::ReadEvents(id, path_id);
61 ThrowIfError(handle);
63}

◆ FileSystemWatcher_UnwatchPath()

void FUNCTION_NAME() dart::bin::FileSystemWatcher_UnwatchPath ( Dart_NativeArguments  args)

Definition at line 51 of file file_system_watcher.cc.

51 {
52 intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0));
53 intptr_t path_id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1));
54 FileSystemWatcher::UnwatchPath(id, path_id);
55}

◆ FileSystemWatcher_WatchPath()

void FUNCTION_NAME() dart::bin::FileSystemWatcher_WatchPath ( Dart_NativeArguments  args)

Definition at line 37 of file file_system_watcher.cc.

37 {
38 intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0));
39 Namespace* namespc = Namespace::GetNamespace(args, 1);
40 const char* path = DartUtils::GetStringValue(Dart_GetNativeArgument(args, 2));
41 int events = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3));
42 bool recursive = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 4));
43 intptr_t path_id =
44 FileSystemWatcher::WatchPath(id, namespc, path, events, recursive);
45 if (path_id == -1) {
46 Dart_ThrowException(DartUtils::NewDartOSError());
47 }
49}

◆ Filter_CreateZLibDeflate()

void FUNCTION_NAME() dart::bin::Filter_CreateZLibDeflate ( Dart_NativeArguments  args)

Definition at line 114 of file filter.cc.

114 {
115 Dart_Handle filter_obj = Dart_GetNativeArgument(args, 0);
117 bool gzip = DartUtils::GetBooleanValue(gzip_obj);
119 int64_t level =
120 DartUtils::GetInt64ValueCheckRange(level_obj, kMinInt32, kMaxInt32);
121 Dart_Handle window_bits_obj = Dart_GetNativeArgument(args, 3);
122 int64_t window_bits = DartUtils::GetIntegerValue(window_bits_obj);
123 Dart_Handle mLevel_obj = Dart_GetNativeArgument(args, 4);
124 int64_t mem_level = DartUtils::GetIntegerValue(mLevel_obj);
125 Dart_Handle strategy_obj = Dart_GetNativeArgument(args, 5);
126 int64_t strategy = DartUtils::GetIntegerValue(strategy_obj);
129 bool raw = DartUtils::GetBooleanValue(raw_obj);
130
131 Dart_Handle err;
132 uint8_t* dictionary = nullptr;
133 intptr_t dictionary_length = 0;
134 if (!Dart_IsNull(dict_obj)) {
135 err = CopyDictionary(dict_obj, &dictionary);
136 if (Dart_IsError(err)) {
138 }
139 ASSERT(dictionary != nullptr);
140 dictionary_length = 0;
141 err = Dart_ListLength(dict_obj, &dictionary_length);
142 if (Dart_IsError(err)) {
143 delete[] dictionary;
145 }
146 }
147
148 ZLibDeflateFilter* filter = new ZLibDeflateFilter(
149 gzip, static_cast<int32_t>(level), static_cast<int32_t>(window_bits),
150 static_cast<int32_t>(mem_level), static_cast<int32_t>(strategy),
151 dictionary, dictionary_length, raw);
152 if (filter == nullptr) {
153 delete[] dictionary;
155 Dart_NewApiError("Could not allocate ZLibDeflateFilter"));
156 }
157 if (!filter->Init()) {
158 delete filter;
160 DartUtils::NewInternalError("Failed to create ZLibDeflateFilter"));
161 }
162 Dart_Handle result = Filter::SetFilterAndCreateFinalizer(
163 filter_obj, filter, sizeof(*filter) + dictionary_length);
164 if (Dart_IsError(result)) {
165 delete filter;
167 }
168}
static Dart_Handle CopyDictionary(Dart_Handle dictionary_obj, uint8_t **dictionary)
Definition: filter.cc:35
constexpr int32_t kMinInt32
Definition: globals.h:482
constexpr int32_t kMaxInt32
Definition: globals.h:483

◆ Filter_CreateZLibInflate()

void FUNCTION_NAME() dart::bin::Filter_CreateZLibInflate ( Dart_NativeArguments  args)

Definition at line 69 of file filter.cc.

69 {
71 Dart_Handle window_bits_obj = Dart_GetNativeArgument(args, 1);
72 int64_t window_bits = DartUtils::GetIntegerValue(window_bits_obj);
75 bool raw = DartUtils::GetBooleanValue(raw_obj);
76
77 Dart_Handle err;
78 uint8_t* dictionary = nullptr;
79 intptr_t dictionary_length = 0;
80 if (!Dart_IsNull(dict_obj)) {
81 err = CopyDictionary(dict_obj, &dictionary);
82 if (Dart_IsError(err)) {
84 }
85 ASSERT(dictionary != nullptr);
86 dictionary_length = 0;
87 err = Dart_ListLength(dict_obj, &dictionary_length);
88 if (Dart_IsError(err)) {
89 delete[] dictionary;
91 }
92 }
93
94 ZLibInflateFilter* filter = new ZLibInflateFilter(
95 static_cast<int32_t>(window_bits), dictionary, dictionary_length, raw);
96 if (filter == nullptr) {
97 delete[] dictionary;
99 Dart_NewApiError("Could not allocate ZLibInflateFilter"));
100 }
101 if (!filter->Init()) {
102 delete filter;
104 DartUtils::NewInternalError("Failed to create ZLibInflateFilter"));
105 }
106 err = Filter::SetFilterAndCreateFinalizer(
107 filter_obj, filter, sizeof(*filter) + dictionary_length);
108 if (Dart_IsError(err)) {
109 delete filter;
111 }
112}

◆ Filter_Process()

void FUNCTION_NAME() dart::bin::Filter_Process ( Dart_NativeArguments  args)

Definition at line 170 of file filter.cc.

170 {
171 Dart_Handle filter_obj = Dart_GetNativeArgument(args, 0);
173 intptr_t start = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 2));
174 intptr_t end = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 3));
175 intptr_t chunk_length = end - start;
176 intptr_t length;
178 uint8_t* buffer = nullptr;
179
180 Filter* filter = nullptr;
181 Dart_Handle err = GetFilter(filter_obj, &filter);
182 if (Dart_IsError(err)) {
184 }
185
187 data_obj, &type, reinterpret_cast<void**>(&buffer), &length);
188 if (!Dart_IsError(result)) {
192 Dart_ThrowException(DartUtils::NewInternalError(
193 "Invalid argument passed to Filter_Process"));
194 }
195 uint8_t* zlib_buffer = new uint8_t[chunk_length];
196 if (zlib_buffer == nullptr) {
198 Dart_PropagateError(Dart_NewApiError("Could not allocate zlib buffer"));
199 }
200
201 memmove(zlib_buffer, buffer + start, chunk_length);
203 buffer = zlib_buffer;
204 } else {
205 err = Dart_ListLength(data_obj, &length);
206 if (Dart_IsError(err)) {
208 }
209 buffer = new uint8_t[chunk_length];
210 if (buffer == nullptr) {
211 Dart_PropagateError(Dart_NewApiError("Could not allocate buffer"));
212 }
213 err = Dart_ListGetAsBytes(data_obj, start, buffer, chunk_length);
214 if (Dart_IsError(err)) {
215 delete[] buffer;
217 }
218 }
219 // Process will take ownership of buffer, if successful.
220 if (!filter->Process(buffer, chunk_length)) {
221 delete[] buffer;
222 Dart_ThrowException(DartUtils::NewInternalError(
223 "Call to Process while still processing data"));
224 }
225}
virtual bool Process(uint8_t *data, intptr_t length)=0
static Dart_Handle GetFilter(Dart_Handle filter_obj, Filter **filter)
Definition: filter.cc:20

◆ Filter_Processed()

void FUNCTION_NAME() dart::bin::Filter_Processed ( Dart_NativeArguments  args)

Definition at line 227 of file filter.cc.

227 {
228 Dart_Handle filter_obj = Dart_GetNativeArgument(args, 0);
230 bool flush = DartUtils::GetBooleanValue(flush_obj);
232 bool end = DartUtils::GetBooleanValue(end_obj);
233
234 Filter* filter = nullptr;
235 Dart_Handle err = GetFilter(filter_obj, &filter);
236 if (Dart_IsError(err)) {
238 }
239
240 intptr_t read = filter->Processed(
241 filter->processed_buffer(), filter->processed_buffer_size(), flush, end);
242 if (read < 0) {
244 DartUtils::NewDartFormatException("Filter error, bad data"));
245 } else if (read == 0) {
247 } else {
248 uint8_t* io_buffer;
250 if (Dart_IsNull(result)) {
251 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
252 return;
253 }
254 memmove(io_buffer, filter->processed_buffer(), read);
256 }
257}
static bool read(SkStream *stream, void *buffer, size_t amount)
virtual intptr_t Processed(uint8_t *buffer, intptr_t length, bool finish, bool end)=0
intptr_t processed_buffer_size() const
Definition: filter.h:42
uint8_t * processed_buffer()
Definition: filter.h:41

◆ FormatMessageIntoBuffer()

void dart::bin::FormatMessageIntoBuffer ( DWORD  code,
wchar_t *  buffer,
int  buffer_length 
)

◆ GetArrayItem()

static Dart_CObject * dart::bin::GetArrayItem ( Dart_CObject message,
intptr_t  index 
)
static

Definition at line 153 of file dartdev_isolate.cc.

153 {
154 return message->value.as_array.values[index];
155}
Win32Message message

◆ GetDirectoryFromPath()

static char * dart::bin::GetDirectoryFromPath ( const char *  path,
char *  dir 
)
static

Definition at line 30 of file exe_utils.cc.

30 {
31 const char* sep = File::PathSeparator();
32 const intptr_t sep_length = strlen(sep);
33 intptr_t path_len = strlen(path);
34
35 for (intptr_t i = path_len - 1; i >= 0; --i) {
36 const char* str = path + i;
37 if (StartsWithPathSeparator(str, sep, sep_length)) {
38 if (dir != nullptr) {
39 strncpy(dir, path, i);
40 dir[i] = '\0';
41 return dir;
42 } else {
43 return Utils::StrNDup(path, i + 1);
44 }
45 }
46 }
47 return nullptr;
48}
static bool StartsWithPathSeparator(const char *path, const char *sep, intptr_t sep_length)
Definition: exe_utils.cc:15
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 Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
Definition: switches.h:145

◆ GetEntropy()

bool dart::bin::GetEntropy ( uint8_t *  buffer,
intptr_t  length 
)

Definition at line 73 of file dart_io_api_impl.cc.

73 {
74 return Crypto::GetRandomBytes(length, buffer);
75}

◆ GetFile()

static File * dart::bin::GetFile ( Dart_NativeArguments  args)
static

Definition at line 37 of file file.cc.

37 {
38 File* file;
40 DEBUG_ASSERT(IsFile(dart_this));
42 dart_this, kFileNativeFieldIndex, reinterpret_cast<intptr_t*>(&file));
44 if (file == nullptr) {
46 DartUtils::NewInternalError("No native peer")));
47 }
48 return file;
49}
#define DEBUG_ASSERT(cond)
Definition: assert.h:321
DART_EXPORT Dart_Handle Dart_NewUnhandledExceptionError(Dart_Handle exception)

◆ GetFileNameFromPath()

static const char * dart::bin::GetFileNameFromPath ( const char *  path)
static

Definition at line 53 of file exe_utils.cc.

53 {
54 const char* sep = File::PathSeparator();
55 const intptr_t sep_length = strlen(sep);
56 intptr_t path_len = strlen(path);
57
58 for (intptr_t i = path_len - 1; i >= 0; --i) {
59 const char* str = path + i;
60 if (StartsWithPathSeparator(str, sep, sep_length)) {
61 return str + sep_length;
62 }
63 }
64 // No path separators, assume that path is a file name.
65 return path;
66}

◆ GetFiletimeFromMillis()

FILETIME dart::bin::GetFiletimeFromMillis ( int64_t  millis)

◆ GetFilter() [1/2]

static Dart_Handle dart::bin::GetFilter ( Dart_Handle  filter_obj,
Filter **  filter 
)
static

Definition at line 20 of file filter.cc.

20 {
21 ASSERT(filter != nullptr);
23 Dart_Handle err = Filter::GetFilterNativeField(filter_obj, &result);
24 if (Dart_IsError(err)) {
25 return err;
26 }
27 if (result == nullptr) {
28 return Dart_NewApiError("Filter was destroyed");
29 }
30
31 *filter = result;
32 return Dart_Null();
33}

◆ GetFilter() [2/2]

static SSLFilter * dart::bin::GetFilter ( Dart_NativeArguments  args)
static

Definition at line 53 of file secure_socket_filter.cc.

53 {
54 SSLFilter* filter = nullptr;
56 ASSERT(Dart_IsInstance(dart_this));
58 dart_this, SSLFilter::kSSLFilterNativeFieldIndex,
59 reinterpret_cast<intptr_t*>(&filter)));
60 if (filter == nullptr) {
62 DartUtils::NewInternalError("No native peer")));
63 }
64 return filter;
65}

◆ GetHashmapKeyFromString()

static void * dart::bin::GetHashmapKeyFromString ( char *  key)
inlinestatic

Definition at line 38 of file dartutils.h.

38 {
39 return reinterpret_cast<void*>(key);
40}

◆ GetIntptrArgument()

static bool dart::bin::GetIntptrArgument ( Dart_NativeArguments  args,
intptr_t  idx,
intptr_t *  value 
)
static

Definition at line 19 of file stdio.cc.

21 {
22 ASSERT(value != nullptr);
23 int64_t v;
25 if (Dart_IsError(status)) {
26 // The caller is expecting an OSError if something goes wrong.
27 OSError os_error(-1, "Invalid argument", OSError::kUnknown);
28 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
29 return false;
30 }
31 if ((v < kIntptrMin) || (kIntptrMax < v)) {
32 // The caller is expecting an OSError if something goes wrong.
33 OSError os_error(-1, "Invalid argument", OSError::kUnknown);
34 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
35 return false;
36 }
37 *value = static_cast<intptr_t>(v);
38 return true;
39}
DART_EXPORT Dart_Handle Dart_GetNativeIntegerArgument(Dart_NativeArguments args, int index, int64_t *value)
constexpr intptr_t kIntptrMin
Definition: globals.h:556
constexpr intptr_t kIntptrMax
Definition: globals.h:557

◆ GetIOEmbedderInformation()

void dart::bin::GetIOEmbedderInformation ( Dart_EmbedderInformation info)

Definition at line 53 of file dart_io_api_impl.cc.

53 {
54 ASSERT(info != nullptr);
56
57 Process::GetRSSInformation(&(info->max_rss), &(info->current_rss));
58}

◆ GetPrivateKey()

static EVP_PKEY * dart::bin::GetPrivateKey ( BIO *  bio,
const char *  password 
)
static

Definition at line 411 of file security_context.cc.

411 {
412 EVP_PKEY* key = PEM_read_bio_PrivateKey(bio, nullptr, PasswordCallback,
413 const_cast<char*>(password));
414 if (key == nullptr) {
415 // We try reading data as PKCS12 only if reading as PEM was unsuccessful and
416 // if there is no indication that the data is malformed PEM. We assume the
417 // data is malformed PEM if it contains the start line, i.e. a line
418 // with ----- BEGIN.
419 if (SecureSocketUtils::NoPEMStartLine()) {
420 // Reset the bio, and clear the error from trying to read as PEM.
421 ERR_clear_error();
422 BIO_reset(bio);
423
424 // Try to decode as PKCS12.
425 key = GetPrivateKeyPKCS12(bio, password);
426 }
427 }
428 return key;
429}
static EVP_PKEY * GetPrivateKeyPKCS12(BIO *bio, const char *password)
int PasswordCallback(char *buf, int size, int rwflag, void *userdata)

◆ GetPrivateKeyPKCS12()

static EVP_PKEY * dart::bin::GetPrivateKeyPKCS12 ( BIO *  bio,
const char *  password 
)
static

Definition at line 391 of file security_context.cc.

391 {
392 ScopedPKCS12 p12(d2i_PKCS12_bio(bio, nullptr));
393 if (p12.get() == nullptr) {
394 return nullptr;
395 }
396
397 EVP_PKEY* key = nullptr;
398 X509* cert = nullptr;
399 STACK_OF(X509)* ca_certs = nullptr;
400 int status = PKCS12_parse(p12.get(), password, &key, &cert, &ca_certs);
401 if (status == 0) {
402 return nullptr;
403 }
404
405 // We only care about the private key.
406 ScopedX509 delete_cert(cert);
407 ScopedX509Stack delete_ca_certs(ca_certs);
408 return key;
409}
ScopedSSLType< X509, X509_free > ScopedX509
ScopedSSLStackType< STACK_OF(X509), X509, X509_free > ScopedX509Stack

◆ GetVMServiceAssetsArchiveCallback()

Dart_Handle dart::bin::GetVMServiceAssetsArchiveCallback ( )

Definition at line 1134 of file main_impl.cc.

1134 {
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}
unsigned int observatory_assets_archive_len
const uint8_t * observatory_assets_archive
void Decompress(const uint8_t *input, intptr_t input_len, uint8_t **output, intptr_t *output_length)
Definition: gzip.cc:15

◆ GetX509Certificate()

static X509 * dart::bin::GetX509Certificate ( Dart_NativeArguments  args)
static

Definition at line 635 of file security_context.cc.

635 {
636 X509* certificate = nullptr;
638 ASSERT(Dart_IsInstance(dart_this));
640 dart_this, SSLCertContext::kX509NativeFieldIndex,
641 reinterpret_cast<intptr_t*>(&certificate)));
642 if (certificate == nullptr) {
644 DartUtils::NewInternalError("No native peer")));
645 }
646 return certificate;
647}

◆ hot_reload_rollback_test_mode_callback()

static void dart::bin::hot_reload_rollback_test_mode_callback ( CommandLineOptions vm_options)
static

Definition at line 107 of file main_options.cc.

108 {
109 // Identity reload.
110 vm_options->AddArgument("--identity_reload");
111 // Start reloading quickly.
112 vm_options->AddArgument("--reload_every=4");
113 // Reload from optimized and unoptimized code.
114 vm_options->AddArgument("--reload_every_optimized=false");
115 // Reload less frequently as time goes on.
116 vm_options->AddArgument("--reload_every_back_off");
117 // Ensure that every isolate has reloaded once before exiting.
118 vm_options->AddArgument("--check_reloaded");
119 // Force all reloads to fail and execute the rollback code.
120 vm_options->AddArgument("--reload_force_rollback");
121#if !defined(DART_PRECOMPILED_RUNTIME)
123#endif // !defined(DART_PRECOMPILED_RUNTIME)
124}
void AddArgument(const char *argument)
Definition: dartutils.h:68
void set_use_incremental_compiler(bool value)
Definition: dfe.h:44

◆ hot_reload_test_mode_callback()

static void dart::bin::hot_reload_test_mode_callback ( CommandLineOptions vm_options)
static

Definition at line 89 of file main_options.cc.

89 {
90 // Identity reload.
91 vm_options->AddArgument("--identity_reload");
92 // Start reloading quickly.
93 vm_options->AddArgument("--reload_every=4");
94 // Reload from optimized and unoptimized code.
95 vm_options->AddArgument("--reload_every_optimized=false");
96 // Reload less frequently as time goes on.
97 vm_options->AddArgument("--reload_every_back_off");
98 // Ensure that every isolate has reloaded once before exiting.
99 vm_options->AddArgument("--check_reloaded");
100#if !defined(DART_PRECOMPILED_RUNTIME)
102#endif // !defined(DART_PRECOMPILED_RUNTIME)
103}

◆ InitializeCrashpadClient()

void dart::bin::InitializeCrashpadClient ( )

Definition at line 77 of file crashpad.cc.

77{}

◆ InternetAddress_Parse()

void FUNCTION_NAME() dart::bin::InternetAddress_Parse ( Dart_NativeArguments  args)

Definition at line 245 of file socket_base.cc.

245 {
246 const char* address =
247 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
248 ASSERT(address != nullptr);
249 RawAddr raw;
250 memset(&raw, 0, sizeof(raw));
251 int type = strchr(address, ':') == nullptr ? SocketAddress::TYPE_IPV4
252 : SocketAddress::TYPE_IPV6;
253 if (type == SocketAddress::TYPE_IPV4) {
254 raw.addr.sa_family = AF_INET;
255 } else {
256 raw.addr.sa_family = AF_INET6;
257 }
258 bool ok = SocketBase::ParseAddress(type, address, &raw);
259 if (!ok) {
261 } else {
262 Dart_SetReturnValue(args, SocketAddress::ToTypedData(raw));
263 }
264}
static bool ok(int result)
struct sockaddr addr
Definition: socket_base.h:38

◆ InternetAddress_ParseScopedLinkLocalAddress()

void FUNCTION_NAME() dart::bin::InternetAddress_ParseScopedLinkLocalAddress ( Dart_NativeArguments  args)

Definition at line 266 of file socket_base.cc.

267 {
268 const char* address =
269 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
270 // This must be an IPv6 address.
271 intptr_t type = 1;
272 ASSERT(address != nullptr);
273 OSError* os_error = nullptr;
274 AddressList<SocketAddress>* addresses =
275 SocketBase::LookupAddress(address, type, &os_error);
276 if (addresses != nullptr) {
277 SocketAddress* addr = addresses->GetAt(0);
279 args, Dart_NewInteger(SocketAddress::GetAddrScope(addr->addr())));
280 delete addresses;
281 } else {
282 Dart_SetReturnValue(args, DartUtils::NewDartOSError(os_error));
283 delete os_error;
284 }
285}
T * GetAt(intptr_t i) const
Definition: socket_base.h:141

◆ InternetAddress_RawAddrToString()

void FUNCTION_NAME() dart::bin::InternetAddress_RawAddrToString ( Dart_NativeArguments  args)

Definition at line 287 of file socket_base.cc.

287 {
289 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 0), &addr);
290 // INET6_ADDRSTRLEN is larger than INET_ADDRSTRLEN
291 char str[INET6_ADDRSTRLEN];
292 bool ok = SocketBase::RawAddrToString(&addr, str);
293 if (!ok) {
294 str[0] = '\0';
295 }
297}

◆ IO_NATIVE_LIST()

dart::bin::IO_NATIVE_LIST ( DECLARE_FUNCTION  )

◆ IONativeLookup()

Dart_NativeFunction dart::bin::IONativeLookup ( Dart_Handle  name,
int  argument_count,
bool *  auto_setup_scope 
)

Definition at line 215 of file io_natives.cc.

217 {
218 const char* function_name = nullptr;
221 ASSERT(function_name != nullptr);
222 ASSERT(auto_setup_scope != nullptr);
223 *auto_setup_scope = true;
224 int num_entries = sizeof(IOEntries) / sizeof(struct NativeEntries);
225 for (int i = 0; i < num_entries; i++) {
226 const struct NativeEntries* entry = &(IOEntries[i]);
227 if ((strcmp(function_name, entry->name_) == 0) &&
228 (entry->argument_count_ == argument_count)) {
229 return reinterpret_cast<Dart_NativeFunction>(entry->function_);
230 }
231 }
232 return nullptr;
233}
DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle str, const char **cstr)
void(* Dart_NativeFunction)(Dart_NativeArguments arguments)
Definition: dart_api.h:3207
int argument_count
Definition: fuchsia.cc:52
static const struct dart::bin::NativeEntries IOEntries[]
const char *const function_name
Dart_NativeFunction function_

◆ IONativeSymbol()

const uint8_t * dart::bin::IONativeSymbol ( Dart_NativeFunction  nf)

Definition at line 235 of file io_natives.cc.

235 {
236 int num_entries = sizeof(IOEntries) / sizeof(struct NativeEntries);
237 for (int i = 0; i < num_entries; i++) {
238 const struct NativeEntries* entry = &(IOEntries[i]);
239 if (reinterpret_cast<Dart_NativeFunction>(entry->function_) == nf) {
240 return reinterpret_cast<const uint8_t*>(entry->name_);
241 }
242 }
243 return nullptr;
244}

◆ IOService_NewServicePort()

void FUNCTION_NAME() dart::bin::IOService_NewServicePort ( Dart_NativeArguments  args)

Definition at line 61 of file io_service.cc.

61 {
63 Dart_Port service_port = IOService::GetServicePort();
64 if (service_port != ILLEGAL_PORT) {
65 // Return a send port for the service port.
66 Dart_Handle send_port = Dart_NewSendPort(service_port);
67 Dart_SetReturnValue(args, send_port);
68 }
69}
DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id)

◆ IOServiceCallback()

void dart::bin::IOServiceCallback ( Dart_Port  dest_port_id,
Dart_CObject message 
)

Definition at line 31 of file io_service.cc.

31 {
32 Dart_Port reply_port_id = ILLEGAL_PORT;
33 CObject* response = CObject::IllegalArgumentError();
34 CObjectArray request(message);
35 if ((message->type == Dart_CObject_kArray) && (request.Length() == 4) &&
36 request[0]->IsInt32() && request[1]->IsSendPort() &&
37 request[2]->IsInt32() && request[3]->IsArray()) {
38 CObjectInt32 message_id(request[0]);
39 CObjectSendPort reply_port(request[1]);
40 CObjectInt32 request_id(request[2]);
41 CObjectArray data(request[3]);
42 reply_port_id = reply_port.Value();
43 switch (request_id.Value()) {
45 default:
47 }
48 }
49
50 CObjectArray result(CObject::NewArray(2));
51 result.SetAt(0, request[0]);
52 result.SetAt(1, response);
53 ASSERT(reply_port_id != ILLEGAL_PORT);
54 Dart_PostCObject(reply_port_id, result.AsApiCObject());
55}
@ Dart_CObject_kArray
DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject *message)
#define CASE_REQUEST(type, method, id)
Definition: io_service.cc:26
#define IO_SERVICE_REQUEST_LIST(V)
Definition: io_service.h:19

◆ IsFile()

static bool dart::bin::IsFile ( Dart_Handle  file_obj)
static

Definition at line 25 of file file.cc.

25 {
26 Dart_Handle file_type = ThrowIfError(
27 DartUtils::GetDartType("dart:io", "_RandomAccessFileOpsImpl"));
28 bool isinstance = false;
29 ThrowIfError(Dart_ObjectIsType(file_obj, file_type, &isinstance));
30 return isinstance;
31}
DART_EXPORT Dart_Handle Dart_ObjectIsType(Dart_Handle object, Dart_Handle type, bool *instanceof)

◆ IsolateSetupHelper()

static Dart_Isolate dart::bin::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 
)
static

Definition at line 257 of file main_impl.cc.

264 {
266
267 // Set up the library tag handler for the isolate group shared by all
268 // isolates in the group.
271 result = Dart_SetDeferredLoadHandler(Loader::DeferredLoadHandler);
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;
343 DartUtils::ResolveScript(Dart_NewStringFromCString(script_uri)),
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 =
354 DartUtils::ResolveScript(Dart_NewStringFromCString(script_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));
394 native_assets.dlopen_absolute = &NativeAssets::DlopenAbsolute;
396 native_assets.dlopen_system = &NativeAssets::DlopenSystem;
397 native_assets.dlopen_executable = &NativeAssets::DlopenExecutable;
398 native_assets.dlopen_process = &NativeAssets::DlopenProcess;
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}
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
DART_EXPORT DART_WARN_UNUSED_RESULT char * Dart_IsolateMakeRunnable(Dart_Isolate isolate)
DART_EXPORT Dart_Handle Dart_DebugName(void)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_SortClasses(void)
DART_EXPORT void Dart_SetShouldPauseOnExit(bool should_pause)
DART_EXPORT Dart_Port Dart_GetMainPortId(void)
DART_EXPORT void * Dart_IsolateData(Dart_Isolate isolate)
DART_EXPORT Dart_Handle Dart_NewStringFromCString(const char *str)
DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate)
DART_EXPORT void Dart_SetShouldPauseOnStart(bool should_pause)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_LoadScriptFromKernel(const uint8_t *kernel_buffer, intptr_t kernel_size)
DART_EXPORT bool Dart_IsKernelIsolate(Dart_Isolate isolate)
DART_EXPORT void Dart_InitializeNativeAssetsResolver(NativeAssetsApi *native_assets_api)
@ Dart_Timeline_Event_Async_End
static void * NativeAssetsDlopenRelative(const char *path, char **error)
Definition: main_impl.cc:250
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
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

◆ IsOption()

static bool dart::bin::IsOption ( const char *  arg,
const char *  option 
)
static

Definition at line 386 of file main_options.cc.

386 {
387 if (arg[0] != '-' || arg[1] != '-') {
388 // Special case first two characters to avoid recognizing __flag.
389 return false;
390 }
391 for (int i = 0; option[i] != '\0'; i++) {
392 auto c = arg[i + 2];
393 if (c == '\0') {
394 // Not long enough.
395 return false;
396 }
397 if ((c == '_' ? '-' : c) != option[i]) {
398 return false;
399 }
400 }
401 return true;
402}

◆ IsPrefix()

static bool dart::bin::IsPrefix ( const char *  prefix,
size_t  prefix_len,
const char *  str 
)
static

Definition at line 44 of file options.cc.

44 {
45 ASSERT(prefix != nullptr);
46 ASSERT(str != nullptr);
47 const size_t str_len = strlen(str);
48 if (str_len < prefix_len) {
49 return false;
50 }
51 return strncmp(prefix, str, prefix_len) == 0;
52}

◆ IsSnapshottingForPrecompilation()

static bool dart::bin::IsSnapshottingForPrecompilation ( )
static

Definition at line 138 of file gen_snapshot.cc.

138 {
141}

◆ IsWindowsHost()

static bool dart::bin::IsWindowsHost ( )
static

Definition at line 50 of file dartutils.cc.

50 {
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}

◆ ListeningSocketFinalizer()

static void dart::bin::ListeningSocketFinalizer ( void *  isolate_data,
void *  data 
)
static

Definition at line 1430 of file socket.cc.

1430 {
1431 Socket* socket = reinterpret_cast<Socket*>(data);
1432 const int64_t flags = (1 << kListeningSocket) | (1 << kCloseCommand);
1433 socket->Retain(); // Bump reference till we send the message.
1434 EventHandler::SendFromNative(reinterpret_cast<intptr_t>(socket),
1435 socket->port(), flags);
1436 socket->Release(); // Release the reference we just added above.
1437}
Dart_Port port() const
Definition: socket.h:63

◆ ListNext()

static bool dart::bin::ListNext ( DirectoryListing listing)
static

Definition at line 516 of file directory.cc.

516 {
517 switch (listing->top()->Next(listing)) {
518 case kListFile:
519 return listing->HandleFile(listing->CurrentPath());
520
521 case kListLink:
522 return listing->HandleLink(listing->CurrentPath());
523
524 case kListDirectory:
525 if (listing->recursive()) {
526 listing->Push(new DirectoryListingEntry(listing->top()));
527 }
528 return listing->HandleDirectory(listing->CurrentPath());
529
530 case kListError:
531 return listing->HandleError();
532
533 case kListDone:
534 listing->Pop();
535 if (listing->IsEmpty()) {
536 listing->HandleDone();
537 return false;
538 } else {
539 return true;
540 }
541
542 default:
543 UNREACHABLE();
544 }
545 return false;
546}
ListType Next(DirectoryListing *listing)
const char * CurrentPath()
Definition: directory.h:141
DirectoryListingEntry * top() const
Definition: directory.h:135
void Push(DirectoryListingEntry *directory)
Definition: directory.h:116
virtual bool HandleFile(const char *file_name)=0
virtual void HandleDone()
Definition: directory.h:114
virtual bool HandleDirectory(const char *dir_name)=0
virtual bool HandleLink(const char *link_name)=0
virtual bool HandleError()=0

◆ LoadDynamicLibrary()

static void * dart::bin::LoadDynamicLibrary ( const char *  library_file,
char **  error = nullptr 
)
static

Definition at line 81 of file native_assets_api_impl.cc.

82 {
83 char* utils_error = nullptr;
84 void* handle = Utils::LoadDynamicLibrary(library_file, &utils_error);
85 if (utils_error != nullptr) {
86 if (error != nullptr) {
87 SET_ERROR_MSG(error, "Failed to load dynamic library '%s': %s",
88 library_file != nullptr ? library_file : "<process>",
89 utils_error);
90 }
91 free(utils_error);
92 }
93 return handle;
94}
static void * LoadDynamicLibrary(const char *library_file, char **error=nullptr)
#define SET_ERROR_MSG(error_msg, format,...)

◆ LookupIONative()

Dart_NativeFunction dart::bin::LookupIONative ( Dart_Handle  name,
int  argument_count,
bool *  auto_setup_scope 
)

Definition at line 77 of file dart_io_api_impl.cc.

79 {
80 return IONativeLookup(name, argument_count, auto_setup_scope);
81}
Dart_NativeFunction IONativeLookup(Dart_Handle name, int argument_count, bool *auto_setup_scope)
Definition: io_natives.cc:215

◆ LookupIONativeSymbol()

const uint8_t * dart::bin::LookupIONativeSymbol ( Dart_NativeFunction  nf)

Definition at line 83 of file dart_io_api_impl.cc.

83 {
84 return IONativeSymbol(nf);
85}
const uint8_t * IONativeSymbol(Dart_NativeFunction nf)
Definition: io_natives.cc:235

◆ main()

void dart::bin::main ( int  argc,
char **  argv 
)

Definition at line 789 of file gen_snapshot.cc.

789 {
790#if !defined(DART_HOST_OS_WINDOWS)
791 // Very early so any crashes during startup can also be symbolized.
792 EXEUtils::LoadDartProfilerSymbols(argv[0]);
793#endif
794
795 const int EXTRA_VM_ARGUMENTS = 7;
796 CommandLineOptions vm_options(argc + EXTRA_VM_ARGUMENTS);
798
799 // When running from the command line we assume that we are optimizing for
800 // throughput, and therefore use a larger new gen semi space size and a faster
801 // new gen growth factor unless others have been specified.
802 if (kWordSize <= 4) {
803 vm_options.AddArgument("--new_gen_semi_max_size=16");
804 } else {
805 vm_options.AddArgument("--new_gen_semi_max_size=32");
806 }
807 vm_options.AddArgument("--new_gen_growth_factor=4");
808 vm_options.AddArgument("--deterministic");
809
810 // Parse command line arguments.
811 if (ParseArguments(argc, argv, &vm_options, &inputs) < 0) {
812 PrintUsage();
813 return kErrorExitCode;
814 }
815 DartUtils::SetEnvironment(environment);
816
817 if (!Platform::Initialize()) {
818 Syslog::PrintErr("Initialization failed\n");
819 return kErrorExitCode;
820 }
821 Console::SaveConfig();
823 DartUtils::SetOriginalWorkingDirectory();
824 // Start event handler.
826 EventHandler::Start();
827
829 vm_options.AddArgument("--precompilation");
830 // AOT snapshot can be deployed to another machine,
831 // so generated code should not depend on the CPU features
832 // of the system where snapshot was generated.
833 vm_options.AddArgument("--target_unknown_cpu");
834 } else if (snapshot_kind == kAppJIT) {
835 // App-jit snapshot can be deployed to another machine,
836 // so generated code should not depend on the CPU features
837 // of the system where snapshot was generated.
838 vm_options.AddArgument("--target_unknown_cpu");
839#if !defined(TARGET_ARCH_IA32)
840 vm_options.AddArgument("--link_natives_lazily");
841#endif
842 }
843
844 char* error = Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
845 if (error != nullptr) {
846 Syslog::PrintErr("Setting VM flags failed: %s\n", error);
847 free(error);
848 return kErrorExitCode;
849 }
850
851 Dart_InitializeParams init_params;
852 memset(&init_params, 0, sizeof(init_params));
854 init_params.file_open = DartUtils::OpenFile;
855 init_params.file_read = DartUtils::ReadFile;
856 init_params.file_write = DartUtils::WriteFile;
857 init_params.file_close = DartUtils::CloseFile;
858 init_params.entropy_source = DartUtils::EntropySource;
859 init_params.start_kernel_isolate = false;
860#if defined(DART_HOST_OS_FUCHSIA)
861 init_params.vmex_resource = Platform::GetVMEXResource();
862#endif
863
864 std::unique_ptr<MappedMemory> mapped_vm_snapshot_data;
865 std::unique_ptr<MappedMemory> mapped_vm_snapshot_instructions;
866 std::unique_ptr<MappedMemory> mapped_isolate_snapshot_data;
867 std::unique_ptr<MappedMemory> mapped_isolate_snapshot_instructions;
868 if (load_vm_snapshot_data_filename != nullptr) {
869 mapped_vm_snapshot_data =
870 MapFile(load_vm_snapshot_data_filename, File::kReadOnly,
871 &init_params.vm_snapshot_data);
872 }
873 if (load_vm_snapshot_instructions_filename != nullptr) {
874 mapped_vm_snapshot_instructions =
875 MapFile(load_vm_snapshot_instructions_filename, File::kReadExecute,
876 &init_params.vm_snapshot_instructions);
877 }
878 if (load_isolate_snapshot_data_filename != nullptr) {
879 mapped_isolate_snapshot_data =
880 MapFile(load_isolate_snapshot_data_filename, File::kReadOnly,
882 }
883 if (load_isolate_snapshot_instructions_filename != nullptr) {
884 mapped_isolate_snapshot_instructions =
885 MapFile(load_isolate_snapshot_instructions_filename, File::kReadExecute,
887 }
888
889 error = Dart_Initialize(&init_params);
890 if (error != nullptr) {
891 Syslog::PrintErr("VM initialization failed: %s\n", error);
892 free(error);
893 return kErrorExitCode;
894 }
895
897 if (result != 0) {
898 return result;
899 }
900
902 if (error != nullptr) {
903 Syslog::PrintErr("VM cleanup failed: %s\n", error);
904 free(error);
905 }
906 EventHandler::Stop();
907 return 0;
908}
#define DART_INITIALIZE_PARAMS_CURRENT_VERSION
Definition: dart_api.h:840
DART_EXPORT DART_WARN_UNUSED_RESULT char * Dart_Initialize(Dart_InitializeParams *params)
DART_EXPORT DART_WARN_UNUSED_RESULT char * Dart_SetVMFlags(int argc, const char **argv)
void PrintUsage()
Definition: main.cc:143
char ** argv
Definition: library.h:9
static int CreateIsolateAndSnapshot(const CommandLineOptions &inputs)
static int ParseArguments(int argc, char **argv, CommandLineOptions *vm_options, CommandLineOptions *inputs)
static dart::SimpleHashMap * environment
Definition: gen_snapshot.cc:59
static std::unique_ptr< MappedMemory > MapFile(const char *filename, File::MapType type, const uint8_t **buffer)
constexpr intptr_t kWordSize
Definition: globals.h:509
void Initialize(zx::channel directory_request, std::optional< zx::eventpair > view_ref)
Initializes Dart bindings for the Fuchsia application model.
Definition: fuchsia.cc:103
Dart_FileReadCallback file_read
Definition: dart_api.h:955
const uint8_t * vm_snapshot_data
Definition: dart_api.h:911
Dart_FileOpenCallback file_open
Definition: dart_api.h:954
Dart_FileWriteCallback file_write
Definition: dart_api.h:956
Dart_EntropySource entropy_source
Definition: dart_api.h:958
const uint8_t * vm_snapshot_instructions
Definition: dart_api.h:919
Dart_FileCloseCallback file_close
Definition: dart_api.h:957

◆ MallocFinalizer() [1/2]

static void dart::bin::MallocFinalizer ( void *  isolate_callback_data,
void *  peer 
)
static

Definition at line 355 of file gen_snapshot.cc.

355 {
356 free(peer);
357}

◆ MallocFinalizer() [2/2]

static void dart::bin::MallocFinalizer ( void *  isolate_callback_data,
void *  peer 
)
static

Definition at line 54 of file loader.cc.

54 {
55 free(peer);
56}

◆ MapFile()

static std::unique_ptr< MappedMemory > dart::bin::MapFile ( const char *  filename,
File::MapType  type,
const uint8_t **  buffer 
)
static

Definition at line 413 of file gen_snapshot.cc.

415 {
416 File* file = File::Open(nullptr, filename, File::kRead);
417 if (file == nullptr) {
418 Syslog::PrintErr("Failed to open: %s\n", filename);
420 }
421 RefCntReleaseScope<File> rs(file);
422 intptr_t length = file->Length();
423 if (length == 0) {
424 // Can't map an empty file.
425 *buffer = nullptr;
426 return nullptr;
427 }
428 MappedMemory* mapping = file->Map(type, 0, length);
429 if (mapping == nullptr) {
430 Syslog::PrintErr("Failed to read: %s\n", filename);
432 }
433 *buffer = reinterpret_cast<const uint8_t*>(mapping->address());
434 return std::unique_ptr<MappedMemory>(mapping);
435}
exit(kErrorExitCode)

◆ MaybeLoadCode()

static void dart::bin::MaybeLoadCode ( )
static

Definition at line 372 of file gen_snapshot.cc.

372 {
373 if (compile_all && (snapshot_kind == kAppJIT)) {
376 }
377}

◆ MaybeLoadExtraInputs()

static void dart::bin::MaybeLoadExtraInputs ( const CommandLineOptions inputs)
static

Definition at line 359 of file gen_snapshot.cc.

359 {
360 for (intptr_t i = 1; i < inputs.count(); i++) {
361 uint8_t* buffer = nullptr;
362 intptr_t size = 0;
363 ReadFile(inputs.GetArgument(i), &buffer, &size);
366 CHECK_RESULT(td);
369 }
370}
DART_EXPORT Dart_Handle Dart_NewExternalTypedDataWithFinalizer(Dart_TypedData_Type type, void *data, intptr_t length, void *peer, intptr_t external_allocation_size, Dart_HandleFinalizer callback)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_LoadLibrary(Dart_Handle kernel_buffer)
static void MallocFinalizer(void *isolate_callback_data, void *peer)

◆ Namespace_Create()

void FUNCTION_NAME() dart::bin::Namespace_Create ( Dart_NativeArguments  args)

Definition at line 38 of file namespace.cc.

38 {
39 Dart_Handle namespc_obj = Dart_GetNativeArgument(args, 0);
40 if (Dart_IsError(namespc_obj)) {
41 Dart_PropagateError(namespc_obj);
42 }
43 DEBUG_ASSERT(IsNamespace(namespc_obj));
44
45 // Allocate a native wrapper for the platform namespc bits.
46 Namespace* namespc = nullptr;
48 Dart_Handle native_namespc = Dart_GetNativeArgument(args, 1);
49 if (Dart_IsInteger(native_namespc)) {
50 int64_t namespc_val;
51 result = Dart_IntegerToInt64(native_namespc, &namespc_val);
52 if (Dart_IsError(result)) {
54 }
55 namespc = Namespace::Create(namespc_val);
56 } else if (Dart_IsString(native_namespc)) {
57 const char* namespc_path;
58 result = Dart_StringToCString(native_namespc, &namespc_path);
59 if (Dart_IsError(result)) {
61 }
62 namespc = Namespace::Create(namespc_path);
63 } else {
64 // Propagate a type error.
66 DartUtils::NewDartArgumentError("Argument must be an int or a String"));
67 }
68
69 // We were unable to create a native Namespace wrapper object due to some
70 // OS-level error.
71 if (namespc == nullptr) {
72 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
73 }
74
75 // Set the Dart objects native field to the native wrapper.
77 reinterpret_cast<intptr_t>(namespc));
78 if (Dart_IsError(result)) {
79 namespc->Release();
81 }
82
83 // Set up a finalizer for the Dart object so that we can do any necessary
84 // platform-specific cleanup for the namespc.
85 Dart_NewFinalizableHandle(namespc_obj, reinterpret_cast<void*>(namespc),
86 sizeof(*namespc), ReleaseNamespace);
87 Dart_SetReturnValue(args, namespc_obj);
88}
DART_EXPORT bool Dart_IsInteger(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_IntegerToInt64(Dart_Handle integer, int64_t *value)
static void ReleaseNamespace(void *isolate_callback_data, void *peer)
Definition: namespace.cc:19
static constexpr int kNamespaceNativeFieldIndex
Definition: namespace.cc:17

◆ Namespace_GetDefault()

void FUNCTION_NAME() dart::bin::Namespace_GetDefault ( Dart_NativeArguments  args)

Definition at line 90 of file namespace.cc.

90 {
91 Dart_SetIntegerReturnValue(args, Namespace::Default());
92}

◆ Namespace_GetPointer()

void FUNCTION_NAME() dart::bin::Namespace_GetPointer ( Dart_NativeArguments  args)

Definition at line 94 of file namespace.cc.

94 {
95 Namespace* namespc = Namespace::GetNamespace(args, 0);
96 ASSERT(namespc != nullptr);
97 namespc->Retain();
98 Dart_SetIntegerReturnValue(args, reinterpret_cast<intptr_t>(namespc));
99}

◆ NativeAssetsDlopenRelative()

static void * dart::bin::NativeAssetsDlopenRelative ( const char *  path,
char **  error 
)
static

Definition at line 250 of file main_impl.cc.

250 {
251 auto isolate_group_data =
253 const char* script_uri = isolate_group_data->script_url;
254 return NativeAssets::DlopenRelative(path, script_uri, error);
255}
DART_EXPORT void * Dart_CurrentIsolateGroupData(void)

◆ NextAsmCallback()

static void dart::bin::NextAsmCallback ( void *  callback_data,
intptr_t  loading_unit_id,
void **  write_callback_data,
void **  write_debug_callback_data 
)
static

Definition at line 579 of file gen_snapshot.cc.

582 {
583 NextLoadingUnit(callback_data, loading_unit_id, write_callback_data,
584 write_debug_callback_data, assembly_filename, "S");
585}
static void NextLoadingUnit(void *callback_data, intptr_t loading_unit_id, void **write_callback_data, void **write_debug_callback_data, const char *main_filename, const char *suffix)

◆ NextElfCallback()

static void dart::bin::NextElfCallback ( void *  callback_data,
intptr_t  loading_unit_id,
void **  write_callback_data,
void **  write_debug_callback_data 
)
static

Definition at line 587 of file gen_snapshot.cc.

590 {
591 NextLoadingUnit(callback_data, loading_unit_id, write_callback_data,
592 write_debug_callback_data, elf_filename, "so");
593}

◆ NextLoadingUnit()

static void dart::bin::NextLoadingUnit ( void *  callback_data,
intptr_t  loading_unit_id,
void **  write_callback_data,
void **  write_debug_callback_data,
const char *  main_filename,
const char *  suffix 
)
static

Definition at line 548 of file gen_snapshot.cc.

553 {
554 char* filename = loading_unit_id == 1
555 ? Utils::StrDup(main_filename)
556 : Utils::SCreate("%s-%" Pd ".part.%s", main_filename,
557 loading_unit_id, suffix);
558 File* file = OpenFile(filename);
559 *write_callback_data = file;
560
561 char* debug_filename = nullptr;
562 if (debugging_info_filename != nullptr) {
563 debug_filename =
564 loading_unit_id == 1
565 ? Utils::StrDup(debugging_info_filename)
566 : Utils::SCreate("%s-%" Pd ".part.so", debugging_info_filename,
567 loading_unit_id);
568 File* debug_file = OpenFile(debug_filename);
569 *write_debug_callback_data = debug_file;
570 }
571
572 WriteLoadingUnitManifest(reinterpret_cast<File*>(callback_data),
573 loading_unit_id, filename, debug_filename);
574 free(debug_filename);
575
576 free(filename);
577}
static void WriteLoadingUnitManifest(File *manifest_file, intptr_t id, const char *path, const char *debug_path=nullptr)
#define Pd
Definition: globals.h:408

◆ NormalSocketFinalizer()

static void dart::bin::NormalSocketFinalizer ( void *  isolate_data,
void *  data 
)
static

Definition at line 1421 of file socket.cc.

1421 {
1422 Socket* socket = reinterpret_cast<Socket*>(data);
1423 const int64_t flags = 1 << kCloseCommand;
1424 socket->Retain(); // Bump reference till we send the message.
1425 EventHandler::SendFromNative(reinterpret_cast<intptr_t>(socket),
1426 socket->port(), flags);
1427 socket->Release(); // Release the reference we just added above.
1428}

◆ NotifyServerState()

void dart::bin::NotifyServerState ( Dart_NativeArguments  args)

Definition at line 39 of file vmservice_impl.cc.

39 {
41 const char* uri_chars;
43 if (Dart_IsError(uri_arg)) {
44 VmService::SetServerAddress("");
46 return;
47 }
48 Dart_Handle result = Dart_StringToCString(uri_arg, &uri_chars);
49 if (Dart_IsError(result)) {
50 VmService::SetServerAddress("");
52 return;
53 }
54 VmService::SetServerAddress(uri_chars);
56}

◆ NSProcessInfoOperatingSystemVersionString()

std::string dart::bin::NSProcessInfoOperatingSystemVersionString ( )

Definition at line 19 of file platform_macos_cocoa.mm.

19 {
20 @autoreleasepool {
21 // `operatingSystemVersionString` has been available since iOS 2.0+ and macOS 10.2+.
22 NSString* version =
23 [[NSProcessInfo processInfo] operatingSystemVersionString];
24 return std::string([version UTF8String]);
25 }
26}

◆ OnExitHook()

static void dart::bin::OnExitHook ( int64_t  exit_code)
static

Definition at line 133 of file main_impl.cc.

133 {
135 Syslog::PrintErr(
136 "A snapshot was requested, but a secondary isolate "
137 "performed a hard exit (%" Pd64 ").\n",
138 exit_code);
139 Platform::Exit(kErrorExitCode);
140 }
141 if (exit_code == 0) {
142 if (Options::gen_snapshot_kind() == kAppJIT) {
143 Snapshot::GenerateAppJIT(Options::snapshot_filename());
144 }
146 }
147}
static Dart_Isolate main_isolate
Definition: main_impl.cc:73
#define Pd64
Definition: globals.h:416

◆ OnIsolateInitialize()

static bool dart::bin::OnIsolateInitialize ( void **  child_callback_data,
char **  error 
)
static

Definition at line 201 of file main_impl.cc.

201 {
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 {
225 result = DartUtils::ResolveScript(Dart_NewStringFromCString(script_uri));
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:
245 *error = Utils::StrDup(Dart_GetError(result));
247 return false;
248}

◆ OnIsolateShutdown()

static void dart::bin::OnIsolateShutdown ( void *  isolate_group_data,
void *  isolate_data 
)
static

Definition at line 907 of file main_impl.cc.

907 {
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}
DART_EXPORT bool Dart_IsFatalError(Dart_Handle handle)
DART_EXPORT Dart_Handle Dart_GetStickyError(void)

◆ OpenFile() [1/2]

static File * dart::bin::OpenFile ( const char *  filename)
static

Definition at line 324 of file gen_snapshot.cc.

324 {
325 File* file = File::Open(nullptr, filename, File::kWriteTruncate);
326 if (file == nullptr) {
327 PrintErrAndExit("Error: Unable to write file: %s\n\n", filename);
328 }
329 return file;
330}

◆ OpenFile() [2/2]

void * dart::bin::OpenFile ( const char *  name,
bool  write 
)

Definition at line 60 of file dart_io_api_impl.cc.

60 {
62}
void * OpenFile(const char *name, bool write)
void write(SkWStream *wStream, const T &text)
Definition: skqp.cpp:188

◆ OpenLoadingUnitManifest()

static File * dart::bin::OpenLoadingUnitManifest ( )
static

Definition at line 495 of file gen_snapshot.cc.

495 {
496 File* manifest_file = OpenFile(loading_unit_manifest_filename);
497 if (!manifest_file->Print("{ \"loadingUnits\": [\n ")) {
498 PrintErrAndExit("Error: Unable to write file: %s\n\n",
499 loading_unit_manifest_filename);
500 }
501 return manifest_file;
502}

◆ OSError_inProgressErrorCode()

void FUNCTION_NAME() dart::bin::OSError_inProgressErrorCode ( Dart_NativeArguments  args)

Definition at line 20 of file utils.cc.

20 {
21 Dart_SetIntegerReturnValue(args, EINPROGRESS);
22}

◆ ParseArguments()

static int dart::bin::ParseArguments ( int  argc,
char **  argv,
CommandLineOptions vm_options,
CommandLineOptions inputs 
)
static

Definition at line 199 of file gen_snapshot.cc.

202 {
203 // Skip the binary name.
204 int i = 1;
205
206 // Parse out the vm options.
207 while ((i < argc) && OptionProcessor::IsValidShortFlag(argv[i])) {
208 if (OptionProcessor::TryProcess(argv[i], vm_options)) {
209 i += 1;
210 continue;
211 }
212 vm_options->AddArgument(argv[i]);
213 i += 1;
214 }
215
216 // Parse out the kernel inputs.
217 while (i < argc) {
218 inputs->AddArgument(argv[i]);
219 i++;
220 }
221
222 if (help) {
223 PrintUsage();
224 Platform::Exit(0);
225 } else if (version) {
226 Syslog::PrintErr("Dart SDK version: %s\n", Dart_VersionString());
227 Platform::Exit(0);
228 }
229
230 // Verify consistency of arguments.
231 if (inputs->count() < 1) {
232 Syslog::PrintErr("At least one input is required\n");
233 return -1;
234 }
235
236 switch (snapshot_kind) {
237 case kCore: {
238 if ((vm_snapshot_data_filename == nullptr) ||
239 (isolate_snapshot_data_filename == nullptr)) {
240 Syslog::PrintErr(
241 "Building a core snapshot requires specifying output files for "
242 "--vm_snapshot_data and --isolate_snapshot_data.\n\n");
243 return -1;
244 }
245 break;
246 }
247 case kApp:
248 case kAppJIT: {
249 if ((load_vm_snapshot_data_filename == nullptr) ||
250 (isolate_snapshot_data_filename == nullptr) ||
251 (isolate_snapshot_instructions_filename == nullptr)) {
252 Syslog::PrintErr(
253 "Building an app JIT snapshot requires specifying input files for "
254 "--load_vm_snapshot_data and --load_vm_snapshot_instructions, an "
255 " output file for --isolate_snapshot_data, and an output "
256 "file for --isolate_snapshot_instructions.\n\n");
257 return -1;
258 }
259 break;
260 }
261 case kAppAOTElf: {
262 if (elf_filename == nullptr) {
263 Syslog::PrintErr(
264 "Building an AOT snapshot as ELF requires specifying "
265 "an output file for --elf.\n\n");
266 return -1;
267 }
268 break;
269 }
270 case kAppAOTAssembly:
271 case kVMAOTAssembly: {
272 if (assembly_filename == nullptr) {
273 Syslog::PrintErr(
274 "Building an AOT snapshot as assembly requires specifying "
275 "an output file for --assembly.\n\n");
276 return -1;
277 }
278 break;
279 }
280 }
281
282 if (!obfuscate && obfuscation_map_filename != nullptr) {
283 Syslog::PrintErr(
284 "--save-obfuscation_map=<...> should only be specified when "
285 "obfuscation is enabled by the --obfuscate flag.\n\n");
286 return -1;
287 }
288
290 if (obfuscate) {
291 Syslog::PrintErr(
292 "Obfuscation can only be enabled when building an AOT snapshot.\n\n");
293 return -1;
294 }
295
296 if (debugging_info_filename != nullptr) {
297 Syslog::PrintErr(
298 "--save-debugging-info=<...> can only be enabled when building an "
299 "AOT snapshot.\n\n");
300 return -1;
301 }
302
303 if (strip) {
304 Syslog::PrintErr(
305 "Stripping can only be enabled when building an AOT snapshot.\n\n");
306 return -1;
307 }
308 }
309
310 return 0;
311}
DART_EXPORT const char * Dart_VersionString(void)
help
Definition: zip.py:79

◆ PasswordCallback()

int dart::bin::PasswordCallback ( char *  buf,
int  size,
int  rwflag,
void *  userdata 
)

Definition at line 384 of file security_context.cc.

384 {
385 char* password = static_cast<char*>(userdata);
386 ASSERT(size == PEM_BUFSIZE);
387 strncpy(buf, password, size);
388 return strlen(password);
389}

◆ Platform_Environment()

void FUNCTION_NAME() dart::bin::Platform_Environment ( Dart_NativeArguments  args)

Definition at line 89 of file platform.cc.

89 {
90 intptr_t count = 0;
91 char** env = Platform::Environment(&count);
92 if (env == nullptr) {
93 OSError error(-1, "Failed to retrieve environment variables.",
95 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error));
96 } else {
99 intptr_t result_idx = 0;
100 for (intptr_t env_idx = 0; env_idx < count; env_idx++) {
101 Dart_Handle str = DartUtils::NewString(env[env_idx]);
102 if (Dart_IsError(str)) {
103 // Silently skip over environment entries that are not valid UTF8
104 // strings.
105 continue;
106 }
107 Dart_Handle error = Dart_ListSetAt(result, result_idx, str);
109 result_idx++;
110 }
112 }
113}
Definition: __init__.py:1

◆ Platform_ExecutableArguments()

void FUNCTION_NAME() dart::bin::Platform_ExecutableArguments ( Dart_NativeArguments  args)

Definition at line 74 of file platform.cc.

74 {
75 int end = Platform::GetScriptIndex();
76 char** argv = Platform::GetArgv();
77 Dart_Handle string_type = DartUtils::GetDartType("dart:core", "String");
78 ThrowIfError(string_type);
81 for (intptr_t i = 1; i < end; i++) {
83 ThrowIfError(str);
85 }
87}
DART_EXPORT Dart_Handle Dart_NewListOfTypeFilled(Dart_Handle element_type, Dart_Handle fill_object, intptr_t length)
DART_EXPORT Dart_Handle Dart_EmptyString(void)

◆ Platform_ExecutableName()

void FUNCTION_NAME() dart::bin::Platform_ExecutableName ( Dart_NativeArguments  args)

Definition at line 56 of file platform.cc.

56 {
57 if (Platform::GetExecutableName() != nullptr) {
59 args, Dart_NewStringFromCString(Platform::GetExecutableName()));
60 } else {
62 }
63}

◆ Platform_GetVersion()

void FUNCTION_NAME() dart::bin::Platform_GetVersion ( Dart_NativeArguments  args)

Definition at line 115 of file platform.cc.

◆ Platform_LocaleName()

void FUNCTION_NAME() dart::bin::Platform_LocaleName ( Dart_NativeArguments  args)

Definition at line 119 of file platform.cc.

119 {
120 const char* locale = Platform::LocaleName();
121 if (locale == nullptr) {
122 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
123 } else {
125 }
126}

◆ Platform_LocalHostname()

void FUNCTION_NAME() dart::bin::Platform_LocalHostname ( Dart_NativeArguments  args)

Definition at line 44 of file platform.cc.

44 {
45 const intptr_t HOSTNAME_LENGTH = 256;
46 char hostname[HOSTNAME_LENGTH];
47 if (Platform::LocalHostname(hostname, HOSTNAME_LENGTH)) {
48 Dart_Handle str = DartUtils::NewString(hostname);
49 ThrowIfError(str);
51 } else {
52 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
53 }
54}

◆ Platform_NumberOfProcessors()

void FUNCTION_NAME() dart::bin::Platform_NumberOfProcessors ( Dart_NativeArguments  args)

Definition at line 17 of file platform.cc.

17 {
18 Dart_SetReturnValue(args, Dart_NewInteger(Platform::NumberOfProcessors()));
19}

◆ Platform_OperatingSystem()

void FUNCTION_NAME() dart::bin::Platform_OperatingSystem ( Dart_NativeArguments  args)

Definition at line 21 of file platform.cc.

21 {
22 Dart_Handle str = DartUtils::NewString(Platform::OperatingSystem());
23 ThrowIfError(str);
25}

◆ Platform_OperatingSystemVersion()

void FUNCTION_NAME() dart::bin::Platform_OperatingSystemVersion ( Dart_NativeArguments  args)

Definition at line 27 of file platform.cc.

27 {
28 const char* version = Platform::OperatingSystemVersion();
29 if (version == nullptr) {
30 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
31 } else {
33 ThrowIfError(str);
35 }
36}

◆ Platform_PathSeparator()

void FUNCTION_NAME() dart::bin::Platform_PathSeparator ( Dart_NativeArguments  args)

Definition at line 38 of file platform.cc.

38 {
39 Dart_Handle str = DartUtils::NewString(File::PathSeparator());
40 ThrowIfError(str);
42}

◆ Platform_ResolvedExecutableName()

void FUNCTION_NAME() dart::bin::Platform_ResolvedExecutableName ( Dart_NativeArguments  args)

Definition at line 65 of file platform.cc.

65 {
66 if (Platform::GetResolvedExecutableName() != nullptr) {
68 args, Dart_NewStringFromCString(Platform::GetResolvedExecutableName()));
69 } else {
71 }
72}

◆ PRINTF_ATTRIBUTE()

dart::bin::PRINTF_ATTRIBUTE ( ,
 
) const

◆ PrintUsage()

static void dart::bin::PrintUsage ( )
static

Definition at line 144 of file gen_snapshot.cc.

144 {
145 Syslog::PrintErr(
146"Usage: gen_snapshot [<vm-flags>] [<options>] <dart-kernel-file> \n"
147" \n"
148"Common options: \n"
149"--help \n"
150" Display this message (add --verbose for information about all VM options).\n"
151"--version \n"
152" Print the SDK version. \n"
153" \n"
154"To create a core snapshot: \n"
155"--snapshot_kind=core \n"
156"--vm_snapshot_data=<output-file> \n"
157"--isolate_snapshot_data=<output-file> \n"
158"<dart-kernel-file> \n"
159" \n"
160"To create an AOT application snapshot as assembly suitable for compilation \n"
161"as a static or dynamic library: \n"
162"--snapshot_kind=app-aot-assembly \n"
163"--assembly=<output-file> \n"
164"[--strip] \n"
165"[--obfuscate] \n"
166"[--save-debugging-info=<debug-filename>] \n"
167"[--save-obfuscation-map=<map-filename>] \n"
168"<dart-kernel-file> \n"
169" \n"
170"To create an AOT application snapshot as an ELF shared library: \n"
171"--snapshot_kind=app-aot-elf \n"
172"--elf=<output-file> \n"
173"[--strip] \n"
174"[--obfuscate] \n"
175"[--save-debugging-info=<debug-filename>] \n"
176"[--save-obfuscation-map=<map-filename>] \n"
177"<dart-kernel-file> \n"
178" \n"
179"AOT snapshots can be obfuscated: that is all identifiers will be renamed \n"
180"during compilation. This mode is enabled with --obfuscate flag. Mapping \n"
181"between original and obfuscated names can be serialized as a JSON array \n"
182"using --save-obfuscation-map=<filename> option. See dartbug.com/30524 \n"
183"for implementation details and limitations of the obfuscation pass. \n"
184" \n"
185"\n");
186 if (verbose) {
187 Syslog::PrintErr(
188"The following options are only used for VM development and may\n"
189"be changed in any future version:\n");
190 const char* print_flags = "--print_flags";
191 char* error = Dart_SetVMFlags(1, &print_flags);
192 ASSERT(error == nullptr);
193 }
194}

◆ Process_ClearSignalHandler()

void FUNCTION_NAME() dart::bin::Process_ClearSignalHandler ( Dart_NativeArguments  args)

Definition at line 313 of file process.cc.

313 {
314 intptr_t signal = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0));
315 Process::ClearSignalHandler(signal, Dart_GetMainPortId());
316}

◆ Process_Exit()

void FUNCTION_NAME() dart::bin::Process_Exit ( Dart_NativeArguments  args)

Definition at line 260 of file process.cc.

260 {
261 int64_t status = 0;
262 // Ignore result if passing invalid argument and just exit 0.
263 DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 0), &status);
264 Process::RunExitHook(status);
266 // We're not doing a full VM shutdown with Dart_Cleanup, which might block,
267 // and other VM threads may be accessing state with global destructors, so
268 // we skip global destructors by using _exit instead of exit.
269 Platform::_Exit(static_cast<int>(status));
270}

◆ Process_GetExitCode()

void FUNCTION_NAME() dart::bin::Process_GetExitCode ( Dart_NativeArguments  args)

Definition at line 279 of file process.cc.

279 {
280 Dart_SetIntegerReturnValue(args, Process::GlobalExitCode());
281}

◆ Process_KillPid()

void FUNCTION_NAME() dart::bin::Process_KillPid ( Dart_NativeArguments  args)

Definition at line 253 of file process.cc.

253 {
254 intptr_t pid = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0));
255 intptr_t signal = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1));
256 bool success = Process::Kill(pid, signal);
258}
static void Kill(Thread *thread, JSONStream *js)
Definition: service.cc:4400

◆ Process_Pid()

void FUNCTION_NAME() dart::bin::Process_Pid ( Dart_NativeArguments  args)

Definition at line 291 of file process.cc.

291 {
292 // Ignore result if passing invalid argument and just set exit code to 0.
293 intptr_t pid = -1;
295 if (Dart_IsNull(process)) {
296 pid = Process::CurrentProcessId();
297 } else {
298 Process::GetProcessIdNativeField(process, &pid);
299 }
301}
static void process(const char *inPath, const char *lexer, const char *token, const char *hPath, const char *cppPath)
Definition: Main.cpp:114

◆ Process_SetExitCode()

void FUNCTION_NAME() dart::bin::Process_SetExitCode ( Dart_NativeArguments  args)

Definition at line 272 of file process.cc.

272 {
273 int64_t status = 0;
274 // Ignore result if passing invalid argument and just set exit code to 0.
275 DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 0), &status);
276 Process::SetGlobalExitCode(status);
277}

◆ Process_SetSignalHandler()

void FUNCTION_NAME() dart::bin::Process_SetSignalHandler ( Dart_NativeArguments  args)

Definition at line 303 of file process.cc.

303 {
304 intptr_t signal = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0));
305 intptr_t id = Process::SetSignalHandler(signal);
306 if (id == -1) {
307 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
308 } else {
310 }
311}

◆ Process_Sleep()

void FUNCTION_NAME() dart::bin::Process_Sleep ( Dart_NativeArguments  args)

Definition at line 283 of file process.cc.

283 {
284 ScopedBlockingCall blocker;
285 int64_t milliseconds = 0;
286 // Ignore result if passing invalid argument and just set exit code to 0.
287 DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 0), &milliseconds);
288 TimerUtils::Sleep(milliseconds);
289}

◆ Process_Start()

void FUNCTION_NAME() dart::bin::Process_Start ( Dart_NativeArguments  args)

Definition at line 76 of file process.cc.

76 {
78 intptr_t process_stdin;
79 intptr_t process_stdout;
80 intptr_t process_stderr;
81 intptr_t exit_event;
82 Namespace* namespc = Namespace::GetNamespace(args, 1);
83 Dart_Handle status_handle = Dart_GetNativeArgument(args, 11);
84 Dart_Handle path_handle = Dart_GetNativeArgument(args, 2);
86
87#if DART_HOST_OS_IOS
88 // Do the iOS check here because the return value of Process::Start is
89 // interpreted as a error with 0 meaning success while `ProcessException`
90 // (which will be constructed with `_errorCode`) interprets 0 to mean that
91 // no OS error code was available.
92 result = DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
94 result = DartUtils::SetStringField(
95 status_handle, "_errorMessage",
96 "Starting new processes is not supported on iOS");
99 return;
100#endif
101
102 // The Dart code verifies that the path implements the String
103 // interface. However, only builtin Strings are handled by
104 // GetStringValue.
105 if (!Dart_IsString(path_handle)) {
106 result = DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
108 result = DartUtils::SetStringField(status_handle, "_errorMessage",
109 "Path must be a builtin string");
112 return;
113 }
114 const char* path = DartUtils::GetStringValue(path_handle);
116 intptr_t args_length = 0;
117 char** string_args =
118 ExtractCStringList(arguments, status_handle,
119 "Arguments must be builtin strings", &args_length);
120 if (string_args == nullptr) {
122 return;
123 }
124 Dart_Handle working_directory_handle = Dart_GetNativeArgument(args, 4);
125 // Defaults to the current working directory.
126 const char* working_directory = nullptr;
127 if (Dart_IsString(working_directory_handle)) {
128 working_directory = DartUtils::GetStringValue(working_directory_handle);
129 } else if (!Dart_IsNull(working_directory_handle)) {
130 result = DartUtils::SetIntegerField(status_handle, "_errorCode", 0);
132 result =
133 DartUtils::SetStringField(status_handle, "_errorMessage",
134 "WorkingDirectory must be a builtin string");
137 return;
138 }
140 intptr_t environment_length = 0;
141 char** string_environment = nullptr;
142 if (!Dart_IsNull(environment)) {
143 string_environment = ExtractCStringList(
144 environment, status_handle,
145 "Environment values must be builtin strings", &environment_length);
146 if (string_environment == nullptr) {
148 return;
149 }
150 }
151 int64_t mode =
152 DartUtils::GetInt64ValueCheckRange(Dart_GetNativeArgument(args, 6), 0, 3);
153 Dart_Handle stdin_handle = Dart_GetNativeArgument(args, 7);
154 Dart_Handle stdout_handle = Dart_GetNativeArgument(args, 8);
155 Dart_Handle stderr_handle = Dart_GetNativeArgument(args, 9);
156 Dart_Handle exit_handle = Dart_GetNativeArgument(args, 10);
157 intptr_t pid = -1;
158 char* os_error_message = nullptr; // Scope allocated by Process::Start.
159
160 int error_code = Process::Start(
161 namespc, path, string_args, args_length, working_directory,
162 string_environment, environment_length,
163 static_cast<ProcessStartMode>(mode), &process_stdout, &process_stdin,
164 &process_stderr, &pid, &exit_event, &os_error_message);
165 if (error_code == 0) {
166 if (Process::ModeHasStdio(static_cast<ProcessStartMode>(mode))) {
167 Socket::SetSocketIdNativeField(stdin_handle, process_stdin,
168 Socket::kFinalizerNormal);
169 Socket::SetSocketIdNativeField(stdout_handle, process_stdout,
170 Socket::kFinalizerNormal);
171 Socket::SetSocketIdNativeField(stderr_handle, process_stderr,
172 Socket::kFinalizerNormal);
173 }
174 if (Process::ModeIsAttached(static_cast<ProcessStartMode>(mode))) {
175 Socket::SetSocketIdNativeField(exit_handle, exit_event,
176 Socket::kFinalizerNormal);
177 }
178 Process::SetProcessIdNativeField(process, pid);
179 } else {
180 result =
181 DartUtils::SetIntegerField(status_handle, "_errorCode", error_code);
183
184 const char* error_message = (os_error_message != nullptr)
185 ? os_error_message
186 : "Failed to get error message";
187 Dart_Handle val = DartUtils::NewString(error_message);
188 if (Dart_IsError(val)) {
189 // Try to clean the message from non-ASCII characters.
190 const intptr_t len = strlen(error_message);
191 char* ascii_message =
192 reinterpret_cast<char*>(Dart_ScopeAllocate(len + 1));
193 for (intptr_t i = 0; i < len; i++) {
194 if (static_cast<uint8_t>(error_message[i]) < 0x80) {
195 ascii_message[i] = error_message[i];
196 } else {
197 ascii_message[i] = '?';
198 }
199 }
200 ascii_message[len] = '\0';
201
202 val = DartUtils::NewStringFormatted(
203 "Failed to start %s. OS returned an error (code %d) which can't be "
204 "fully converted to Dart string (%s): %s",
205 path, error_code, Dart_GetError(val), ascii_message);
206 }
207 result = Dart_SetField(status_handle, DartUtils::NewString("_errorMessage"),
208 val);
210 }
211 Dart_SetBooleanReturnValue(args, error_code == 0);
212}
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_SetField(Dart_Handle container, Dart_Handle name, Dart_Handle value)
static char ** ExtractCStringList(Dart_Handle strings, Dart_Handle status_handle, const char *error_msg, intptr_t *length)
Definition: process.cc:23
ProcessStartMode
Definition: process.h:81

◆ Process_Wait()

void FUNCTION_NAME() dart::bin::Process_Wait ( Dart_NativeArguments  args)

Definition at line 214 of file process.cc.

214 {
216 Socket* process_stdin =
217 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 1));
218 Socket* process_stdout =
219 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 2));
220 Socket* process_stderr =
221 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 3));
222 Socket* exit_event =
223 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 4));
225 intptr_t pid;
226 Process::GetProcessIdNativeField(process, &pid);
227 bool success = Process::Wait(pid, process_stdin->fd(), process_stdout->fd(),
228 process_stderr->fd(), exit_event->fd(), &result);
229 // Process::Wait() closes the file handles, so blow away the fds in the
230 // Sockets so that they don't get picked up by the finalizer on _NativeSocket.
231 process_stdin->CloseFd();
232 process_stdout->CloseFd();
233 process_stderr->CloseFd();
234 exit_event->CloseFd();
235 if (success) {
236 Dart_Handle out = result.stdout_data();
238 Dart_Handle err = result.stderr_data();
239 ThrowIfError(err);
240 Dart_Handle list = Dart_NewList(4);
241 Dart_ListSetAt(list, 0, Dart_NewInteger(pid));
242 Dart_ListSetAt(list, 1, Dart_NewInteger(result.exit_code()));
243 Dart_ListSetAt(list, 2, out);
244 Dart_ListSetAt(list, 3, err);
246 } else {
247 Dart_Handle error = DartUtils::NewDartOSError();
248 Process::Kill(pid, 9);
250 }
251}
intptr_t fd() const
Definition: socket.h:52

◆ ProcessEnvironmentOption()

static bool dart::bin::ProcessEnvironmentOption ( const char *  arg,
CommandLineOptions vm_options 
)
static

Definition at line 61 of file gen_snapshot.cc.

62 {
63 return OptionProcessor::ProcessEnvironmentOption(arg, vm_options,
65}
static bool ProcessEnvironmentOption(const char *arg, CommandLineOptions *vm_options)
Definition: gen_snapshot.cc:61

◆ ProcessInfo_CurrentRSS()

void FUNCTION_NAME() dart::bin::ProcessInfo_CurrentRSS ( Dart_NativeArguments  args)

Definition at line 375 of file process.cc.

375 {
376 int64_t current_rss = Process::CurrentRSS();
377 if (current_rss < 0) {
378 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
379 return;
380 }
381 Dart_SetIntegerReturnValue(args, current_rss);
382}

◆ ProcessInfo_MaxRSS()

void FUNCTION_NAME() dart::bin::ProcessInfo_MaxRSS ( Dart_NativeArguments  args)

Definition at line 384 of file process.cc.

384 {
385 int64_t max_rss = Process::MaxRSS();
386 if (max_rss < 0) {
387 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
388 return;
389 }
391}

◆ RawSocketOption_GetOptionValue()

void FUNCTION_NAME() dart::bin::RawSocketOption_GetOptionValue ( Dart_NativeArguments  args)

Definition at line 1343 of file socket.cc.

1343 {
1345 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0)));
1346 switch (key) {
1347 case DART_SOL_SOCKET:
1348 Dart_SetIntegerReturnValue(args, SOL_SOCKET);
1349 break;
1350 case DART_IPPROTO_IP:
1351 Dart_SetIntegerReturnValue(args, IPPROTO_IP);
1352 break;
1354 Dart_SetIntegerReturnValue(args, IP_MULTICAST_IF);
1355 break;
1356 case DART_IPPROTO_IPV6:
1357 Dart_SetIntegerReturnValue(args, IPPROTO_IPV6);
1358 break;
1360 Dart_SetIntegerReturnValue(args, IPV6_MULTICAST_IF);
1361 break;
1362 case DART_IPPROTO_TCP:
1363 Dart_SetIntegerReturnValue(args, IPPROTO_TCP);
1364 break;
1365 case DART_IPPROTO_UDP:
1366 Dart_SetIntegerReturnValue(args, IPPROTO_UDP);
1367 break;
1368 default:
1370 "option to getOptionValue() is outside expected range"));
1371 break;
1372 }
1373}
_RawSocketOptions
Definition: socket.cc:1333

◆ ReadFile() [1/2]

static void dart::bin::ReadFile ( const char *  filename,
uint8_t **  buffer,
intptr_t *  size 
)
static

Definition at line 342 of file gen_snapshot.cc.

342 {
343 File* file = File::Open(nullptr, filename, File::kRead);
344 if (file == nullptr) {
345 PrintErrAndExit("Error: Unable to read file: %s\n", filename);
346 }
347 RefCntReleaseScope<File> rs(file);
348 *size = file->Length();
349 *buffer = reinterpret_cast<uint8_t*>(malloc(*size));
350 if (!file->ReadFully(*buffer, *size)) {
351 PrintErrAndExit("Error: Unable to read file: %s\n", filename);
352 }
353}

◆ ReadFile() [2/2]

void dart::bin::ReadFile ( uint8_t **  data,
intptr_t *  file_len,
void *  stream 
)

Definition at line 63 of file dart_io_api_impl.cc.

63 {
65}
void ReadFile(uint8_t **data, intptr_t *file_len, void *stream)

◆ ReadFileFully()

static uint8_t * dart::bin::ReadFileFully ( const char *  filename,
intptr_t *  file_len,
const char **  error_msg 
)
static

Definition at line 329 of file dartutils.cc.

331 {
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}
#define SET_ERROR_MSG(error_msg, format,...)
Definition: dartutils.cc:323
fml::UniqueFD OpenFile(const char *path, bool create_if_necessary, FilePermission permission)
This can open a directory on POSIX, but not on Windows.
Definition: file_posix.cc:66

◆ RegisterKernelBlob()

static const char * dart::bin::RegisterKernelBlob ( const uint8_t *  kernel_buffer,
intptr_t  kernel_buffer_size 
)
static

Definition at line 898 of file main_impl.cc.

899 {
900 return dfe.RegisterKernelBlob(kernel_buffer, kernel_buffer_size);
901}
const char * RegisterKernelBlob(const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
Definition: dfe.cc:482

◆ ReleaseCertificate()

static void dart::bin::ReleaseCertificate ( void *  isolate_data,
void *  context_pointer 
)
static

Definition at line 129 of file security_context.cc.

129 {
130 X509* cert = reinterpret_cast<X509*>(context_pointer);
131 X509_free(cert);
132}

◆ ReleaseFile()

static void dart::bin::ReleaseFile ( void *  isolate_callback_data,
void *  peer 
)
static

Definition at line 74 of file file.cc.

74 {
75 File* file = reinterpret_cast<File*>(peer);
76 file->Release();
77}

◆ ReleaseListing()

static void dart::bin::ReleaseListing ( void *  isolate_callback_data,
void *  peer 
)
static

Definition at line 167 of file directory.cc.

167 {
168 AsyncDirectoryListing* listing =
169 reinterpret_cast<AsyncDirectoryListing*>(peer);
170 listing->Release();
171}

◆ ReleaseNamespace()

static void dart::bin::ReleaseNamespace ( void *  isolate_callback_data,
void *  peer 
)
static

Definition at line 19 of file namespace.cc.

19 {
20 Namespace* namespc = reinterpret_cast<Namespace*>(peer);
21 ASSERT(namespc != nullptr);
22 namespc->Release();
23}

◆ ResolveSymbol()

static void * dart::bin::ResolveSymbol ( void *  handle,
const char *  symbol,
char **  error 
)
static

Definition at line 216 of file native_assets_api_impl.cc.

216 {
217#if defined(DART_HOST_OS_WINDOWS)
218 if (handle == kWindowsDynamicLibraryProcessPtr) {
219 return LookupSymbolInProcess(symbol, error);
220 }
221#endif
222 return Utils::ResolveSymbolInDynamicLibrary(handle, symbol, error);
223}

◆ ResourceHandleImpl_toFile()

void FUNCTION_NAME() dart::bin::ResourceHandleImpl_toFile ( Dart_NativeArguments  args)

Definition at line 1613 of file socket.cc.

1613 {
1614#if defined(DART_HOST_OS_WINDOWS) || defined(DART_HOST_OS_FUCHSIA)
1616 DartUtils::NewDartUnsupportedError(
1617 "This is not supported on this operating system"));
1618#else
1620 Dart_Handle handle_field = ThrowIfError(
1621 Dart_GetField(handle_object, DartUtils::NewString("_handle")));
1622 intptr_t fd = DartUtils::GetIntegerValue(handle_field);
1623
1624 Dart_Handle random_access_file_type = ThrowIfError(
1625 DartUtils::GetDartType(DartUtils::kIOLibURL, "_RandomAccessFile"));
1626
1627 Dart_Handle dart_new_args[2];
1628 dart_new_args[1] = ThrowIfError(Dart_NewStringFromCString("<handle>"));
1629
1630 File* file = File::OpenFD(fd);
1631
1632 Dart_Handle result = Dart_NewInteger(reinterpret_cast<intptr_t>(file));
1633 if (Dart_IsError(result)) {
1634 file->Release();
1636 }
1637 dart_new_args[0] = result;
1638
1639 Dart_Handle new_random_access_file =
1640 Dart_New(random_access_file_type,
1641 /*constructor_name=*/Dart_Null(),
1642 /*number_of_arguments=*/2, dart_new_args);
1643 if (Dart_IsError(new_random_access_file)) {
1644 file->Release();
1645 Dart_PropagateError(new_random_access_file);
1646 }
1647
1648 Dart_SetReturnValue(args, new_random_access_file);
1649#endif // defined(DART_HOST_OS_WINDOWS) || defined(DART_HOST_OS_FUCHSIA)
1650}
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_New(Dart_Handle type, Dart_Handle constructor_name, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_GetField(Dart_Handle container, Dart_Handle name)

◆ ResourceHandleImpl_toRawDatagramSocket()

void FUNCTION_NAME() dart::bin::ResourceHandleImpl_toRawDatagramSocket ( Dart_NativeArguments  args)

Definition at line 1690 of file socket.cc.

1691 {
1693 DartUtils::NewDartUnsupportedError(
1694 "This is not supported on this operating system"));
1695}

◆ ResourceHandleImpl_toRawSocket()

void FUNCTION_NAME() dart::bin::ResourceHandleImpl_toRawSocket ( Dart_NativeArguments  args)

Definition at line 1658 of file socket.cc.

1658 {
1659#if defined(DART_HOST_OS_WINDOWS) || defined(DART_HOST_OS_FUCHSIA)
1661 DartUtils::NewDartUnsupportedError(
1662 "This is not supported on this operating system"));
1663#else
1665 Dart_Handle handle_field = ThrowIfError(
1666 Dart_GetField(handle_object, DartUtils::NewString("_handle")));
1667 intptr_t fd = DartUtils::GetIntegerValue(handle_field);
1668
1669 SocketAddress* socket_address = reinterpret_cast<SocketAddress*>(
1671 ASSERT(socket_address != nullptr);
1672 SocketBase::GetSocketName(fd, socket_address);
1673
1674 // return a list describing socket_address: (type, hostname, typed_data_addr,
1675 // fd)
1678 list, 0, ThrowIfError(Dart_NewInteger(socket_address->GetType()))));
1680 list, 1,
1681 ThrowIfError(Dart_NewStringFromCString(socket_address->as_string()))));
1683 list, 2, SocketAddress::ToTypedData(socket_address->addr())));
1685
1687#endif // defined(DART_HOST_OS_WINDOWS) || defined(DART_HOST_OS_FUCHSIA)
1688}
const char * as_string() const
Definition: socket_base.h:67
const RawAddr & addr() const
Definition: socket_base.h:68

◆ ResourceHandleImpl_toSocket()

void FUNCTION_NAME() dart::bin::ResourceHandleImpl_toSocket ( Dart_NativeArguments  args)

Definition at line 1652 of file socket.cc.

1652 {
1654 DartUtils::NewDartUnsupportedError(
1655 "This is not supported on this operating system"));
1656}

◆ RunMainIsolate()

void dart::bin::RunMainIsolate ( const char *  script_name,
const char *  package_config_override,
CommandLineOptions dart_options 
)

Definition at line 991 of file main_impl.cc.

993 {
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;
1037 Process::TerminateExitCodeHandler();
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}
static std::string base_name(const std::string &path)
Definition: SkSLMinify.cpp:46
Dart_Handle CreateRuntimeOptions()
Definition: dartutils.cc:58
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_RunLoop(void)
DART_EXPORT bool Dart_IsClosure(Dart_Handle object)
DART_EXPORT Dart_Handle Dart_RootLibrary(void)
DART_EXPORT bool Dart_IsCompilationError(Dart_Handle handle)
void ErrorExit(int exit_code, const char *format,...)
Definition: error_exit.cc:18
static void SetProcessName()
Definition: runner.cc:119

◆ SecureSocket_Connect()

void FUNCTION_NAME() dart::bin::SecureSocket_Connect ( Dart_NativeArguments  args)

Definition at line 103 of file secure_socket_filter.cc.

103 {
104 Dart_Handle host_name_object = ThrowIfError(Dart_GetNativeArgument(args, 1));
106 bool is_server = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3));
107 bool request_client_certificate =
108 DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 4));
109 bool require_client_certificate =
110 DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 5));
111 Dart_Handle protocols_handle = ThrowIfError(Dart_GetNativeArgument(args, 6));
112
113 const char* host_name = nullptr;
114 // TODO(whesse): Is truncating a Dart string containing \0 what we want?
115 ThrowIfError(Dart_StringToCString(host_name_object, &host_name));
116
117 SSLCertContext* context = nullptr;
118 if (!Dart_IsNull(context_object)) {
120 context_object, SSLCertContext::kSecurityContextNativeFieldIndex,
121 reinterpret_cast<intptr_t*>(&context)));
122 }
123
124 // The protocols_handle is guaranteed to be a valid Uint8List.
125 // It will have the correct length encoding of the protocols array.
126 ASSERT(!Dart_IsNull(protocols_handle));
127 GetFilter(args)->Connect(host_name, context, is_server,
128 request_client_certificate,
129 require_client_certificate, protocols_handle);
130}
void Connect(const char *hostname, SSLCertContext *context, bool is_server, bool request_client_certificate, bool require_client_certificate, Dart_Handle protocols_handle)
static SSLFilter * GetFilter(Dart_NativeArguments args)

◆ SecureSocket_Destroy()

void FUNCTION_NAME() dart::bin::SecureSocket_Destroy ( Dart_NativeArguments  args)

Definition at line 132 of file secure_socket_filter.cc.

132 {
133 SSLFilter* filter = GetFilter(args);
134 // There are two paths that can clean up an SSLFilter object. First,
135 // there is this explicit call to Destroy(), called from
136 // _SecureFilter.destroy() in Dart code. After a call to destroy(), the Dart
137 // code maintains the invariant that there will be no further SSLFilter
138 // requests sent to the IO Service. Therefore, the internals of the SSLFilter
139 // are safe to deallocate, but not the SSLFilter itself, which is already
140 // set up to be cleaned up by the finalizer.
141 //
142 // The second path is through the finalizer, which we have to do in case
143 // some mishap prevents a call to _SecureFilter.destroy().
144 filter->Destroy();
145}

◆ SecureSocket_FilterPointer()

void FUNCTION_NAME() dart::bin::SecureSocket_FilterPointer ( Dart_NativeArguments  args)

Definition at line 213 of file secure_socket_filter.cc.

213 {
214 SSLFilter* filter = GetFilter(args);
215 // This filter pointer is passed to the IO Service thread. The IO Service
216 // thread must Release() the pointer when it is done with it.
217 filter->Retain();
218 intptr_t filter_pointer = reinterpret_cast<intptr_t>(filter);
219 Dart_SetReturnValue(args, Dart_NewInteger(filter_pointer));
220}

◆ SecureSocket_GetSelectedProtocol()

void FUNCTION_NAME() dart::bin::SecureSocket_GetSelectedProtocol ( Dart_NativeArguments  args)

Definition at line 173 of file secure_socket_filter.cc.

174 {
176}
void GetSelectedProtocol(Dart_NativeArguments args)

◆ SecureSocket_Handshake()

void FUNCTION_NAME() dart::bin::SecureSocket_Handshake ( Dart_NativeArguments  args)

Definition at line 147 of file secure_socket_filter.cc.

147 {
150
151 Dart_Port port_id;
153 int result = GetFilter(args)->Handshake(port_id);
155}
int Handshake(Dart_Port reply_port)
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 port
Definition: switches.h:87

◆ SecureSocket_Init()

void FUNCTION_NAME() dart::bin::SecureSocket_Init ( Dart_NativeArguments  args)

Definition at line 86 of file secure_socket_filter.cc.

86 {
88 SSLFilter* filter = new SSLFilter();
89 Dart_Handle err = SetFilter(args, filter);
90 if (Dart_IsError(err)) {
91 filter->Release();
93 }
94 err = filter->Init(dart_this);
95 if (Dart_IsError(err)) {
96 // The finalizer was set up by SetFilter. It will delete `filter` if there
97 // is an error.
98 filter->Destroy();
100 }
101}
static Dart_Handle SetFilter(Dart_NativeArguments args, SSLFilter *filter)

◆ SecureSocket_MarkAsTrusted()

void FUNCTION_NAME() dart::bin::SecureSocket_MarkAsTrusted ( Dart_NativeArguments  args)

Definition at line 157 of file secure_socket_filter.cc.

157 {
159}
void MarkAsTrusted(Dart_NativeArguments args)

◆ SecureSocket_NewX509CertificateWrapper()

void FUNCTION_NAME() dart::bin::SecureSocket_NewX509CertificateWrapper ( Dart_NativeArguments  args)

Definition at line 161 of file secure_socket_filter.cc.

162 {
163// This is to be used only in conjunction with certificate trust evaluator
164// running asynchronously, which is only used on mac/ios at the moment.
165#if !defined(DART_HOST_OS_MACOS)
166 FATAL("This is to be used only on mac/ios platforms");
167#endif
168 intptr_t x509_pointer = DartUtils::GetNativeIntptrArgument(args, 0);
169 X509* x509 = reinterpret_cast<X509*>(x509_pointer);
170 Dart_SetReturnValue(args, X509Helper::WrappedX509Certificate(x509));
171}

◆ SecureSocket_PeerCertificate()

void FUNCTION_NAME() dart::bin::SecureSocket_PeerCertificate ( Dart_NativeArguments  args)

Definition at line 208 of file secure_socket_filter.cc.

208 {
209 Dart_Handle cert = ThrowIfError(GetFilter(args)->PeerCertificate());
211}

◆ SecureSocket_RegisterBadCertificateCallback()

void FUNCTION_NAME() dart::bin::SecureSocket_RegisterBadCertificateCallback ( Dart_NativeArguments  args)

Definition at line 189 of file secure_socket_filter.cc.

190 {
193 Dart_ThrowException(DartUtils::NewDartArgumentError(
194 "Illegal argument to RegisterBadCertificateCallback"));
195 }
197}
void RegisterBadCertificateCallback(Dart_Handle callback)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback

◆ SecureSocket_RegisterHandshakeCompleteCallback()

void FUNCTION_NAME() dart::bin::SecureSocket_RegisterHandshakeCompleteCallback ( Dart_NativeArguments  args)

Definition at line 178 of file secure_socket_filter.cc.

179 {
180 Dart_Handle handshake_complete =
182 if (!Dart_IsClosure(handshake_complete)) {
183 Dart_ThrowException(DartUtils::NewDartArgumentError(
184 "Illegal argument to RegisterHandshakeCompleteCallback"));
185 }
187}
void RegisterHandshakeCompleteCallback(Dart_Handle handshake_complete)

◆ SecureSocket_RegisterKeyLogPort()

void FUNCTION_NAME() dart::bin::SecureSocket_RegisterKeyLogPort ( Dart_NativeArguments  args)

Definition at line 199 of file secure_socket_filter.cc.

199 {
202
203 Dart_Port port_id;
206}
void RegisterKeyLogPort(Dart_Port key_log_port)

◆ SecurityContext_Allocate()

void FUNCTION_NAME() dart::bin::SecurityContext_Allocate ( Dart_NativeArguments  args)

Definition at line 825 of file security_context.cc.

825 {
826 SSLFilter::InitializeLibrary();
827 SSL_CTX* ctx = SSL_CTX_new(TLS_method());
828 SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, SSLCertContext::CertificateCallback);
829 SSL_CTX_set_keylog_callback(ctx, SSLCertContext::KeyLogCallback);
830 SSL_CTX_set_min_proto_version(ctx, TLS1_2_VERSION);
831 SSL_CTX_set_cipher_list(ctx, "HIGH:MEDIUM");
832 SSLCertContext* context = new SSLCertContext(ctx);
833 Dart_Handle err = SetSecurityContext(args, context);
834 if (Dart_IsError(err)) {
835 delete context;
837 }
838}
static Dart_Handle SetSecurityContext(Dart_NativeArguments args, SSLCertContext *context)

◆ SecurityContext_SetAllowTlsRenegotiation()

void FUNCTION_NAME() dart::bin::SecurityContext_SetAllowTlsRenegotiation ( Dart_NativeArguments  args)

Definition at line 888 of file security_context.cc.

889 {
890 SSLCertContext* context = SSLCertContext::GetSecurityContext(args);
891 Dart_Handle allow_tls_handle = ThrowIfError(Dart_GetNativeArgument(args, 1));
892
893 ASSERT(context != nullptr);
894 ASSERT(allow_tls_handle != nullptr);
895
896 if (!Dart_IsBoolean(allow_tls_handle)) {
897 Dart_ThrowException(DartUtils::NewDartArgumentError(
898 "Non-boolean argument passed to SetAllowTlsRenegotiation"));
899 }
900 bool allow = DartUtils::GetBooleanValue(allow_tls_handle);
901 context->set_allow_tls_renegotiation(allow);
902}
void set_allow_tls_renegotiation(bool allow)
DART_EXPORT bool Dart_IsBoolean(Dart_Handle object)

◆ SecurityContext_SetAlpnProtocols()

void FUNCTION_NAME() dart::bin::SecurityContext_SetAlpnProtocols ( Dart_NativeArguments  args)

Definition at line 932 of file security_context.cc.

933 {
934 SSLCertContext* context = SSLCertContext::GetSecurityContext(args);
935 Dart_Handle protocols_handle = ThrowIfError(Dart_GetNativeArgument(args, 1));
936 Dart_Handle is_server_handle = ThrowIfError(Dart_GetNativeArgument(args, 2));
937 if (Dart_IsBoolean(is_server_handle)) {
938 bool is_server = DartUtils::GetBooleanValue(is_server_handle);
939 SSLCertContext::SetAlpnProtocolList(protocols_handle, nullptr, context,
940 is_server);
941 } else {
942 Dart_ThrowException(DartUtils::NewDartArgumentError(
943 "Non-boolean is_server argument passed to SetAlpnProtocols"));
944 }
945}

◆ SecurityContext_SetClientAuthoritiesBytes()

void FUNCTION_NAME() dart::bin::SecurityContext_SetClientAuthoritiesBytes ( Dart_NativeArguments  args)

Definition at line 851 of file security_context.cc.

852 {
853 SSLCertContext* context = SSLCertContext::GetSecurityContext(args);
854 Dart_Handle client_authorities_bytes =
856 const char* password = SSLCertContext::GetPasswordArgument(args, 2);
857
858 ASSERT(context != nullptr);
859 ASSERT(password != nullptr);
860
861 context->SetClientAuthoritiesBytes(client_authorities_bytes, password);
862}
void SetClientAuthoritiesBytes(Dart_Handle client_authorities_bytes, const char *password)

◆ SecurityContext_SetTrustedCertificatesBytes()

void FUNCTION_NAME() dart::bin::SecurityContext_SetTrustedCertificatesBytes ( Dart_NativeArguments  args)

Definition at line 840 of file security_context.cc.

841 {
842 SSLCertContext* context = SSLCertContext::GetSecurityContext(args);
844 const char* password = SSLCertContext::GetPasswordArgument(args, 2);
845
846 ASSERT(context != nullptr);
847 ASSERT(password != nullptr);
848 context->SetTrustedCertificatesBytes(cert_bytes, password);
849}
void SetTrustedCertificatesBytes(Dart_Handle cert_bytes, const char *password)

◆ SecurityContext_TrustBuiltinRoots()

void FUNCTION_NAME() dart::bin::SecurityContext_TrustBuiltinRoots ( Dart_NativeArguments  args)

Definition at line 879 of file security_context.cc.

880 {
881 SSLCertContext* context = SSLCertContext::GetSecurityContext(args);
882
883 ASSERT(context != nullptr);
884
885 context->TrustBuiltinRoots();
886}

◆ SecurityContext_UseCertificateChainBytes()

void FUNCTION_NAME() dart::bin::SecurityContext_UseCertificateChainBytes ( Dart_NativeArguments  args)

Definition at line 864 of file security_context.cc.

865 {
866 SSLCertContext* context = SSLCertContext::GetSecurityContext(args);
867 Dart_Handle cert_chain_bytes = ThrowIfError(Dart_GetNativeArgument(args, 1));
868 const char* password = SSLCertContext::GetPasswordArgument(args, 2);
869
870 ASSERT(context != nullptr);
871 ASSERT(password != nullptr);
872
873 int status = context->UseCertificateChainBytes(cert_chain_bytes, password);
874
875 SecureSocketUtils::CheckStatus(status, "TlsException",
876 "Failure in useCertificateChainBytes");
877}
int UseCertificateChainBytes(Dart_Handle cert_chain_bytes, const char *password)

◆ SecurityContext_UsePrivateKeyBytes()

void FUNCTION_NAME() dart::bin::SecurityContext_UsePrivateKeyBytes ( Dart_NativeArguments  args)

Definition at line 797 of file security_context.cc.

798 {
799 SSLCertContext* context = SSLCertContext::GetSecurityContext(args);
800 const char* password = SSLCertContext::GetPasswordArgument(args, 2);
801
802 int status;
803 EVP_PKEY* key;
804 {
806 key = GetPrivateKey(bio.bio(), password);
807 }
808 if (key == nullptr) {
809 Dart_ThrowException(DartUtils::NewDartArgumentError(
810 "Expected private key, but none was found"));
811 }
812 status = SSL_CTX_use_PrivateKey(context->context(), key);
813 // SSL_CTX_use_PrivateKey increments the reference count of key on success,
814 // so we have to call EVP_PKEY_free on both success and failure.
815 EVP_PKEY_free(key);
816
817 // TODO(24184): Handle different expected errors here - file missing,
818 // incorrect password, file not a PEM, and throw exceptions.
819 // SecureSocketUtils::CheckStatus should also throw an exception in uncaught
820 // cases.
821 SecureSocketUtils::CheckStatus(status, "TlsException",
822 "Failure in usePrivateKeyBytes");
823}
SSL_CTX * context() const
static EVP_PKEY * GetPrivateKey(BIO *bio, const char *password)

◆ ServerSocket_Accept()

void FUNCTION_NAME() dart::bin::ServerSocket_Accept ( Dart_NativeArguments  args)

Definition at line 1044 of file socket.cc.

1044 {
1045 Socket* socket =
1046 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
1047 intptr_t new_socket = ServerSocket::Accept(socket->fd());
1048 if (new_socket >= 0) {
1049 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 1), new_socket,
1050 Socket::kFinalizerNormal);
1052 } else {
1054 }
1055}
DART_EXPORT Dart_Handle Dart_True(void)
DART_EXPORT Dart_Handle Dart_False(void)

◆ ServerSocket_CreateBindListen()

void FUNCTION_NAME() dart::bin::ServerSocket_CreateBindListen ( Dart_NativeArguments  args)

Definition at line 995 of file socket.cc.

995 {
997 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 1), &addr);
998 int64_t port = DartUtils::GetInt64ValueCheckRange(
999 Dart_GetNativeArgument(args, 2), 0, 65535);
1000 SocketAddress::SetAddrPort(&addr, port);
1001 int64_t backlog = DartUtils::GetInt64ValueCheckRange(
1002 Dart_GetNativeArgument(args, 3), 0, 65535);
1003 bool v6_only = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 4));
1004 bool shared = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 5));
1005 if (addr.addr.sa_family == AF_INET6) {
1006 Dart_Handle scope_id_arg = Dart_GetNativeArgument(args, 6);
1007 int64_t scope_id =
1008 DartUtils::GetInt64ValueCheckRange(scope_id_arg, 0, 65535);
1009 SocketAddress::SetAddrScope(&addr, scope_id);
1010 }
1011
1012 Dart_Handle socket_object = Dart_GetNativeArgument(args, 0);
1013 Dart_Handle result = ListeningSocketRegistry::Instance()->CreateBindListen(
1014 socket_object, addr, backlog, v6_only, shared);
1016}

◆ ServerSocket_CreateUnixDomainBindListen()

void FUNCTION_NAME() dart::bin::ServerSocket_CreateUnixDomainBindListen ( Dart_NativeArguments  args)

Definition at line 1018 of file socket.cc.

1019 {
1020#if defined(DART_HOST_OS_WINDOWS)
1021 OSError os_error(
1022 -1, "Unix domain sockets are not available on this operating system.",
1024 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
1025#else
1027 if (Dart_IsNull(address)) {
1028 Dart_SetReturnValue(args, DartUtils::NewDartArgumentError(
1029 "expect address to be of type String"));
1030 }
1031 const char* path = DartUtils::GetStringValue(address);
1032 int64_t backlog = DartUtils::GetInt64ValueCheckRange(
1033 Dart_GetNativeArgument(args, 2), 0, 65535);
1034 bool shared = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3));
1035 Namespace* namespc = Namespace::GetNamespace(args, 4);
1036 Dart_Handle socket_object = Dart_GetNativeArgument(args, 0);
1038 ListeningSocketRegistry::Instance()->CreateUnixDomainBindListen(
1039 socket_object, namespc, path, backlog, shared);
1041#endif // defined(DART_HOST_OS_WINDOWS)
1042}

◆ ServiceStreamCancelCallback()

static void dart::bin::ServiceStreamCancelCallback ( const char *  stream_id)
static

Definition at line 940 of file main_impl.cc.

940 {
941 if (strcmp(stream_id, kStdoutStreamId) == 0) {
942 SetCaptureStdout(false);
943 } else if (strcmp(stream_id, kStderrStreamId) == 0) {
944 SetCaptureStderr(false);
945 }
946}
void SetCaptureStdout(bool value)
Definition: file_support.cc:25
static constexpr const char * kStderrStreamId
Definition: main_impl.cc:927
static constexpr const char * kStdoutStreamId
Definition: main_impl.cc:926
void SetCaptureStderr(bool value)
Definition: file_support.cc:29

◆ ServiceStreamListenCallback()

static bool dart::bin::ServiceStreamListenCallback ( const char *  stream_id)
static

Definition at line 929 of file main_impl.cc.

929 {
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}

◆ SetCaptureStderr()

void dart::bin::SetCaptureStderr ( bool  value)

Definition at line 29 of file file_support.cc.

29 {
31}
static bool capture_stderr
Definition: file_support.cc:23

◆ SetCaptureStdout()

void dart::bin::SetCaptureStdout ( bool  value)

Definition at line 25 of file file_support.cc.

25 {
27}
static bool capture_stdout
Definition: file_support.cc:20

◆ SetClientAuthorities()

static int dart::bin::SetClientAuthorities ( SSL_CTX *  context,
ScopedMemBIO bio,
const char *  password 
)
static

Definition at line 291 of file security_context.cc.

293 {
294 int status = SetClientAuthoritiesPEM(context, bio->bio());
295 if (status == 0) {
296 if (SecureSocketUtils::NoPEMStartLine()) {
297 ERR_clear_error();
298 BIO_reset(bio->bio());
299 status = SetClientAuthoritiesPKCS12(context, bio, password);
300 }
301 } else {
302 // The PEM file was successfully parsed.
303 ERR_clear_error();
304 }
305 return status;
306}
static int SetClientAuthoritiesPEM(SSL_CTX *context, BIO *bio)
static int SetClientAuthoritiesPKCS12(SSL_CTX *context, ScopedMemBIO *bio, const char *password)

◆ SetClientAuthoritiesPEM()

static int dart::bin::SetClientAuthoritiesPEM ( SSL_CTX *  context,
BIO *  bio 
)
static

Definition at line 277 of file security_context.cc.

277 {
278 int status = 0;
279 X509* cert = nullptr;
280 while ((cert = PEM_read_bio_X509(bio, nullptr, nullptr, nullptr)) !=
281 nullptr) {
282 status = SSL_CTX_add_client_CA(context, cert);
283 X509_free(cert); // The name has been extracted.
284 if (status == 0) {
285 return status;
286 }
287 }
288 return SecureSocketUtils::NoPEMStartLine() ? status : 0;
289}

◆ SetClientAuthoritiesPKCS12()

static int dart::bin::SetClientAuthoritiesPKCS12 ( SSL_CTX *  context,
ScopedMemBIO bio,
const char *  password 
)
static

Definition at line 251 of file security_context.cc.

253 {
254 CBS cbs;
255 CBS_init(&cbs, bio->data(), bio->length());
256
257 EVP_PKEY* key = nullptr;
258 ScopedX509Stack cert_stack(sk_X509_new_null());
259 int status = PKCS12_get_key_and_certs(&key, cert_stack.get(), &cbs, password);
260 if (status == 0) {
261 return status;
262 }
263
264 X509* ca;
265 while ((ca = sk_X509_shift(cert_stack.get())) != nullptr) {
266 status = SSL_CTX_add_client_CA(context, ca);
267 // SSL_CTX_add_client_CA increments the reference count of ca on success.
268 X509_free(ca); // The name has been extracted.
269 if (status == 0) {
270 return status;
271 }
272 }
273
274 return status;
275}

◆ SetExecutableArguments()

void dart::bin::SetExecutableArguments ( int  script_index,
char **  argv 
)

Definition at line 49 of file dart_io_api_impl.cc.

49 {
51}
void SetExecutableArguments(int script_index, char **argv)

◆ SetExecutableName()

void dart::bin::SetExecutableName ( const char *  executable_name)

Definition at line 45 of file dart_io_api_impl.cc.

45 {
46 Platform::SetExecutableName(executable_name);
47}
void SetExecutableName(const char *executable_name)

◆ SetFile()

static void dart::bin::SetFile ( Dart_Handle  dart_this,
intptr_t  file_pointer 
)
static

Definition at line 51 of file file.cc.

51 {
52 DEBUG_ASSERT(IsFile(dart_this));
54 dart_this, kFileNativeFieldIndex, file_pointer);
56}

◆ SetFilter()

static Dart_Handle dart::bin::SetFilter ( Dart_NativeArguments  args,
SSLFilter filter 
)
static

Definition at line 72 of file secure_socket_filter.cc.

72 {
73 ASSERT(filter != nullptr);
75 RETURN_IF_ERROR(dart_this);
76 ASSERT(Dart_IsInstance(dart_this));
78 dart_this, SSLFilter::kSSLFilterNativeFieldIndex,
79 reinterpret_cast<intptr_t>(filter));
80 RETURN_IF_ERROR(err);
81 Dart_NewFinalizableHandle(dart_this, reinterpret_cast<void*>(filter),
82 SSLFilter::kApproximateSize, DeleteFilter);
83 return Dart_Null();
84}
static void DeleteFilter(void *isolate_data, void *context_pointer)
#define RETURN_IF_ERROR(handle)

◆ SetSecurityContext()

static Dart_Handle dart::bin::SetSecurityContext ( Dart_NativeArguments  args,
SSLCertContext context 
)
static

Definition at line 114 of file security_context.cc.

115 {
117 RETURN_IF_ERROR(dart_this);
118 ASSERT(Dart_IsInstance(dart_this));
120 dart_this, SSLCertContext::kSecurityContextNativeFieldIndex,
121 reinterpret_cast<intptr_t>(context));
122 RETURN_IF_ERROR(err);
123 Dart_NewFinalizableHandle(dart_this, context,
124 SSLCertContext::kApproximateSize,
126 return Dart_Null();
127}
static void DeleteSecurityContext(void *isolate_data, void *context_pointer)
#define RETURN_IF_ERROR(handle)

◆ SetSystemTempDirectory()

void dart::bin::SetSystemTempDirectory ( const char *  system_temp)

Definition at line 41 of file dart_io_api_impl.cc.

41 {
42 Directory::SetSystemTemp(system_temp);
43}

◆ SetTrustedCertificatesBytesPEM()

static int dart::bin::SetTrustedCertificatesBytesPEM ( SSL_CTX *  context,
BIO *  bio 
)
static

Definition at line 207 of file security_context.cc.

207 {
208 X509_STORE* store = SSL_CTX_get_cert_store(context);
209
210 int status = 0;
211 X509* cert = nullptr;
212 while ((cert = PEM_read_bio_X509(bio, nullptr, nullptr, nullptr)) !=
213 nullptr) {
214 status = X509_STORE_add_cert(store, cert);
215 // X509_STORE_add_cert increments the reference count of cert on success.
216 X509_free(cert);
217 if (status == 0) {
218 return status;
219 }
220 }
221
222 // If no PEM start line is found, it means that we read to the end of the
223 // file, or that the file isn't PEM. In the first case, status will be
224 // non-zero indicating success. In the second case, status will be 0,
225 // indicating that we should try to read as PKCS12. If there is some other
226 // error, we return it up to the caller.
227 return SecureSocketUtils::NoPEMStartLine() ? status : 0;
228}
SI void store(P *ptr, const T &val)

◆ SetTrustedCertificatesBytesPKCS12()

static int dart::bin::SetTrustedCertificatesBytesPKCS12 ( SSL_CTX *  context,
ScopedMemBIO bio,
const char *  password 
)
static

Definition at line 180 of file security_context.cc.

182 {
183 CBS cbs;
184 CBS_init(&cbs, bio->data(), bio->length());
185
186 EVP_PKEY* key = nullptr;
187 ScopedX509Stack cert_stack(sk_X509_new_null());
188 int status = PKCS12_get_key_and_certs(&key, cert_stack.get(), &cbs, password);
189 if (status == 0) {
190 return status;
191 }
192
193 X509_STORE* store = SSL_CTX_get_cert_store(context);
194 X509* ca;
195 while ((ca = sk_X509_shift(cert_stack.get())) != nullptr) {
196 status = X509_STORE_add_cert(store, ca);
197 // X509_STORE_add_cert increments the reference count of cert on success.
198 X509_free(ca);
199 if (status == 0) {
200 return status;
201 }
202 }
203
204 return status;
205}

◆ SetupCoreLibraries()

static Dart_Handle dart::bin::SetupCoreLibraries ( Dart_Isolate  isolate,
IsolateData isolate_data,
bool  is_isolate_group_start,
bool  is_kernel_isolate,
const char **  resolved_packages_config 
)
static

Definition at line 149 of file main_impl.cc.

153 {
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
184 result = Dart_SetEnvironmentCallback(DartUtils::EnvironmentCallback);
185 if (Dart_IsError(result)) return result;
186
187 // Setup the native resolver as the snapshot does not carry it.
188 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary);
189 Builtin::SetNativeResolver(Builtin::kIOLibrary);
190 Builtin::SetNativeResolver(Builtin::kCLILibrary);
191 VmService::SetNativeResolver();
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}
const char * packages_file() const
Definition: isolate_data.h:149
IsolateGroupData * isolate_group_data() const
Definition: isolate_data.h:128

◆ ShouldCaptureStderr()

bool dart::bin::ShouldCaptureStderr ( )

Definition at line 37 of file file_support.cc.

37 {
38 return capture_stderr;
39}

◆ ShouldCaptureStdout()

bool dart::bin::ShouldCaptureStdout ( )

Definition at line 33 of file file_support.cc.

33 {
34 return capture_stdout;
35}

◆ Shutdown()

static void dart::bin::Shutdown ( Dart_NativeArguments  args)
static

Definition at line 58 of file vmservice_impl.cc.

58 {
59 // NO-OP.
60}

◆ SignalSocketFinalizer()

static void dart::bin::SignalSocketFinalizer ( void *  isolate_data,
void *  data 
)
static

Definition at line 1447 of file socket.cc.

1447 {
1448 Socket* socket = reinterpret_cast<Socket*>(data);
1449 const int64_t flags = (1 << kSignalSocket) | (1 << kCloseCommand);
1450 socket->Retain(); // Bump reference till we send the message.
1451 EventHandler::SendFromNative(reinterpret_cast<intptr_t>(socket),
1452 socket->port(), flags);
1453 socket->Release(); // Release the reference we just added above.
1454}

◆ SingleArgDart_Invoke()

static Dart_Handle dart::bin::SingleArgDart_Invoke ( Dart_Handle  lib,
const char *  method,
Dart_Handle  arg 
)
static

Definition at line 312 of file dartutils.cc.

314 {
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}

◆ SizeInBytes()

static int dart::bin::SizeInBytes ( Dart_TypedData_Type  type)
static

Definition at line 1199 of file file.cc.

1199 {
1200 switch (type) {
1204 return 1;
1207 return 2;
1211 return 4;
1215 return 8;
1219 return 16;
1220 default:
1221 break;
1222 }
1223 UNREACHABLE();
1224 return -1;
1225}
@ Dart_TypedData_kFloat32x4
Definition: dart_api.h:2626
@ Dart_TypedData_kInt32x4
Definition: dart_api.h:2625
@ Dart_TypedData_kUint32
Definition: dart_api.h:2620
@ Dart_TypedData_kInt32
Definition: dart_api.h:2619
@ Dart_TypedData_kUint16
Definition: dart_api.h:2618
@ Dart_TypedData_kFloat64x2
Definition: dart_api.h:2627
@ Dart_TypedData_kUint64
Definition: dart_api.h:2622
@ Dart_TypedData_kFloat32
Definition: dart_api.h:2623
@ Dart_TypedData_kInt16
Definition: dart_api.h:2617
@ Dart_TypedData_kFloat64
Definition: dart_api.h:2624
@ Dart_TypedData_kUint8Clamped
Definition: dart_api.h:2616

◆ Socket_Available()

void FUNCTION_NAME() dart::bin::Socket_Available ( Dart_NativeArguments  args)

Definition at line 519 of file socket.cc.

519 {
520 Socket* socket =
521 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
522 intptr_t available = SocketBase::Available(socket->fd());
523 if (available >= 0) {
525 } else {
526 // Available failed. Mark socket as having data, to trigger a future read
527 // event where the actual error can be reported.
529 }
530}

◆ Socket_AvailableDatagram()

void FUNCTION_NAME() dart::bin::Socket_AvailableDatagram ( Dart_NativeArguments  args)

Definition at line 1409 of file socket.cc.

1409 {
1410 const int kReceiveBufferLen = 1;
1411 Socket* socket =
1412 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
1413 ASSERT(socket != nullptr);
1414 // Ensure that a receive buffer for peeking the UDP socket exists.
1415 uint8_t recv_buffer[kReceiveBufferLen];
1416 bool available = SocketBase::AvailableDatagram(socket->fd(), recv_buffer,
1417 kReceiveBufferLen);
1418 Dart_SetBooleanReturnValue(args, available);
1419}

◆ Socket_CreateBindConnect()

void FUNCTION_NAME() dart::bin::Socket_CreateBindConnect ( Dart_NativeArguments  args)

Definition at line 391 of file socket.cc.

391 {
393 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 1), &addr);
395 int64_t port = DartUtils::GetInt64ValueCheckRange(port_arg, 0, 65535);
396 SocketAddress::SetAddrPort(&addr, static_cast<intptr_t>(port));
397 RawAddr sourceAddr;
398 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 3), &sourceAddr);
399 Dart_Handle source_port_arg = Dart_GetNativeArgument(args, 4);
400 int64_t source_port =
401 DartUtils::GetInt64ValueCheckRange(source_port_arg, 0, 65535);
402 SocketAddress::SetAddrPort(&sourceAddr, static_cast<intptr_t>(source_port));
403
404 if (addr.addr.sa_family == AF_INET6) {
405 Dart_Handle scope_id_arg = Dart_GetNativeArgument(args, 5);
406 int64_t scope_id =
407 DartUtils::GetInt64ValueCheckRange(scope_id_arg, 0, 65535);
408 SocketAddress::SetAddrScope(&addr, scope_id);
409 }
410 intptr_t socket = Socket::CreateBindConnect(addr, sourceAddr);
411 OSError error;
412 if (socket >= 0) {
413 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 0), socket,
414 Socket::kFinalizerNormal);
416 } else {
417 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error));
418 }
419}

◆ Socket_CreateBindDatagram()

void FUNCTION_NAME() dart::bin::Socket_CreateBindDatagram ( Dart_NativeArguments  args)

Definition at line 498 of file socket.cc.

498 {
500 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 1), &addr);
502 int64_t port = DartUtils::GetInt64ValueCheckRange(port_arg, 0, 65535);
503 SocketAddress::SetAddrPort(&addr, port);
504 bool reuse_addr = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3));
505 bool reuse_port = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 4));
506 int ttl = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 5));
507 intptr_t socket =
508 Socket::CreateBindDatagram(addr, reuse_addr, reuse_port, ttl);
509 if (socket >= 0) {
510 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 0), socket,
511 Socket::kFinalizerNormal);
513 } else {
514 OSError error;
515 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error));
516 }
517}

◆ Socket_CreateConnect()

void FUNCTION_NAME() dart::bin::Socket_CreateConnect ( Dart_NativeArguments  args)

Definition at line 363 of file socket.cc.

363 {
365 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 1), &addr);
367 int64_t port = DartUtils::GetInt64ValueCheckRange(port_arg, 0, 65535);
368 SocketAddress::SetAddrPort(&addr, static_cast<intptr_t>(port));
369 if (addr.addr.sa_family == AF_INET6) {
370 Dart_Handle scope_id_arg = Dart_GetNativeArgument(args, 3);
371 int64_t scope_id =
372 DartUtils::GetInt64ValueCheckRange(scope_id_arg, 0, 65535);
373 SocketAddress::SetAddrScope(&addr, scope_id);
374 }
375 intptr_t socket = Socket::CreateConnect(addr);
376 OSError error;
377 if (socket >= 0) {
378 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 0), socket,
379 Socket::kFinalizerNormal);
381 } else {
382 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error));
383 }
384}

◆ Socket_CreateUnixDomainBindConnect()

void FUNCTION_NAME() dart::bin::Socket_CreateUnixDomainBindConnect ( Dart_NativeArguments  args)

Definition at line 421 of file socket.cc.

422 {
423#if defined(DART_HOST_OS_WINDOWS) || defined(DART_HOST_OS_FUCHSIA)
424 OSError os_error(
425 -1, "Unix domain sockets are not available on this operating system.",
427 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
428#else
431 if (Dart_IsNull(address)) {
432 Dart_SetReturnValue(args, DartUtils::NewDartArgumentError(
433 "expect address to be of type String"));
434 }
435 Dart_Handle result = SocketAddress::GetUnixDomainSockAddr(
436 DartUtils::GetStringValue(address), Namespace::GetNamespace(args, 3),
437 &addr);
438 if (!Dart_IsNull(result)) {
440 }
441
442 RawAddr sourceAddr;
443 address = Dart_GetNativeArgument(args, 2);
444 if (Dart_IsNull(address)) {
445 return Dart_SetReturnValue(
446 args,
447 DartUtils::NewDartArgumentError("expect address to be of type String"));
448 }
449 result = SocketAddress::GetUnixDomainSockAddr(
450 DartUtils::GetStringValue(address), Namespace::GetNamespace(args, 3),
451 &sourceAddr);
452 if (!Dart_IsNull(result)) {
454 }
455
456 intptr_t socket = Socket::CreateUnixDomainBindConnect(addr, sourceAddr);
457 if (socket >= 0) {
458 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 0), socket,
459 Socket::kFinalizerNormal);
461 } else {
462 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
463 }
464#endif // defined(DART_HOST_OS_WINDOWS) || defined(DART_HOST_OS_FUCHSIA)
465}

◆ Socket_CreateUnixDomainConnect()

void FUNCTION_NAME() dart::bin::Socket_CreateUnixDomainConnect ( Dart_NativeArguments  args)

Definition at line 467 of file socket.cc.

467 {
468#if defined(DART_HOST_OS_WINDOWS) || defined(DART_HOST_OS_FUCHSIA)
469 OSError os_error(
470 -1, "Unix domain sockets are not available on this operating system.",
472 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
473#else
476 if (Dart_IsNull(address)) {
477 return Dart_SetReturnValue(
478 args,
479 DartUtils::NewDartArgumentError("expect address to be of type String"));
480 }
481 Dart_Handle result = SocketAddress::GetUnixDomainSockAddr(
482 DartUtils::GetStringValue(address), Namespace::GetNamespace(args, 2),
483 &addr);
484 if (!Dart_IsNull(result)) {
486 }
487 intptr_t socket = Socket::CreateUnixDomainConnect(addr);
488 if (socket >= 0) {
489 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 0), socket,
490 Socket::kFinalizerNormal);
492 } else {
493 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
494 }
495#endif // defined(DART_HOST_OS_WINDOWS) || defined(DART_HOST_OS_FUCHSIA)
496}

◆ Socket_Fatal()

void FUNCTION_NAME() dart::bin::Socket_Fatal ( Dart_NativeArguments  args)

Definition at line 940 of file socket.cc.

940 {
942 const char* msgStr =
943 (!Dart_IsNull(msg)) ? DartUtils::GetStringValue(msg) : nullptr;
944 FATAL("Fatal error in dart:io (socket): %s", msgStr);
945}

◆ Socket_GetError()

void FUNCTION_NAME() dart::bin::Socket_GetError ( Dart_NativeArguments  args)

Definition at line 928 of file socket.cc.

928 {
929 Socket* socket =
930 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
931 OSError os_error;
932 SocketBase::GetError(socket->fd(), &os_error);
933 if (os_error.code() != 0) {
934 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
935 } else {
937 }
938}

◆ Socket_GetFD()

void FUNCTION_NAME() dart::bin::Socket_GetFD ( Dart_NativeArguments  args)

Definition at line 947 of file socket.cc.

947 {
948 Socket* socket =
949 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
951}

◆ Socket_GetOption()

void FUNCTION_NAME() dart::bin::Socket_GetOption ( Dart_NativeArguments  args)

Definition at line 1183 of file socket.cc.

1183 {
1184 Socket* socket =
1185 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
1186 int64_t option = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1));
1187 intptr_t protocol = static_cast<intptr_t>(
1188 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)));
1189 bool ok = false;
1190 switch (option) {
1191 case 0: { // TCP_NODELAY.
1192 bool enabled;
1193 ok = SocketBase::GetNoDelay(socket->fd(), &enabled);
1194 if (ok) {
1196 }
1197 break;
1198 }
1199 case 1: { // IP_MULTICAST_LOOP.
1200 bool enabled;
1201 ok = SocketBase::GetMulticastLoop(socket->fd(), protocol, &enabled);
1202 if (ok) {
1204 }
1205 break;
1206 }
1207 case 2: { // IP_MULTICAST_TTL.
1208 int value;
1209 ok = SocketBase::GetMulticastHops(socket->fd(), protocol, &value);
1210 if (ok) {
1212 }
1213 break;
1214 }
1215 case 3: { // IP_MULTICAST_IF.
1216 UNIMPLEMENTED();
1217 break;
1218 }
1219 case 4: { // IP_BROADCAST.
1220 bool enabled;
1221 ok = SocketBase::GetBroadcast(socket->fd(), &enabled);
1222 if (ok) {
1224 }
1225 break;
1226 }
1227 default:
1228 UNREACHABLE();
1229 break;
1230 }
1231 // In case of failure the return value is not set above.
1232 if (!ok) {
1233 Dart_ThrowException(DartUtils::NewDartOSError());
1234 }
1235}
#define UNIMPLEMENTED

◆ Socket_GetPort()

void FUNCTION_NAME() dart::bin::Socket_GetPort ( Dart_NativeArguments  args)

Definition at line 889 of file socket.cc.

889 {
890 Socket* socket =
891 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
892 intptr_t port = SocketBase::GetPort(socket->fd());
893 if (port > 0) {
895 } else {
896 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
897 }
898}

◆ Socket_GetRawOption()

void FUNCTION_NAME() dart::bin::Socket_GetRawOption ( Dart_NativeArguments  args)

Definition at line 1306 of file socket.cc.

1306 {
1307 Socket* socket =
1308 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
1309 int64_t level = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1));
1310 int64_t option = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2));
1312 ASSERT(Dart_IsList(data_obj));
1313 char* data = nullptr;
1314 intptr_t length;
1317 data_obj, &type, reinterpret_cast<void**>(&data), &length);
1318 if (Dart_IsError(data_result)) {
1319 Dart_PropagateError(data_result);
1320 }
1321 unsigned int int_length = static_cast<unsigned int>(length);
1322 bool result =
1323 SocketBase::GetOption(socket->fd(), static_cast<int>(level),
1324 static_cast<int>(option), data, &int_length);
1325
1326 Dart_TypedDataReleaseData(data_obj);
1327 if (!result) {
1328 Dart_ThrowException(DartUtils::NewDartOSError());
1329 }
1330}

◆ Socket_GetRemotePeer()

void FUNCTION_NAME() dart::bin::Socket_GetRemotePeer ( Dart_NativeArguments  args)

Definition at line 900 of file socket.cc.

900 {
901 Socket* socket =
902 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
903 intptr_t port = 0;
904 SocketAddress* addr = SocketBase::GetRemotePeer(socket->fd(), &port);
905 if (addr != nullptr) {
906 Dart_Handle list = Dart_NewList(2);
907 int type = addr->GetType();
908 Dart_Handle entry;
909 if (type == SocketAddress::TYPE_UNIX) {
910 entry = Dart_NewList(2);
911 } else {
912 entry = Dart_NewList(3);
913 RawAddr raw = addr->addr();
914 Dart_ListSetAt(entry, 2, SocketAddress::ToTypedData(raw));
915 }
917 Dart_ListSetAt(entry, 1, Dart_NewStringFromCString(addr->as_string()));
918
919 Dart_ListSetAt(list, 0, entry);
922 delete addr;
923 } else {
924 Dart_ThrowException(DartUtils::NewDartOSError());
925 }
926}

◆ Socket_GetSocketId()

void FUNCTION_NAME() dart::bin::Socket_GetSocketId ( Dart_NativeArguments  args)

Definition at line 974 of file socket.cc.

974 {
975 Socket* socket =
976 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
977 intptr_t id = reinterpret_cast<intptr_t>(socket);
979}

◆ Socket_GetStdioHandle()

void FUNCTION_NAME() dart::bin::Socket_GetStdioHandle ( Dart_NativeArguments  args)

Definition at line 965 of file socket.cc.

965 {
966 int64_t num =
967 DartUtils::GetInt64ValueCheckRange(Dart_GetNativeArgument(args, 1), 0, 2);
968 intptr_t socket = SocketBase::GetStdioHandle(num);
969 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 0), socket,
970 Socket::kFinalizerStdio);
972}
DART_EXPORT Dart_Handle Dart_NewBoolean(bool value)

◆ Socket_GetType()

void FUNCTION_NAME() dart::bin::Socket_GetType ( Dart_NativeArguments  args)

Definition at line 953 of file socket.cc.

953 {
954 Socket* socket =
955 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
956 OSError os_error;
957 intptr_t type = SocketBase::GetType(socket->fd());
958 if (type >= 0) {
960 } else {
961 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
962 }
963}

◆ Socket_HasPendingWrite()

void FUNCTION_NAME() dart::bin::Socket_HasPendingWrite ( Dart_NativeArguments  args)

Definition at line 727 of file socket.cc.

727 {
728#if defined(DART_HOST_OS_WINDOWS)
729 Socket* socket =
730 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
731 const bool result = SocketBase::HasPendingWrite(socket->fd());
732#else
733 const bool result = false;
734#endif // defined(DART_HOST_OS_WINDOWS)
736}

◆ Socket_JoinMulticast()

void FUNCTION_NAME() dart::bin::Socket_JoinMulticast ( Dart_NativeArguments  args)

Definition at line 1375 of file socket.cc.

1375 {
1376 Socket* socket =
1377 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
1378 RawAddr addr;
1379 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 1), &addr);
1380 RawAddr interface;
1381 if (Dart_GetNativeArgument(args, 2) != Dart_Null()) {
1382 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 2), &interface);
1383 }
1384 int interfaceIndex =
1385 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3));
1386 if (!SocketBase::JoinMulticast(socket->fd(), addr, interface,
1387 interfaceIndex)) {
1388 Dart_ThrowException(DartUtils::NewDartOSError());
1389 }
1390}

◆ Socket_LeaveMulticast()

void FUNCTION_NAME() dart::bin::Socket_LeaveMulticast ( Dart_NativeArguments  args)

Definition at line 1392 of file socket.cc.

1392 {
1393 Socket* socket =
1394 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
1395 RawAddr addr;
1396 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 1), &addr);
1397 RawAddr interface;
1398 if (Dart_GetNativeArgument(args, 2) != Dart_Null()) {
1399 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 2), &interface);
1400 }
1401 int interfaceIndex =
1402 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3));
1403 if (!SocketBase::LeaveMulticast(socket->fd(), addr, interface,
1404 interfaceIndex)) {
1405 Dart_ThrowException(DartUtils::NewDartOSError());
1406 }
1407}

◆ Socket_Read()

void FUNCTION_NAME() dart::bin::Socket_Read ( Dart_NativeArguments  args)

Definition at line 532 of file socket.cc.

532 {
533 Socket* socket =
534 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
535 int64_t length = 0;
536 if (DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 1), &length) &&
537 (length >= 0)) {
538 if (Socket::short_socket_read()) {
539 length = (length + 1) / 2;
540 }
541 uint8_t* buffer = nullptr;
543 if (Dart_IsNull(result)) {
544 Dart_ThrowException(DartUtils::NewDartOSError());
545 }
546 if (Dart_IsError(result)) {
548 }
549 ASSERT(buffer != nullptr);
550 intptr_t bytes_read =
551 SocketBase::Read(socket->fd(), buffer, length, SocketBase::kAsync);
552 if (bytes_read == length) {
554 } else if (bytes_read > 0) {
555 uint8_t* new_buffer = nullptr;
556 Dart_Handle new_result = IOBuffer::Allocate(bytes_read, &new_buffer);
557 if (Dart_IsNull(new_result)) {
558 Dart_ThrowException(DartUtils::NewDartOSError());
559 }
560 if (Dart_IsError(new_result)) {
561 Dart_PropagateError(new_result);
562 }
563 ASSERT(new_buffer != nullptr);
564 memmove(new_buffer, buffer, bytes_read);
565 Dart_SetReturnValue(args, new_result);
566 } else if (bytes_read == 0) {
567 // On MacOS when reading from a tty Ctrl-D will result in reading one
568 // less byte then reported as available.
570 } else {
571 ASSERT(bytes_read == -1);
572 Dart_ThrowException(DartUtils::NewDartOSError());
573 }
574 } else {
575 Dart_Handle exception;
576 {
577 // Make sure OSError destructor is called.
578 OSError os_error(-1, "Invalid argument", OSError::kUnknown);
579 exception = DartUtils::NewDartOSError(&os_error);
580 }
581 Dart_ThrowException(exception);
582 }
583}
SK_API bool Read(SkStreamSeekable *src, SkDocumentPage *dstArray, int dstArrayCount, const SkDeserialProcs *=nullptr)

◆ Socket_ReceiveMessage()

void FUNCTION_NAME() dart::bin::Socket_ReceiveMessage ( Dart_NativeArguments  args)

Definition at line 668 of file socket.cc.

668 {
669 Socket* socket = Socket::GetSocketIdNativeField(
671 ASSERT(socket != nullptr);
672
673 int64_t buffer_num_bytes = 0;
674 DartUtils::GetInt64Value(ThrowIfError(Dart_GetNativeArgument(args, 1)),
675 &buffer_num_bytes);
676 int64_t buffer_num_bytes_allocated = buffer_num_bytes;
677 uint8_t* buffer = nullptr;
678 Dart_Handle data = IOBuffer::Allocate(buffer_num_bytes, &buffer);
679 if (Dart_IsNull(data)) {
680 Dart_ThrowException(DartUtils::NewDartOSError());
681 }
682 ASSERT(buffer != nullptr);
683
684 // Can't rely on RAII since Dart_ThrowException won't call destructors.
685 OSError* os_error = new OSError();
686 SocketControlMessage* control_messages;
687 const intptr_t messages_read = SocketBase::ReceiveMessage(
688 socket->fd(), buffer, &buffer_num_bytes, &control_messages,
689 SocketBase::kAsync, os_error);
690 if (messages_read < 0) {
691 ASSERT(messages_read == -1);
692 Dart_Handle error = DartUtils::NewDartOSError(os_error);
693 delete os_error;
695 }
696 delete os_error;
697 if (buffer_num_bytes > 0 && buffer_num_bytes != buffer_num_bytes_allocated) {
698 // If received fewer than allocated buffer size, truncate buffer.
699 uint8_t* new_buffer = nullptr;
700 Dart_Handle new_data = IOBuffer::Allocate(buffer_num_bytes, &new_buffer);
701 if (Dart_IsNull(new_data)) {
702 Dart_ThrowException(DartUtils::NewDartOSError());
703 }
704 ASSERT(new_buffer != nullptr);
705 memmove(new_buffer, buffer, buffer_num_bytes);
706 data = new_data;
707 }
708
709 // returned list has a (level, type, message bytes) triple for every message,
710 // plus last element is raw data uint8list.
711 Dart_Handle list = ThrowIfError(Dart_NewList(messages_read * 3 + 1));
712 int j = 0;
713 for (intptr_t i = 0; i < messages_read; i++) {
714 SocketControlMessage* message = control_messages + i;
715 Dart_Handle uint8list_message_data = ThrowIfError(
716 DartUtils::MakeUint8Array(message->data(), message->data_length()));
718 list, j++, ThrowIfError(Dart_NewInteger(message->level()))));
720 list, j++, ThrowIfError(Dart_NewInteger(message->type()))));
721 ThrowIfError(Dart_ListSetAt(list, j++, uint8list_message_data));
722 }
725}

◆ Socket_RecvFrom()

void FUNCTION_NAME() dart::bin::Socket_RecvFrom ( Dart_NativeArguments  args)

Definition at line 585 of file socket.cc.

585 {
586 // TODO(sgjesse): Use a MTU value here. Only the loopback adapter can
587 // handle 64k datagrams.
588 const int kReceiveBufferLen = 65536;
589 Socket* socket =
590 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
591
592 // Ensure that a receive buffer for the UDP socket exists.
593 ASSERT(socket != nullptr);
594 uint8_t* recv_buffer = socket->udp_receive_buffer();
595 if (recv_buffer == nullptr) {
596 recv_buffer = reinterpret_cast<uint8_t*>(malloc(kReceiveBufferLen));
597 socket->set_udp_receive_buffer(recv_buffer);
598 }
599
600 // Read data into the buffer.
601 RawAddr addr;
602 const intptr_t bytes_read = SocketBase::RecvFrom(
603 socket->fd(), recv_buffer, kReceiveBufferLen, &addr, SocketBase::kAsync);
604 if (bytes_read == 0) {
606 return;
607 }
608 if (bytes_read < 0) {
609 ASSERT(bytes_read == -1);
610 Dart_ThrowException(DartUtils::NewDartOSError());
611 }
612
613 // Datagram data read. Copy into buffer of the exact size,
614 ASSERT(bytes_read >= 0);
615 uint8_t* data_buffer = nullptr;
616 Dart_Handle data = IOBuffer::Allocate(bytes_read, &data_buffer);
617 if (Dart_IsNull(data)) {
618 Dart_ThrowException(DartUtils::NewDartOSError());
619 }
620 if (Dart_IsError(data)) {
622 }
623 ASSERT(data_buffer != nullptr);
624 memmove(data_buffer, recv_buffer, bytes_read);
625
626 // Get the port and clear it in the sockaddr structure.
627 int port = SocketAddress::GetAddrPort(addr);
628 // TODO(21403): Add checks for AF_UNIX, if unix domain sockets
629 // are used in SOCK_DGRAM.
630 enum internet_type { IPv4, IPv6 };
631 internet_type type;
632 if (addr.addr.sa_family == AF_INET) {
633 addr.in.sin_port = 0;
634 type = IPv4;
635 } else {
636 ASSERT(addr.addr.sa_family == AF_INET6);
637 addr.in6.sin6_port = 0;
638 type = IPv6;
639 }
640 // Format the address to a string using the numeric format.
641 char numeric_address[INET6_ADDRSTRLEN];
642 SocketBase::FormatNumericAddress(addr, numeric_address, INET6_ADDRSTRLEN);
643
644 // Create a Datagram object with the data and sender address and port.
645 const int kNumArgs = 5;
646 Dart_Handle dart_args[kNumArgs];
647 dart_args[0] = data;
648 dart_args[1] = Dart_NewStringFromCString(numeric_address);
649 if (Dart_IsError(dart_args[1])) {
650 Dart_PropagateError(dart_args[1]);
651 }
652 dart_args[2] = SocketAddress::ToTypedData(addr);
653 dart_args[3] = Dart_NewInteger(port);
654 dart_args[4] = Dart_NewInteger(type);
655 if (Dart_IsError(dart_args[3])) {
656 Dart_PropagateError(dart_args[3]);
657 }
658 // TODO(sgjesse): Cache the _makeDatagram function somewhere.
660 if (Dart_IsError(io_lib)) {
661 Dart_PropagateError(io_lib);
662 }
664 io_lib, DartUtils::NewString("_makeDatagram"), kNumArgs, dart_args);
666}
void set_udp_receive_buffer(uint8_t *buffer)
Definition: socket.h:67
uint8_t * udp_receive_buffer() const
Definition: socket.h:66

◆ Socket_SendMessage()

void FUNCTION_NAME() dart::bin::Socket_SendMessage ( Dart_NativeArguments  args)

Definition at line 785 of file socket.cc.

785 {
786 Socket* socket =
787 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
788 intptr_t offset = DartUtils::GetNativeIntptrArgument(args, 2);
789 intptr_t length = DartUtils::GetNativeIntptrArgument(args, 3);
790
791 // List of triples <level, type, data> arranged to minimize dart api use in
792 // native methods.
793 Dart_Handle control_message_list_dart =
795 ASSERT(Dart_IsList(control_message_list_dart));
796 intptr_t num_control_messages_pieces;
798 Dart_ListLength(control_message_list_dart, &num_control_messages_pieces));
799 intptr_t num_control_messages = num_control_messages_pieces / 3;
800 ASSERT((num_control_messages * 3) == num_control_messages_pieces);
801 SocketControlMessage* control_messages =
802 reinterpret_cast<SocketControlMessage*>(Dart_ScopeAllocate(
803 sizeof(SocketControlMessage) * num_control_messages));
804 ASSERT(control_messages != nullptr);
805
806 SocketControlMessage* control_message = control_messages;
807 intptr_t j = 0;
808 for (intptr_t i = 0; i < num_control_messages; i++, control_message++) {
809 int level = DartUtils::GetIntegerValue(
810 ThrowIfError(Dart_ListGetAt(control_message_list_dart, j++)));
811 int type = DartUtils::GetIntegerValue(
812 ThrowIfError(Dart_ListGetAt(control_message_list_dart, j++)));
813 Dart_Handle uint8list_dart =
814 ThrowIfError(Dart_ListGetAt(control_message_list_dart, j++));
815
816 TypedDataScope data(uint8list_dart);
817 void* copied_data = Dart_ScopeAllocate(data.size_in_bytes());
818 ASSERT(copied_data != nullptr);
819 memmove(copied_data, data.data(), data.size_in_bytes());
820 new (control_message)
821 SocketControlMessage(level, type, copied_data, data.size_in_bytes());
822 }
823
824 // Can't rely on RAII since Dart_ThrowException won't call destructors.
825 OSError* os_error = new OSError();
826 intptr_t bytes_written;
827 {
828 Dart_Handle buffer_dart = Dart_GetNativeArgument(args, 1);
829 TypedDataScope data(buffer_dart);
830
831 ASSERT((offset + length) <= data.size_in_bytes());
832 uint8_t* buffer_at_offset =
833 reinterpret_cast<uint8_t*>(data.data()) + offset;
834 bytes_written = SocketBase::SendMessage(
835 socket->fd(), buffer_at_offset, length, control_messages,
836 num_control_messages, SocketBase::kAsync, os_error);
837 }
838
839 if (bytes_written < 0) {
840 Dart_Handle error = DartUtils::NewDartOSError(os_error);
841 delete os_error;
843 }
844 delete os_error;
845
846 Dart_SetIntegerReturnValue(args, bytes_written);
847}
SeparatedVector2 offset
#define SendMessage

◆ Socket_SendTo()

void FUNCTION_NAME() dart::bin::Socket_SendTo ( Dart_NativeArguments  args)

Definition at line 849 of file socket.cc.

849 {
850 Socket* socket =
851 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
852 Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1);
853 intptr_t offset = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 2));
854 intptr_t length = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 3));
855 Dart_Handle address_obj = Dart_GetNativeArgument(args, 4);
856 ASSERT(Dart_IsList(address_obj));
858 SocketAddress::GetSockAddr(address_obj, &addr);
859 int64_t port = DartUtils::GetInt64ValueCheckRange(
860 Dart_GetNativeArgument(args, 5), 0, 65535);
861 SocketAddress::SetAddrPort(&addr, port);
863 uint8_t* buffer = nullptr;
864 intptr_t len;
866 buffer_obj, &type, reinterpret_cast<void**>(&buffer), &len);
867 if (Dart_IsError(result)) {
869 }
870 ASSERT((offset + length) <= len);
871 buffer += offset;
872 intptr_t bytes_written = SocketBase::SendTo(socket->fd(), buffer, length,
873 addr, SocketBase::kAsync);
874 if (bytes_written >= 0) {
875 Dart_TypedDataReleaseData(buffer_obj);
876 Dart_SetIntegerReturnValue(args, bytes_written);
877 } else {
878 // Extract OSError before we release data, as it may override the error.
880 {
881 OSError os_error;
882 Dart_TypedDataReleaseData(buffer_obj);
883 error = DartUtils::NewDartOSError(&os_error);
884 }
886 }
887}

◆ Socket_SetOption()

void FUNCTION_NAME() dart::bin::Socket_SetOption ( Dart_NativeArguments  args)

Definition at line 1237 of file socket.cc.

1237 {
1238 bool result = false;
1239 Socket* socket =
1240 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
1241 int64_t option = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1));
1242 intptr_t protocol = static_cast<intptr_t>(
1243 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)));
1244 switch (option) {
1245 case 0: // TCP_NODELAY.
1246 result = SocketBase::SetNoDelay(
1247 socket->fd(),
1248 DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3)));
1249 break;
1250 case 1: // IP_MULTICAST_LOOP.
1251 result = SocketBase::SetMulticastLoop(
1252 socket->fd(), protocol,
1253 DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3)));
1254 break;
1255 case 2: // IP_MULTICAST_TTL.
1256 result = SocketBase::SetMulticastHops(
1257 socket->fd(), protocol,
1258 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3)));
1259 break;
1260 case 3: { // IP_MULTICAST_IF.
1261 UNIMPLEMENTED();
1262 break;
1263 }
1264 case 4: // IP_BROADCAST.
1265 result = SocketBase::SetBroadcast(
1266 socket->fd(),
1267 DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3)));
1268 break;
1269 default:
1271 Dart_NewApiError("option to setOption() is outside expected range"));
1272 break;
1273 }
1274 if (!result) {
1275 Dart_ThrowException(DartUtils::NewDartOSError());
1276 }
1277}

◆ Socket_SetRawOption()

void FUNCTION_NAME() dart::bin::Socket_SetRawOption ( Dart_NativeArguments  args)

Definition at line 1279 of file socket.cc.

1279 {
1280 Socket* socket =
1281 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
1282 int64_t level = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1));
1283 int64_t option = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2));
1285 ASSERT(Dart_IsList(data_obj));
1286 char* data = nullptr;
1287 intptr_t length;
1290 data_obj, &type, reinterpret_cast<void**>(&data), &length);
1291 if (Dart_IsError(data_result)) {
1292 Dart_PropagateError(data_result);
1293 }
1294
1295 bool result = SocketBase::SetOption(socket->fd(), static_cast<int>(level),
1296 static_cast<int>(option), data,
1297 static_cast<int>(length));
1298
1299 Dart_TypedDataReleaseData(data_obj);
1300
1301 if (!result) {
1302 Dart_ThrowException(DartUtils::NewDartOSError());
1303 }
1304}

◆ Socket_SetSocketId()

void FUNCTION_NAME() dart::bin::Socket_SetSocketId ( Dart_NativeArguments  args)

Definition at line 981 of file socket.cc.

981 {
982 intptr_t id = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1));
983 intptr_t type_flag =
984 DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 2));
985 Socket::SocketFinalizer finalizer;
986 if (Socket::IsSignalSocketFlag(type_flag)) {
987 finalizer = Socket::kFinalizerSignal;
988 } else {
989 finalizer = Socket::kFinalizerNormal;
990 }
991 Socket::SetSocketIdNativeField(Dart_GetNativeArgument(args, 0), id,
992 finalizer);
993}

◆ Socket_WriteList()

void FUNCTION_NAME() dart::bin::Socket_WriteList ( Dart_NativeArguments  args)

Definition at line 738 of file socket.cc.

738 {
739 Socket* socket =
740 Socket::GetSocketIdNativeField(Dart_GetNativeArgument(args, 0));
741 Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1);
742 ASSERT(Dart_IsList(buffer_obj));
743 intptr_t offset = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 2));
744 intptr_t length = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 3));
745 bool short_write = false;
746 if (Socket::short_socket_write()) {
747 if (length > 1) {
748 short_write = true;
749 }
750 length = (length + 1) / 2;
751 }
753 uint8_t* buffer = nullptr;
754 intptr_t len;
756 buffer_obj, &type, reinterpret_cast<void**>(&buffer), &len);
757 if (Dart_IsError(result)) {
759 }
760 ASSERT((offset + length) <= len);
761 buffer += offset;
762 intptr_t bytes_written =
763 SocketBase::Write(socket->fd(), buffer, length, SocketBase::kAsync);
764 if (bytes_written >= 0) {
765 Dart_TypedDataReleaseData(buffer_obj);
766 if (short_write) {
767 // If the write was forced 'short', indicate by returning the negative
768 // number of bytes. A forced short write may not trigger a write event.
769 Dart_SetIntegerReturnValue(args, -bytes_written);
770 } else {
771 Dart_SetIntegerReturnValue(args, bytes_written);
772 }
773 } else {
774 // Extract OSError before we release data, as it may override the error.
776 {
777 OSError os_error;
778 Dart_TypedDataReleaseData(buffer_obj);
779 error = DartUtils::NewDartOSError(&os_error);
780 }
782 }
783}

◆ SocketBase_IsBindError()

void FUNCTION_NAME() dart::bin::SocketBase_IsBindError ( Dart_NativeArguments  args)

Definition at line 299 of file socket_base.cc.

299 {
300 intptr_t error_number =
301 DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1));
302 bool is_bind_error = SocketBase::IsBindError(error_number);
303 Dart_SetBooleanReturnValue(args, is_bind_error ? true : false);
304}

◆ SocketControlMessage_fromHandles()

void FUNCTION_NAME() dart::bin::SocketControlMessage_fromHandles ( Dart_NativeArguments  args)

Definition at line 1511 of file socket.cc.

1512 {
1513#if defined(DART_HOST_OS_WINDOWS) || defined(DART_HOST_OS_FUCHSIA)
1515 DartUtils::NewDartUnsupportedError(
1516 "This is not supported on this operating system"));
1517#else
1519 Dart_Handle handles_dart = Dart_GetNativeArgument(args, 1);
1520 if (Dart_IsNull(handles_dart)) {
1522 DartUtils::NewDartArgumentError("handles list can't be null"));
1523 }
1524 ASSERT(Dart_IsList(handles_dart));
1525 intptr_t num_handles;
1526 ThrowIfError(Dart_ListLength(handles_dart, &num_handles));
1527 intptr_t num_bytes = num_handles * sizeof(int);
1528 int* handles = reinterpret_cast<int*>(Dart_ScopeAllocate(num_bytes));
1529 Dart_Handle handle_dart_string =
1531 for (intptr_t i = 0; i < num_handles; i++) {
1532 Dart_Handle handle_dart = ThrowIfError(Dart_ListGetAt(handles_dart, i));
1533 Dart_Handle handle_int_dart =
1534 ThrowIfError(Dart_GetField(handle_dart, handle_dart_string));
1535 handles[i] = DartUtils::GetIntegerValue(handle_int_dart);
1536 }
1537
1538 Dart_Handle uint8list_dart =
1540 ThrowIfError(Dart_ListSetAsBytes(uint8list_dart, /*offset=*/0,
1541 reinterpret_cast<const uint8_t*>(handles),
1542 num_bytes));
1543 Dart_Handle dart_new_args[] = {Dart_NewInteger(SOL_SOCKET),
1544 Dart_NewInteger(SCM_RIGHTS), uint8list_dart};
1545
1546 Dart_Handle socket_control_message_impl = ThrowIfError(DartUtils::GetDartType(
1547 DartUtils::kIOLibURL, "_SocketControlMessageImpl"));
1549 args,
1550 Dart_New(socket_control_message_impl,
1551 /*constructor_name=*/Dart_Null(),
1552 sizeof(dart_new_args) / sizeof(Dart_Handle), dart_new_args));
1553#endif // defined(DART_HOST_OS_WINDOWS) || defined(DART_HOST_OS_FUCHSIA)
1554}

◆ SocketControlMessageImpl_extractHandles()

void FUNCTION_NAME() dart::bin::SocketControlMessageImpl_extractHandles ( Dart_NativeArguments  args)

Definition at line 1556 of file socket.cc.

1557 {
1558#if defined(DART_HOST_OS_WINDOWS) || defined(DART_HOST_OS_FUCHSIA)
1560 DartUtils::NewDartUnsupportedError(
1561 "This is not supported on this operating system"));
1562#else
1563 Dart_Handle handle_type = ThrowIfError(
1564 DartUtils::GetDartType(DartUtils::kIOLibURL, "ResourceHandle"));
1565
1566 Dart_Handle message_dart = Dart_GetNativeArgument(args, 0);
1567 intptr_t level = DartUtils::GetIntegerValue(
1568 ThrowIfError(Dart_GetField(message_dart, DartUtils::NewString("level"))));
1569 intptr_t type = DartUtils::GetIntegerValue(
1570 ThrowIfError(Dart_GetField(message_dart, DartUtils::NewString("type"))));
1571 if (level != SOL_SOCKET || type != SCM_RIGHTS) {
1573 handle_type, Dart_Null(), 0)));
1574 return;
1575 }
1576
1577 Dart_Handle data_dart =
1578 ThrowIfError(Dart_GetField(message_dart, DartUtils::NewString("data")));
1579 ASSERT(Dart_IsTypedData(data_dart));
1580
1581 void* data;
1582 intptr_t bytes_count;
1583 Dart_TypedData_Type data_type;
1585 Dart_TypedDataAcquireData(data_dart, &data_type, &data, &bytes_count));
1586 ASSERT(data_type == Dart_TypedData_kUint8);
1587 int* ints_data = reinterpret_cast<int*>(Dart_ScopeAllocate(bytes_count));
1588 ASSERT(ints_data != nullptr);
1589 memmove(ints_data, data, bytes_count);
1591 intptr_t ints_count = bytes_count / sizeof(int);
1592
1593 Dart_Handle handle_impl_type =
1594 DartUtils::GetDartType(DartUtils::kIOLibURL, "_ResourceHandleImpl");
1595 Dart_Handle sentinel = ThrowIfError(
1596 Dart_GetField(handle_impl_type, DartUtils::NewString("_sentinel")));
1597 Dart_Handle handle_list =
1598 ThrowIfError(Dart_NewListOfTypeFilled(handle_type, sentinel, ints_count));
1599 for (intptr_t i = 0; i < ints_count; i++) {
1600 Dart_Handle constructor_args[] = {
1601 ThrowIfError(Dart_NewInteger(*(ints_data + i)))};
1602 Dart_Handle handle_impl = ThrowIfError(Dart_New(
1603 handle_impl_type,
1604 /*constructor_name=*/Dart_Null(),
1605 sizeof(constructor_args) / sizeof(Dart_Handle), constructor_args));
1606 ThrowIfError(Dart_ListSetAt(handle_list, i, handle_impl));
1607 }
1608
1609 Dart_SetReturnValue(args, handle_list);
1610#endif // defined(DART_HOST_OS_WINDOWS) || defined(DART_HOST_OS_FUCHSIA)
1611}

◆ StartsWithPathSeparator()

static bool dart::bin::StartsWithPathSeparator ( const char *  path,
const char *  sep,
intptr_t  sep_length 
)
static

Definition at line 15 of file exe_utils.cc.

17 {
18 return (strncmp(path, sep, sep_length) == 0
19#if defined(DART_HOST_OS_WINDOWS)
20 // TODO(aam): GetExecutableName doesn't work reliably on Windows,
21 || *path == '/'
22#endif
23 ); // NOLINT
24}

◆ Stdin_AnsiSupported()

void FUNCTION_NAME() dart::bin::Stdin_AnsiSupported ( Dart_NativeArguments  args)

Definition at line 154 of file stdio.cc.

154 {
155 bool supported = false;
156 intptr_t fd;
157 if (!GetIntptrArgument(args, 0, &fd)) {
158 return;
159 }
160 if (Stdin::AnsiSupported(fd, &supported)) {
162 } else {
163 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
164 }
165}
static bool GetIntptrArgument(Dart_NativeArguments args, intptr_t idx, intptr_t *value)
Definition: stdio.cc:19

◆ Stdin_GetEchoMode()

void FUNCTION_NAME() dart::bin::Stdin_GetEchoMode ( Dart_NativeArguments  args)

Definition at line 55 of file stdio.cc.

55 {
56 bool enabled = false;
57 intptr_t fd;
58 if (!GetIntptrArgument(args, 0, &fd)) {
59 return;
60 }
61 if (Stdin::GetEchoMode(fd, &enabled)) {
63 } else {
64 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
65 }
66}

◆ Stdin_GetEchoNewlineMode()

void FUNCTION_NAME() dart::bin::Stdin_GetEchoNewlineMode ( Dart_NativeArguments  args)

Definition at line 88 of file stdio.cc.

88 {
89 bool enabled = false;
90 intptr_t fd;
91 if (!GetIntptrArgument(args, 0, &fd)) {
92 return;
93 }
94 if (Stdin::GetEchoNewlineMode(fd, &enabled)) {
96 } else {
97 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
98 }
99}

◆ Stdin_GetLineMode()

void FUNCTION_NAME() dart::bin::Stdin_GetLineMode ( Dart_NativeArguments  args)

Definition at line 121 of file stdio.cc.

121 {
122 bool enabled = false;
123 intptr_t fd;
124 if (!GetIntptrArgument(args, 0, &fd)) {
125 return;
126 }
127 if (Stdin::GetLineMode(fd, &enabled)) {
129 } else {
130 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
131 }
132}

◆ Stdin_ReadByte()

void FUNCTION_NAME() dart::bin::Stdin_ReadByte ( Dart_NativeArguments  args)

Definition at line 41 of file stdio.cc.

41 {
42 ScopedBlockingCall blocker;
43 intptr_t fd;
44 if (!GetIntptrArgument(args, 0, &fd)) {
45 return;
46 }
47 int byte = -1;
48 if (Stdin::ReadByte(fd, &byte)) {
50 } else {
51 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
52 }
53}

◆ Stdin_SetEchoMode()

void FUNCTION_NAME() dart::bin::Stdin_SetEchoMode ( Dart_NativeArguments  args)

Definition at line 68 of file stdio.cc.

68 {
69 intptr_t fd;
70 if (!GetIntptrArgument(args, 0, &fd)) {
71 return;
72 }
73 bool enabled;
74 Dart_Handle status = Dart_GetNativeBooleanArgument(args, 1, &enabled);
75 if (Dart_IsError(status)) {
76 // The caller is expecting an OSError if something goes wrong.
77 OSError os_error(-1, "Invalid argument", OSError::kUnknown);
78 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
79 return;
80 }
81 if (Stdin::SetEchoMode(fd, enabled)) {
83 } else {
84 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
85 }
86}
DART_EXPORT Dart_Handle Dart_GetNativeBooleanArgument(Dart_NativeArguments args, int index, bool *value)

◆ Stdin_SetEchoNewlineMode()

void FUNCTION_NAME() dart::bin::Stdin_SetEchoNewlineMode ( Dart_NativeArguments  args)

Definition at line 101 of file stdio.cc.

101 {
102 intptr_t fd;
103 if (!GetIntptrArgument(args, 0, &fd)) {
104 return;
105 }
106 bool enabled;
107 Dart_Handle status = Dart_GetNativeBooleanArgument(args, 1, &enabled);
108 if (Dart_IsError(status)) {
109 // The caller is expecting an OSError if something goes wrong.
110 OSError os_error(-1, "Invalid argument", OSError::kUnknown);
111 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
112 return;
113 }
114 if (Stdin::SetEchoNewlineMode(fd, enabled)) {
116 } else {
117 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
118 }
119}

◆ Stdin_SetLineMode()

void FUNCTION_NAME() dart::bin::Stdin_SetLineMode ( Dart_NativeArguments  args)

Definition at line 134 of file stdio.cc.

134 {
135 intptr_t fd;
136 if (!GetIntptrArgument(args, 0, &fd)) {
137 return;
138 }
139 bool enabled;
140 Dart_Handle status = Dart_GetNativeBooleanArgument(args, 1, &enabled);
141 if (Dart_IsError(status)) {
142 // The caller is expecting an OSError if something goes wrong.
143 OSError os_error(-1, "Invalid argument", OSError::kUnknown);
144 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
145 return;
146 }
147 if (Stdin::SetLineMode(fd, enabled)) {
149 } else {
150 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
151 }
152}

◆ StdioSocketFinalizer()

static void dart::bin::StdioSocketFinalizer ( void *  isolate_data,
void *  data 
)
static

Definition at line 1439 of file socket.cc.

1439 {
1440 Socket* socket = reinterpret_cast<Socket*>(data);
1441 if (socket->fd() >= 0) {
1442 socket->CloseFd();
1443 }
1444 socket->Release();
1445}

◆ Stdout_AnsiSupported()

void FUNCTION_NAME() dart::bin::Stdout_AnsiSupported ( Dart_NativeArguments  args)

Definition at line 183 of file stdio.cc.

183 {
184 intptr_t fd;
185 if (!GetIntptrArgument(args, 0, &fd)) {
186 return;
187 }
188 bool supported = false;
189 if (Stdout::AnsiSupported(fd, &supported)) {
191 } else {
192 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
193 }
194}

◆ Stdout_GetTerminalSize()

void FUNCTION_NAME() dart::bin::Stdout_GetTerminalSize ( Dart_NativeArguments  args)

Definition at line 167 of file stdio.cc.

167 {
168 intptr_t fd;
169 if (!GetIntptrArgument(args, 0, &fd)) {
170 return;
171 }
172 int size[2];
173 if (Stdout::GetTerminalSize(fd, size)) {
174 Dart_Handle list = Dart_NewList(2);
175 Dart_ListSetAt(list, 0, Dart_NewInteger(size[0]));
176 Dart_ListSetAt(list, 1, Dart_NewInteger(size[1]));
178 } else {
179 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
180 }
181}

◆ StreamingCloseCallback()

static void dart::bin::StreamingCloseCallback ( void *  callback_data)
static

Definition at line 490 of file gen_snapshot.cc.

490 {
491 File* file = reinterpret_cast<File*>(callback_data);
492 file->Release();
493}

◆ StreamingWriteCallback() [1/2]

static void dart::bin::StreamingWriteCallback ( void *  callback_data,
const uint8_t *  buffer,
intptr_t  size 
)
static

Definition at line 481 of file gen_snapshot.cc.

483 {
484 File* file = reinterpret_cast<File*>(callback_data);
485 if ((file != nullptr) && !file->WriteFully(buffer, size)) {
486 PrintErrAndExit("Error: Unable to write snapshot file\n\n");
487 }
488}

◆ StreamingWriteCallback() [2/2]

static void dart::bin::StreamingWriteCallback ( void *  callback_data,
const uint8_t *  buffer,
intptr_t  size 
)
static

Definition at line 753 of file snapshot_utils.cc.

755 {
756 File* file = reinterpret_cast<File*>(callback_data);
757 if (!file->WriteFully(buffer, size)) {
758 ErrorExit(kErrorExitCode, "Unable to write snapshot file\n");
759 }
760}

◆ StringToSystemEncoding()

void FUNCTION_NAME() dart::bin::StringToSystemEncoding ( Dart_NativeArguments  args)

Definition at line 349 of file process.cc.

349 {
351 char* utf8;
352 intptr_t utf8_len;
354 Dart_StringToUTF8(str, reinterpret_cast<uint8_t**>(&utf8), &utf8_len);
356 intptr_t system_len;
357 const char* system_string =
358 StringUtils::Utf8ToConsoleString(utf8, utf8_len, &system_len);
359 if (system_string == nullptr) {
360 Dart_ThrowException(DartUtils::NewDartUnsupportedError(
361 "StringToSystemEncoding not supported on this operating system"));
362 }
363 uint8_t* buffer = nullptr;
364 Dart_Handle external_array = IOBuffer::Allocate(system_len, &buffer);
365 if (Dart_IsNull(external_array)) {
366 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
367 return;
368 }
369 if (!Dart_IsError(external_array)) {
370 memmove(buffer, system_string, system_len);
371 }
372 Dart_SetReturnValue(args, external_array);
373}

◆ SynchronousSocket_Available()

void FUNCTION_NAME() dart::bin::SynchronousSocket_Available ( Dart_NativeArguments  args)

Definition at line 185 of file sync_socket.cc.

185 {
186 SynchronousSocket* socket = nullptr;
187 Dart_Handle result = SynchronousSocket::GetSocketIdNativeField(
188 Dart_GetNativeArgument(args, 0), &socket);
190
191 intptr_t available = SynchronousSocket::Available(socket->fd());
192 if (available >= 0) {
194 } else {
195 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
196 }
197}
#define DART_CHECK_ERROR(handle)
Definition: sync_socket.cc:28

◆ SynchronousSocket_CloseSync()

void FUNCTION_NAME() dart::bin::SynchronousSocket_CloseSync ( Dart_NativeArguments  args)

Definition at line 199 of file sync_socket.cc.

199 {
200 SynchronousSocket* socket = nullptr;
201 Dart_Handle result = SynchronousSocket::GetSocketIdNativeField(
202 Dart_GetNativeArgument(args, 0), &socket);
204
205 SynchronousSocket::Close(socket->fd());
206 socket->SetClosedFd();
207}

◆ SynchronousSocket_CreateConnectSync()

void FUNCTION_NAME() dart::bin::SynchronousSocket_CreateConnectSync ( Dart_NativeArguments  args)

Definition at line 101 of file sync_socket.cc.

102 {
104 SocketAddress::GetSockAddr(Dart_GetNativeArgument(args, 1), &addr);
106 DART_CHECK_ERROR(port_arg);
107 int64_t port = DartUtils::GetInt64ValueCheckRange(port_arg, 0, 65535);
108 SocketAddress::SetAddrPort(&addr, static_cast<intptr_t>(port));
109 intptr_t socket = SynchronousSocket::CreateConnect(addr);
110 if (socket >= 0) {
111 Dart_Handle error = SynchronousSocket::SetSocketIdNativeField(
115 } else {
116 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
117 }
118}

◆ SynchronousSocket_GetPort()

void FUNCTION_NAME() dart::bin::SynchronousSocket_GetPort ( Dart_NativeArguments  args)

Definition at line 265 of file sync_socket.cc.

265 {
266 SynchronousSocket* socket = nullptr;
267 Dart_Handle result = SynchronousSocket::GetSocketIdNativeField(
268 Dart_GetNativeArgument(args, 0), &socket);
270
271 intptr_t port = SynchronousSocket::GetPort(socket->fd());
272 if (port > 0) {
274 } else {
275 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
276 }
277}

◆ SynchronousSocket_GetRemotePeer()

void FUNCTION_NAME() dart::bin::SynchronousSocket_GetRemotePeer ( Dart_NativeArguments  args)

Definition at line 279 of file sync_socket.cc.

279 {
280 SynchronousSocket* socket = nullptr;
281 Dart_Handle result = SynchronousSocket::GetSocketIdNativeField(
282 Dart_GetNativeArgument(args, 0), &socket);
284
285 intptr_t port = 0;
286 SocketAddress* addr = SynchronousSocket::GetRemotePeer(socket->fd(), &port);
287 if (addr == nullptr) {
288 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
289 return;
290 }
291 Dart_Handle list = Dart_NewList(2);
293
294 Dart_Handle entry = Dart_NewList(3);
296
298 Dart_ListSetAt(entry, 0, Dart_NewInteger(addr->GetType()));
300 error =
301 Dart_ListSetAt(entry, 1, Dart_NewStringFromCString(addr->as_string()));
303
304 RawAddr raw = addr->addr();
305 error = Dart_ListSetAt(entry, 2, SocketAddress::ToTypedData(raw));
307
308 error = Dart_ListSetAt(list, 0, entry);
313 delete addr;
314}
#define DART_CHECK_ERROR_AND_CLEANUP(handle, ptr)
Definition: sync_socket.cc:19

◆ SynchronousSocket_LookupRequest()

void FUNCTION_NAME() dart::bin::SynchronousSocket_LookupRequest ( Dart_NativeArguments  args)

Definition at line 41 of file sync_socket.cc.

41 {
44 args, DartUtils::NewDartArgumentError("Invalid argument count."));
45 return;
46 }
47
48 char* peer = nullptr;
49 Dart_Handle host_arg =
50 Dart_GetNativeStringArgument(args, 0, reinterpret_cast<void**>(&peer));
51 DART_CHECK_ERROR(host_arg);
52
53 char* host = nullptr;
54 host_arg = Dart_StringToCString(host_arg, const_cast<const char**>(&host));
55 DART_CHECK_ERROR(host_arg);
56
57 int64_t type = 0;
59 DART_CHECK_ERROR(port_error);
60
61 OSError* os_error = nullptr;
62 AddressList<SocketAddress>* addresses =
63 SocketBase::LookupAddress(host, type, &os_error);
64 if (addresses == nullptr) {
65 Dart_SetReturnValue(args, DartUtils::NewDartOSError(os_error));
66 return;
67 }
68
69 Dart_Handle array = Dart_NewList(addresses->count());
70 DART_CHECK_ERROR_AND_CLEANUP(array, addresses);
71
72 for (intptr_t i = 0; i < addresses->count(); i++) {
73 SocketAddress* addr = addresses->GetAt(i);
74 Dart_Handle entry = Dart_NewList(3);
75 DART_CHECK_ERROR_AND_CLEANUP(entry, addresses);
76
81
82 Dart_Handle as_string = Dart_NewStringFromCString(addr->as_string());
83 DART_CHECK_ERROR_AND_CLEANUP(as_string, addresses);
84 error = Dart_ListSetAt(entry, 1, as_string);
86
87 RawAddr raw = addr->addr();
88 Dart_Handle data = SocketAddress::ToTypedData(raw);
90
91 error = Dart_ListSetAt(entry, 2, data);
93 error = Dart_ListSetAt(array, i, entry);
95 }
96 delete addresses;
98 return;
99}
DART_EXPORT int Dart_GetNativeArgumentCount(Dart_NativeArguments args)
DART_EXPORT Dart_Handle Dart_GetNativeStringArgument(Dart_NativeArguments args, int arg_index, void **peer)
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 host
Definition: switches.h:74

◆ SynchronousSocket_Read()

void FUNCTION_NAME() dart::bin::SynchronousSocket_Read ( Dart_NativeArguments  args)

Definition at line 209 of file sync_socket.cc.

209 {
210 SynchronousSocket* socket = nullptr;
211 Dart_Handle result = SynchronousSocket::GetSocketIdNativeField(
212 Dart_GetNativeArgument(args, 0), &socket);
214
215 int64_t length = 0;
216 if (!DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 1), &length) ||
217 (length < 0)) {
218 Dart_SetReturnValue(args, DartUtils::NewDartArgumentError(
219 "First parameter must be an integer."));
220 return;
221 }
222 uint8_t* buffer = nullptr;
224 if (Dart_IsNull(result)) {
225 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
226 return;
227 }
228 ASSERT(buffer != nullptr);
229 intptr_t bytes_read = SynchronousSocket::Read(socket->fd(), buffer, length);
230 if (bytes_read == length) {
232 } else if (bytes_read > 0) {
233 uint8_t* new_buffer = nullptr;
234 Dart_Handle new_result = IOBuffer::Allocate(bytes_read, &new_buffer);
235 if (Dart_IsNull(new_result)) {
236 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
237 return;
238 }
239 ASSERT(new_buffer != nullptr);
240 memmove(new_buffer, buffer, bytes_read);
241 Dart_SetReturnValue(args, new_result);
242 } else if (bytes_read == -1) {
243 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
244 }
245}

◆ SynchronousSocket_ReadList()

void FUNCTION_NAME() dart::bin::SynchronousSocket_ReadList ( Dart_NativeArguments  args)

Definition at line 153 of file sync_socket.cc.

153 {
154 SynchronousSocket* socket = nullptr;
155 Dart_Handle result = SynchronousSocket::GetSocketIdNativeField(
156 Dart_GetNativeArgument(args, 0), &socket);
158
159 Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1);
160 if (!Dart_IsList(buffer_obj)) {
161 Dart_SetReturnValue(args, DartUtils::NewDartArgumentError(
162 "First parameter must be a List<int>"));
163 return;
164 }
165 intptr_t offset = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 2));
166 intptr_t bytes = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 3));
167 intptr_t array_len = 0;
168
169 result = Dart_ListLength(buffer_obj, &array_len);
171
172 uint8_t* buffer = Dart_ScopeAllocate(bytes);
173 intptr_t bytes_read = SynchronousSocket::Read(socket->fd(), buffer, bytes);
174 if (bytes_read < 0) {
175 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
176 return;
177 }
178 if (bytes_read > 0) {
179 result = Dart_ListSetAsBytes(buffer_obj, offset, buffer, bytes_read);
181 }
182 Dart_SetIntegerReturnValue(args, bytes_read);
183}

◆ SynchronousSocket_ShutdownRead()

void FUNCTION_NAME() dart::bin::SynchronousSocket_ShutdownRead ( Dart_NativeArguments  args)

Definition at line 247 of file sync_socket.cc.

247 {
248 SynchronousSocket* socket = nullptr;
249 Dart_Handle result = SynchronousSocket::GetSocketIdNativeField(
250 Dart_GetNativeArgument(args, 0), &socket);
252
253 SynchronousSocket::ShutdownRead(socket->fd());
254}

◆ SynchronousSocket_ShutdownWrite()

void FUNCTION_NAME() dart::bin::SynchronousSocket_ShutdownWrite ( Dart_NativeArguments  args)

Definition at line 256 of file sync_socket.cc.

256 {
257 SynchronousSocket* socket = nullptr;
258 Dart_Handle result = SynchronousSocket::GetSocketIdNativeField(
259 Dart_GetNativeArgument(args, 0), &socket);
261
262 SynchronousSocket::ShutdownWrite(socket->fd());
263}

◆ SynchronousSocket_WriteList()

void FUNCTION_NAME() dart::bin::SynchronousSocket_WriteList ( Dart_NativeArguments  args)

Definition at line 120 of file sync_socket.cc.

120 {
121 SynchronousSocket* socket = nullptr;
122 Dart_Handle result = SynchronousSocket::GetSocketIdNativeField(
123 Dart_GetNativeArgument(args, 0), &socket);
125
126 Dart_Handle buffer_obj = Dart_GetNativeArgument(args, 1);
127 if (!Dart_IsList(buffer_obj)) {
128 Dart_SetReturnValue(args, DartUtils::NewDartArgumentError(
129 "First parameter must be a List<int>"));
130 return;
131 }
132 intptr_t offset = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 2));
133 intptr_t length = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 3));
135 uint8_t* buffer = nullptr;
136 intptr_t len;
138 reinterpret_cast<void**>(&buffer), &len);
140 ASSERT((offset + length) <= len);
141 buffer += offset;
142 intptr_t bytes_written =
143 SynchronousSocket::Write(socket->fd(), buffer, length);
144 Dart_TypedDataReleaseData(buffer_obj);
145 if (bytes_written >= 0) {
146 Dart_SetIntegerReturnValue(args, bytes_written);
147 } else {
148 OSError os_error;
149 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&os_error));
150 }
151}

◆ SynchronousSocketFinalizer()

static void dart::bin::SynchronousSocketFinalizer ( void *  isolate_data,
void *  data 
)
static

Definition at line 316 of file sync_socket.cc.

316 {
317 SynchronousSocket* socket = reinterpret_cast<SynchronousSocket*>(data);
318 if (socket->fd() >= 0) {
319 SynchronousSocket::Close(socket->fd());
320 socket->SetClosedFd();
321 }
322 delete socket;
323}

◆ SystemEncodingToString()

void FUNCTION_NAME() dart::bin::SystemEncodingToString ( Dart_NativeArguments  args)

Definition at line 328 of file process.cc.

328 {
330 intptr_t bytes_length = 0;
331 Dart_Handle result = Dart_ListLength(bytes, &bytes_length);
333 uint8_t* buffer = Dart_ScopeAllocate(bytes_length + 1);
334 result = Dart_ListGetAsBytes(bytes, 0, buffer, bytes_length);
335 buffer[bytes_length] = '\0';
337 intptr_t len;
338 char* str = StringUtils::ConsoleStringToUtf8(reinterpret_cast<char*>(buffer),
339 bytes_length, &len);
340 if (str == nullptr) {
341 Dart_ThrowException(DartUtils::NewDartUnsupportedError(
342 "SystemEncodingToString not supported on this operating system"));
343 }
344 result = Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(str), len);
347}
DART_EXPORT Dart_Handle Dart_NewStringFromUTF8(const uint8_t *utf8_array, intptr_t length)

◆ TEST_CASE() [1/4]

dart::bin::TEST_CASE ( GetRandomBytes  )

Definition at line 13 of file crypto_test.cc.

13 {
14 const intptr_t kNumRandomBytes = 127;
15 uint8_t buf[kNumRandomBytes];
16 const bool res = Crypto::GetRandomBytes(kNumRandomBytes, buf);
17 EXPECT(res);
18}
#define EXPECT(type, expectedAlignment, expectedSize)

◆ TEST_CASE() [2/4]

dart::bin::TEST_CASE ( SecureSocketUtils_CertAlreadyExpired  )

Definition at line 106 of file secure_socket_utils_test.cc.

106 {
107 const char* valid_before_2021 =
108 "-----BEGIN CERTIFICATE-----\n"
109 "MIIFazCCA1OgAwIBAgIUY+S+GbniK1WC9821VgAJusuF33UwDQYJKoZIhvcNAQEL\n"
110 "BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM\n"
111 "GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yMDA4MjUxNzAyNDFaFw0yMDA5\n"
112 "MjQxNzAyNDFaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw\n"
113 "HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggIiMA0GCSqGSIb3DQEB\n"
114 "AQUAA4ICDwAwggIKAoICAQDNfCrlXNeGKpF0PHzjkG5UfsSYvwfNUTqnzC3AkTMY\n"
115 "AZyyqDCA780TPZH48aZ/QFegFdIBUkEijFLuRKUqAv5jHxaVhMQcr5ujdCAJWT+e\n"
116 "5jc0cvukdWnFFqZwJWur4/3RsUnaWXY+oDk0pGuZD7VeNm9PTi1pQogwAivhSynM\n"
117 "YxCq0cO0JPM0Dr7ks99V1gDWrEOqjJGeEzvRlwdx+GPkvMvmrSHxWOphN/ji2MRx\n"
118 "tZ0T5FrrrGEtfp8gtTe5q5V+di1GvbuE6Y+MVYGIJeu3yqHkoh/TTS9Ex+QRm9nh\n"
119 "QM1Pm4hi2PofSSEdj15cUw6vfPJWewZiytcVJFTt2in1YuYufZMwPLP/ylnAQLkM\n"
120 "dq3TIF1g4ym9xLgQ/ZgnMX6g6ReOqG/1Au5InPUXMo3n56N959gQD1K8J2C4xtQP\n"
121 "MxrDAbGuYOmCterPAmW4aIVgbxIXwEK7lzTZyHUOvwjNaEfu0fuVOd9NC2B+g8So\n"
122 "I188ty96/BVwQO5bAzGekJn9xHVcTUU067b5zNfCpo4XGKaKVNGGR+AXhtjRXbrX\n"
123 "N9/BOHdABlV5W32HkhT4fr/BSSp/UyCnBZRPvLcI3Nvraok8snn/eGt6IW3y171O\n"
124 "3tYx4Gz7+M2K/T1rMuujVXOx6srtZ8oQIqFgZTR0sKKsim1umHAmoTJrG3wEOlUs\n"
125 "awIDAQABo1MwUTAdBgNVHQ4EFgQUzTOEhm+P6rWyBkKAkctA9FvheC8wHwYDVR0j\n"
126 "BBgwFoAUzTOEhm+P6rWyBkKAkctA9FvheC8wDwYDVR0TAQH/BAUwAwEB/zANBgkq\n"
127 "hkiG9w0BAQsFAAOCAgEABYYIBheuGRbmRhsS39zy0jDhqmDbsyIFd3/NoMZ+WvW4\n"
128 "NFcVRATalIX6ScXl7RGs1p855OiqOHij1tCzBClZXZ1zWD2v0KfWMFjR/S79HJOI\n"
129 "w3RGaMvALUJtOCz5in5Odryuo3GBkxKNonS+HAjnrWosqBCorerjn/TdIscTbA6h\n"
130 "7Iwy5umyyY63E69ehD7aANc/mxk++BWdAs3kPSXMI7PDpWUW5WV0hPUpe3sf0eY8\n"
131 "skfXa+UJ2qDmVkMmHUIOhi92zTRv6ROQXGY52JhHZOFSFxvqjWkk1M8q6Vm2ln2s\n"
132 "2GUa2j4emp+zti2JuFAwDgEK8wyqlq14hA8hTHL27mxpht990QGAU+qmcfhUf/qd\n"
133 "cIPkbz53Dpezzd96SuHQyjALaTbEw2vis9WpsejOKiaAp8264t0DgtLUndj4wVfC\n"
134 "3xti1jubmouUEdbNh7bnDfXxdxuAECFzhEG9mrosnTemuUVQSXIyrNfHRKDEaGv1\n"
135 "zh2Jij4HI+OKnJuao/9vsbNPib7k8tR0JKbXZD3HvOfQi5wMtlCUedu9eZ3Cq9Mu\n"
136 "1NwIwFoSU5pwO4PopiYL2hAEJXd0SN6TnWZThU28qTulrCb8enNU6BfkokTlkmYs\n"
137 "HUzvFarVyhKbQkyD/P3ckC/p2mg9aE7iLO5wTY1gegcSDF4R4479t/aDWMmevis=\n"
138 "-----END CERTIFICATE-----\n";
139 size_t len = strlen(valid_before_2021);
140 BIO* cert_bio = BIO_new(BIO_s_mem());
141 BIO_write(cert_bio, valid_before_2021, len);
142 X509* cert_X509 = PEM_read_bio_X509(cert_bio, nullptr, nullptr, nullptr);
143 EXPECT(cert_X509 != nullptr);
144 EXPECT(!SecureSocketUtils::IsCurrentTimeInsideCertValidDateRange(cert_X509));
145 BIO_free(cert_bio);
146 X509_free(cert_X509);
147}

◆ TEST_CASE() [3/4]

dart::bin::TEST_CASE ( SecureSocketUtils_CertNotYetValid  )

Definition at line 18 of file secure_socket_utils_test.cc.

18 {
19 const char* valid_after_2121 =
20 "-----BEGIN CERTIFICATE-----\n"
21 "MIIFbzCCA1egAwIBAgIUO6PLWc8zatZF5Cc07uYdjDy4UGowDQYJKoZIhvcNAQEL\n"
22 "BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM\n"
23 "GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAiGA8yMTIxMDgwMTE3MDUwNFoYDzIx\n"
24 "MzEwNzMwMTcwNTA0WjBFMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0\n"
25 "ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIICIjANBgkqhkiG\n"
26 "9w0BAQEFAAOCAg8AMIICCgKCAgEAvgmd8v2K4ngOI/dOa/sn63uetG9sUhzTdViO\n"
27 "87q7s4XeFmziS3BMQyMqTmrIHJAKuZp66ZH6ZOno54UX2KedI4hf0He3NbAitGgI\n"
28 "o6z/WBglH+ByORUEU1Yzh03akja5C8Hp9IUpC6PGJEolPsZeoBMZs1bCxwD9miHy\n"
29 "bs/NYsUGsDJwUZFEW2UTjYuyeTPSdkIgoZIPCp8tp9E6jy7fb2H2XE0Z+rJ4rU/e\n"
30 "0aQ1Q7gNBnBWrJAGgYfQj9XbFx6nNEW6XUBqIV/uUmz9y64pMQ21I9e64Qn5KHDo\n"
31 "08CzQ651dGY1GJkziUuQITkPN4EqS6D5R74ruTJW0lp/cg7RNPoTAXBXI+Nqz7WE\n"
32 "bscerDKFGgaAZ8WXqvwpHqwGeiilZT/OwSwjrN8zaW6eLljAStGhLgn6j/Te8rfW\n"
33 "9+AGSjesJ8dJ+dppFG8A+1Auvtii12Jk8hj/IM/udt5ZLs6meSOYPeNF3UqHrA7s\n"
34 "O39KsMy7ppFQPwBBXgKZMXQlt6uMmi/2s/OHXZRpf7c09n6+3NKYutMsYHO6SrlD\n"
35 "hYcWdpjlv632O5WAdjehohDLfYLugsPPt/hJC3UAA8QfNrEXVHx3D2qgowLB9Brx\n"
36 "zC7aT/0rmVQu2wXvekc8tIRUnDgr8tLjSuEyj9nBb7cWUOWi/1YiEb5T1x7/zyhP\n"
37 "5p8g8l8CAwEAAaNTMFEwHQYDVR0OBBYEFN1Mf9EDYiYYds9IB9qvOYEmDhs5MB8G\n"
38 "A1UdIwQYMBaAFN1Mf9EDYiYYds9IB9qvOYEmDhs5MA8GA1UdEwEB/wQFMAMBAf8w\n"
39 "DQYJKoZIhvcNAQELBQADggIBAA8DjwXFECGFKPNc//kTSUUcMxRLORBH/oSe2hml\n"
40 "dNRtjkVHWcPDsn5Md0cM6e0kOXw2AEqRK9keYN/27JGHBvzu1MbzSHd1czeGx46d\n"
41 "5QI5MyI0U8iiYoW8IJURrnAuD+9yS6O4b7c9qnTwwdsAy98gzfWZbrb++mgoWDrt\n"
42 "Ma4V1zKMUZYezV95zlBmB9sKxbJlLP6pMGPENsbNuqB1KK8uAYnd4YYdEx97lt7o\n"
43 "SeUySohZQasheI73jJuYdDwqDcGCtRvwaOyDuOsDZVNqjNiqiI3aaGVII2lNbjOO\n"
44 "g85pN4pWB+1b3wdEt+c5VETYX3SiJNOyhy3rp68liegeeNVTgNdp5vSxmogWxtCN\n"
45 "uv6uim0Lw//Ezz6acc15CLdaS1msS2V/5Ogk7/cYEajtWp8l7/dy9Gf8ekzRBaET\n"
46 "3vw7sla+YhsUI+NZQG79gfkDfYmRMpW6djaWgY9c5l/NJ8ev1ZQWj1i5t4w7lW5h\n"
47 "3wB8qVV7BQ3zY36iEes4hvmXmykCOgQ2yXTOVZVhKYAxoaRMgkJSWL9rsPvmHEM8\n"
48 "b3gjUC/5nwTzLZAw0iYLtPpSnFwhprZPPWF+k5FQAx/UQ+0qjqY8EbfWLzexm+7P\n"
49 "Sm35NlpFHH6vyyj48RVYQcw8KvDvbuUwjiauydhYCCLoQVdywec8d3fUu6NdBusm\n"
50 "q8uu\n"
51 "-----END CERTIFICATE-----\n";
52 size_t len = strlen(valid_after_2121);
53 BIO* cert_bio = BIO_new(BIO_s_mem());
54 BIO_write(cert_bio, valid_after_2121, len);
55 X509* cert_X509 = PEM_read_bio_X509(cert_bio, nullptr, nullptr, nullptr);
56 EXPECT(cert_X509 != nullptr);
57 EXPECT(!SecureSocketUtils::IsCurrentTimeInsideCertValidDateRange(cert_X509));
58 BIO_free(cert_bio);
59 X509_free(cert_X509);
60}

◆ TEST_CASE() [4/4]

dart::bin::TEST_CASE ( SecureSocketUtils_CertValid  )

Definition at line 62 of file secure_socket_utils_test.cc.

62 {
63 const char* valid_in_2021 =
64 "-----BEGIN CERTIFICATE-----\n"
65 "MIIFbTCCA1WgAwIBAgIUFmzKjF/PfpFX+5+pF1LXzbFzL/4wDQYJKoZIhvcNAQEL\n"
66 "BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM\n"
67 "GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAgFw0yMTA4MjUxNzA1NTNaGA8yMTIx\n"
68 "MDgwMTE3MDU1M1owRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUx\n"
69 "ITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDCCAiIwDQYJKoZIhvcN\n"
70 "AQEBBQADggIPADCCAgoCggIBAMdupz2RQB1fHii6EACZq8MPbDk+xoxHb111Z85C\n"
71 "VK47tC+Sn16DmWKwmcMp7mbPIO8jUSJOk8FrZWsSFZ9xBzXb/H2W6kFNb8XqKyhH\n"
72 "vweeTekPuONrpJIqBJiIEXqyMoxiqwbtl38ZVo5DwFvc8mriFVYapMLb3DKQxOMR\n"
73 "uM32R40VVf1S/LcYab/UTdxdtoI6MINv5SFsmp7Cd+8nUMXdetCTdlu5aoHSTUE0\n"
74 "EzsYG4WTQqi3WpvnTuFlFq4LLd7NYmWUoiUJiB5u7vSEZM91u/eGtOm9Y7OzwJUp\n"
75 "Obv3hEIrNS0c/qXuG89+7vlcW5AqJkyWhNgoMRXFXYlqPFKWwYOU0t/vjSlFlB3u\n"
76 "8a0zNur6d95IC/9XSGFgW3FYnEzTPiorR8y/dbw8P5ioP2yMrm1b6v+TlyOyQ3Hu\n"
77 "gCKJy7Ah1IpUG7wefZIpTN8CaumusUwJdCcGBPfwyOD1yvF8UyETJ5ZB7JC7jXgj\n"
78 "KUpytSeN79m15s+ksn6tS9uLqTHr3Yr7J7ha3m2UO4gl2QOa20/fdmenVqEsq+Z7\n"
79 "1PuDaitEVaCQE3/286rwNQPgoDgDbIckZOzOzYq0b3lZZBlSZRpcsrBEf3KJIz9Y\n"
80 "X5R5bLvw/qtCVjHDankA2EqMYKf9LBCLkQ0GUMpu3aS7xZhn4A6tIcqtRpe1+ruZ\n"
81 "k5GdAgMBAAGjUzBRMB0GA1UdDgQWBBRzt8cxhCiZoLnnKWgLDt5nPctfYTAfBgNV\n"
82 "HSMEGDAWgBRzt8cxhCiZoLnnKWgLDt5nPctfYTAPBgNVHRMBAf8EBTADAQH/MA0G\n"
83 "CSqGSIb3DQEBCwUAA4ICAQCUzlwgMiwnNo4VM2FCroJpGP/8gEsMcUUpfeQnKALm\n"
84 "MudiNPWVQk7uHeAKXvzoSlq/7/ZYKqlXxqiNXhkawnBl0lyR4Bnj8GbQMkujZzUS\n"
85 "EUI5UlPqlvy4WJw9ybgPPyl5D/0D7dkK0xAVxMktjaCGKtPQ/UCY2APxyoISmhSl\n"
86 "0+ql1YpHM1XIty/mzlTAIZ7bnbKDPA3J3OjaCP0Skhf2g4Wkch3+6Wx5xfYnyRv1\n"
87 "UbihStrvN1dH9d+D642C45qpRa2l3GJvDxdyr6xSa3l9IajUYbpMFe0yymuxqWhX\n"
88 "bDLi0ouKmowKNiiqUmUEJhJBbt/XdTIeeyTcaz2ZHVmMU9E72OhsjzxAvajoDBv9\n"
89 "FJ3THlLlh7iHBv24Hghx5V6FCliO6uLUdLB1d8WNUtEWdzf17ZlPqRIkjSY+6kSJ\n"
90 "dNwQhl5kYL0caOKWvEEP9f2HondKxtVpYGHgtKvcvCj/hz8UCk9R3odcwweq48RK\n"
91 "fKNRHy3nQfWttSSbBH8SwSmtX2VesMu6jMcqwU/8YSrWTJa/5UexlNR9qRrDnhya\n"
92 "kqZCaETfx15LUkPPuyn+z76z2+hNW0VDpnUVRystHHkDz+q2cbH/bsfY47Et0Bsb\n"
93 "TozWCPRzEkmzTTaAZLtqXa5MzWsZweBzK5owXlOPTD2eo1UphgtOqsKPE/RB/Qgq\n"
94 "dw==\n"
95 "-----END CERTIFICATE-----\n";
96 size_t len = strlen(valid_in_2021);
97 BIO* cert_bio = BIO_new(BIO_s_mem());
98 BIO_write(cert_bio, valid_in_2021, len);
99 X509* cert_X509 = PEM_read_bio_X509(cert_bio, nullptr, nullptr, nullptr);
100 EXPECT(cert_X509 != nullptr);
101 EXPECT(SecureSocketUtils::IsCurrentTimeInsideCertValidDateRange(cert_X509));
102 BIO_free(cert_bio);
103 X509_free(cert_X509);
104}

◆ ThrowIfError()

static Dart_Handle dart::bin::ThrowIfError ( Dart_Handle  handle)
inlinestatic

Definition at line 31 of file dartutils.h.

31 {
32 if (Dart_IsError(handle)) {
33 Dart_PropagateError(handle);
34 }
35 return handle;
36}

◆ ToWinAPIDirectoryPath()

std::unique_ptr< wchar_t[]> dart::bin::ToWinAPIDirectoryPath ( const char *  path,
bool  force_long_prefix = false 
)

◆ TryReadAppSnapshotBlobs()

static AppSnapshot * dart::bin::TryReadAppSnapshotBlobs ( const char *  script_name,
File file 
)
static

Definition at line 101 of file snapshot_utils.cc.

102 {
103 if ((file->Length() - file->Position()) < kAppSnapshotHeaderSize) {
104 return nullptr;
105 }
106
107 int64_t header[2];
109 if (!file->ReadFully(&header, kAppSnapshotHeaderSize)) {
110 return nullptr;
111 }
112 int64_t isolate_data_size = header[0];
113 int64_t isolate_data_position =
115 int64_t isolate_instructions_size = header[1];
116 int64_t isolate_instructions_position =
117 isolate_data_position + isolate_data_size;
118 if (isolate_instructions_size != 0) {
119 isolate_instructions_position =
120 Utils::RoundUp(isolate_instructions_position, kAppSnapshotPageSize);
121 }
122
123 MappedMemory* isolate_data_mapping = nullptr;
124 if (isolate_data_size != 0) {
125 isolate_data_mapping =
126 file->Map(File::kReadOnly, isolate_data_position, isolate_data_size);
127 if (isolate_data_mapping == nullptr) {
128 FATAL("Failed to memory map snapshot: %s\n", script_name);
129 }
130 }
131
132 MappedMemory* isolate_instr_mapping = nullptr;
133 if (isolate_instructions_size != 0) {
134 isolate_instr_mapping =
135 file->Map(File::kReadExecute, isolate_instructions_position,
136 isolate_instructions_size);
137 if (isolate_instr_mapping == nullptr) {
138 FATAL("Failed to memory map snapshot: %s\n", script_name);
139 }
140 }
141
142 auto app_snapshot = new MappedAppSnapshot(
143 nullptr, nullptr, isolate_data_mapping, isolate_instr_mapping);
144 return app_snapshot;
145}
static constexpr int64_t kAppSnapshotPageSize
static constexpr int64_t kAppSnapshotHeaderSize
static void RoundUp(Vector< char > buffer, int *length, int *decimal_point)
Definition: fixed-dtoa.cc:189
static const char header[]
Definition: skpbench.cpp:88

◆ TryReadFile()

static bool dart::bin::TryReadFile ( const char *  script_uri,
uint8_t **  buffer,
intptr_t *  size,
bool  decode_uri = true 
)
static

Reads [script_uri] file, returns [true] if successful, [false] otherwise.

If successful, newly allocated buffer with file contents is returned in [buffer], file contents byte count - in [size].

Definition at line 295 of file dfe.cc.

298 {
299 void* script_file = decode_uri ? DartUtils::OpenFileUri(script_uri, false)
300 : DartUtils::OpenFile(script_uri, false);
301 if (script_file == nullptr) {
302 return false;
303 }
304 DartUtils::ReadFile(buffer, size, script_file);
305 DartUtils::CloseFile(script_file);
306 return *buffer != nullptr;
307}

◆ TryReadKernelListBuffer()

static bool dart::bin::TryReadKernelListBuffer ( const char *  script_uri,
uint8_t *  buffer,
intptr_t  buffer_size,
uint8_t **  kernel_ir,
intptr_t *  kernel_ir_size 
)
static

Definition at line 385 of file dfe.cc.

389 {
390 const char* kernel_list_dirname = DartUtils::DirName(script_uri);
391 if (strcmp(kernel_list_dirname, script_uri) == 0) {
392 kernel_list_dirname = "";
393 }
394 KernelIRNode* kernel_ir_head = nullptr;
395 KernelIRNode* kernel_ir_tail = nullptr;
396 // Add all kernels to the linked list
397 char* filename =
398 reinterpret_cast<char*>(buffer + kernel_list_magic_number.length);
399 intptr_t filename_size = buffer_size - kernel_list_magic_number.length;
400 char* tail = reinterpret_cast<char*>(memchr(filename, '\n', filename_size));
401 while (tail != nullptr) {
402 *tail = '\0';
403 intptr_t this_kernel_size;
404 uint8_t* this_buffer;
405
406 StringPointer resolved_filename(
407 File::IsAbsolutePath(filename)
408 ? Utils::StrDup(filename)
409 : Utils::SCreate("%s%s", kernel_list_dirname, filename));
410 if (!TryReadFile(resolved_filename.c_str(), &this_buffer,
411 &this_kernel_size)) {
412 return false;
413 }
414
415 uint8_t* this_kernel_ir;
416 if (!TryReadSimpleKernelBuffer(this_buffer, &this_kernel_ir,
417 &this_kernel_size)) {
418 // Abandon read if any of the files in the list are invalid.
419 KernelIRNode::Delete(kernel_ir_head);
420 *kernel_ir = nullptr;
421 *kernel_ir_size = -1;
422 return false;
423 }
424 KernelIRNode::Add(&kernel_ir_head, &kernel_ir_tail,
425 new KernelIRNode(this_kernel_ir, this_kernel_size));
426 filename_size -= tail + 1 - filename;
427 filename = tail + 1;
428 tail = reinterpret_cast<char*>(memchr(filename, '\n', filename_size));
429 }
430 free(buffer);
431
432 KernelIRNode::Merge(kernel_ir_head, kernel_ir, kernel_ir_size);
433 KernelIRNode::Delete(kernel_ir_head);
434 return true;
435}
static uint32_t buffer_size(uint32_t offset, uint32_t maxAlignment)
MagicNumberData kernel_list_magic_number
Definition: dartutils.cc:45
static bool TryReadSimpleKernelBuffer(uint8_t *buffer, uint8_t **p_kernel_ir, intptr_t *p_kernel_ir_size)
Definition: dfe.cc:272
static bool TryReadFile(const char *script_uri, uint8_t **buffer, intptr_t *size, bool decode_uri=true)
Definition: dfe.cc:295
static bool IsAbsolutePath(const char *path)
Definition: file_win.cc:37

◆ TryReadSimpleKernelBuffer()

static bool dart::bin::TryReadSimpleKernelBuffer ( uint8_t *  buffer,
uint8_t **  p_kernel_ir,
intptr_t *  p_kernel_ir_size 
)
static

Definition at line 272 of file dfe.cc.

274 {
275 DartUtils::MagicNumber magic_number =
276 DartUtils::SniffForMagicNumber(buffer, *p_kernel_ir_size);
277 if (magic_number == DartUtils::kKernelMagicNumber) {
278 // Do not free buffer if this is a kernel file - kernel_file will be
279 // backed by the same memory as the buffer and caller will own it.
280 // Caller is responsible for freeing the buffer when this function
281 // returns true.
282 *p_kernel_ir = buffer;
283 return true;
284 }
285 free(buffer);
286 *p_kernel_ir = nullptr;
287 *p_kernel_ir_size = -1;
288 return false;
289}

◆ UnregisterKernelBlob()

static void dart::bin::UnregisterKernelBlob ( const char *  kernel_blob_uri)
static

Definition at line 902 of file main_impl.cc.

902 {
903 dfe.UnregisterKernelBlob(kernel_blob_uri);
904}
void UnregisterKernelBlob(const char *uri)
Definition: dfe.cc:531

◆ UseChainBytes()

static int dart::bin::UseChainBytes ( SSL_CTX *  context,
ScopedMemBIO bio,
const char *  password 
)
static

Definition at line 612 of file security_context.cc.

614 {
615 int status = UseChainBytesPEM(context, bio->bio());
616 if (status == 0) {
617 if (SecureSocketUtils::NoPEMStartLine()) {
618 ERR_clear_error();
619 BIO_reset(bio->bio());
620 status = UseChainBytesPKCS12(context, bio, password);
621 }
622 } else {
623 // The PEM file was successfully read.
624 ERR_clear_error();
625 }
626 return status;
627}
static int UseChainBytesPEM(SSL_CTX *context, BIO *bio)
static int UseChainBytesPKCS12(SSL_CTX *context, ScopedMemBIO *bio, const char *password)

◆ UseChainBytesPEM()

static int dart::bin::UseChainBytesPEM ( SSL_CTX *  context,
BIO *  bio 
)
static

Definition at line 577 of file security_context.cc.

577 {
578 int status = 0;
579 ScopedX509 x509(PEM_read_bio_X509_AUX(bio, nullptr, nullptr, nullptr));
580 if (x509.get() == nullptr) {
581 return 0;
582 }
583
584 status = SSL_CTX_use_certificate(context, x509.get());
585 if (ERR_peek_error() != 0) {
586 // Key/certificate mismatch doesn't imply status is 0.
587 status = 0;
588 }
589 if (status == 0) {
590 return status;
591 }
592
593 SSL_CTX_clear_chain_certs(context);
594
595 X509* ca;
596 while ((ca = PEM_read_bio_X509(bio, nullptr, nullptr, nullptr)) != nullptr) {
597 status = SSL_CTX_add0_chain_cert(context, ca);
598 // SSL_CTX_add0_chain_cert does not inc ref count, so don't free unless the
599 // call fails.
600 if (status == 0) {
601 X509_free(ca);
602 return status;
603 }
604 // Note that we must not free `ca` if it was successfully added to the
605 // chain. We must free the main certificate x509, though since its reference
606 // count is increased by SSL_CTX_use_certificate.
607 }
608
609 return SecureSocketUtils::NoPEMStartLine() ? status : 0;
610}

◆ UseChainBytesPKCS12()

static int dart::bin::UseChainBytesPKCS12 ( SSL_CTX *  context,
ScopedMemBIO bio,
const char *  password 
)
static

Definition at line 538 of file security_context.cc.

540 {
541 CBS cbs;
542 CBS_init(&cbs, bio->data(), bio->length());
543
544 EVP_PKEY* key = nullptr;
545 ScopedX509Stack certs(sk_X509_new_null());
546 int status = PKCS12_get_key_and_certs(&key, certs.get(), &cbs, password);
547 if (status == 0) {
548 return status;
549 }
550
551 X509* ca = sk_X509_shift(certs.get());
552 status = SSL_CTX_use_certificate(context, ca);
553 if (ERR_peek_error() != 0) {
554 // Key/certificate mismatch doesn't imply status is 0.
555 status = 0;
556 }
557 X509_free(ca);
558 if (status == 0) {
559 return status;
560 }
561
562 SSL_CTX_clear_chain_certs(context);
563
564 while ((ca = sk_X509_shift(certs.get())) != nullptr) {
565 status = SSL_CTX_add0_chain_cert(context, ca);
566 // SSL_CTX_add0_chain_cert does not inc ref count, so don't free unless the
567 // call fails.
568 if (status == 0) {
569 X509_free(ca);
570 return status;
571 }
572 }
573
574 return status;
575}

◆ Utf8ToWideChar()

std::unique_ptr< wchar_t[]> dart::bin::Utf8ToWideChar ( const char *  path)

◆ va_end()

dart::bin::va_end ( args  )

◆ va_start()

dart::bin::va_start ( args  ,
format   
)

◆ VM_UNIT_TEST_CASE()

dart::bin::VM_UNIT_TEST_CASE ( CircularLinkedList  )

Definition at line 12 of file eventhandler_test.cc.

12 {
14
15 EXPECT(!list.HasHead());
16
17 list.Add(1);
18 EXPECT(list.HasHead());
19 EXPECT(list.head() == 1);
20
21 // Test: Inserts don't move head.
22 for (int i = 2; i <= 100; i++) {
23 list.Add(i);
24 EXPECT(list.head() == 1);
25 }
26
27 // Test: Rotate cycle through all elements in insertion order.
28 for (int i = 1; i <= 100; i++) {
29 EXPECT(list.HasHead());
30 EXPECT(list.head() == i);
31 list.Rotate();
32 }
33
34 // Test: Removing head results in next element to be head.
35 for (int i = 1; i <= 100; i++) {
36 list.RemoveHead();
37 for (int j = i + 1; j <= 100; j++) {
38 EXPECT(list.HasHead());
39 EXPECT(list.head() == j);
40 list.Rotate();
41 }
42 }
43
44 // Test: Removing all items individually make list empty.
45 EXPECT(!list.HasHead());
46
47 // Test: Removing all items at once makes list empty.
48 for (int i = 1; i <= 100; i++) {
49 list.Add(i);
50 }
51 list.RemoveAll();
52 EXPECT(!list.HasHead());
53
54 // Test: Remove individual items just deletes them without modifying head.
55 for (int i = 1; i <= 10; i++) {
56 list.Add(i);
57 }
58 for (int i = 2; i <= 9; i++) {
59 list.Remove(i);
60 }
61 EXPECT(list.head() == 1);
62 list.Rotate();
63 EXPECT(list.head() == 10);
64 list.Rotate();
65 EXPECT(list.head() == 1);
66
67 // Test: Remove nonexistent element leaves list un-changed.
68 list.Remove(4242);
69 EXPECT(list.head() == 1);
70
71 // Test: Remove head element individually moves head to next element.
72 list.Remove(1);
73 EXPECT(list.HasHead());
74 EXPECT(list.head() == 10);
75 list.Remove(10);
76 EXPECT(!list.HasHead());
77
78 // Test: Remove nonexistent element from empty list works.
79 list.Remove(4242);
80}
void RemoveAll(ClearFun clear=nullptr)
Definition: eventhandler.h:185
void RemoveHead(ClearFun clear=nullptr)
Definition: eventhandler.h:138

◆ VmServiceIONativeResolver()

static Dart_NativeFunction dart::bin::VmServiceIONativeResolver ( Dart_Handle  name,
int  num_arguments,
bool *  auto_setup_scope 
)
static

Definition at line 73 of file vmservice_impl.cc.

75 {
76 const char* function_name = nullptr;
79 ASSERT(function_name != nullptr);
80 *auto_setup_scope = true;
81 intptr_t n =
83 for (intptr_t i = 0; i < n; i++) {
85 if ((strcmp(function_name, entry.name) == 0) &&
86 (num_arguments == entry.num_arguments)) {
87 return entry.function;
88 }
89 }
90 return nullptr;
91}
static VmServiceIONativeEntry _VmServiceIONativeEntries[]

◆ VmServiceIONativeSymbol()

const uint8_t * dart::bin::VmServiceIONativeSymbol ( Dart_NativeFunction  nf)

Definition at line 93 of file vmservice_impl.cc.

93 {
94 intptr_t n =
96 for (intptr_t i = 0; i < n; i++) {
98 if (reinterpret_cast<Dart_NativeFunction>(entry.function) == nf) {
99 return reinterpret_cast<const uint8_t*>(entry.name);
100 }
101 }
102 return nullptr;
103}

◆ WrapError()

static void dart::bin::WrapError ( const char *  path,
char **  error 
)
static

Definition at line 101 of file native_assets_api_impl.cc.

101 {
102 if (*error != nullptr) {
103 char* inner_error = *error;
104 SET_ERROR_MSG(error, "Failed to load dynamic library '%s': %s", path,
105 inner_error);
106 free(inner_error);
107 }
108}

◆ WrapErrorRelative()

static void dart::bin::WrapErrorRelative ( const char *  path,
const char *  script_uri,
char **  error 
)
static

Definition at line 110 of file native_assets_api_impl.cc.

112 {
113 if (*error != nullptr) {
114 char* inner_error = *error;
116 "Failed to load dynamic library '%s' relative to '%s': %s",
117 path, script_uri, inner_error);
118 free(inner_error);
119 }
120}

◆ WrapMallocedKernelBuffer()

static Dart_Handle dart::bin::WrapMallocedKernelBuffer ( uint8_t *  kernel_buffer,
intptr_t  kernel_buffer_size 
)
static

Definition at line 57 of file loader.cc.

58 {
60 Dart_TypedData_kUint8, kernel_buffer, kernel_buffer_size, kernel_buffer,
61 kernel_buffer_size, MallocFinalizer);
62 if (Dart_IsError(result)) {
63 free(kernel_buffer);
64 }
65 return result;
66}

◆ WriteDepsFile()

static void dart::bin::WriteDepsFile ( )
static

Definition at line 99 of file main_impl.cc.

99 {
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}
@ Dart_KernelCompilationStatus_Ok
Definition: dart_api.h:3785
DART_EXPORT Dart_KernelCompilationResult Dart_KernelListDependencies(void)

◆ WriteFile() [1/2]

static void dart::bin::WriteFile ( const char *  filename,
const uint8_t *  buffer,
const intptr_t  size 
)
static

Definition at line 332 of file gen_snapshot.cc.

334 {
335 File* file = OpenFile(filename);
337 if (!file->WriteFully(buffer, size)) {
338 PrintErrAndExit("Error: Unable to write file: %s\n\n", filename);
339 }
340}

◆ WriteFile() [2/2]

void dart::bin::WriteFile ( const void *  buffer,
intptr_t  num_bytes,
void *  stream 
)

Definition at line 66 of file dart_io_api_impl.cc.

66 {
68}
void WriteFile(const void *buffer, intptr_t num_bytes, void *stream)

◆ WriteInt64()

static bool dart::bin::WriteInt64 ( File file,
int64_t  size 
)
static

Definition at line 652 of file snapshot_utils.cc.

652 {
653 return file->WriteFully(&size, sizeof(size));
654}

◆ WriteLoadingUnitManifest()

static void dart::bin::WriteLoadingUnitManifest ( File manifest_file,
intptr_t  id,
const char *  path,
const char *  debug_path = nullptr 
)
static

Definition at line 504 of file gen_snapshot.cc.

507 {
508 TextBuffer line(128);
509 if (id != 1) {
510 line.AddString(",\n ");
511 }
512 line.Printf("{\n \"id\": %" Pd ",\n \"path\": \"", id);
513 line.AddEscapedString(path);
514 if (debug_path != nullptr) {
515 line.Printf("\",\n \"debugPath\": \"");
516 line.AddEscapedString(debug_path);
517 }
518 line.AddString("\",\n \"libraries\": [\n ");
520 CHECK_RESULT(uris);
521 intptr_t length;
523 for (intptr_t i = 0; i < length; i++) {
524 const char* uri;
526 if (i != 0) {
527 line.AddString(",\n ");
528 }
529 line.AddString("\"");
530 line.AddEscapedString(uri);
531 line.AddString("\"");
532 }
533 line.AddString("\n ]}");
534 if (!manifest_file->Print("%s", line.buffer())) {
535 PrintErrAndExit("Error: Unable to write file: %s\n\n",
536 loading_unit_manifest_filename);
537 }
538}
DART_EXPORT Dart_Handle Dart_LoadingUnitLibraryUris(intptr_t loading_unit_id)

◆ WriteSnapshotFile()

static void dart::bin::WriteSnapshotFile ( const char *  filename,
const uint8_t *  buffer,
const intptr_t  size 
)
static

Definition at line 635 of file snapshot_utils.cc.

637 {
638 File* file = File::Open(nullptr, filename, File::kWriteTruncate);
639 if (file == nullptr) {
640 ErrorExit(kErrorExitCode, "Unable to open file %s for writing snapshot\n",
641 filename);
642 }
643
644 if (!file->WriteFully(buffer, size)) {
645 ErrorExit(kErrorExitCode, "Unable to write file %s for writing snapshot\n",
646 filename);
647 }
648 file->Release();
649}

◆ X509_Der()

void FUNCTION_NAME() dart::bin::X509_Der ( Dart_NativeArguments  args)

Definition at line 904 of file security_context.cc.

904 {
905 Dart_SetReturnValue(args, X509Helper::GetDer(args));
906}

◆ X509_EndValidity()

void FUNCTION_NAME() dart::bin::X509_EndValidity ( Dart_NativeArguments  args)

Definition at line 928 of file security_context.cc.

928 {
929 Dart_SetReturnValue(args, X509Helper::GetEndValidity(args));
930}

◆ X509_Issuer()

void FUNCTION_NAME() dart::bin::X509_Issuer ( Dart_NativeArguments  args)

Definition at line 920 of file security_context.cc.

920 {
921 Dart_SetReturnValue(args, X509Helper::GetIssuer(args));
922}

◆ X509_Pem()

void FUNCTION_NAME() dart::bin::X509_Pem ( Dart_NativeArguments  args)

Definition at line 908 of file security_context.cc.

908 {
909 Dart_SetReturnValue(args, X509Helper::GetPem(args));
910}

◆ X509_Sha1()

void FUNCTION_NAME() dart::bin::X509_Sha1 ( Dart_NativeArguments  args)

Definition at line 912 of file security_context.cc.

912 {
913 Dart_SetReturnValue(args, X509Helper::GetSha1(args));
914}

◆ X509_StartValidity()

void FUNCTION_NAME() dart::bin::X509_StartValidity ( Dart_NativeArguments  args)

Definition at line 924 of file security_context.cc.

924 {
925 Dart_SetReturnValue(args, X509Helper::GetStartValidity(args));
926}

◆ X509_Subject()

void FUNCTION_NAME() dart::bin::X509_Subject ( Dart_NativeArguments  args)

Definition at line 916 of file security_context.cc.

916 {
917 Dart_SetReturnValue(args, X509Helper::GetSubject(args));
918}

Variable Documentation

◆ _VmServiceIONativeEntries

VmServiceIONativeEntry dart::bin::_VmServiceIONativeEntries[]
static
Initial value:
= {
{"VMServiceIO_NotifyServerState", 1, NotifyServerState},
{"VMServiceIO_Shutdown", 0, Shutdown},
}
static void Shutdown(Dart_NativeArguments args)
void NotifyServerState(Dart_NativeArguments args)

Definition at line 68 of file vmservice_impl.cc.

◆ aotcoff_arm32_magic_number

MagicNumberData dart::bin::aotcoff_arm32_magic_number = {2, {0x01, 0xC0}}

Definition at line 40 of file dartutils.cc.

◆ aotcoff_arm64_magic_number

MagicNumberData dart::bin::aotcoff_arm64_magic_number = {2, {0xAA, 0x64}}

Definition at line 41 of file dartutils.cc.

◆ aotcoff_riscv32_magic_number

MagicNumberData dart::bin::aotcoff_riscv32_magic_number = {2, {0x50, 0x32}}

Definition at line 42 of file dartutils.cc.

◆ aotcoff_riscv64_magic_number

MagicNumberData dart::bin::aotcoff_riscv64_magic_number = {2, {0x50, 0x64}}

Definition at line 43 of file dartutils.cc.

◆ aotelf_magic_number

MagicNumberData dart::bin::aotelf_magic_number = {4, {0x7F, 0x45, 0x4C, 0x46, 0x0}}

Definition at line 36 of file dartutils.cc.

◆ aotmacho32_magic_number

MagicNumberData dart::bin::aotmacho32_magic_number = {4, {0xFE, 0xED, 0xFA, 0xCE}}

Definition at line 37 of file dartutils.cc.

◆ aotmacho64_arm64_magic_number

MagicNumberData dart::bin::aotmacho64_arm64_magic_number = {4, {0xCF, 0xFA, 0xED, 0xFE}}

Definition at line 39 of file dartutils.cc.

◆ aotmacho64_magic_number

MagicNumberData dart::bin::aotmacho64_magic_number = {4, {0xFE, 0xED, 0xFA, 0xCF}}

Definition at line 38 of file dartutils.cc.

◆ api_false_

CObject CObject::false_& dart::bin::api_false_

Definition at line 877 of file dartutils.cc.

◆ api_null_

CObject CObject::null_& dart::bin::api_null_

Definition at line 875 of file dartutils.cc.

◆ api_true_

CObject CObject::true_& dart::bin::api_true_

Definition at line 876 of file dartutils.cc.

◆ app_isolate_snapshot_data

const uint8_t* dart::bin::app_isolate_snapshot_data = nullptr
static

Definition at line 69 of file main_impl.cc.

◆ app_isolate_snapshot_instructions

const uint8_t* dart::bin::app_isolate_snapshot_instructions = nullptr
static

Definition at line 70 of file main_impl.cc.

◆ app_script_uri

char* dart::bin::app_script_uri = nullptr
static

Definition at line 68 of file main_impl.cc.

◆ appjit_magic_number

MagicNumberData dart::bin::appjit_magic_number = {8, {0xdc, 0xdc, 0xf6, 0xf6, 0, 0, 0, 0}}

Definition at line 35 of file dartutils.cc.

◆ BuiltinEntries [1/2]

struct dart::bin::NativeEntries dart::bin::BuiltinEntries[] = {BUILTIN_NATIVE_LIST(REGISTER_FUNCTION)}
static

◆ BuiltinEntries [2/2]

struct dart::bin::NativeEntries dart::bin::BuiltinEntries[] = {BUILTIN_NATIVE_LIST(REGISTER_FUNCTION)}
static

◆ capture_stderr

bool dart::bin::capture_stderr = false
static

Definition at line 23 of file file_support.cc.

◆ capture_stdout

bool dart::bin::capture_stdout = false
static

Definition at line 20 of file file_support.cc.

◆ core_isolate_snapshot_data

const uint8_t * dart::bin::core_isolate_snapshot_data = kDartCoreIsolateSnapshotData

Definition at line 54 of file main_impl.cc.

◆ core_isolate_snapshot_instructions

const uint8_t * dart::bin::core_isolate_snapshot_instructions
Initial value:
=
const uint8_t kDartCoreIsolateSnapshotInstructions[]

Definition at line 55 of file main_impl.cc.

◆ DART_UNUSED

const char kMachOAppSnapshotNoteName [] dart::bin::DART_UNUSED = "__dart_app_snap"
static

Definition at line 33 of file snapshot_utils.cc.

◆ DEFAULT_VM_SERVICE_SERVER_IP

constexpr const char* dart::bin::DEFAULT_VM_SERVICE_SERVER_IP = "localhost"
staticconstexpr

Definition at line 97 of file main_options.h.

◆ DEFAULT_VM_SERVICE_SERVER_PORT

constexpr int dart::bin::DEFAULT_VM_SERVICE_SERVER_PORT = 8181
staticconstexpr

Definition at line 98 of file main_options.h.

◆ dfe

DFE dart::bin::dfe

Definition at line 59 of file dfe.cc.

◆ environment

dart::SimpleHashMap* dart::bin::environment = nullptr
static

Definition at line 59 of file gen_snapshot.cc.

◆ event_handler

EventHandler* dart::bin::event_handler = nullptr
static

Definition at line 18 of file eventhandler.cc.

◆ file_schema

const char* dart::bin::file_schema = "file://"

Definition at line 44 of file native_assets_api_impl.cc.

◆ file_schema_length

const int dart::bin::file_schema_length = 7

Definition at line 45 of file native_assets_api_impl.cc.

◆ globalTcpListeningSocketRegistry

ListeningSocketRegistry* dart::bin::globalTcpListeningSocketRegistry = nullptr

Definition at line 28 of file socket.cc.

◆ gzip_magic_number

MagicNumberData dart::bin::gzip_magic_number = {2, {0x1f, 0x8b, 0, 0}}

Definition at line 48 of file dartutils.cc.

◆ INVALID_VM_SERVICE_SERVER_PORT

constexpr int dart::bin::INVALID_VM_SERVICE_SERVER_PORT = -1
staticconstexpr

Definition at line 99 of file main_options.h.

◆ IOEntries

const struct dart::bin::NativeEntries dart::bin::IOEntries[] = {IO_NATIVE_LIST(REGISTER_FUNCTION)}
static

◆ isolate_snapshot_data

const uint8_t* dart::bin::isolate_snapshot_data = nullptr

Definition at line 69 of file gen_snapshot.cc.

◆ isolate_snapshot_instructions

const uint8_t* dart::bin::isolate_snapshot_instructions = nullptr

Definition at line 70 of file gen_snapshot.cc.

◆ kApiErrorExitCode

constexpr int dart::bin::kApiErrorExitCode = 253
constexpr

Definition at line 14 of file error_exit.h.

◆ kAppSnapshotHeaderSize

constexpr int64_t dart::bin::kAppSnapshotHeaderSize = 2 * kInt64Size
staticconstexpr

Definition at line 29 of file snapshot_utils.cc.

◆ kAppSnapshotPageSize

constexpr int64_t dart::bin::kAppSnapshotPageSize = 64 * KB
staticconstexpr

Definition at line 31 of file snapshot_utils.cc.

◆ kAsyncDirectoryListerFieldIndex

constexpr int dart::bin::kAsyncDirectoryListerFieldIndex = 0
staticconstexpr

Definition at line 147 of file directory.cc.

◆ kCompilationErrorExitCode

constexpr int dart::bin::kCompilationErrorExitCode = 254
constexpr

Definition at line 16 of file error_exit.h.

◆ kDartFrontendErrorExitCode

constexpr int dart::bin::kDartFrontendErrorExitCode = 252
constexpr

Definition at line 12 of file error_exit.h.

◆ kernel_isolate_is_running

bool dart::bin::kernel_isolate_is_running = false
static

Definition at line 71 of file main_impl.cc.

◆ kernel_list_magic_number

MagicNumberData dart::bin::kernel_list_magic_number
Initial value:
= {
7,
{0x23, 0x40, 0x64, 0x69, 0x6c, 0x6c, 0x0a}}

Definition at line 45 of file dartutils.cc.

◆ kernel_magic_number

MagicNumberData dart::bin::kernel_magic_number = {4, {0x90, 0xab, 0xcd, 0xef}}

Definition at line 44 of file dartutils.cc.

◆ kernel_service_dill

const uint8_t* dart::bin::kernel_service_dill = kKernelServiceDill

Definition at line 46 of file dfe.cc.

◆ kernel_service_dill_size

const intptr_t dart::bin::kernel_service_dill_size = kKernelServiceDillSize

Definition at line 47 of file dfe.cc.

◆ kErrorExitCode

constexpr int dart::bin::kErrorExitCode = 255
constexpr

Definition at line 18 of file error_exit.h.

◆ kFileNativeFieldIndex

constexpr int dart::bin::kFileNativeFieldIndex = 0
staticconstexpr

Definition at line 22 of file file.cc.

◆ kFilterPointerNativeField

constexpr int dart::bin::kFilterPointerNativeField = 0
staticconstexpr

Definition at line 18 of file filter.cc.

◆ kInfinityTimeout

constexpr intptr_t dart::bin::kInfinityTimeout = -1
staticconstexpr

Definition at line 108 of file eventhandler.h.

◆ kInterruptMessageSize

constexpr intptr_t dart::bin::kInterruptMessageSize = sizeof(InterruptMessage)
staticconstexpr

Definition at line 107 of file eventhandler.h.

◆ kKernelServiceSnapshot

const char dart::bin::kKernelServiceSnapshot[] = "kernel-service.dart.snapshot"

Definition at line 62 of file dfe.cc.

◆ kNamespaceNativeFieldIndex

constexpr int dart::bin::kNamespaceNativeFieldIndex = 0
staticconstexpr

Definition at line 17 of file namespace.cc.

◆ kProcessIdNativeField

constexpr int dart::bin::kProcessIdNativeField = 0
staticconstexpr

Definition at line 20 of file process.cc.

◆ kShutdownId

constexpr intptr_t dart::bin::kShutdownId = -2
staticconstexpr

Definition at line 110 of file eventhandler.h.

◆ kSnapshotKindNames [1/2]

const char* const dart::bin::kSnapshotKindNames[]
static
Initial value:
= {
"core",
"app",
"app-jit",
"app-aot-assembly",
"app-aot-elf",
"vm-aot-assembly",
nullptr,
}

Definition at line 86 of file gen_snapshot.cc.

◆ kSnapshotKindNames [2/2]

const char* const dart::bin::kSnapshotKindNames[]
static
Initial value:
= {
"none",
"kernel",
"app-jit",
nullptr,
}

Definition at line 31 of file main_options.cc.

◆ kSnapshotsDirectory

const char dart::bin::kSnapshotsDirectory[] = "snapshots"

Definition at line 63 of file dfe.cc.

◆ kSocketIdNativeField [1/2]

constexpr int dart::bin::kSocketIdNativeField = 0
staticconstexpr

Definition at line 26 of file socket.cc.

◆ kSocketIdNativeField [2/2]

constexpr int dart::bin::kSocketIdNativeField = 0
staticconstexpr

Definition at line 39 of file sync_socket.cc.

◆ kStderrStreamId

constexpr const char* dart::bin::kStderrStreamId = "Stderr"
staticconstexpr

Definition at line 927 of file main_impl.cc.

◆ kStdoutStreamId

constexpr const char* dart::bin::kStdoutStreamId = "Stdout"
staticconstexpr

Definition at line 926 of file main_impl.cc.

◆ kTimerId

constexpr intptr_t dart::bin::kTimerId = -1
staticconstexpr

Definition at line 109 of file eventhandler.h.

◆ kVerbosityLevelNames

const char* const dart::bin::kVerbosityLevelNames[]
static
Initial value:
= {
"error", "warning", "info", "all", nullptr,
}

Definition at line 39 of file main_options.cc.

◆ kVMServiceIOLibraryUri

constexpr const char* dart::bin::kVMServiceIOLibraryUri = "dart:vmservice_io"
staticconstexpr

Definition at line 37 of file vmservice_impl.cc.

◆ kZLibFlagAcceptAnyHeader

const int dart::bin::kZLibFlagAcceptAnyHeader = 32

Definition at line 16 of file filter.cc.

◆ kZLibFlagUseGZipHeader

const int dart::bin::kZLibFlagUseGZipHeader = 16

Definition at line 15 of file filter.cc.

◆ main_isolate

Dart_Isolate dart::bin::main_isolate = nullptr
static

Definition at line 73 of file main_impl.cc.

◆ observatory_assets_archive

const uint8_t * dart::bin::observatory_assets_archive = observatory_assets_archive_

Definition at line 15 of file observatory_assets_empty.cc.

◆ observatory_assets_archive_

const uint8_t dart::bin::observatory_assets_archive_[] = {'\0'}
static

Definition at line 13 of file observatory_assets_empty.cc.

◆ observatory_assets_archive_len

unsigned int dart::bin::observatory_assets_archive_len = 0

Definition at line 14 of file observatory_assets_empty.cc.

◆ platform_strong_dill

const uint8_t* dart::bin::platform_strong_dill = kPlatformStrongDill

Definition at line 54 of file dfe.cc.

◆ platform_strong_dill_size

const intptr_t dart::bin::platform_strong_dill_size = kPlatformStrongDillSize

Definition at line 55 of file dfe.cc.

◆ root_certificates_pem

const unsigned char * dart::bin::root_certificates_pem = root_certificates_pem_

Definition at line 18309 of file root_certificates.cc.

◆ root_certificates_pem_

const unsigned char dart::bin::root_certificates_pem_[]

Definition at line 17 of file root_certificates.cc.

◆ root_certificates_pem_length

unsigned int dart::bin::root_certificates_pem_length = 219488

Definition at line 18310 of file root_certificates.cc.

◆ shutdown_monitor

Monitor* dart::bin::shutdown_monitor = nullptr
static

Definition at line 19 of file eventhandler.cc.

◆ snapshot_kind

SnapshotKind dart::bin::snapshot_kind = kCore
static

Definition at line 83 of file gen_snapshot.cc.

◆ SSL_LOG_CERTS

const bool dart::bin::SSL_LOG_CERTS = false

Definition at line 24 of file secure_socket_utils.h.

◆ SSL_LOG_DATA

const bool dart::bin::SSL_LOG_DATA = false

Definition at line 23 of file secure_socket_utils.h.

◆ SSL_LOG_STATUS

const bool dart::bin::SSL_LOG_STATUS = false

Definition at line 22 of file secure_socket_utils.h.

◆ vm_run_app_snapshot

bool dart::bin::vm_run_app_snapshot = false
static

Global state used to control and store generation of application snapshots. An application snapshot can be generated and run using the following command dart –snapshot-kind=app-jit –snapshot=<app_snapshot_filename> <script_uri> [<script_options>] To Run the application snapshot generated above, use : dart <app_snapshot_filename> [<script_options>]

Definition at line 67 of file main_impl.cc.

◆ vm_snapshot_data

const uint8_t * dart::bin::vm_snapshot_data = kDartVmSnapshotData

Definition at line 52 of file main_impl.cc.

◆ vm_snapshot_instructions

const uint8_t * dart::bin::vm_snapshot_instructions = kDartVmSnapshotInstructions

Definition at line 53 of file main_impl.cc.