diff --git a/lang/spidermonkey38/Makefile b/lang/spidermonkey38/Makefile new file mode 100644 index 000000000000..c53b7ae2392e --- /dev/null +++ b/lang/spidermonkey38/Makefile @@ -0,0 +1,123 @@ +# Created by: Kubilay Kocak +# $FreeBSD$ + +PORTNAME= spidermonkey38 +PORTVERSION= 38.8.0 +CATEGORIES= lang +MASTER_SITES= MOZILLA/firefox/releases/${PORTVERSION}esr/source +DISTNAME= firefox-${PORTVERSION}esr.source + +MAINTAINER= kwm@FreeBSD.org +COMMENT= Standalone JavaScript based from Mozilla 38-esr + +LIB_DEPENDS= libnspr4.so:devel/nspr \ + libffi.so:devel/libffi \ + libicudata.so:devel/icu + +GNU_CONFIGURE= yes +USES= compiler:c++11-lib gmake pathfix perl5 pkgconfig \ + python:2,build readline tar:bzip2 +USE_PERL5= build +USE_LDCONFIG= yes + +WRKSRC= ${WRKDIR}/mozilla-esr38/js/src + +CONFIGURE_ARGS= --with-pthreads \ + --with-intl-api \ + --with-system-zlib \ + --enable-system-ffi \ + --with-system-icu \ + --with-system-nspr + +OPTIONS_DEFINE= DEBUG GCZEAL JEMALLOC METHODJIT OPTIMIZE READLINE \ + THREADSAFE TRACEJIT UTF8 DTRACE +OPTIONS_DEFAULT=METHODJIT OPTIMIZE READLINE THREADSAFE TRACEJIT +OPTIONS_SUB= yes + +DEBUG_CONFIGURE_ENABLE= debug debug-symbols +DEBUG_CONFIGURE_DISABLE=debug + +DTRACE_CONFIGURE_ENABLE=dtrace profiling +DTRACE_LIBS= -lelf + +GCZEAL_DESC= Enable Zealous garbage collecting +GCZEAL_CONFIGURE_ENABLE=gczeal + +JEMALLOC_DESC= Use jemalloc as memory allocator +JEMALLOC_CONFIGURE_ENABLE= jemalloc + +METHODJIT_DESC= Enable method JIT support +METHODJIT_CONFIGURE_ENABLE= methodjit + +OPTIMIZE_DESC= Enable compiler optimizations +OPTIMIZE_CONFIGURE_ENABLE= optimize + +READLINE_DESC= Link js shell to system readline library +READLINE_CONFIGURE_ENABLE= readline + +THREADSAFE_DESC=Enable multiple thread support +THREADSAFE_CONFIGURE_ENABLE= threadsafe + +TRACEJIT_DESC= Enable tracing JIT support +TRACEJIT_CONFIGURE_ENABLE= tracejit + +UTF8_DESC= Treat strings as UTF8 instead of ISO-8859-1 +UTF8_CFLAGS= -DJS_C_STRINGS_ARE_UTF8 + +.include + +.if ${ARCH} == amd64 +CONFIGURE_TARGET= x86_64-portbld-freebsd${OSREL} +.endif + +## Skip some tests because bundled icu differs from system +#rm tests/test262/intl402/ch10/10.2/10.2.3_b.js tests/Intl/DateTimeFormat/format.js tests/ecma_6/String/normalize-generateddata-part1-not-listed.js + +#tests/jstests.py -d -s --no-progress ../../js/src/js/src/shell/js + +regression-test: build + @${ECHO_MSG} -n "===> Running jstests.py: " + @cd ${WRKSRC} && ${SETENV} TZ=PST8PDT ${PYTHON_CMD} tests/jstests.py \ + -d -s --no-progress ./js/src/shell/js +.if ${PORT_OPTIONS:MMETHODJIT} || ${PORT_OPTIONS:MTRACEJIT} + @${ECHO_MSG} -n "===> Running jit_test.py: " + @cd ${WRKSRC} && ${SETENV} TZ=PST8PDT ${PYTHON_CMD} jit-test/jit_test.py \ + -d -s --no-progress --jitflags=,m,j,mj,mjp,am,amj,amjp,amd ./js/src/shell/js +.endif + +.include "Makefile.filelist" + +post-install: + ${RM} ${STAGEDIR}${PREFIX}/lib/libjs_static.ajs + ${LN} -fs libmozjs-38.so ${STAGEDIR}${PREFIX}/lib/libmozjs-38.so.1 +# the build installs symlinks, replace them with real files. +# fedora has a nice for loop, but I can't get it to work in make, ideas? + ${RM} -rf ${STAGEDIR}${PREFIX}/include/mozjs-38/* + ${INSTALL_DATA} ${WRKSRC}/js/src/js-config.h \ + ${STAGEDIR}${PREFIX}/include/mozjs-38/ +.for file in ${BASEFILES} + ${INSTALL_DATA} ${WRKSRC}/${file} \ + ${STAGEDIR}${PREFIX}/include/mozjs-38/ +.endfor + ${MKDIR} ${STAGEDIR}${PREFIX}/include/mozjs-38/js +.for file in ${JSFILES} + ${INSTALL_DATA} ${WRKSRC}/../public/${file} \ + ${STAGEDIR}${PREFIX}/include/mozjs-38/js/ +.endfor + ${MKDIR} ${STAGEDIR}${PREFIX}/include/mozjs-38/mozilla +.for file in ${MOZILLAFILES} + ${INSTALL_DATA} ${WRKSRC}/../../mfbt/${file} \ + ${STAGEDIR}${PREFIX}/include/mozjs-38/mozilla/ +.endfor +# Install files, not symlinks to build directory +#.for link in `find ${STAGEDIR}${PREFIX} -type l`; do +# header=`readlink ${link}`; \ +# rm -f ${link}; \ +# cp -p ${header} ${link} +#.endfor +.if ! ${PORT_OPTIONS:MDTRACE} + @${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/js38 + @${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/libmozjs-38.* +.endif + +.include diff --git a/lang/spidermonkey38/Makefile.filelist b/lang/spidermonkey38/Makefile.filelist new file mode 100644 index 000000000000..6fc1c5ef8017 --- /dev/null +++ b/lang/spidermonkey38/Makefile.filelist @@ -0,0 +1,32 @@ +BASEFILES= js.msg jsalloc.h jsapi.h jsbytecode.h \ + jsclist.h jscpucfg.h jsfriendapi.h perf/jsperf.h jsprf.h \ + jsprototypes.h jspubtd.h jstypes.h jsversion.h jswrapper.h + +JSFILES= CallArgs.h CallNonGenericMethod.h CharacterEncoding.h \ + Class.h Conversions.h Date.h Debug.h GCAPI.h HashTable.h \ + HeapAPI.h Id.h LegacyIntTypes.h MemoryMetrics.h Principals.h \ + ProfilingFrameIterator.h ProfilingStack.h Proxy.h \ + RequiredDefines.h RootingAPI.h SliceBudget.h \ + StructuredClone.h TracingAPI.h TrackedOptimizationInfo.h \ + TypeDecls.h UbiNode.h UbiNodeTraverse.h Utility.h Value.h \ + Vector.h WeakMapPtr.h + +MOZILLAFILES= Alignment.h AllocPolicy.h AlreadyAddRefed.h Array.h \ + ArrayUtils.h Assertions.h Atomics.h Attributes.h \ + BinarySearch.h BloomFilter.h Casting.h ChaosMode.h \ + Char16.h CheckedInt.h Compiler.h Compression.h Constants.h \ + DebugOnly.h decimal/Decimal.h Endian.h EnumSet.h EnumeratedArray.h \ + FloatingPoint.h GuardObjects.h HashFunctions.h \ + IntegerPrintfMacros.h IntegerRange.h IntegerTypeTraits.h \ + IteratorTraits.h JSONWriter.h Likely.h LinkedList.h \ + MacroArgs.h MacroForEach.h MathAlgorithms.h Maybe.h \ + MaybeOneOf.h MemoryChecking.h MemoryReporting.h Move.h \ + NullPtr.h NumericLimits.h Opaque.h Pair.h \ + PodOperations.h Poison.h Range.h RangedPtr.h \ + ReentrancyGuard.h RefCountType.h RefPtr.h \ + ReverseIterator.h RollingMean.h SHA1.h Scoped.h \ + SegmentedVector.h SizePrintfMacros.h SplayTree.h \ + TaggedAnonymousMemory.h TemplateLib.h ThreadLocal.h \ + ToString.h TypeTraits.h TypedEnumBits.h Types.h \ + UniquePtr.h Vector.h WeakPtr.h double-conversion/double-conversion.h \ + unused.h double-conversion/utils.h diff --git a/lang/spidermonkey38/distinfo b/lang/spidermonkey38/distinfo new file mode 100644 index 000000000000..2293795d7f30 --- /dev/null +++ b/lang/spidermonkey38/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1496648333 +SHA256 (firefox-38.8.0esr.source.tar.bz2) = 9475adcee29d590383c4885bc5f958093791d1db4302d694a5d2766698f59982 +SIZE (firefox-38.8.0esr.source.tar.bz2) = 181198635 diff --git a/lang/spidermonkey38/files/patch-bug1143022 b/lang/spidermonkey38/files/patch-bug1143022 new file mode 100644 index 000000000000..055720864d95 --- /dev/null +++ b/lang/spidermonkey38/files/patch-bug1143022 @@ -0,0 +1,132 @@ +From a7a5b5ce485512e659fd4f8a1edb2cda3021517f Mon Sep 17 00:00:00 2001 +From: Zheng Xu +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 +--- gc/Memory.cpp ++++ 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 +--- jsapi-tests/testGCAllocator.cpp ++++ 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/lang/spidermonkey38/files/patch-bug702179 b/lang/spidermonkey38/files/patch-bug702179 new file mode 100644 index 000000000000..7b03dd2a01ca --- /dev/null +++ b/lang/spidermonkey38/files/patch-bug702179 @@ -0,0 +1,18 @@ +--- Makefile.in.orig 2017-06-04 16:18:05.147255000 +0200 ++++ Makefile.in 2017-06-04 16:22:53.394133000 +0200 +@@ -208,10 +207,13 @@ + SCRIPTS = $(JS_CONFIG_NAME) + SDK_BINARY = $(JS_CONFIG_NAME) + +-$(LIBRARY_NAME).pc: js.pc ++$(JS_CONFIG_NAME): js-config + cp $^ $@ + +-install:: $(LIBRARY_NAME).pc ++$(JS_LIBRARY_NAME).pc: js.pc ++ cp $^ $@ ++ ++install:: $(JS_LIBRARY_NAME).pc + $(SYSINSTALL) $^ $(DESTDIR)$(prefix)/libdata/pkgconfig + + install:: js-config.h diff --git a/lang/spidermonkey38/files/patch-configure b/lang/spidermonkey38/files/patch-configure new file mode 100644 index 000000000000..61bf7df25a93 --- /dev/null +++ b/lang/spidermonkey38/files/patch-configure @@ -0,0 +1,14 @@ +--- configure.orig 2017-06-04 16:12:22.514695000 +0200 ++++ configure 2017-06-04 16:14:49.482786000 +0200 +@@ -1696,9 +1696,8 @@ + MOZJS_PATCH_VERSION=`echo $MOZILLA_VERSION | sed "s|^[0-9]*\.[0-9]*[^0-9]*||"` + IS_ALPHA=`echo $MOZILLA_VERSION | grep '[ab]'` + +-JS_SHELL_NAME=js +-JS_CONFIG_NAME=js-config +- ++JS_SHELL_NAME=js$MOZJS_MAJOR_VERSION ++JS_CONFIG_NAME=js$MOZJS_MAJOR_VERSION-config + + if test -n "$IS_ALPHA"; then + diff --git a/lang/spidermonkey38/pkg-descr b/lang/spidermonkey38/pkg-descr new file mode 100644 index 000000000000..2db0b2ca559f --- /dev/null +++ b/lang/spidermonkey38/pkg-descr @@ -0,0 +1,3 @@ +Spidermonkey is the JavaScript interpreter from the Mozilla project. + +WWW: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey diff --git a/lang/spidermonkey38/pkg-plist b/lang/spidermonkey38/pkg-plist new file mode 100644 index 000000000000..bfafdf58f946 --- /dev/null +++ b/lang/spidermonkey38/pkg-plist @@ -0,0 +1,121 @@ +bin/js38 +bin/js38-config +include/mozjs-38/js-config.h +include/mozjs-38/js.msg +include/mozjs-38/js/CallArgs.h +include/mozjs-38/js/CallNonGenericMethod.h +include/mozjs-38/js/CharacterEncoding.h +include/mozjs-38/js/Class.h +include/mozjs-38/js/Conversions.h +include/mozjs-38/js/Date.h +include/mozjs-38/js/Debug.h +include/mozjs-38/js/GCAPI.h +include/mozjs-38/js/HashTable.h +include/mozjs-38/js/HeapAPI.h +include/mozjs-38/js/Id.h +include/mozjs-38/js/LegacyIntTypes.h +include/mozjs-38/js/MemoryMetrics.h +include/mozjs-38/js/Principals.h +include/mozjs-38/js/ProfilingFrameIterator.h +include/mozjs-38/js/ProfilingStack.h +include/mozjs-38/js/Proxy.h +include/mozjs-38/js/RequiredDefines.h +include/mozjs-38/js/RootingAPI.h +include/mozjs-38/js/SliceBudget.h +include/mozjs-38/js/StructuredClone.h +include/mozjs-38/js/TracingAPI.h +include/mozjs-38/js/TrackedOptimizationInfo.h +include/mozjs-38/js/TypeDecls.h +include/mozjs-38/js/UbiNode.h +include/mozjs-38/js/UbiNodeTraverse.h +include/mozjs-38/js/Utility.h +include/mozjs-38/js/Value.h +include/mozjs-38/js/Vector.h +include/mozjs-38/js/WeakMapPtr.h +include/mozjs-38/jsalloc.h +include/mozjs-38/jsapi.h +include/mozjs-38/jsbytecode.h +include/mozjs-38/jsclist.h +include/mozjs-38/jscpucfg.h +include/mozjs-38/jsfriendapi.h +include/mozjs-38/jsperf.h +include/mozjs-38/jsprf.h +include/mozjs-38/jsprototypes.h +include/mozjs-38/jspubtd.h +include/mozjs-38/jstypes.h +include/mozjs-38/jsversion.h +include/mozjs-38/jswrapper.h +include/mozjs-38/mozilla/Alignment.h +include/mozjs-38/mozilla/AllocPolicy.h +include/mozjs-38/mozilla/AlreadyAddRefed.h +include/mozjs-38/mozilla/Array.h +include/mozjs-38/mozilla/ArrayUtils.h +include/mozjs-38/mozilla/Assertions.h +include/mozjs-38/mozilla/Atomics.h +include/mozjs-38/mozilla/Attributes.h +include/mozjs-38/mozilla/BinarySearch.h +include/mozjs-38/mozilla/BloomFilter.h +include/mozjs-38/mozilla/Casting.h +include/mozjs-38/mozilla/ChaosMode.h +include/mozjs-38/mozilla/Char16.h +include/mozjs-38/mozilla/CheckedInt.h +include/mozjs-38/mozilla/Compiler.h +include/mozjs-38/mozilla/Compression.h +include/mozjs-38/mozilla/Constants.h +include/mozjs-38/mozilla/DebugOnly.h +include/mozjs-38/mozilla/Decimal.h +include/mozjs-38/mozilla/Endian.h +include/mozjs-38/mozilla/EnumSet.h +include/mozjs-38/mozilla/EnumeratedArray.h +include/mozjs-38/mozilla/FloatingPoint.h +include/mozjs-38/mozilla/GuardObjects.h +include/mozjs-38/mozilla/HashFunctions.h +include/mozjs-38/mozilla/IntegerPrintfMacros.h +include/mozjs-38/mozilla/IntegerRange.h +include/mozjs-38/mozilla/IntegerTypeTraits.h +include/mozjs-38/mozilla/IteratorTraits.h +include/mozjs-38/mozilla/JSONWriter.h +include/mozjs-38/mozilla/Likely.h +include/mozjs-38/mozilla/LinkedList.h +include/mozjs-38/mozilla/MacroArgs.h +include/mozjs-38/mozilla/MacroForEach.h +include/mozjs-38/mozilla/MathAlgorithms.h +include/mozjs-38/mozilla/Maybe.h +include/mozjs-38/mozilla/MaybeOneOf.h +include/mozjs-38/mozilla/MemoryChecking.h +include/mozjs-38/mozilla/MemoryReporting.h +include/mozjs-38/mozilla/Move.h +include/mozjs-38/mozilla/NullPtr.h +include/mozjs-38/mozilla/NumericLimits.h +include/mozjs-38/mozilla/Opaque.h +include/mozjs-38/mozilla/Pair.h +include/mozjs-38/mozilla/PodOperations.h +include/mozjs-38/mozilla/Poison.h +include/mozjs-38/mozilla/Range.h +include/mozjs-38/mozilla/RangedPtr.h +include/mozjs-38/mozilla/ReentrancyGuard.h +include/mozjs-38/mozilla/RefCountType.h +include/mozjs-38/mozilla/RefPtr.h +include/mozjs-38/mozilla/ReverseIterator.h +include/mozjs-38/mozilla/RollingMean.h +include/mozjs-38/mozilla/SHA1.h +include/mozjs-38/mozilla/Scoped.h +include/mozjs-38/mozilla/SegmentedVector.h +include/mozjs-38/mozilla/SizePrintfMacros.h +include/mozjs-38/mozilla/SplayTree.h +include/mozjs-38/mozilla/TaggedAnonymousMemory.h +include/mozjs-38/mozilla/TemplateLib.h +include/mozjs-38/mozilla/ThreadLocal.h +include/mozjs-38/mozilla/ToString.h +include/mozjs-38/mozilla/TypeTraits.h +include/mozjs-38/mozilla/TypedEnumBits.h +include/mozjs-38/mozilla/Types.h +include/mozjs-38/mozilla/UniquePtr.h +include/mozjs-38/mozilla/Vector.h +include/mozjs-38/mozilla/WeakPtr.h +include/mozjs-38/mozilla/double-conversion.h +include/mozjs-38/mozilla/unused.h +include/mozjs-38/mozilla/utils.h +lib/libmozjs-38.so +lib/libmozjs-38.so.1 +libdata/pkgconfig/mozjs-38.pc