Bug 1508091 - Add redirection for mach_vm_map, r=lsmyth.
authorBrian Hackett <bhackett1024@gmail.com>
Sat, 17 Nov 2018 11:49:36 -1000
changeset 504023 44f52ad4773bbe634f031ad08cf3a0e6f2310ae5
parent 504022 d0c382d99e7646c161244b7e73429362f6caaa58
child 504024 436fe5156b0a113bc53392c368bc5d8e2a3d39ef
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsmyth
bugs1508091
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1508091 - Add redirection for mach_vm_map, r=lsmyth.
toolkit/recordreplay/ProcessRedirectDarwin.cpp
--- a/toolkit/recordreplay/ProcessRedirectDarwin.cpp
+++ b/toolkit/recordreplay/ProcessRedirectDarwin.cpp
@@ -193,16 +193,17 @@ namespace recordreplay {
   MACRO(mach_absolute_time, RR_ScalarRval, Preamble_mach_absolute_time, \
         nullptr, Preamble_PassThrough)                           \
   MACRO(mach_msg, RR_Compose<RR_ScalarRval, RR_WriteBuffer<0, 3>>, \
         nullptr, nullptr, Preamble_WaitForever)                  \
   MACRO(mach_timebase_info,                                      \
         RR_Compose<RR_ScalarRval, RR_WriteBufferFixedSize<0, sizeof(mach_timebase_info_data_t)>>) \
   MACRO(mach_vm_allocate, nullptr, Preamble_mach_vm_allocate)    \
   MACRO(mach_vm_deallocate, nullptr, Preamble_mach_vm_deallocate) \
+  MACRO(mach_vm_map, nullptr, Preamble_mach_vm_map)              \
   MACRO(mach_vm_protect, nullptr, Preamble_mach_vm_protect)      \
   MACRO(rand, RR_ScalarRval)                                     \
   MACRO(realpath,                                                \
         RR_SaveRvalHadErrorZero<RR_Compose<RR_CStringRval,       \
                                            RR_WriteOptionalBufferFixedSize<1, PATH_MAX>>>) \
   MACRO(realpath$DARWIN_EXTSN,                                   \
         RR_SaveRvalHadErrorZero<RR_Compose<RR_CStringRval,       \
                                            RR_WriteOptionalBufferFixedSize<1, PATH_MAX>>>) \
@@ -1492,16 +1493,36 @@ Preamble_mach_vm_deallocate(CallArgument
   auto& address = aArguments->Arg<1, void*>();
   auto& size = aArguments->Arg<2, size_t>();
   DeallocateMemory(address, size, MemoryKind::Tracked);
   aArguments->Rval<size_t>() = KERN_SUCCESS;
   return PreambleResult::Veto;
 }
 
 static PreambleResult
+Preamble_mach_vm_map(CallArguments* aArguments)
+{
+  if (IsRecording()) {
+    return PreambleResult::PassThrough;
+  } else if (AreThreadEventsPassedThrough()) {
+    // We should only reach this at startup, when initializing the graphics
+    // shared memory block.
+    MOZ_RELEASE_ASSERT(!HasSavedCheckpoint());
+    return PreambleResult::PassThrough;
+  }
+
+  auto size = aArguments->Arg<2, size_t>();
+  auto address = aArguments->Arg<1, void**>();
+
+  *address = AllocateMemory(size, MemoryKind::Tracked);
+  aArguments->Rval<size_t>() = KERN_SUCCESS;
+  return PreambleResult::Veto;
+}
+
+static PreambleResult
 Preamble_mach_vm_protect(CallArguments* aArguments)
 {
   // Ignore any mach_vm_protect calls that occur after saving a checkpoint, as for mprotect.
   if (!HasSavedCheckpoint()) {
     return PreambleResult::PassThrough;
   }
   aArguments->Rval<size_t>() = KERN_SUCCESS;
   return PreambleResult::Veto;