Bug 1525416 - Teach libffi/src/closures.c about ARM64_WIN64 r=froydnj
authorDavid Major <dmajor@mozilla.com>
Tue, 12 Feb 2019 21:44:46 +0000
changeset 458810 430f461b9636
parent 458809 91ac960f7b59
child 458811 932e8c798e28
push id35548
push useropoprus@mozilla.com
push dateWed, 13 Feb 2019 09:48:26 +0000
treeherdermozilla-central@93e37c529818 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1525416
milestone67.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 1525416 - Teach libffi/src/closures.c about ARM64_WIN64 r=froydnj I added ARM64_WIN64 to every line that mentioned X86_WIN32 and X86_WIN64. This makes sure the allocation routines do the proper VirtualProtect on the trampolines. Differential Revision: https://phabricator.services.mozilla.com/D19567
js/src/ctypes/libffi/src/closures.c
--- a/js/src/ctypes/libffi/src/closures.c
+++ b/js/src/ctypes/libffi/src/closures.c
@@ -40,17 +40,17 @@
    option is defined will attempt to map such pages once, but if it
    fails, it falls back to creating a temporary file in a writable and
    executable filesystem and mapping pages from it into separate
    locations in the virtual memory space, one location writable and
    another executable.  */
 #  define FFI_MMAP_EXEC_WRIT 1
 #  define HAVE_MNTENT 1
 # endif
-# if defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)
+# if defined(X86_WIN32) || defined(X86_WIN64) || defined(ARM64_WIN64) || defined(__OS2__)
 /* Windows systems may have Data Execution Protection (DEP) enabled, 
    which requires the use of VirtualMalloc/VirtualFree to alloc/free
    executable memory. */
 #  define FFI_MMAP_EXEC_WRIT 1
 # endif
 #endif
 
 #if FFI_MMAP_EXEC_WRIT && !defined FFI_MMAP_EXEC_SELINUX
@@ -106,17 +106,17 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <errno.h>
 #ifndef _MSC_VER
 #include <unistd.h>
 #endif
 #include <string.h>
 #include <stdio.h>
-#if !defined(X86_WIN32) && !defined(X86_WIN64)
+#if !defined(X86_WIN32) && !defined(X86_WIN64) && !defined(ARM64_WIN64)
 #ifdef HAVE_MNTENT
 #include <mntent.h>
 #endif /* HAVE_MNTENT */
 #include <sys/param.h>
 #include <pthread.h>
 
 /* We don't want sys/mman.h to be included after we redefine mmap and
    dlmunmap.  */
@@ -209,17 +209,17 @@ emutramp_enabled_check (void)
 
 #elif defined (__CYGWIN__) || defined(__INTERIX)
 
 #include <sys/mman.h>
 
 /* Cygwin is Linux-like, but not quite that Linux-like.  */
 #define is_selinux_enabled() 0
 
-#endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */
+#endif /* !defined(X86_WIN32) && !defined(X86_WIN64) && !defined(ARM64_WIN64) */
 
 #ifndef FFI_MMAP_EXEC_EMUTRAMP_PAX
 #define is_emutramp_enabled() 0
 #endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */
 
 /* Declare all functions defined in dlmalloc.c as static.  */
 static void *dlmalloc(size_t);
 static void dlfree(void*);
@@ -232,31 +232,31 @@ static size_t dlmalloc_footprint(void) M
 static size_t dlmalloc_max_footprint(void) MAYBE_UNUSED;
 static void** dlindependent_calloc(size_t, size_t, void**) MAYBE_UNUSED;
 static void** dlindependent_comalloc(size_t, size_t*, void**) MAYBE_UNUSED;
 static void *dlpvalloc(size_t) MAYBE_UNUSED;
 static int dlmalloc_trim(size_t) MAYBE_UNUSED;
 static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED;
 static void dlmalloc_stats(void) MAYBE_UNUSED;
 
-#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX)
+#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(ARM64_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX)
 /* Use these for mmap and munmap within dlmalloc.c.  */
 static void *dlmmap(void *, size_t, int, int, int, off_t);
 static int dlmunmap(void *, size_t);
-#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */
+#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(ARM64_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */
 
 #define mmap dlmmap
 #define munmap dlmunmap
 
 #include "dlmalloc.c"
 
 #undef mmap
 #undef munmap
 
-#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX)
+#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(ARM64_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX)
 
 /* A mutex used to synchronize access to *exec* variables in this file.  */
 static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 /* A file descriptor of a temporary file from which we'll map
    executable pages.  */
 static int execfd = -1;
 
@@ -567,17 +567,17 @@ segment_holding_code (mstate m, char* ad
 	&& addr < add_segment_exec_offset (sp->base, sp) + sp->size)
       return sp;
     if ((sp = sp->next) == 0)
       return 0;
   }
 }
 #endif
 
-#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */
+#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(ARM64_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */
 
 /* Allocate a chunk of memory with the given size.  Returns a pointer
    to the writable address, and sets *CODE to the executable
    corresponding virtual address.  */
 void *
 ffi_closure_alloc (size_t size, void **code)
 {
   void *ptr;