[gnome-sdk-images/gnome-3-24] mozjs38: apply patches from Fedora



commit c205738e519c3219ab1fc0b56177524ad44fa95f
Author: Bartłomiej Piotrowski <b bpiotrowski pl>
Date:   Mon May 8 13:02:32 2017 +0200

    mozjs38: apply patches from Fedora

 mozjs38-1143022.patch         |  132 +++++++++++++++++++++++++++++++++++++++++
 mozjs38-fix-64bit-archs.patch |   30 +++++++++
 org.gnome.Sdk.json.in         |    8 +++
 3 files changed, 170 insertions(+), 0 deletions(-)
---
diff --git a/mozjs38-1143022.patch b/mozjs38-1143022.patch
new file mode 100644
index 0000000..9ab665a
--- /dev/null
+++ b/mozjs38-1143022.patch
@@ -0,0 +1,132 @@
+From a7a5b5ce485512e659fd4f8a1edb2cda3021517f Mon Sep 17 00:00:00 2001
+From: Zheng Xu <zheng xu linaro org>
+Date: Thu, 01 Sep 2016 16:58:30 +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: I2853e284b92aecf609e00bb82718e5df535bbba2
+---
+
+diff --git a/js/src/gc/Memory.cpp b/js/src/gc/Memory.cpp
+index 8db2c68e..db2063d 100644
+--- a/js/src/gc/Memory.cpp
++++ b/js/src/gc/Memory.cpp
+@@ -379,7 +379,7 @@
+ MapMemoryAt(void* desired, size_t length, int prot = PROT_READ | PROT_WRITE,
+             int flags = MAP_PRIVATE | MAP_ANON, int fd = -1, off_t offset = 0)
+ {
+-#if defined(__ia64__) || (defined(__sparc64__) && defined(__NetBSD__))
++#if defined(__ia64__) || (defined(__sparc64__) && defined(__NetBSD__)) || defined(__aarch64__)
+     MOZ_ASSERT(0xffff800000000000ULL & (uintptr_t(desired) + length - 1) == 0);
+ #endif
+     void* region = mmap(desired, length, prot, flags, fd, offset);
+@@ -429,6 +429,41 @@
+         return nullptr;
+     }
+     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 = UINT64_C(0x0000070000000000);
++    const uintptr_t end   = UINT64_C(0x0000800000000000);
++    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 ? nullptr : region;
+ #else
+     void* region = MozTaggedAnonymousMmap(nullptr, length, prot, flags, fd, offset, "js-gc-heap");
+     if (region == MAP_FAILED)
+diff --git a/js/src/jsapi-tests/testGCAllocator.cpp b/js/src/jsapi-tests/testGCAllocator.cpp
+index 2d36d2f..9bf1692 100644
+--- a/js/src/jsapi-tests/testGCAllocator.cpp
++++ b/js/src/jsapi-tests/testGCAllocator.cpp
+@@ -257,7 +257,7 @@
+ void*
+ mapMemoryAt(void* desired, size_t length)
+ {
+-#if defined(__ia64__) || (defined(__sparc64__) && defined(__NetBSD__))
++#if defined(__ia64__) || (defined(__sparc64__) && defined(__NetBSD__)) || defined(__aarch64__)
+     MOZ_RELEASE_ASSERT(0xffff800000000000ULL & (uintptr_t(desired) + length - 1) == 0);
+ #endif
+     void* region = mmap(desired, length, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+@@ -274,21 +274,45 @@
+ void*
+ mapMemory(size_t length)
+ {
+-    void* hint = nullptr;
++    int prot = PROT_READ | PROT_WRITE;
++    int flags = MAP_PRIVATE | MAP_ANON;
++    int fd = -1;
++    off_t offset = 0;
++    // The test code must be aligned with the implementation in gc/Memory.cpp.
+ #if defined(__ia64__) || (defined(__sparc64__) && defined(__NetBSD__))
+-    hint = (void*)0x0000070000000000ULL;
+-#endif
+-    void* region = mmap(hint, length, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
++    void* region = mmap((void*)0x0000070000000000, length, prot, flags, fd, offset);
+     if (region == MAP_FAILED)
+         return nullptr;
+-#if defined(__ia64__) || (defined(__sparc64__) && defined(__NetBSD__))
+-    if ((uintptr_t(region) + (length - 1)) & 0xffff800000000000ULL) {
++    if ((uintptr_t(region) + (length - 1)) & 0xffff800000000000) {
+         if (munmap(region, length))
+             MOZ_RELEASE_ASSERT(errno == ENOMEM);
+         return nullptr;
+     }
+-#endif
+     return region;
++#elif defined(__aarch64__)
++    const uintptr_t start = UINT64_C(0x0000070000000000);
++    const uintptr_t end   = UINT64_C(0x0000800000000000);
++    const uintptr_t step  = js::gc::ChunkSize;
++    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_RELEASE_ASSERT(errno == ENOMEM);
++                }
++                region = MAP_FAILED;
++            }
++        }
++    }
++    return region == MAP_FAILED ? nullptr : region;
++#else
++    void* region = mmap(nullptr, length, prot, flags, fd, offset);
++    if (region == MAP_FAILED)
++        return nullptr;
++    return region;
++#endif
+ }
+ 
+ void
diff --git a/mozjs38-fix-64bit-archs.patch b/mozjs38-fix-64bit-archs.patch
new file mode 100644
index 0000000..50f8882
--- /dev/null
+++ b/mozjs38-fix-64bit-archs.patch
@@ -0,0 +1,30 @@
+diff --git a/tests/js1_5/Array/regress-157652.js b/tests/js1_5/Array/regress-157652.js
+index 0bdba8f..9d77802 100644
+--- a/js/src/tests/js1_5/Array/regress-157652.js
++++ b/js/src/tests/js1_5/Array/regress-157652.js
+@@ -1,4 +1,4 @@
+-// |reftest| skip-if(xulRuntime.XPCOMABI.match(/x86_64/)||Android) -- No test results
++// |reftest| skip-if(xulRuntime.XPCOMABI.match(/x86_64|aarch64|ppc64|ppc64le|s390x/)||Android) -- No test 
results
+ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+ /* This Source Code Form is subject to the terms of the Mozilla Public
+  * License, v. 2.0. If a copy of the MPL was not distributed with this
+diff --git a/tests/js1_5/Array/regress-330812.js b/tests/js1_5/Array/regress-330812.js
+index 3a39297..c48f4c8 100644
+--- a/js/src/tests/js1_5/Array/regress-330812.js
++++ b/js/src/tests/js1_5/Array/regress-330812.js
+@@ -1,4 +1,4 @@
+-// |reftest| skip-if(xulRuntime.XPCOMABI.match(/x86_64/)||Android) -- No test results
++// |reftest| skip-if(xulRuntime.XPCOMABI.match(/x86_64|aarch64|ppc64|ppc64le|s390x/)||Android) -- No test 
results
+ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+ /* This Source Code Form is subject to the terms of the Mozilla Public
+  * License, v. 2.0. If a copy of the MPL was not distributed with this
+diff --git a/tests/js1_5/Regress/regress-422348.js b/tests/js1_5/Regress/regress-422348.js
+index f2443c2..7ae83f4 100644
+--- a/js/src/tests/js1_5/Regress/regress-422348.js
++++ b/js/src/tests/js1_5/Regress/regress-422348.js
+@@ -1,4 +1,4 @@
+-// |reftest| skip-if(xulRuntime.XPCOMABI.match(/x86_64/)) -- On 64-bit, takes forever rather than throwing
++// |reftest| skip-if(xulRuntime.XPCOMABI.match(/x86_64|aarch64|ppc64|ppc64le|s390x/)) -- On 64-bit, takes 
forever rather than throwing
+ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+ /* This Source Code Form is subject to the terms of the Mozilla Public
+  * License, v. 2.0. If a copy of the MPL was not distributed with this
diff --git a/org.gnome.Sdk.json.in b/org.gnome.Sdk.json.in
index 8424342..ebead39 100644
--- a/org.gnome.Sdk.json.in
+++ b/org.gnome.Sdk.json.in
@@ -638,6 +638,14 @@
                     "path": "mozjs38-1269317.patch"
                 },
                 {
+                    "type": "patch",
+                    "path": "mozjs38-fix-64bit-archs.patch"
+                },
+                {
+                    "type": "patch",
+                    "path": "mozjs38-1143022.patch"
+                },
+                {
                     "type": "shell",
                     "commands": [
                         /* Work around mtime issue in configure and configure.ac (see bug 778802) */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]