about summary refs log tree commit diff
path: root/pkgs/development/interpreters/spidermonkey
diff options
context:
space:
mode:
authorRobin Gloster <mail@glob.in>2017-05-20 13:57:49 +0200
committerRobin Gloster <mail@glob.in>2017-05-20 14:55:44 +0200
commitda9adb8fab40a3dd86d6cfcbd103657ca98e5a48 (patch)
tree25c6af6c8753a49d4774eb901d9696ccefa9d461 /pkgs/development/interpreters/spidermonkey
parent9beb44fb84fa579edcbdb9089facce25248bac02 (diff)
parentc9f3893451103c52e70566a5d043ab5e35014e6c (diff)
downloadnixlib-da9adb8fab40a3dd86d6cfcbd103657ca98e5a48.tar
nixlib-da9adb8fab40a3dd86d6cfcbd103657ca98e5a48.tar.gz
nixlib-da9adb8fab40a3dd86d6cfcbd103657ca98e5a48.tar.bz2
nixlib-da9adb8fab40a3dd86d6cfcbd103657ca98e5a48.tar.lz
nixlib-da9adb8fab40a3dd86d6cfcbd103657ca98e5a48.tar.xz
nixlib-da9adb8fab40a3dd86d6cfcbd103657ca98e5a48.tar.zst
nixlib-da9adb8fab40a3dd86d6cfcbd103657ca98e5a48.zip
Merge remote-tracking branch 'upstream/master' into gcc-6
Diffstat (limited to 'pkgs/development/interpreters/spidermonkey')
-rw-r--r--pkgs/development/interpreters/spidermonkey/17.nix3
-rw-r--r--pkgs/development/interpreters/spidermonkey/38.nix2
-rw-r--r--pkgs/development/interpreters/spidermonkey/aarch64-48bit-va-fix.patch106
-rw-r--r--pkgs/development/interpreters/spidermonkey/aarch64-double-conversion.patch13
4 files changed, 123 insertions, 1 deletions
diff --git a/pkgs/development/interpreters/spidermonkey/17.nix b/pkgs/development/interpreters/spidermonkey/17.nix
index a2ecfb2ef97a..33acb792f761 100644
--- a/pkgs/development/interpreters/spidermonkey/17.nix
+++ b/pkgs/development/interpreters/spidermonkey/17.nix
@@ -20,6 +20,9 @@ stdenv.mkDerivation rec {
   postPatch = ''
     # Fixes an issue with version detection under perl 5.22.x
     sed -i 's/(defined\((@TEMPLATE_FILE)\))/\1/' config/milestone.pl
+  '' + stdenv.lib.optionalString stdenv.isAarch64 ''
+    patch -p1 -d ../.. < ${./aarch64-double-conversion.patch}
+    patch -p1 -d ../.. < ${./aarch64-48bit-va-fix.patch}
   '';
 
   preConfigure = ''
diff --git a/pkgs/development/interpreters/spidermonkey/38.nix b/pkgs/development/interpreters/spidermonkey/38.nix
index b4823817d4b7..e2a4ad2e3020 100644
--- a/pkgs/development/interpreters/spidermonkey/38.nix
+++ b/pkgs/development/interpreters/spidermonkey/38.nix
@@ -53,7 +53,7 @@ stdenv.mkDerivation rec {
 
   meta = with stdenv.lib; {
     description = "Mozilla's JavaScript engine written in C/C++";
-    homepage = https://developer.mozilla.org/en/SpiderMonkey;
+    homepage = "https://developer.mozilla.org/en/SpiderMonkey";
     # TODO: MPL/GPL/LGPL tri-license.
 
     maintainers = [ maintainers.abbradar ];
diff --git a/pkgs/development/interpreters/spidermonkey/aarch64-48bit-va-fix.patch b/pkgs/development/interpreters/spidermonkey/aarch64-48bit-va-fix.patch
new file mode 100644
index 000000000000..8258a46b1748
--- /dev/null
+++ b/pkgs/development/interpreters/spidermonkey/aarch64-48bit-va-fix.patch
@@ -0,0 +1,106 @@
+From a0c0f32299419359b44ac0f880c1ea9073ae51e1 Mon Sep 17 00:00:00 2001
+From: Zheng Xu <zheng.xu@linaro.org>
+Date: Fri, 02 Sep 2016 17:40:05 +0800
+Subject: [PATCH] Bug 1143022 - Manually mmap on arm64 to ensure high 17 bits are clear. r=ehoogeveen
+
+There might be 48-bit VA on arm64 depending on kernel configuration.
+Manually mmap heap memory to align with the assumption made by JS engine.
+
+Change-Id: Ic5d2b2fe4b758b3c87cc0688348af7e71a991146
+---
+
+diff --git a/js/src/gc/Memory.cpp b/js/src/gc/Memory.cpp
+index 5b386a2..38101cf 100644
+--- a/js/src/gc/Memory.cpp
++++ b/js/src/gc/Memory.cpp
+@@ -309,6 +309,75 @@
+ #endif
+ }
+ 
++static inline void *
++MapMemory(size_t length, int prot, int flags, int fd, off_t offset)
++{
++#if defined(__ia64__)
++    /*
++     * The JS engine assumes that all allocated pointers have their high 17 bits clear,
++     * which ia64's mmap doesn't support directly. However, we can emulate it by passing
++     * mmap an "addr" parameter with those bits clear. The mmap will return that address,
++     * or the nearest available memory above that address, providing a near-guarantee
++     * that those bits are clear. If they are not, we return NULL below to indicate
++     * out-of-memory.
++     *
++     * The addr is chosen as 0x0000070000000000, which still allows about 120TB of virtual
++     * address space.
++     *
++     * See Bug 589735 for more information.
++     */
++    void *region = mmap((void*)0x0000070000000000, length, prot, flags, fd, offset);
++    if (region == MAP_FAILED)
++        return MAP_FAILED;
++    /*
++     * If the allocated memory doesn't have its upper 17 bits clear, consider it
++     * as out of memory.
++     */
++    if ((uintptr_t(region) + (length - 1)) & 0xffff800000000000) {
++        JS_ALWAYS_TRUE(0 == munmap(region, length));
++        return MAP_FAILED;
++    }
++    return region;
++#elif defined(__aarch64__)
++   /*
++    * There might be similar virtual address issue on arm64 which depends on
++    * hardware and kernel configurations. But the work around is slightly
++    * different due to the different mmap behavior.
++    *
++    * TODO: Merge with the above code block if this implementation works for
++    * ia64 and sparc64.
++    */
++    const uintptr_t start = (uintptr_t)(0x0000070000000000UL);
++    const uintptr_t end   = (uintptr_t)(0x0000800000000000UL);
++    const uintptr_t step  = ChunkSize;
++   /*
++    * Optimization options if there are too many retries in practice:
++    * 1. Examine /proc/self/maps to find an available address. This file is
++    *    not always available, however. In addition, even if we examine
++    *    /proc/self/maps, we may still need to retry several times due to
++    *    racing with other threads.
++    * 2. Use a global/static variable with lock to track the addresses we have
++    *    allocated or tried.
++    */
++    uintptr_t hint;
++    void* region = MAP_FAILED;
++    for (hint = start; region == MAP_FAILED && hint + length <= end; hint += step) {
++        region = mmap((void*)hint, length, prot, flags, fd, offset);
++        if (region != MAP_FAILED) {
++            if ((uintptr_t(region) + (length - 1)) & 0xffff800000000000) {
++                if (munmap(region, length)) {
++                    MOZ_ASSERT(errno == ENOMEM);
++                }
++                region = MAP_FAILED;
++            }
++        }
++    }
++    return region == MAP_FAILED ? NULL : region;
++#else
++    return mmap(NULL, length, prot, flags, fd, offset);
++#endif
++}
++
+ void *
+ MapAlignedPages(size_t size, size_t alignment)
+ {
+@@ -322,12 +391,12 @@
+ 
+     /* Special case: If we want page alignment, no further work is needed. */
+     if (alignment == PageSize) {
+-        return mmap(NULL, size, prot, flags, -1, 0);
++        return MapMemory(size, prot, flags, -1, 0);
+     }
+ 
+     /* Overallocate and unmap the region's edges. */
+     size_t reqSize = Min(size + 2 * alignment, 2 * size);
+-    void *region = mmap(NULL, reqSize, prot, flags, -1, 0);
++    void *region = MapMemory(reqSize, prot, flags, -1, 0);
+     if (region == MAP_FAILED)
+         return NULL;
+ 
diff --git a/pkgs/development/interpreters/spidermonkey/aarch64-double-conversion.patch b/pkgs/development/interpreters/spidermonkey/aarch64-double-conversion.patch
new file mode 100644
index 000000000000..bf41ce0a8a21
--- /dev/null
+++ b/pkgs/development/interpreters/spidermonkey/aarch64-double-conversion.patch
@@ -0,0 +1,13 @@
+diff -ru mozjs17.0.0-orig/mfbt/double-conversion/utils.h mozjs17.0.0/mfbt/double-conversion/utils.h
+--- mozjs17.0.0-orig/mfbt/double-conversion/utils.h	2013-02-11 17:33:28.000000000 -0500
++++ mozjs17.0.0/mfbt/double-conversion/utils.h	2016-12-03 20:39:07.915042988 -0500
+@@ -58,7 +58,8 @@
+     defined(__mips__) || defined(__powerpc__) || \
+     defined(__sparc__) || defined(__sparc) || defined(__s390__) || \
+     defined(__SH4__) || defined(__alpha__) || \
+-    defined(_MIPS_ARCH_MIPS32R2)
++    defined(_MIPS_ARCH_MIPS32R2) || \
++    defined(__AARCH64EL__)
+ #define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
+ #elif defined(_M_IX86) || defined(__i386__) || defined(__i386)
+ #if defined(_WIN32)