[vm] Avoid querying boot time on Mac/iOS.

mach_absolute_time uses the same clock as CLOCK_UPTIME_RAW. There are privacy concerns that boot time can be used for device fingerprinting. Dart doesn't not need to know boot time, only some monotonic clock.

TEST=ci
Change-Id: I57acd080bb93ce9cf51b4b90aec09bb7cab7f7af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348044
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
diff --git a/runtime/bin/utils_macos.cc b/runtime/bin/utils_macos.cc
index 924132f..9ce28f0 100644
--- a/runtime/bin/utils_macos.cc
+++ b/runtime/bin/utils_macos.cc
@@ -71,25 +71,15 @@
   return false;
 }
 
-static mach_timebase_info_data_t timebase_info;
-
-void TimerUtils::InitOnce() {
-  kern_return_t kr = mach_timebase_info(&timebase_info);
-  ASSERT(KERN_SUCCESS == kr);
-}
+void TimerUtils::InitOnce() {}
 
 int64_t TimerUtils::GetCurrentMonotonicMillis() {
   return GetCurrentMonotonicMicros() / 1000;
 }
 
 int64_t TimerUtils::GetCurrentMonotonicMicros() {
-  ASSERT(timebase_info.denom != 0);
-  // timebase_info converts absolute time tick units into nanoseconds.  Convert
-  // to microseconds.
-  int64_t result = mach_absolute_time() / kNanosecondsPerMicrosecond;
-  result *= timebase_info.numer;
-  result /= timebase_info.denom;
-  return result;
+  return clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW) /
+         kNanosecondsPerMicrosecond;
 }
 
 void TimerUtils::Sleep(int64_t millis) {
diff --git a/runtime/vm/os_macos.cc b/runtime/vm/os_macos.cc
index b668ba0..24f2120 100644
--- a/runtime/vm/os_macos.cc
+++ b/runtime/vm/os_macos.cc
@@ -70,19 +70,8 @@
   return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec;
 }
 
-static mach_timebase_info_data_t timebase_info;
-
 int64_t OS::GetCurrentMonotonicTicks() {
-  if (timebase_info.denom == 0) {
-    kern_return_t kr = mach_timebase_info(&timebase_info);
-    ASSERT(KERN_SUCCESS == kr);
-  }
-  ASSERT(timebase_info.denom != 0);
-  // timebase_info converts absolute time tick units into nanoseconds.
-  int64_t result = mach_absolute_time();
-  result *= timebase_info.numer;
-  result /= timebase_info.denom;
-  return result;
+  return clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW);
 }
 
 int64_t OS::GetCurrentMonotonicFrequency() {