6#if defined(DART_HOST_OS_MACOS)
13#include <mach-o/loader.h>
14#include <mach/clock.h>
16#include <mach/mach_time.h>
17#include <sys/resource.h>
33 return static_cast<intptr_t
>(getpid());
36static bool LocalTime(int64_t seconds_since_epoch, tm* tm_result) {
37 time_t seconds =
static_cast<time_t
>(seconds_since_epoch);
38 if (seconds != seconds_since_epoch)
return false;
39 struct tm* error_code = localtime_r(&seconds, tm_result);
40 return error_code !=
nullptr;
45 bool succeeded = LocalTime(seconds_since_epoch, &decomposed);
47 return (succeeded && (decomposed.tm_zone !=
nullptr)) ? decomposed.tm_zone
53 bool succeeded = LocalTime(seconds_since_epoch, &decomposed);
56 return succeeded ?
static_cast<int>(decomposed.tm_gmtoff) : 0;
66 if (gettimeofday(&tv,
nullptr) < 0) {
70 return (
static_cast<int64_t
>(tv.tv_sec) * 1000000) + tv.tv_usec;
74 return clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW);
87 return clock_gettime_nsec_np(CLOCK_THREAD_CPUTIME_ID) /
92#if defined(SUPPORT_TIMELINE)
93 if (Timeline::recorder_discards_clock_values())
return -1;
106#elif TARGET_ARCH_ARM64
108#elif TARGET_ARCH_IA32
123 return sysconf(_SC_NPROCESSORS_ONLN);
141 req.tv_sec =
static_cast<int32_t
>(seconds);
142 req.tv_nsec =
static_cast<long>(nanos);
144 int r = nanosleep(&req, &rem);
160 return reinterpret_cast<uintptr_t
>(
161 __builtin_extract_return_addr(__builtin_return_address(0)));
193 va_list measure_args;
194 va_copy(measure_args,
args);
208 va_copy(print_args,
args);
215 ASSERT(str !=
nullptr && strlen(str) > 0 &&
value !=
nullptr);
221 }
else if (str[0] ==
'+') {
224 if ((str[
i] ==
'0') && (str[
i + 1] ==
'x' || str[
i + 1] ==
'X') &&
225 (str[
i + 2] !=
'\0')) {
232 *
value =
static_cast<int64_t
>(strtoull(str, &endptr,
base));
236 return ((errno == 0) && (endptr != str) && (*endptr == 0));
260 if (gettimeofday(&tv,
nullptr) < 0) {
261 FATAL(
"gettimeofday returned an error (%s)\n", strerror(errno));
265 struct tm* error_code = localtime_r(&(tv.tv_sec), &decomposed);
266 if (error_code ==
nullptr) {
267 FATAL(
"localtime_r returned an error (%s)\n", strerror(errno));
288 const Image instructions_image(snapshot_instructions);
289 if (
auto*
const image_build_id = instructions_image.build_id()) {
290 return {instructions_image.build_id_length(), image_build_id};
292 const uint8_t* dso_base =
GetAppDSOBase(snapshot_instructions);
293 const auto& macho_header =
294 *
reinterpret_cast<const struct mach_header*
>(dso_base);
299 const size_t macho_header_size = macho_header.magic ==
MH_MAGIC
300 ?
sizeof(
struct mach_header)
301 : sizeof(struct mach_header_64);
302 const uint8_t* it = dso_base + macho_header_size;
303 const uint8_t*
end = it + macho_header.sizeofcmds;
305 const auto& current_cmd = *reinterpret_cast<const struct load_command*>(it);
306 if ((current_cmd.cmd & ~LC_REQ_DYLD) == LC_UUID) {
307 const auto& uuid_cmd = *reinterpret_cast<const struct uuid_command*>(it);
309 static_cast<intptr_t>(uuid_cmd.cmdsize - sizeof(struct load_command)),
312 it += current_cmd.cmdsize;
static DART_NORETURN void Exit(int code)
static int NumberOfAvailableProcessors()
static const char * GetTimeZoneName(int64_t seconds_since_epoch)
static void SleepMicros(int64_t micros)
static int64_t GetCurrentTimeMillis()
static void RegisterCodeObservers()
static int64_t GetCurrentMonotonicMicros()
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static void Sleep(int64_t millis)
static void Print(const char *format,...) PRINTF_ATTRIBUTE(1
static bool StringToInt64(const char *str, int64_t *value)
static BuildId GetAppBuildId(const uint8_t *snapshot_instructions)
static const uint8_t * GetAppDSOBase(const uint8_t *snapshot_instructions)
static int64_t GetCurrentTimeMicros()
static intptr_t ActivationFrameAlignment()
static void static void static void VFPrint(FILE *stream, const char *format, va_list args)
static DART_NORETURN void Abort()
static char static char * VSCreate(Zone *zone, const char *format, va_list args)
static int64_t GetCurrentThreadCPUMicros()
static uintptr_t GetProgramCounter()
static intptr_t ProcessId()
static void PrepareToAbort()
static int64_t GetCurrentMonotonicFrequency()
static char * SCreate(Zone *zone, const char *format,...) PRINTF_ATTRIBUTE(2
static int64_t GetCurrentMonotonicTicks()
static int64_t GetCurrentMonotonicMicrosForTimeline()
static int GetTimeZoneOffsetInSeconds(int64_t seconds_since_epoch)
static int static int VSNPrint(char *str, size_t size, const char *format, va_list args)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
uint32_t uint32_t * format
constexpr intptr_t kMicrosecondsPerMillisecond
constexpr intptr_t kMicrosecondsPerSecond
constexpr intptr_t kNanosecondsPerMicrosecond
void * malloc(size_t size)
constexpr intptr_t kNanosecondsPerSecond
constexpr int32_t kMaxInt32
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