mozjs 17.0.0: fix aarch64 and 64k page builds, generic cleanups

* Mozjs17 has problems with 64k page sizes (powerpc64, aarch64 and probably others) and lacks support for aarch64. Patches were lifted from the fedora src rpm and rediffed.

* Regenerate configure with autoconf-2.13 to make the fixes mentioned above take effect.

* Provide proper config.guess and config.sub files

* Explicitly disable static builds and regroup configure options.

* Also clean out the patches/ dir present in the tarball to avoid conflicts with the OE patcher.

Signed-off-by: Koen Kooi <koen.kooi@linaro.org>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
This commit is contained in:
Koen Kooi 2015-03-03 20:47:55 +08:00 committed by Martin Jansa
parent 5fffea1646
commit 2a3ffe806a
6 changed files with 3562 additions and 3 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,75 @@
From d4a15ad82292ff6d772dcc631df98754d20be31b Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Tue, 18 Mar 2014 11:46:05 -0400
Subject: [PATCH 2/5] Move JS_BYTES_PER_WORD out of config.h
Instead define it in terms of the already extant GNU C extension
__SIZEOF_POINTER__. This avoids multiarch conflicts when 32 and 64
bit packages of js are co-installed.
---
Upstream-status: Pending
js/src/configure.in | 9 ---------
js/src/js-config.h.in | 1 -
js/src/jstypes.h | 12 ++++++++++++
3 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/js/src/configure.in b/js/src/configure.in
index 15605b2..64c7606 100644
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -2345,15 +2345,6 @@ else
AC_MSG_RESULT(no)
fi
-MOZ_SIZE_OF_TYPE(JS_BYTES_PER_WORD, void*, 4 8)
-if test "$moz_cv_size_of_JS_BYTES_PER_WORD" -eq "4"; then
- AC_DEFINE(JS_BITS_PER_WORD_LOG2, 5)
-elif test "$moz_cv_size_of_JS_BYTES_PER_WORD" -eq "8"; then
- AC_DEFINE(JS_BITS_PER_WORD_LOG2, 6)
-else
- AC_MSG_ERROR([Unexpected JS_BYTES_PER_WORD])
-fi
-
MOZ_ALIGN_OF_TYPE(JS_ALIGN_OF_POINTER, void*, 2 4 8 16)
MOZ_SIZE_OF_TYPE(JS_BYTES_PER_DOUBLE, double, 6 8 10 12 14)
diff --git a/js/src/js-config.h.in b/js/src/js-config.h.in
index 6889e00..4775420 100644
--- a/js/src/js-config.h.in
+++ b/js/src/js-config.h.in
@@ -56,7 +56,6 @@
#undef JS_INT32_TYPE
#undef JS_INT64_TYPE
#undef JS_INTPTR_TYPE
-#undef JS_BYTES_PER_WORD
/* Some mozilla code uses JS-friend APIs that depend on JS_METHODJIT being
correct. */
diff --git a/js/src/jstypes.h b/js/src/jstypes.h
index d0cf183..3e7928f 100644
--- a/js/src/jstypes.h
+++ b/js/src/jstypes.h
@@ -24,6 +24,18 @@
#include "mozilla/Util.h"
#include "js-config.h"
+#ifndef JS_BYTES_PER_WORD
+#define JS_BYTES_PER_WORD __SIZEOF_POINTER__
+#endif
+#ifndef JS_BITS_PER_WORD_LOG2
+#if JS_BYTES_PER_WORD == 8
+#define JS_BITS_PER_WORD_LOG2 6
+#elif JS_BYTES_PER_WORD == 4
+#define JS_BITS_PER_WORD_LOG2 5
+#else
+#error Unhandled JS_BYTES_PER_WORD
+#endif
+#endif
/***********************************************************************
** MACROS: JS_EXTERN_API
--
1.9.3

View File

@ -0,0 +1,76 @@
From 15e710e331d36eb279852b5cd1ba37a9a6005217 Mon Sep 17 00:00:00 2001
From: Koen Kooi <koen.kooi@linaro.org>
Date: Mon, 2 Mar 2015 19:08:22 +0800
Subject: [PATCH 3/5] Add AArch64 support
---
Upstream-status: Pending
js/src/assembler/jit/ExecutableAllocator.h | 6 ++++++
js/src/assembler/wtf/Platform.h | 4 ++++
js/src/configure.in | 4 ++++
mfbt/double-conversion/utils.h | 1 +
4 files changed, 15 insertions(+)
diff --git a/js/src/assembler/jit/ExecutableAllocator.h b/js/src/assembler/jit/ExecutableAllocator.h
index c071c33..90764c3 100644
--- a/js/src/assembler/jit/ExecutableAllocator.h
+++ b/js/src/assembler/jit/ExecutableAllocator.h
@@ -382,6 +382,12 @@ public:
{
reprotectRegion(start, size, Executable);
}
+#elif WTF_CPU_AARCH64 && WTF_PLATFORM_LINUX
+ static void cacheFlush(void* code, size_t size)
+ {
+ intptr_t end = reinterpret_cast<intptr_t>(code) + size;
+ __builtin___clear_cache(reinterpret_cast<char*>(code), reinterpret_cast<char*>(end));
+ }
#else
static void makeWritable(void*, size_t) {}
static void makeExecutable(void*, size_t) {}
diff --git a/js/src/assembler/wtf/Platform.h b/js/src/assembler/wtf/Platform.h
index 0c84896..e8763a7 100644
--- a/js/src/assembler/wtf/Platform.h
+++ b/js/src/assembler/wtf/Platform.h
@@ -325,6 +325,10 @@
#define WTF_THUMB_ARCH_VERSION 0
#endif
+/* CPU(AArch64) - 64-bit ARM */
+#if defined(__aarch64__)
+#define WTF_CPU_AARCH64 1
+#endif
/* WTF_CPU_ARMV5_OR_LOWER - ARM instruction set v5 or earlier */
/* On ARMv5 and below the natural alignment is required.
diff --git a/js/src/configure.in b/js/src/configure.in
index 64c7606..0673aca 100644
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -1121,6 +1121,10 @@ arm*)
CPU_ARCH=arm
;;
+aarch64)
+ CPU_ARCH=aarch64
+ ;;
+
mips|mipsel)
CPU_ARCH="mips"
;;
diff --git a/mfbt/double-conversion/utils.h b/mfbt/double-conversion/utils.h
index 0eec2d9..fe26dab 100644
--- a/mfbt/double-conversion/utils.h
+++ b/mfbt/double-conversion/utils.h
@@ -58,6 +58,7 @@
defined(__mips__) || defined(__powerpc__) || \
defined(__sparc__) || defined(__sparc) || defined(__s390__) || \
defined(__SH4__) || defined(__alpha__) || \
+ defined(__aarch64__) || \
defined(_MIPS_ARCH_MIPS32R2)
#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
#elif defined(_M_IX86) || defined(__i386__) || defined(__i386)
--
1.9.3

View File

@ -0,0 +1,103 @@
From 0128c5a9eeee0d3fc0deb9129dd20eb79338c8f4 Mon Sep 17 00:00:00 2001
From: Koen Kooi <koen.kooi@linaro.org>
Date: Mon, 2 Mar 2015 19:08:59 +0800
Subject: [PATCH 4/5] mozbug746112-no-decommit-on-large-pages
---
Upstream-status: Pending
js/src/gc/Heap.h | 15 ++++++++++-----
js/src/jsgc.cpp | 15 ++++++++++++---
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/js/src/gc/Heap.h b/js/src/gc/Heap.h
index b8f8c78..1cfd269 100644
--- a/js/src/gc/Heap.h
+++ b/js/src/gc/Heap.h
@@ -103,26 +103,31 @@ struct Cell
};
/*
- * Page size is 4096 by default, except for SPARC, where it is 8192.
+ * Page size must be static to support our arena pointer optimizations, so we
+ * are forced to support each platform with non-4096 pages as a special case.
+ * Note: The freelist supports a maximum arena shift of 15.
* Note: Do not use JS_CPU_SPARC here, this header is used outside JS.
* Bug 692267: Move page size definition to gc/Memory.h and include it
* directly once jsgc.h is no longer an installed header.
*/
#if defined(SOLARIS) && (defined(__sparc) || defined(__sparcv9))
const size_t PageShift = 13;
+const size_t ArenaShift = PageShift;
+#elif defined(__powerpc__)
+const size_t PageShift = 16;
+const size_t ArenaShift = 12;
#else
const size_t PageShift = 12;
+const size_t ArenaShift = PageShift;
#endif
const size_t PageSize = size_t(1) << PageShift;
+const size_t ArenaSize = size_t(1) << ArenaShift;
+const size_t ArenaMask = ArenaSize - 1;
const size_t ChunkShift = 20;
const size_t ChunkSize = size_t(1) << ChunkShift;
const size_t ChunkMask = ChunkSize - 1;
-const size_t ArenaShift = PageShift;
-const size_t ArenaSize = PageSize;
-const size_t ArenaMask = ArenaSize - 1;
-
/*
* This is the maximum number of arenas we allow in the FreeCommitted state
* before we trigger a GC_SHRINK to release free arenas to the OS.
diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp
index b3caf05..a258d2d 100644
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -251,6 +251,13 @@ static const int BackgroundPhaseLength[] = {
sizeof(BackgroundPhaseStrings) / sizeof(AllocKind)
};
+/* Unused memory decommiting requires the arena size match the page size. */
+static bool
+DecommitEnabled()
+{
+ return PageSize == ArenaSize;
+}
+
#ifdef DEBUG
void
ArenaHeader::checkSynchronizedWithFreeList() const
@@ -742,7 +749,8 @@ Chunk::fetchNextDecommittedArena()
decommittedArenas.unset(offset);
Arena *arena = &arenas[offset];
- MarkPagesInUse(arena, ArenaSize);
+ if (DecommitEnabled())
+ MarkPagesInUse(arena, ArenaSize);
arena->aheader.setAsNotAllocated();
return &arena->aheader;
@@ -2731,7 +2739,7 @@ DecommitArenasFromAvailableList(JSRuntime *rt, Chunk **availableListHeadp)
chunk->removeFromAvailableList();
size_t arenaIndex = Chunk::arenaIndex(aheader->arenaAddress());
- bool ok;
+ bool ok = true;
{
/*
* If the main thread waits for the decommit to finish, skip
@@ -2741,7 +2749,8 @@ DecommitArenasFromAvailableList(JSRuntime *rt, Chunk **availableListHeadp)
Maybe<AutoUnlockGC> maybeUnlock;
if (!rt->isHeapBusy())
maybeUnlock.construct(rt);
- ok = MarkPagesUnused(aheader->getArena(), ArenaSize);
+ if (DecommitEnabled())
+ ok = MarkPagesUnused(aheader->getArena(), ArenaSize);
}
if (ok) {
--
1.9.3

View File

@ -0,0 +1,44 @@
From 9c42920c2b635a399bd1f93833efdeb1696f17ee Mon Sep 17 00:00:00 2001
From: Koen Kooi <koen.kooi@linaro.org>
Date: Mon, 2 Mar 2015 19:09:57 +0800
Subject: [PATCH 5/5] aarch64-64k-page
---
Upstream-status: Pending
js/src/gc/Heap.h | 2 +-
js/src/gc/Memory.cpp | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/js/src/gc/Heap.h b/js/src/gc/Heap.h
index 1cfd269..f4dbcda 100644
--- a/js/src/gc/Heap.h
+++ b/js/src/gc/Heap.h
@@ -113,7 +113,7 @@ struct Cell
#if defined(SOLARIS) && (defined(__sparc) || defined(__sparcv9))
const size_t PageShift = 13;
const size_t ArenaShift = PageShift;
-#elif defined(__powerpc__)
+#elif defined(__powerpc__) || defined(__aarch64__)
const size_t PageShift = 16;
const size_t ArenaShift = 12;
#else
diff --git a/js/src/gc/Memory.cpp b/js/src/gc/Memory.cpp
index 5b386a2..e5ad018 100644
--- a/js/src/gc/Memory.cpp
+++ b/js/src/gc/Memory.cpp
@@ -302,8 +302,11 @@ GetPageFaultCount()
void
InitMemorySubsystem()
{
+ /* aarch64 may have 64KB or 4KB pages */
+#ifndef __aarch64__
if (size_t(sysconf(_SC_PAGESIZE)) != PageSize)
MOZ_CRASH();
+#endif
}
void *
--
1.9.3

View File

@ -4,9 +4,15 @@ LIC_FILES_CHKSUM = "file://../../LICENSE;md5=815ca599c9df247a0c7f619bab123dad"
SRC_URI = " \
http://ftp.mozilla.org/pub/mozilla.org/js/${BPN}${PV}.tar.gz \
file://0001-js.pc.in-do-not-include-RequiredDefines.h-for-depend.patch \
file://0001-mozjs17.0.0-fix-the-compile-bug-of-powerpc.patch \
"
file://0001-js.pc.in-do-not-include-RequiredDefines.h-for-depend.patch \
file://0002-Move-JS_BYTES_PER_WORD-out-of-config.h.patch;patchdir=../../ \
file://0003-Add-AArch64-support.patch;patchdir=../../ \
file://0004-mozbug746112-no-decommit-on-large-pages.patch;patchdir=../../ \
file://0005-aarch64-64k-page.patch;patchdir=../../ \
file://0001-regenerate-configure.patch;patchdir=../../ \
"
SRC_URI[md5sum] = "20b6f8f1140ef6e47daa3b16965c9202"
SRC_URI[sha256sum] = "321e964fe9386785d3bf80870640f2fa1c683e32fe988eeb201b04471c172fba"
@ -22,16 +28,33 @@ EXTRA_OECONF = " \
--host=${BUILD_SYS} \
--build=${BUILD_SYS} \
--prefix=${prefix} \
--libdir=${libdir} \
--with-nspr-libs='-lplds4 -lplc4 -lnspr4' \
--enable-threadsafe \
--libdir=${libdir} \
--disable-static \
"
# mozjs requires autoreconf 2.13
do_configure() {
( cd ${S}
gnu-configize --force
mv config.guess config.sub build/autoconf )
${S}/configure ${EXTRA_OECONF}
}
# patch.bbclass will try to apply the patches already present and fail, so clean them out
do_sourceclean() {
(
cd ${WORKDIR}/${PN}${PV}/patches
for i in $(cat series | awk '{print $1}') ; do
rm -f $i
done
rm -f series
)
}
addtask sourceclean before do_patch after do_unpack
PACKAGES =+ "lib${PN}"
FILES_lib${PN} += "${libdir}/lib*.so"
FILES_${PN}-dev += "${bindir}/js17-config"