Bug 1485701 - make the interceptor code compilable, if not functional, on aarch64 windows; r=aklotz
authorNathan Froyd <froydnj@mozilla.com>
Tue, 28 Aug 2018 09:27:57 -0400
changeset 488731 1642245157667814068b0d39d3b03d74801cca8a
parent 488730 dd857ab01989843d0feae7eb4525b374e6a34439
child 488732 514f97264e6c75713ff3828931c5415a69697ca7
push id9734
push usershindli@mozilla.com
push dateThu, 30 Aug 2018 12:18:07 +0000
treeherdermozilla-beta@71c71ab3afae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaklotz
bugs1485701
milestone63.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 1485701 - make the interceptor code compilable, if not functional, on aarch64 windows; r=aklotz
mozglue/misc/interceptor/PatcherDetour.h
mozglue/misc/interceptor/TargetFunction.h
mozglue/misc/nsWindowsDllInterceptor.h
--- a/mozglue/misc/interceptor/PatcherDetour.h
+++ b/mozglue/misc/interceptor/PatcherDetour.h
@@ -47,16 +47,19 @@ public:
     if (!this->mVMPolicy.ShouldUnhookUponDestruction()) {
       return;
     }
 
 #if defined(_M_IX86)
     size_t nBytes = 1 + sizeof(intptr_t);
 #elif defined(_M_X64)
     size_t nBytes = 2 + sizeof(intptr_t);
+#elif defined(_M_ARM64)
+    size_t nBytes = 4;
+    MOZ_RELEASE_ASSERT(false, "Shouldn't get here");
 #else
 #error "Unknown processor type"
 #endif
 
     const auto& tramps = this->mVMPolicy.Items();
     for (auto&& tramp : tramps) {
       // First we read the pointer to the interceptor instance.
       Maybe<uintptr_t> instance = tramp.ReadEncodedPointer();
@@ -125,16 +128,18 @@ public:
       if (opcode2 != 0xBB) {
         continue;
       }
 
       origBytes.WritePointer(tramp.GetCurrentRemoteAddress());
       if (!origBytes) {
         continue;
       }
+#elif defined(_M_ARM64)
+      MOZ_RELEASE_ASSERT(false, "Shouldn't get here")
 #else
 #error "Unknown processor type"
 #endif
 
       origBytes.Commit();
     }
 
     this->mVMPolicy.Clear();
@@ -958,16 +963,18 @@ protected:
           return;
         }
         COPY_CODES(len + 1);
       } else {
         MOZ_ASSERT_UNREACHABLE("Unrecognized opcode sequence");
         return;
       }
     }
+#elif defined(_M_ARM64)
+      MOZ_RELEASE_ASSERT(false, "Shouldn't get here")
 #else
 #error "Unknown processor type"
 #endif
 
     if (origBytes.GetOffset() > 100) {
       //printf ("Too big!");
       return;
     }
--- a/mozglue/misc/interceptor/TargetFunction.h
+++ b/mozglue/misc/interceptor/TargetFunction.h
@@ -356,17 +356,17 @@ private:
   // In an ideal world, we'd only read 5 bytes on 32-bit and 13 bytes on 64-bit,
   // to match the minimum bytes that we need to write in in order to patch the
   // target function. Since the actual opcodes will often require us to pull in
   // extra bytes above that minimum, we set the inline storage to be larger than
   // those minima in an effort to give the Vector extra wiggle room before it
   // needs to touch the heap.
 #if defined(_M_IX86)
   static const size_t kInlineStorage = 16;
-#elif defined(_M_X64)
+#elif defined(_M_X64) || defined(_M_ARM64)
   static const size_t kInlineStorage = 32;
 #endif
   Vector<uint8_t, kInlineStorage> mLocalBytes;
   bool mAccumulatedStatus;
   AutoProtect mProtect;
 };
 
 template <typename MMPolicy>
@@ -581,17 +581,17 @@ private:
   // In an ideal world, we'd only read 5 bytes on 32-bit and 13 bytes on 64-bit,
   // to match the minimum bytes that we need to write in in order to patch the
   // target function. Since the actual opcodes will often require us to pull in
   // extra bytes above that minimum, we set the inline storage to be larger than
   // those minima in an effort to give the Vector extra wiggle room before it
   // needs to touch the heap.
 #if defined(_M_IX86)
   static const size_t kInlineStorage = 16;
-#elif defined(_M_X64)
+#elif defined(_M_X64) || defined(_M_ARM64)
   static const size_t kInlineStorage = 32;
 #endif
 
   const MMPolicyOutOfProcess&     mMMPolicy;
   Vector<uint8_t, kInlineStorage> mLocalBytes;
   uint8_t const * const           mBase;
 };
 
--- a/mozglue/misc/nsWindowsDllInterceptor.h
+++ b/mozglue/misc/nsWindowsDllInterceptor.h
@@ -427,16 +427,21 @@ private:
    * TestDllInterceptor in order to detect future failures.  Even if this
    * succeeds now, updates to the detoured DLL could cause it to fail in
    * the future.
    */
   bool AddDetour(const char* aName, intptr_t aHookDest, void** aOrigFunc)
   {
     // Generally, code should not call this method directly. Use AddHook unless
     // there is a specific need to avoid nop space patches.
+#if defined(_M_ARM64)
+    // XXX: this is just to get things compiling; we'll have to add real
+    // support at some future point.
+    return false;
+#endif
 
     if (!mModule) {
       return false;
     }
 
     FARPROC proc = ::GetProcAddress(mModule, aName);
     if (!proc) {
       return false;