Index: build/premake/extern_libs5.lua =================================================================== --- build/premake/extern_libs5.lua +++ build/premake/extern_libs5.lua @@ -533,9 +533,9 @@ }, spidermonkey = { compile_settings = function() - if _OPTIONS["with-system-mozjs38"] then + if _OPTIONS["with-system-mozjs45"] then if not _OPTIONS["android"] then - pkgconfig.add_includes("mozjs-38") + pkgconfig.add_includes("mozjs-45") end else if os.istarget("windows") then @@ -553,31 +553,25 @@ end end, link_settings = function() - if _OPTIONS["with-system-mozjs38"] then + if _OPTIONS["with-system-mozjs45"] then if _OPTIONS["android"] then - links { "mozjs-38" } + links { "mozjs-45" } else - pkgconfig.add_links("nspr") - pkgconfig.add_links("mozjs-38") + pkgconfig.add_links("mozjs-45") end else - if os.istarget("macosx") then - add_default_lib_paths("nspr") - links { "nspr4", "plc4", "plds4" } - end - filter { "Debug", "action:vs2013" } - links { "mozjs38-ps-debug-vc120" } + links { "mozjs45-ps-debug-vc120" } filter { "Release", "action:vs2013" } - links { "mozjs38-ps-release-vc120" } + links { "mozjs45-ps-release-vc120" } filter { "Debug", "action:vs2015" } - links { "mozjs38-ps-debug-vc140" } + links { "mozjs45-ps-debug-vc140" } filter { "Release", "action:vs2015" } - links { "mozjs38-ps-release-vc140" } + links { "mozjs45-ps-release-vc140" } filter { "Debug", "action:not vs*" } - links { "mozjs38-ps-debug" } + links { "mozjs45-ps-debug" } filter { "Release", "action:not vs*" } - links { "mozjs38-ps-release" } + links { "mozjs45-ps-release" } filter { } add_source_lib_paths("spidermonkey") end Index: build/workspaces/clean-workspaces.sh =================================================================== --- build/workspaces/clean-workspaces.sh +++ build/workspaces/clean-workspaces.sh @@ -33,11 +33,12 @@ (cd ../../libraries/source/fcollada/src && rm -rf ./output) (cd ../../libraries/source/nvtt/src && rm -rf ./build) (cd ../../libraries/source/spidermonkey && rm -f .already-built) - (cd ../../libraries/source/spidermonkey && rm -rf ./mozjs-38.0.0) + (cd ../../libraries/source/spidermonkey && rm -rf ./mozjs-45.0.2) fi # Still delete the directory of previous SpiderMonkey versions to # avoid wasting disk space if people clean workspaces after updating. +(cd ../../libraries/source/spidermonkey && rm -rf ./mozjs-38.0.0) (cd ../../libraries/source/spidermonkey && rm -rf ./mozjs31) (cd ../../libraries/source/spidermonkey && rm -rf ./mozjs24) Index: libraries/osx/build-osx-libs.sh =================================================================== --- libraries/osx/build-osx-libs.sh +++ libraries/osx/build-osx-libs.sh @@ -39,8 +39,6 @@ # NOTE: remember to also update LIB_URL below when changing version GNUTLS_VERSION="gnutls-3.6.8" GLOOX_VERSION="gloox-1.0.22" -# NSPR is necessary for threadsafe Spidermonkey -NSPR_VERSION="4.15" # OS X only includes part of ICU, and only the dylib # NOTE: remember to also update LIB_URL below when changing version ICU_VERSION="icu4c-59_1" @@ -49,7 +47,7 @@ SODIUM_VERSION="libsodium-1.0.16" # -------------------------------------------------------------- # Bundled with the game: -# * SpiderMonkey 38 +# * SpiderMonkey 45 # * NVTT # * FCollada # -------------------------------------------------------------- @@ -751,41 +749,6 @@ popd > /dev/null # -------------------------------------------------------------- -echo -e "Building NSPR..." - -LIB_VERSION="${NSPR_VERSION}" -LIB_ARCHIVE="nspr-$LIB_VERSION.tar.gz" -LIB_DIRECTORY="nspr-$LIB_VERSION" -LIB_URL="https://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v$LIB_VERSION/src/" - -mkdir -p nspr -pushd nspr > /dev/null - -NSPR_DIR="$(pwd)" - -if [[ "$force_rebuild" = "true" ]] || [[ ! -e .already-built ]] || [[ .already-built -ot $LIB_DIRECTORY ]] -then - rm -f .already-built - download_lib $LIB_URL $LIB_ARCHIVE - - rm -rf $LIB_DIRECTORY bin include lib share - tar -xf $LIB_ARCHIVE - pushd $LIB_DIRECTORY/nspr - - (CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS" \ - ./configure --prefix="$NSPR_DIR" \ - --enable-64bit \ - && make ${JOBS} && make install) || die "NSPR build failed" - popd - # TODO: how can we not build the dylibs? - rm -f lib/*.dylib - touch .already-built -else - already_built -fi -popd > /dev/null - -# -------------------------------------------------------------- echo -e "Building ICU..." LIB_VERSION="${ICU_VERSION}" @@ -940,9 +903,9 @@ # be customized, so we build and install them from bundled sources # -------------------------------------------------------------------- echo -e "Building Spidermonkey..." -LIB_VERSION="mozjs-38.2.1" -LIB_ARCHIVE="$LIB_VERSION.rc0.tar.bz2" -LIB_DIRECTORY="mozjs-38.0.0" +LIB_VERSION="mozjs-45.0.2" +LIB_ARCHIVE="$LIB_VERSION.tar.bz2" +LIB_DIRECTORY="mozjs-45.0.2" pushd ../source/spidermonkey/ > /dev/null @@ -963,20 +926,17 @@ popd pushd $LIB_DIRECTORY/js/src - # We want separate debug/release versions of the library, so change their install name in the Makefile - perl -i.bak -pe 's/(^STATIC_LIBRARY_NAME\s+=).*/$1'\''mozjs38-ps-debug'\''/' moz.build CONF_OPTS="--target=$ARCH-apple-darwin --prefix=${INSTALL_DIR} - --with-system-nspr - --with-nspr-prefix=${NSPR_DIR} + --enable-posix-nspr-emulation --with-system-zlib=${ZLIB_DIR} --disable-tests - --disable-shared-js" + --disable-shared-js + --disable-jemalloc + --without-intl-api" # Change the default location where the tracelogger should store its output, which is /tmp/ on OSX. TLCXXFLAGS='-DTRACE_LOG_DIR="\"../../source/tools/tracelogger/\""' - # Uncomment this line for 32-bit 10.5 cross compile: - #CONF_OPTS="$CONF_OPTS --target=i386-apple-darwin9.0.0" if [[ $MIN_OSX_VERSION && ${MIN_OSX_VERSION-_} ]]; then CONF_OPTS="$CONF_OPTS --enable-macos-target=$MIN_OSX_VERSION" fi @@ -984,6 +944,8 @@ CONF_OPTS="$CONF_OPTS --with-macosx-sdk=$SYSROOT" fi + # We want separate debug/release versions of the library, so change their install name in the Makefile + perl -i.bak -pe 's/(^STATIC_LIBRARY_NAME\s+=).*/$1'\''mozjs45-ps-debug'\''/' moz.build mkdir -p build-debug pushd build-debug (CC="clang" CXX="clang++" CXXFLAGS="${TLCXXFLAGS}" AR=ar CROSS_COMPILE=1 \ @@ -996,11 +958,11 @@ # js-config.h is different for debug and release builds, so we need different include directories for both mkdir -p $INCLUDE_DIR_DEBUG cp -R -L dist/include/* $INCLUDE_DIR_DEBUG/ - cp dist/lib/*.a $INSTALL_DIR/lib + cp dist/sdk/lib/*.a $INSTALL_DIR/lib popd mv moz.build.bak moz.build - perl -i.bak -pe 's/(^STATIC_LIBRARY_NAME\s+=).*/$1'\''mozjs38-ps-release'\''/' moz.build + perl -i.bak -pe 's/(^STATIC_LIBRARY_NAME\s+=).*/$1'\''mozjs45-ps-release'\''/' moz.build mkdir -p build-release pushd build-release (CC="clang" CXX="clang++" CXXFLAGS="${TLCXXFLAGS}" AR=ar CROSS_COMPILE=1 \ @@ -1010,7 +972,8 @@ # js-config.h is different for debug and release builds, so we need different include directories for both mkdir -p $INCLUDE_DIR_RELEASE cp -R -L dist/include/* $INCLUDE_DIR_RELEASE/ - cp dist/lib/*.a $INSTALL_DIR/lib + cp dist/sdk/lib/*.a $INSTALL_DIR/lib + cp js/src/*.a $INSTALL_DIR/lib popd mv moz.build.bak moz.build Index: libraries/source/spidermonkey/ExportJSPropertyDescriptor.diff =================================================================== --- /dev/null +++ libraries/source/spidermonkey/ExportJSPropertyDescriptor.diff @@ -0,0 +1,26 @@ +diff --git a/js/src/jsapi.h b/js/src/jsapi.h +index 29406243..2370457f 100644 +--- a/js/src/jsapi.h ++++ b/js/src/jsapi.h +@@ -2399,7 +2399,7 @@ JS_FreezeObject(JSContext* cx, JS::Handle obj); + + /*** Property descriptors ************************************************************************/ + +-struct JSPropertyDescriptor : public JS::Traceable { ++struct JS_PUBLIC_API(JSPropertyDescriptor) : public JS::Traceable { + JSObject* obj; + unsigned attrs; + JSGetterOp getter; +diff --git a/js/src/jspubtd.h b/js/src/jspubtd.h +index ba592525..3c185527 100644 +--- a/js/src/jspubtd.h ++++ b/js/src/jspubtd.h +@@ -97,7 +97,7 @@ struct JSFunctionSpec; + struct JSLocaleCallbacks; + struct JSObjectMap; + struct JSPrincipals; +-struct JSPropertyDescriptor; ++struct JS_PUBLIC_API(JSPropertyDescriptor); + struct JSPropertyName; + struct JSPropertySpec; + struct JSRuntime; Index: libraries/source/spidermonkey/FixLinking.diff =================================================================== --- /dev/null +++ libraries/source/spidermonkey/FixLinking.diff @@ -0,0 +1,49 @@ +From dcf520da15d940c900d7e8ffd5a9b05427c54dc8 Mon Sep 17 00:00:00 2001 +From: Philip Chimento +Date: Wed, 5 Jul 2017 22:47:44 -0700 +Subject: [PATCH 4/9] headers: Fix symbols visibility + +Some symbols that need to be public are not marked as such. +--- + js/public/Utility.h | 2 +- + js/src/jsalloc.h | 4 +++- + 2 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/js/public/Utility.h b/js/public/Utility.h +index 75214c32..f50fd8dd 100644 +--- a/js/public/Utility.h ++++ b/js/public/Utility.h +@@ -77,7 +77,7 @@ enum ThreadType { + # if defined(DEBUG) || defined(JS_OOM_BREAKPOINT) + extern bool InitThreadType(void); + extern void SetThreadType(ThreadType); +-extern uint32_t GetThreadType(void); ++extern JS_FRIEND_API(uint32_t) GetThreadType(void); + # else + inline bool InitThreadType(void) { return true; } + inline void SetThreadType(ThreadType t) {}; +diff --git a/js/src/jsalloc.h b/js/src/jsalloc.h +index b9ae5190..234ea9dc 100644 +--- a/js/src/jsalloc.h ++++ b/js/src/jsalloc.h +@@ -17,6 +17,8 @@ + #include "js/TypeDecls.h" + #include "js/Utility.h" + ++extern JS_PUBLIC_API(void) JS_ReportOutOfMemory(JSContext* cx); ++ + namespace js { + + enum class AllocFunction { +@@ -130,7 +132,7 @@ class TempAllocPolicy + + bool checkSimulatedOOM() const { + if (js::oom::ShouldFailWithOOM()) { +- js::ReportOutOfMemory(reinterpret_cast(cx_)); ++ JS_ReportOutOfMemory(reinterpret_cast(cx_)); + return false; + } + +-- +2.11.0 (Apple Git-81) + Index: libraries/source/spidermonkey/FixMozglueStatic.diff =================================================================== --- /dev/null +++ libraries/source/spidermonkey/FixMozglueStatic.diff @@ -0,0 +1,20 @@ +diff --git a/mozglue/build/moz.build b/mozglue/build/moz.build +index 58e2db6..1cfb504 100644 +--- a/mozglue/build/moz.build ++++ b/mozglue/build/moz.build +@@ -4,12 +4,9 @@ + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + +-# Build mozglue as a shared lib on Windows, OSX and Android. +-# If this is ever changed, update MOZ_SHARED_MOZGLUE in browser/installer/Makefile.in +-if CONFIG['OS_TARGET'] in ('WINNT', 'Darwin', 'Android'): +- SharedLibrary('mozglue') +-else: +- Library('mozglue') ++# Build mozglue as a static lib into js for 0 A.D. ++Library('mozglue') ++FINAL_LIBRARY = 'js' + + if not CONFIG['MOZ_CRT']: + SDK_LIBRARY = True Index: libraries/source/spidermonkey/FixNonx86.diff =================================================================== --- /dev/null +++ libraries/source/spidermonkey/FixNonx86.diff @@ -0,0 +1,206 @@ +diff --git a/js/src/gc/Memory.cpp b/js/src/gc/Memory.cpp +--- a/js/src/gc/Memory.cpp ++++ b/js/src/gc/Memory.cpp +@@ -430,17 +430,17 @@ InitMemorySubsystem() + if (pageSize == 0) + pageSize = allocGranularity = size_t(sysconf(_SC_PAGESIZE)); + } + + static inline void* + 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); + if (region == MAP_FAILED) + return nullptr; + /* + * mmap treats the given address as a hint unless the MAP_FIXED flag is + * used (which isn't usually what you want, as this overrides existing +@@ -480,16 +480,51 @@ MapMemory(size_t length, int prot = PROT + * as out of memory. + */ + if ((uintptr_t(region) + (length - 1)) & 0xffff800000000000) { + if (munmap(region, length)) + MOZ_ASSERT(errno == ENOMEM); + 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 = js::gc::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) + return nullptr; + return region; + #endif + } + +diff --git a/js/src/jsapi-tests/testGCAllocator.cpp b/js/src/jsapi-tests/testGCAllocator.cpp +--- a/js/src/jsapi-tests/testGCAllocator.cpp ++++ b/js/src/jsapi-tests/testGCAllocator.cpp +@@ -307,48 +307,72 @@ void* mapMemoryAt(void* desired, size_t + void* mapMemory(size_t length) { return nullptr; } + void unmapPages(void* p, size_t size) { } + + #elif defined(XP_UNIX) + + 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); + if (region == MAP_FAILED) + return nullptr; + if (region != desired) { + if (munmap(region, length)) + MOZ_RELEASE_ASSERT(errno == ENOMEM); + return nullptr; + } + return region; + } + + 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; + } ++ 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 +- return region; + } + + void + unmapPages(void* p, size_t size) + { + if (munmap(p, size)) + MOZ_RELEASE_ASSERT(errno == ENOMEM); + } + +diff --git a/js/src/jit/AtomicOperations.h b/js/src/jit/AtomicOperations.h +index 8606a18..60af775 100644 +--- a/js/src/jit/AtomicOperations.h ++++ b/js/src/jit/AtomicOperations.h +@@ -302,7 +302,9 @@ AtomicOperations::isLockfree(int32_t size) + # include "jit/mips-shared/AtomicOperations-mips-shared.h" + #elif defined(__ppc64__) || defined(__PPC64_) \ + || defined(__ppc64le__) || defined(__PPC64LE__) \ +- || defined(__ppc__) || defined(__PPC__) ++ || defined(__ppc__) || defined(__PPC__) \ ++ || defined(__aarch64__) || defined(__arm__) \ ++ || defined(__s390x__) || defined(__mips__) + # include "jit/none/AtomicOperations-ppc.h" + #elif defined(JS_CODEGEN_NONE) + # include "jit/none/AtomicOperations-none.h" + +diff --git a/js/src/tests/js1_5/Array/regress-157652.js b/js/src/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/js/src/tests/js1_5/Array/regress-330812.js b/js/src/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/js/src/tests/js1_5/Regress/regress-422348.js b/js/src/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 + Index: libraries/source/spidermonkey/FixTracelogger.diff =================================================================== --- libraries/source/spidermonkey/FixTracelogger.diff +++ libraries/source/spidermonkey/FixTracelogger.diff @@ -1,184 +1,22 @@ -diff --git a/js/src/jit-test/tests/tracelogger/bug1231170.js b/js/src/jit-test/tests/tracelogger/bug1231170.js -new file mode 100644 -index 0000000..023e93e ---- /dev/null -+++ b/js/src/jit-test/tests/tracelogger/bug1231170.js -@@ -0,0 +1,3 @@ -+var du = new Debugger(); -+if (typeof du.drainTraceLogger === "function") -+ du.drainTraceLogger(); diff --git a/js/src/jit-test/tests/tracelogger/bug1266649.js b/js/src/jit-test/tests/tracelogger/bug1266649.js new file mode 100644 -index 0000000..81ae7ad +index 0000000..2878e0c --- /dev/null +++ b/js/src/jit-test/tests/tracelogger/bug1266649.js -@@ -0,0 +1,10 @@ +@@ -0,0 +1,8 @@ + +var du = new Debugger(); -+if (typeof du.setupTraceLogger === "function" && -+ typeof oomTest === 'function') -+{ ++if (typeof du.setupTraceLogger === "function") { + du.setupTraceLogger({ + Scripts: true + }) + oomTest(() => function(){}); +} -diff --git a/js/src/jit/Ion.cpp b/js/src/jit/Ion.cpp -index 93e2fda..09049d6 100644 ---- a/js/src/jit/Ion.cpp -+++ b/js/src/jit/Ion.cpp -@@ -1055,6 +1055,8 @@ IonScript::Destroy(FreeOp* fop, IonScript* script) - - script->destroyCaches(); - script->unlinkFromRuntime(fop); -+ // Frees the potential event we have set. -+ script->traceLoggerScriptEvent_ = TraceLoggerEvent(); - fop->free_(script); - } - -diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp -index 26262fd..af7f313 100644 ---- a/js/src/vm/Debugger.cpp -+++ b/js/src/vm/Debugger.cpp -@@ -369,10 +369,10 @@ Debugger::Debugger(JSContext* cx, NativeObject* dbg) - objects(cx), - environments(cx), - #ifdef NIGHTLY_BUILD -- traceLoggerLastDrainedId(0), -+ traceLoggerLastDrainedSize(0), - traceLoggerLastDrainedIteration(0), - #endif -- traceLoggerScriptedCallsLastDrainedId(0), -+ traceLoggerScriptedCallsLastDrainedSize(0), - traceLoggerScriptedCallsLastDrainedIteration(0) - { - assertSameCompartment(cx, dbg); -@@ -3907,9 +3907,9 @@ Debugger::drainTraceLogger(JSContext* cx, unsigned argc, Value* vp) - size_t num; - TraceLoggerThread* logger = TraceLoggerForMainThread(cx->runtime()); - bool lostEvents = logger->lostEvents(dbg->traceLoggerLastDrainedIteration, -- dbg->traceLoggerLastDrainedId); -+ dbg->traceLoggerLastDrainedSize); - EventEntry* events = logger->getEventsStartingAt(&dbg->traceLoggerLastDrainedIteration, -- &dbg->traceLoggerLastDrainedId, -+ &dbg->traceLoggerLastDrainedSize, - &num); - - RootedObject array(cx, NewDenseEmptyArray(cx)); -@@ -4002,10 +4002,10 @@ Debugger::drainTraceLoggerScriptCalls(JSContext* cx, unsigned argc, Value* vp) - size_t num; - TraceLoggerThread* logger = TraceLoggerForMainThread(cx->runtime()); - bool lostEvents = logger->lostEvents(dbg->traceLoggerScriptedCallsLastDrainedIteration, -- dbg->traceLoggerScriptedCallsLastDrainedId); -+ dbg->traceLoggerScriptedCallsLastDrainedSize); - EventEntry* events = logger->getEventsStartingAt( - &dbg->traceLoggerScriptedCallsLastDrainedIteration, -- &dbg->traceLoggerScriptedCallsLastDrainedId, -+ &dbg->traceLoggerScriptedCallsLastDrainedSize, - &num); - - RootedObject array(cx, NewDenseEmptyArray(cx)); -diff --git a/js/src/vm/Debugger.h b/js/src/vm/Debugger.h -index 8cac36a..c92d685 100644 ---- a/js/src/vm/Debugger.h -+++ b/js/src/vm/Debugger.h -@@ -314,10 +314,10 @@ class Debugger : private mozilla::LinkedListElement - * lost events. - */ - #ifdef NIGHTLY_BUILD -- uint32_t traceLoggerLastDrainedId; -+ uint32_t traceLoggerLastDrainedSize; - uint32_t traceLoggerLastDrainedIteration; - #endif -- uint32_t traceLoggerScriptedCallsLastDrainedId; -+ uint32_t traceLoggerScriptedCallsLastDrainedSize; - uint32_t traceLoggerScriptedCallsLastDrainedIteration; - - class FrameRange; diff --git a/js/src/vm/TraceLogging.cpp b/js/src/vm/TraceLogging.cpp -index 6715b36..9766a6f 100644 +index ce7acc6..8f8aca4 100644 --- a/js/src/vm/TraceLogging.cpp +++ b/js/src/vm/TraceLogging.cpp -@@ -131,7 +131,7 @@ TraceLoggerThread::init() - { - if (!pointerMap.init()) - return false; -- if (!extraTextId.init()) -+ if (!textIdPayloads.init()) - return false; - if (!events.init()) - return false; -@@ -185,10 +185,10 @@ TraceLoggerThread::~TraceLoggerThread() - graph = nullptr; - } - -- for (TextIdHashMap::Range r = extraTextId.all(); !r.empty(); r.popFront()) -- js_delete(r.front().value()); -- extraTextId.finish(); -- pointerMap.finish(); -+ if (textIdPayloads.initialized()) { -+ for (TextIdHashMap::Range r = textIdPayloads.all(); !r.empty(); r.popFront()) -+ js_delete(r.front().value()); -+ } - } - - bool -@@ -287,7 +287,7 @@ TraceLoggerThread::eventText(uint32_t id) - if (id < TraceLogger_Last) - return TLTextIdString(static_cast(id)); - -- TextIdHashMap::Ptr p = extraTextId.lookup(id); -+ TextIdHashMap::Ptr p = textIdPayloads.lookup(id); - MOZ_ASSERT(p); - - return p->value()->string(); -@@ -341,13 +341,15 @@ TraceLoggerThread::extractScriptDetails(uint32_t textId, const char** filename, - TraceLoggerEventPayload* - TraceLoggerThread::getOrCreateEventPayload(TraceLoggerTextId textId) - { -- TextIdHashMap::AddPtr p = extraTextId.lookupForAdd(textId); -- if (p) -+ TextIdHashMap::AddPtr p = textIdPayloads.lookupForAdd(textId); -+ if (p) { -+ MOZ_ASSERT(p->value()->textId() == textId); // Sanity check. - return p->value(); -+ } - - TraceLoggerEventPayload* payload = js_new(textId, (char*)nullptr); - -- if (!extraTextId.add(p, textId, payload)) -+ if (!textIdPayloads.add(p, textId, payload)) - return nullptr; - - return payload; -@@ -357,8 +359,10 @@ TraceLoggerEventPayload* - TraceLoggerThread::getOrCreateEventPayload(const char* text) - { - PointerHashMap::AddPtr p = pointerMap.lookupForAdd((const void*)text); -- if (p) -+ if (p) { -+ MOZ_ASSERT(p->value()->textId() < nextTextId); // Sanity check. - return p->value(); -+ } - - size_t len = strlen(text); - char* str = js_pod_malloc(len + 1); -@@ -369,7 +373,7 @@ TraceLoggerThread::getOrCreateEventPayload(const char* text) - MOZ_ASSERT(ret == len); - MOZ_ASSERT(strlen(str) == len); - -- uint32_t textId = extraTextId.count() + TraceLogger_Last; -+ uint32_t textId = nextTextId; - - TraceLoggerEventPayload* payload = js_new(textId, str); - if (!payload) { -@@ -377,17 +381,19 @@ TraceLoggerThread::getOrCreateEventPayload(const char* text) - return nullptr; - } - -- if (!extraTextId.putNew(textId, payload)) { -+ if (!textIdPayloads.putNew(textId, payload)) { - js_delete(payload); +@@ -393,14 +393,14 @@ TraceLoggerThread::getOrCreateEventPayload(const char* text) return nullptr; } @@ -188,20 +26,21 @@ if (graph.get()) graph->addTextId(textId, str); -+ nextTextId++; -+ + nextTextId++; + + if (!pointerMap.add(p, text, payload)) + return nullptr; + return payload; } -@@ -407,9 +413,14 @@ TraceLoggerThread::getOrCreateEventPayload(TraceLoggerTextId type, const char* f +@@ -420,10 +420,13 @@ TraceLoggerThread::getOrCreateEventPayload(TraceLoggerTextId type, const char* f if (!traceLoggerState->isTextIdEnabled(type)) return getOrCreateEventPayload(type); - PointerHashMap::AddPtr p = pointerMap.lookupForAdd(ptr); -- if (p) +- if (p) { +- MOZ_ASSERT(p->value()->textId() < nextTextId); // Sanity check. - return p->value(); + PointerHashMap::AddPtr p; + if (ptr) { @@ -210,25 +49,10 @@ + MOZ_ASSERT(p->value()->textId() < nextTextId); // Sanity check. + return p->value(); + } -+ } - - // Compute the length of the string to create. - size_t lenFilename = strlen(filename); -@@ -428,24 +439,28 @@ TraceLoggerThread::getOrCreateEventPayload(TraceLoggerTextId type, const char* f - MOZ_ASSERT(ret == len); - MOZ_ASSERT(strlen(str) == len); - -- uint32_t textId = extraTextId.count() + TraceLogger_Last; -+ uint32_t textId = nextTextId; - TraceLoggerEventPayload* payload = js_new(textId, str); - if (!payload) { - js_free(str); - return nullptr; } -- if (!extraTextId.putNew(textId, payload)) { -+ if (!textIdPayloads.putNew(textId, payload)) { - js_delete(payload); + // Compute the length of the string to create. +@@ -455,14 +458,16 @@ TraceLoggerThread::getOrCreateEventPayload(TraceLoggerTextId type, const char* f return nullptr; } @@ -238,8 +62,8 @@ if (graph.get()) graph->addTextId(textId, str); -+ nextTextId++; -+ + nextTextId++; + + if (ptr) { + if (!pointerMap.add(p, ptr, payload)) + return nullptr; @@ -248,15 +72,7 @@ return payload; } -@@ -453,14 +468,14 @@ TraceLoggerEventPayload* - TraceLoggerThread::getOrCreateEventPayload(TraceLoggerTextId type, JSScript* script) - { - return getOrCreateEventPayload(type, script->filename(), script->lineno(), script->column(), -- script); -+ nullptr); - } - - TraceLoggerEventPayload* +@@ -477,7 +482,7 @@ TraceLoggerEventPayload* TraceLoggerThread::getOrCreateEventPayload(TraceLoggerTextId type, const JS::ReadOnlyCompileOptions& script) { @@ -265,44 +81,11 @@ } void -@@ -485,7 +500,7 @@ TraceLoggerThread::startEvent(uint32_t id) - if (!traceLoggerState->isTextIdEnabled(id)) - return; - -- logTimestamp(id); -+ log(id); - } - - void -@@ -510,7 +525,7 @@ TraceLoggerThread::stopEvent(uint32_t id) - if (!traceLoggerState->isTextIdEnabled(id)) - return; - -- logTimestamp(TraceLogger_Stop); -+ log(TraceLogger_Stop); - } - - void -@@ -522,23 +537,57 @@ TraceLoggerThread::logTimestamp(TraceLoggerTextId id) - void - TraceLoggerThread::logTimestamp(uint32_t id) - { -+ MOZ_ASSERT(id > TraceLogger_LastTreeItem && id < TraceLogger_Last); -+ log(id); -+} -+ -+void -+TraceLoggerThread::log(uint32_t id) -+{ - if (enabled == 0) +@@ -550,19 +555,42 @@ TraceLoggerThread::log(uint32_t id) return; MOZ_ASSERT(traceLoggerState); - if (!events.ensureSpaceBeforeAdd()) { -+ -+ // We request for 3 items to add, since if we don't have enough room -+ // we record the time it took to make more place. To log this information -+ // we need 2 extra free entries. + if (!events.hasSpaceForAdd(3)) { uint64_t start = rdtsc() - traceLoggerState->startupTime; @@ -311,7 +94,9 @@ + if (!events.ensureSpaceBeforeAdd(3)) { + if (graph.get()) + graph->log(events); -+ + +- iteration_++; +- events.clear(); + iteration_++; + events.clear(); + @@ -327,9 +112,7 @@ + + e.removeFront(); + } - -- iteration_++; -- events.clear(); ++ + // Free all payloads that have no uses anymore. + for (TextIdHashMap::Enum e(textIdPayloads); !e.empty(); e.popFront()) { + if (e.front().value()->uses() == 0) { @@ -343,16 +126,29 @@ // Tracelogger. if (graph.get()) { - MOZ_ASSERT(events.capacity() > 2); -+ MOZ_ASSERT(events.hasSpaceForAdd(2)); ++ MOZ_ASSERT(events.capacity() - events.size() > 2); EventEntry& entryStart = events.pushUninitialized(); entryStart.time = start; entryStart.textId = TraceLogger_Internal; -@@ -548,13 +597,6 @@ TraceLoggerThread::logTimestamp(uint32_t id) +@@ -572,26 +600,6 @@ TraceLoggerThread::log(uint32_t id) entryStop.textId = TraceLogger_Stop; } -- // Free all TextEvents that have no uses anymore. -- for (TextIdHashMap::Enum e(extraTextId); !e.empty(); e.popFront()) { +- // Remove the item in the pointerMap for which the payloads +- // have no uses anymore +- for (PointerHashMap::Enum e(pointerMap); !e.empty(); e.popFront()) { +- if (e.front().value()->uses() != 0) +- continue; +- +- TextIdHashMap::Ptr p = textIdPayloads.lookup(e.front().value()->textId()); +- MOZ_ASSERT(p); +- textIdPayloads.remove(p); +- +- e.removeFront(); +- } +- +- // Free all payloads that have no uses anymore. +- for (TextIdHashMap::Enum e(textIdPayloads); !e.empty(); e.popFront()) { - if (e.front().value()->uses() == 0) { - js_delete(e.front().value()); - e.removeFront(); @@ -361,170 +157,33 @@ } uint64_t time = rdtsc() - traceLoggerState->startupTime; -@@ -956,3 +998,16 @@ TraceLoggerEvent::~TraceLoggerEvent() - if (payload_) - payload_->release(); - } -+ -+TraceLoggerEvent& -+TraceLoggerEvent::operator=(const TraceLoggerEvent& other) -+{ -+ if (hasPayload()) -+ payload()->release(); -+ if (other.hasPayload()) -+ other.payload()->use(); -+ -+ payload_ = other.payload_; -+ -+ return *this; -+} diff --git a/js/src/vm/TraceLogging.h b/js/src/vm/TraceLogging.h -index a124dcb..91a1eb0 100644 +index 270478c..313950e 100644 --- a/js/src/vm/TraceLogging.h +++ b/js/src/vm/TraceLogging.h -@@ -110,6 +110,9 @@ class TraceLoggerEvent { - bool hasPayload() const { - return !!payload_; - } -+ -+ TraceLoggerEvent& operator=(const TraceLoggerEvent& other); -+ TraceLoggerEvent(const TraceLoggerEvent& event) = delete; - }; - - /** -@@ -130,6 +133,10 @@ class TraceLoggerEventPayload { - uses_(0) - { } +@@ -242,7 +242,7 @@ class TraceLoggerThread -+ ~TraceLoggerEventPayload() { -+ MOZ_ASSERT(uses_ == 0); -+ } -+ - uint32_t textId() { - return textId_; - } -@@ -166,7 +173,8 @@ class TraceLoggerThread - mozilla::UniquePtr graph; - - PointerHashMap pointerMap; -- TextIdHashMap extraTextId; -+ TextIdHashMap textIdPayloads; -+ uint32_t nextTextId; - - ContinuousSpace events; - -@@ -181,6 +189,7 @@ class TraceLoggerThread - : enabled(0), - failed(false), - graph(), -+ nextTextId(TraceLogger_Last), - iteration_(0), - top(nullptr) - { } -@@ -195,22 +204,22 @@ class TraceLoggerThread - bool enable(JSContext* cx); - bool disable(); - -- // Given the previous iteration and lastEntryId, return an array of events -+ // Given the previous iteration and size, return an array of events - // (there could be lost events). At the same time update the iteration and -- // lastEntry and gives back how many events there are. -- EventEntry* getEventsStartingAt(uint32_t* lastIteration, uint32_t* lastEntryId, size_t* num) { -+ // size and gives back how many events there are. -+ EventEntry* getEventsStartingAt(uint32_t* lastIteration, uint32_t* lastSize, size_t* num) { - EventEntry* start; - if (iteration_ == *lastIteration) { -- MOZ_ASSERT(events.lastEntryId() >= *lastEntryId); -- *num = events.lastEntryId() - *lastEntryId; -- start = events.data() + *lastEntryId + 1; -+ MOZ_ASSERT(*lastSize <= events.size()); -+ *num = events.size() - *lastSize; -+ start = events.data() + *lastSize; - } else { -- *num = events.lastEntryId() + 1; -+ *num = events.size(); - start = events.data(); - } - - *lastIteration = iteration_; -- *lastEntryId = events.lastEntryId(); -+ *lastSize = events.size(); - return start; - } - -@@ -220,16 +229,16 @@ class TraceLoggerThread - const char** lineno, size_t* lineno_len, const char** colno, - size_t* colno_len); - -- bool lostEvents(uint32_t lastIteration, uint32_t lastEntryId) { -+ bool lostEvents(uint32_t lastIteration, uint32_t lastSize) { - // If still logging in the same iteration, there are no lost events. - if (lastIteration == iteration_) { -- MOZ_ASSERT(lastEntryId <= events.lastEntryId()); -+ MOZ_ASSERT(lastSize <= events.size()); - return false; - } - -- // When proceeded to the next iteration and lastEntryId points to -- // the maximum capacity there are no logs that are lost. -- if (lastIteration + 1 == iteration_ && lastEntryId == events.capacity()) -+ // If we are in a consecutive iteration we are only sure we didn't lose any events, -+ // when the lastSize equals the maximum size 'events' can get. -+ if (lastIteration == iteration_ - 1 && lastSize == events.maxSize()) + // If we are in a consecutive iteration we are only sure we didn't lose any events, + // when the lastSize equals the maximum size 'events' can get. +- if (lastIteration == iteration_ - 1 && lastSize == CONTINUOUSSPACE_LIMIT) ++ if (lastIteration == iteration_ - 1 && lastSize == events.max_items()) return false; return true; -@@ -268,6 +277,7 @@ class TraceLoggerThread - void stopEvent(uint32_t id); - private: - void stopEvent(); -+ void log(uint32_t id); - - public: - static unsigned offsetOfEnabled() { -diff --git a/js/src/vm/TraceLoggingGraph.cpp b/js/src/vm/TraceLoggingGraph.cpp -index d1b7f2e..a4eb273 100644 ---- a/js/src/vm/TraceLoggingGraph.cpp -+++ b/js/src/vm/TraceLoggingGraph.cpp -@@ -276,7 +276,7 @@ TraceLoggerGraph::flush() - if (bytesWritten < tree.size()) - return false; - -- treeOffset += tree.lastEntryId(); -+ treeOffset += tree.size(); - tree.clear(); - } - -@@ -359,7 +359,7 @@ TraceLoggerGraph::startEventInternal(uint32_t id, uint64_t timestamp) - - if (parent.lastChildId() == 0) { - MOZ_ASSERT(!entry.hasChildren()); -- MOZ_ASSERT(parent.treeId() == tree.lastEntryId() + treeOffset); -+ MOZ_ASSERT(parent.treeId() == treeOffset + tree.size() - 1); - - if (!updateHasChildren(parent.treeId())) - return false; diff --git a/js/src/vm/TraceLoggingTypes.h b/js/src/vm/TraceLoggingTypes.h -index f1c9d0c..10b76d6 100644 +index bb8ccc7..1d98bf6 100644 --- a/js/src/vm/TraceLoggingTypes.h +++ b/js/src/vm/TraceLoggingTypes.h -@@ -21,7 +21,6 @@ - _(Internal) \ - _(Interpreter) \ - _(InlinedScripts) \ -- _(Invalidation) \ - _(IonCompilation) \ - _(IonCompilationPaused) \ - _(IonLinking) \ -@@ -60,6 +59,7 @@ - - #define TRACELOGGER_LOG_ITEMS(_) \ - _(Bailout) \ -+ _(Invalidation) \ - _(Disable) \ - _(Enable) \ - _(Stop) -@@ -130,6 +130,9 @@ class ContinuousSpace { +@@ -130,15 +130,15 @@ TLTextIdIsTreeEvent(uint32_t id) + id >= TraceLogger_Last; + } + +-// The maximum amount of ram memory a continuous space structure can take (in bytes). +-static const uint32_t CONTINUOUSSPACE_LIMIT = 200 * 1024 * 1024; +- + template + class ContinuousSpace { + T* data_; uint32_t size_; uint32_t capacity_; @@ -534,32 +193,31 @@ public: ContinuousSpace () : data_(nullptr) -@@ -151,6 +154,10 @@ class ContinuousSpace { +@@ -160,6 +160,10 @@ class ContinuousSpace { data_ = nullptr; } -+ static uint32_t maxSize() { ++ uint32_t max_items() { + return LIMIT / sizeof(T); + } + T* data() { return data_; } -@@ -187,11 +194,14 @@ class ContinuousSpace { - if (hasSpaceForAdd(count)) +@@ -197,11 +201,14 @@ class ContinuousSpace { return true; -+ // Limit the size of a continuous buffer. -+ if (size_ + count > maxSize()) -+ return false; -+ uint32_t nCapacity = capacity_ * 2; -- if (size_ + count > nCapacity) -- nCapacity = size_ + count; -- T* entries = (T*) js_realloc(data_, nCapacity * sizeof(T)); -+ nCapacity = (nCapacity < maxSize()) ? nCapacity : maxSize(); - -+ T* entries = (T*) js_realloc(data_, nCapacity * sizeof(T)); - if (!entries) - return false; +- if (size_ + count > nCapacity || nCapacity * sizeof(T) > CONTINUOUSSPACE_LIMIT) { ++ if (size_ + count > nCapacity) + nCapacity = size_ + count; + ++ if (nCapacity > max_items()) { ++ nCapacity = max_items(); ++ + // Limit the size of a continuous buffer. +- if (nCapacity * sizeof(T) > CONTINUOUSSPACE_LIMIT) ++ if (size_ + count > nCapacity) + return false; + } Index: libraries/source/spidermonkey/FixVersionDetection.diff =================================================================== --- libraries/source/spidermonkey/FixVersionDetection.diff +++ /dev/null @@ -1,137 +0,0 @@ - -# HG changeset patch -# User Sean Stangl -# Date 1426889983 25200 -# Node ID 4f8bbef857155fbee1d064e014b22dd72512b389 -# Parent 6f42f8ee82468d18acd65e0c2b5bf6c040696224 -Bug 1145882 - Part 1/2 - Only use $PYTHON after defined by MOZ_PYTHON. r=glandium - -diff --git a/js/src/configure.in b/js/src/configure.in ---- a/js/src/configure.in -+++ b/js/src/configure.in -@@ -228,61 +228,16 @@ if test -n "$gonkdir" ; then - fi - - AC_DEFINE(ANDROID) - AC_DEFINE(GONK) - else - MOZ_ANDROID_NDK - fi - --dnl ============================================================== --dnl Get mozilla version from central milestone file --dnl ============================================================== --MOZILLA_VERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir` --MOZILLA_UAVERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir --uaversion` --MOZILLA_SYMBOLVERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir --symbolversion` -- --AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION") --AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION) --AC_DEFINE_UNQUOTED(MOZILLA_UAVERSION,"$MOZILLA_UAVERSION") --AC_SUBST(MOZILLA_SYMBOLVERSION) -- --# Separate version into components for use in shared object naming etc --changequote(,) --MOZJS_MAJOR_VERSION=`echo $MOZILLA_VERSION | sed "s|\(^[0-9]*\)\.[0-9]*.*|\1|"` --MOZJS_MINOR_VERSION=`echo $MOZILLA_VERSION | sed "s|^[0-9]*\.\([0-9]*\).*|\1|"` --MOZJS_PATCH_VERSION=`echo $MOZILLA_VERSION | sed "s|^[0-9]*\.[0-9]*[^0-9]*||"` --IS_ALPHA=`echo $MOZILLA_VERSION | grep '[ab]'` -- --dnl XXX in a temporary bid to avoid developer anger at renaming files --dnl XXX before "js" symlinks exist, don't change names. --dnl --dnl if test -n "$JS_STANDALONE"; then --dnl JS_SHELL_NAME=js$MOZJS_MAJOR_VERSION --dnl JS_CONFIG_NAME=js$MOZJS_MAJOR_VERSION-config --dnl else --JS_SHELL_NAME=js --JS_CONFIG_NAME=js-config --dnl fi -- --changequote([,]) --if test -n "$IS_ALPHA"; then -- changequote(,) -- MOZJS_ALPHA=`echo $MOZILLA_VERSION | sed "s|^[0-9]*\.[0-9\.]*\([^0-9]\).*|\1|"` -- changequote([,]) --fi --AC_DEFINE_UNQUOTED(MOZJS_MAJOR_VERSION,$MOZJS_MAJOR_VERSION) --AC_DEFINE_UNQUOTED(MOZJS_MINOR_VERSION,$MOZJS_MINOR_VERSION) --AC_SUBST(JS_SHELL_NAME) --AC_SUBST(JS_CONFIG_NAME) --AC_SUBST(MOZJS_MAJOR_VERSION) --AC_SUBST(MOZJS_MINOR_VERSION) --AC_SUBST(MOZJS_PATCH_VERSION) --AC_SUBST(MOZJS_ALPHA) -- - dnl ======================================================== - dnl Checks for compilers. - dnl ======================================================== - - dnl AR_FLAGS set here so HOST_AR_FLAGS can be set correctly (see bug 538269) - AR_FLAGS='crs $@' - - if test "$COMPILE_ENVIRONMENT"; then -@@ -733,16 +688,62 @@ fi - if test "$COMPILE_ENVIRONMENT"; then - - AC_PATH_XTRA - - XCFLAGS="$X_CFLAGS" - - fi # COMPILE_ENVIRONMENT - -+dnl ============================================================== -+dnl Get mozilla version from central milestone file -+dnl ============================================================== -+MOZILLA_VERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir` -+MOZILLA_UAVERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir --uaversion` -+MOZILLA_SYMBOLVERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir --symbolversion` -+ -+AC_DEFINE_UNQUOTED(MOZILLA_VERSION,"$MOZILLA_VERSION") -+AC_DEFINE_UNQUOTED(MOZILLA_VERSION_U,$MOZILLA_VERSION) -+AC_DEFINE_UNQUOTED(MOZILLA_UAVERSION,"$MOZILLA_UAVERSION") -+AC_SUBST(MOZILLA_SYMBOLVERSION) -+ -+# Separate version into components for use in shared object naming etc -+changequote(,) -+MOZJS_MAJOR_VERSION=`echo $MOZILLA_VERSION | sed "s|\(^[0-9]*\)\.[0-9]*.*|\1|"` -+MOZJS_MINOR_VERSION=`echo $MOZILLA_VERSION | sed "s|^[0-9]*\.\([0-9]*\).*|\1|"` -+MOZJS_PATCH_VERSION=`echo $MOZILLA_VERSION | sed "s|^[0-9]*\.[0-9]*[^0-9]*||"` -+IS_ALPHA=`echo $MOZILLA_VERSION | grep '[ab]'` -+ -+dnl XXX in a temporary bid to avoid developer anger at renaming files -+dnl XXX before "js" symlinks exist, don't change names. -+dnl -+dnl if test -n "$JS_STANDALONE"; then -+dnl JS_SHELL_NAME=js$MOZJS_MAJOR_VERSION -+dnl JS_CONFIG_NAME=js$MOZJS_MAJOR_VERSION-config -+dnl else -+JS_SHELL_NAME=js -+JS_CONFIG_NAME=js-config -+dnl fi -+ -+changequote([,]) -+if test -n "$IS_ALPHA"; then -+ changequote(,) -+ MOZJS_ALPHA=`echo $MOZILLA_VERSION | sed "s|^[0-9]*\.[0-9\.]*\([^0-9]\).*|\1|"` -+ changequote([,]) -+fi -+AC_DEFINE_UNQUOTED(MOZJS_MAJOR_VERSION,$MOZJS_MAJOR_VERSION) -+AC_DEFINE_UNQUOTED(MOZJS_MINOR_VERSION,$MOZJS_MINOR_VERSION) -+AC_SUBST(JS_SHELL_NAME) -+AC_SUBST(JS_CONFIG_NAME) -+AC_SUBST(MOZJS_MAJOR_VERSION) -+AC_SUBST(MOZJS_MINOR_VERSION) -+AC_SUBST(MOZJS_PATCH_VERSION) -+AC_SUBST(MOZJS_ALPHA) -+ -+ - dnl ======================================================== - dnl set the defaults first - dnl ======================================================== - AS_BIN=$AS - AR_LIST='$(AR) t' - AR_EXTRACT='$(AR) x' - AR_DELETE='$(AR) d' - AS='$(CC)' - Index: libraries/source/spidermonkey/FixVersionDetectionConfigure.diff =================================================================== --- libraries/source/spidermonkey/FixVersionDetectionConfigure.diff +++ /dev/null @@ -1,178 +0,0 @@ -Created from the patched (FixVersionDetection.diff) configure.in, ignoring -unrelated hunks (thus invalidating some hard-coded line numbers). This way -we do not add a dependency on autoconf-2.13. - -diff --git a/js/src/configure b/js/src/configure ---- a/js/src/configure -+++ b/js/src/configure -@@ -1662,70 +1662,6 @@ esac - - fi - --MOZILLA_VERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir` --MOZILLA_UAVERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir --uaversion` --MOZILLA_SYMBOLVERSION=`$PYTHON $srcdir/python/mozbuild/mozbuild/milestone.py --topsrcdir $srcdir --symbolversion` -- --cat >> confdefs.pytmp <> confdefs.h <> confdefs.pytmp <> confdefs.h <> confdefs.pytmp <> confdefs.h <> confdefs.pytmp <> confdefs.h <> confdefs.pytmp <> confdefs.h <> confdefs.pytmp <> confdefs.h <> confdefs.pytmp <> confdefs.h <> confdefs.pytmp <> confdefs.h <> confdefs.pytmp <> confdefs.h <> confdefs.pytmp <> confdefs.h <> $CONFIG_STATUS <> $CONFIG_STATUS < +# Date 1501017350 25200 +# Node ID 5d95b2833b30582ab3df4e28373d749ddbf7c04e +# Parent c24e6fc9f689aeb32de0bf7916b1d0098d4a2bb9 +Bug 1379539 - Remove unnecessary NSPR dependency. r=glandium, a=jcristau + +diff --git a/build/autoconf/nspr-build.m4 b/build/autoconf/nspr-build.m4 +index 970e1e7..66d96b1 100644 +--- a/build/autoconf/nspr-build.m4 ++++ b/build/autoconf/nspr-build.m4 +@@ -167,11 +167,8 @@ fi + + AC_SUBST_LIST(NSPR_CFLAGS) + +-NSPR_PKGCONF_CHECK="nspr" ++PKGCONF_REQUIRES_PRIVATE="Requires.private: nspr" + if test -n "$MOZ_NATIVE_NSPR"; then +- # piggy back on $MOZ_NATIVE_NSPR to set a variable for the nspr check for js.pc +- NSPR_PKGCONF_CHECK="nspr >= $NSPR_MINVER" +- + _SAVE_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS $NSPR_CFLAGS" + AC_TRY_COMPILE([#include "prlog.h"], +@@ -181,8 +178,12 @@ if test -n "$MOZ_NATIVE_NSPR"; then + , + AC_MSG_ERROR([system NSPR does not support PR_STATIC_ASSERT])) + CFLAGS=$_SAVE_CFLAGS ++ # piggy back on $MOZ_NATIVE_NSPR to set a variable for the nspr check for js.pc ++ PKGCONF_REQUIRES_PRIVATE="Requires.private: nspr >= $NSPR_MINVER" ++elif test -n "$JS_POSIX_NSPR"; then ++ PKGCONF_REQUIRES_PRIVATE= + fi +-AC_SUBST(NSPR_PKGCONF_CHECK) ++AC_SUBST([PKGCONF_REQUIRES_PRIVATE]) + + fi # _IS_OUTER_CONFIGURE + +diff --git a/js/src/js.pc.in b/js/src/js.pc.in +index 1efea33..2eae393 100644 +--- a/js/src/js.pc.in ++++ b/js/src/js.pc.in +@@ -6,6 +6,6 @@ includedir=@includedir@ + Name: SpiderMonkey @MOZILLA_VERSION@ + Description: The Mozilla library for JavaScript + Version: @MOZILLA_VERSION@ +-Requires.private: @NSPR_PKGCONF_CHECK@ ++@PKGCONF_REQUIRES_PRIVATE@ + Libs: -L${libdir} -l@JS_LIBRARY_NAME@ + Cflags: -include ${includedir}/@JS_LIBRARY_NAME@/js/RequiredDefines.h -I${includedir}/@JS_LIBRARY_NAME@ Index: libraries/source/spidermonkey/build.sh =================================================================== --- libraries/source/spidermonkey/build.sh +++ libraries/source/spidermonkey/build.sh @@ -27,10 +27,11 @@ MAKE_OPTS="${JOBS}" -CONF_OPTS="--enable-shared-js --disable-tests --without-intl-api" +# jemalloc is outdated on SM45, do not use it +CONF_OPTS="--disable-tests --disable-jemalloc --enable-shared-js --without-intl-api" # Bug 1269319 -# When compiled with GCC 6 (or later), SpiderMonkey 38 (and versions up to 49) is +# When compiled with GCC 6 (or later), SpiderMonkey 45 (and versions up to 49) is # subject to segfaults. Disabling a few optimizations fixes that. # See also #4053 if [ "${OS}" != "Windows_NT" ] @@ -45,19 +46,18 @@ # The default location is . on Windows and /tmp/ on *nix. TLCXXFLAGS='-DTRACE_LOG_DIR="\"../../source/tools/tracelogger/\""' -# We bundle prebuilt binaries for Windows and the .libs for nspr aren't included. +# NSPR is needed on Windows for POSIX emulation. # If you want to build on Windows, check README.txt and edit the absolute paths # to match your environment. if [ "${OS}" = "Windows_NT" ] then - NSPR_INCLUDES="-IC:/Projects/nspr/nspr-4.12/nspr/dist/include/nspr" + NSPR_INCLUDES="-ID:/nspr-4.12/nspr/dist/include/nspr" NSPR_LIBS=" \ - C:/Projects/nspr/nspr-4.12/nspr/dist/lib/nspr4 \ - C:/Projects/nspr/nspr-4.12/nspr/dist/lib/plds4 \ - C:/Projects/nspr/nspr-4.12/nspr/dist/lib/plc4" + D:/nspr-4.12/nspr/dist/lib/nspr4 \ + D:/nspr-4.12/nspr/dist/lib/plds4 \ + D:/nspr-4.12/nspr/dist/lib/plc4" else - NSPR_INCLUDES="`pkg-config nspr --cflags`" - NSPR_LIBS="`pkg-config nspr --libs`" + CONF_OPTS="${CONF_OPTS} --enable-posix-nspr-emulation" fi # If Valgrind looks like it's installed, then set up SM to support it @@ -76,11 +76,11 @@ echo "SpiderMonkey build options: ${CONF_OPTS}" echo ${CONF_OPTS} -FOLDER=mozjs-38.0.0 +FOLDER=mozjs-45.0.2 # Delete the existing directory to avoid conflicts and extract the tarball rm -rf $FOLDER -tar xjf mozjs-38.2.1.rc0.tar.bz2 +tar xjf mozjs-45.0.2.tar.bz2 # Clean up header files that may be left over by earlier versions of SpiderMonkey rm -rf include-unix-* @@ -100,17 +100,43 @@ # the LIBRARY_NAME for each build. # (We use perl instead of sed so that it works with MozillaBuild on Windows, # which has an ancient sed.) -perl -i.bak -pe 's/(SHARED_LIBRARY_NAME\s+=).*/$1 '\''mozjs38-ps-debug'\''/' moz.build +perl -i.bak -pe 's/(SHARED_LIBRARY_NAME\s+=).*/$1 '\''mozjs45-ps-debug'\''/' moz.build mkdir -p build-debug cd build-debug -CXXFLAGS="${CXXFLAGS} ${TLCXXFLAGS}" ../configure ${CONF_OPTS} --with-nspr-libs="$NSPR_LIBS" --with-nspr-cflags="$NSPR_INCLUDES" --enable-debug --disable-optimize --enable-js-diagnostics --enable-gczeal +if [ "${OS}" = "Windows_NT" ] +then + CXXFLAGS="${CXXFLAGS} ${TLCXXFLAGS}" ../configure ${CONF_OPTS} \ + --with-nspr-cflags="${NSPR_INCLUDES}" --with-nspr-libs="${NSPR_LIBS}" \ + --enable-debug \ + --disable-optimize \ + --enable-js-diagnostics \ + --enable-gczeal +else + CXXFLAGS="${CXXFLAGS} ${TLCXXFLAGS}" ../configure ${CONF_OPTS} \ + --enable-debug \ + --disable-optimize \ + --enable-js-diagnostics \ + --enable-gczeal +fi ${MAKE} ${MAKE_OPTS} cd .. -perl -i.bak -pe 's/(SHARED_LIBRARY_NAME\s+=).*/$1 '\''mozjs38-ps-release'\''/' moz.build +perl -i.bak -pe 's/(SHARED_LIBRARY_NAME\s+=).*/$1 '\''mozjs45-ps-release'\''/' moz.build mkdir -p build-release cd build-release -CXXFLAGS="${CXXFLAGS} ${TLCXXFLAGS}" ../configure ${CONF_OPTS} --with-nspr-libs="$NSPR_LIBS" --with-nspr-cflags="$NSPR_INCLUDES" --enable-optimize # --enable-gczeal --enable-debug-symbols +if [ "${OS}" = "Windows_NT" ] +then + CXXFLAGS="${CXXFLAGS} ${TLCXXFLAGS}" ../configure ${CONF_OPTS} \ + --with-nspr-cflags="${NSPR_INCLUDES}" --with-nspr-libs="${NSPR_LIBS}" \ + --enable-optimize \ + #--enable-gczeal \ + #--enable-debug-symbols +else + CXXFLAGS="${CXXFLAGS} ${TLCXXFLAGS}" ../configure ${CONF_OPTS} \ + --enable-optimize \ + #--enable-gczeal \ + #--enable-debug-symbols +fi ${MAKE} ${MAKE_OPTS} cd .. @@ -147,12 +173,12 @@ # Bug #776126 # SpiderMonkey uses a tweaked zlib when building, and it wrongly copies its own files to include dirs # afterwards, so we have to remove them to not have them conflicting with the regular zlib - cd ${FOLDER}/js/src/build-release/dist/include + pushd ${FOLDER}/js/src/build-release/dist/include rm mozzconf.h zconf.h zlib.h - cd ../../../../../.. - cd ${FOLDER}/js/src/build-debug/dist/include + popd + pushd ${FOLDER}/js/src/build-debug/dist/include rm mozzconf.h zconf.h zlib.h - cd ../../../../../.. + popd fi # Copy files into the necessary locations for building and running the game @@ -164,16 +190,16 @@ cp -R -L ${FOLDER}/js/src/build-debug/dist/include/* ${INCLUDE_DIR_DEBUG}/ mkdir -p lib/ -cp -L ${FOLDER}/js/src/build-debug/dist/lib/${LIB_PREFIX}mozjs38-ps-debug${LIB_SRC_SUFFIX} lib/${LIB_PREFIX}mozjs38-ps-debug${LIB_DST_SUFFIX} -cp -L ${FOLDER}/js/src/build-release/dist/lib/${LIB_PREFIX}mozjs38-ps-release${LIB_SRC_SUFFIX} lib/${LIB_PREFIX}mozjs38-ps-release${LIB_DST_SUFFIX} -cp -L ${FOLDER}/js/src/build-debug/dist/bin/${LIB_PREFIX}mozjs38-ps-debug${DLL_SRC_SUFFIX} ../../../binaries/system/${LIB_PREFIX}mozjs38-ps-debug${DLL_DST_SUFFIX} -cp -L ${FOLDER}/js/src/build-release/dist/bin/${LIB_PREFIX}mozjs38-ps-release${DLL_SRC_SUFFIX} ../../../binaries/system/${LIB_PREFIX}mozjs38-ps-release${DLL_DST_SUFFIX} +cp -L ${FOLDER}/js/src/build-debug/dist/sdk/lib/${LIB_PREFIX}mozjs45-ps-debug${LIB_SRC_SUFFIX} lib/${LIB_PREFIX}mozjs45-ps-debug${LIB_DST_SUFFIX} +cp -L ${FOLDER}/js/src/build-release/dist/sdk/lib/${LIB_PREFIX}mozjs45-ps-release${LIB_SRC_SUFFIX} lib/${LIB_PREFIX}mozjs45-ps-release${LIB_DST_SUFFIX} +cp -L ${FOLDER}/js/src/build-debug/dist/bin/${LIB_PREFIX}mozjs45-ps-debug${DLL_SRC_SUFFIX} ../../../binaries/system/${LIB_PREFIX}mozjs45-ps-debug${DLL_DST_SUFFIX} +cp -L ${FOLDER}/js/src/build-release/dist/bin/${LIB_PREFIX}mozjs45-ps-release${DLL_SRC_SUFFIX} ../../../binaries/system/${LIB_PREFIX}mozjs45-ps-release${DLL_DST_SUFFIX} # On Windows, also copy debugging symbols files if [ "${OS}" = "Windows_NT" ] then - cp -L ${FOLDER}/js/src/build-debug/js/src/${LIB_PREFIX}mozjs38-ps-debug.pdb ../../../binaries/system/${LIB_PREFIX}mozjs38-ps-debug.pdb - cp -L ${FOLDER}/js/src/build-release/js/src/${LIB_PREFIX}mozjs38-ps-release.pdb ../../../binaries/system/${LIB_PREFIX}mozjs38-ps-release.pdb + cp -L ${FOLDER}/js/src/build-debug/js/src/${LIB_PREFIX}mozjs45-ps-debug-vc140.pdb ../../../binaries/system/${LIB_PREFIX}mozjs45-ps-debug-vc140.pdb + cp -L ${FOLDER}/js/src/build-release/js/src/${LIB_PREFIX}mozjs45-ps-release-vc140.pdb ../../../binaries/system/${LIB_PREFIX}mozjs45-ps-release-vc140.pdb fi # Flag that it's already been built successfully so we can skip it next time Index: libraries/source/spidermonkey/patch.sh =================================================================== --- libraries/source/spidermonkey/patch.sh +++ libraries/source/spidermonkey/patch.sh @@ -2,45 +2,23 @@ # Apply patches if needed # This script gets called from build-osx-libs.sh and build.sh. -# Fix the version specification code which used PYTHON before it was set. -# The second patch is required to not add autoconf as a dependency. -patch -p1 < ../FixVersionDetection.diff -patch -p1 < ../FixVersionDetectionConfigure.diff +# Remove the unnecessary NSPR dependency. +# Will be included in SM52. +# https://bugzilla.mozilla.org/show_bug.cgi?id=1379539 +patch -p1 < ../RemoveNSPRDependency.diff # Fix the path to the moz.build file in the zlib module patch -p1 < ../FixZLibMozBuild.diff -# === Fix the SM38 tracelogger === +# === Fix the SM45 tracelogger === # This patch is a squashed version of several patches that were adapted # to fix failing hunks. # # Applied in the following order, they are: -# * https://bugzilla.mozilla.org/show_bug.cgi?id=1223767 -# Assertion failure: i < size_, at js/src/vm/TraceLoggingTypes.h:210 -# Also fix stop-information to make reduce.py work correctly. -# * https://bugzilla.mozilla.org/show_bug.cgi?id=1227914 -# Limit the memory tracelogger can take. -# This causes tracelogger to flush data to the disk regularly and prevents out of -# memory issues if a lot of data gets logged. -# * https://bugzilla.mozilla.org/show_bug.cgi?id=1155618 -# Fix tracelogger destructor that touches possibly uninitialised hash table. -# * https://bugzilla.mozilla.org/show_bug.cgi?id=1223636 -# Don't treat extraTextId as containing only extra ids. -# This fixes an assertion failure: id == nextTextId at js/src/vm/TraceLoggingGraph.cpp -# * https://bugzilla.mozilla.org/show_bug.cgi?id=1227028 -# Fix when to keep the payload of a TraceLogger event. -# This fixes an assertion failure: textId < uint32_t(1 << 31) at js/src/vm/TraceLoggingGraph.h # * https://bugzilla.mozilla.org/show_bug.cgi?id=1266649 # Handle failing to add to pointermap gracefully. # * https://bugzilla.mozilla.org/show_bug.cgi?id=1280648 # Don't cache based on pointers to movable GC things. -# * https://bugzilla.mozilla.org/show_bug.cgi?id=1224123 -# Fix the use of LastEntryId in tracelogger.h. -# * https://bugzilla.mozilla.org/show_bug.cgi?id=1231170 -# Use size in debugger instead of the current id to track last logged item. -# * https://bugzilla.mozilla.org/show_bug.cgi?id=1221844 -# Move TraceLogger_Invalidation to LOG_ITEM. -# Add some debug checks to logTimestamp. # * https://bugzilla.mozilla.org/show_bug.cgi?id=1255766 # Also mark resizing of memory. # * https://bugzilla.mozilla.org/show_bug.cgi?id=1259403 @@ -51,5 +29,25 @@ # Patch embedded python psutil to work with FreeBSD 12 after revision 315662 # Based on: https://svnweb.freebsd.org/ports/head/sysutils/py-psutil121/files/patch-_psutil_bsd.c?revision=436575&view=markup -# Related: https://bugzilla.mozilla.org/show_bug.cgi?id=1238983 +# psutil will be upgraded in SM60: https://bugzilla.mozilla.org/show_bug.cgi?id=1436857 patch -p0 < ../FixpsutilFreeBSD.diff + +# Patch some parts of the code to support extra processor architectures +# Includes https://bugzilla.mozilla.org/show_bug.cgi?id=1143022 and https://bugzilla.mozilla.org/show_bug.cgi?id=1277742 +patch -p1 < ../FixNonx86.diff + +# Always link mozglue into the shared library when building standalone. +# Will be included in SM60. Custom version of the patch for SM45, which doesn't have the same build system. +# https://bugzilla.mozilla.org/show_bug.cgi?id=1176787 +patch -p1 < ../FixMozglueStatic.diff + +# JSPropertyDescriptor is not public in SM45. +# Will be fixed in SM52. +# https://bugzilla.mozilla.org/show_bug.cgi?id=1316079 +patch -p1 < ../ExportJSPropertyDescriptor.diff + +# When trying to link pyrogenesis, js::oom::GetThreadType() and js::ReportOutOfMemory() +# are marked as unresolved symbols. +# Will be included in SM52. +# https://bugzilla.mozilla.org/show_bug.cgi?id=1379538 +patch -p1 < ../FixLinking.diff Index: source/gui/IGUIObject.h =================================================================== --- source/gui/IGUIObject.h +++ source/gui/IGUIObject.h @@ -56,7 +56,7 @@ // Allow getProperty to access things like GetParent() friend bool JSI_IGUIObject::getProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp); - friend bool JSI_IGUIObject::setProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool UNUSED(strict), JS::MutableHandleValue vp); + friend bool JSI_IGUIObject::setProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp, JS::ObjectOpResult& result); friend bool JSI_IGUIObject::getComputedSize(JSContext* cx, uint argc, JS::Value* vp); public: Index: source/gui/IGUIObject.cpp =================================================================== --- source/gui/IGUIObject.cpp +++ source/gui/IGUIObject.cpp @@ -346,7 +346,7 @@ JS::CompileOptions options(cx); options.setFileAndLine(CodeName.c_str(), 0); - options.setCompileAndGo(true); + options.setIsRunOnce(true); JS::RootedFunction func(cx); JS::AutoObjectVector emptyScopeChain(cx); Index: source/gui/scripting/JSInterface_IGUIObject.h =================================================================== --- source/gui/scripting/JSInterface_IGUIObject.h +++ source/gui/scripting/JSInterface_IGUIObject.h @@ -25,7 +25,7 @@ extern JSClass JSI_class; extern JSFunctionSpec JSI_methods[]; bool getProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp); - bool setProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool UNUSED(strict), JS::MutableHandleValue vp); + bool setProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp, JS::ObjectOpResult& result); bool toString(JSContext* cx, uint argc, JS::Value* vp); bool focus(JSContext* cx, uint argc, JS::Value* vp); bool blur(JSContext* cx, uint argc, JS::Value* vp); Index: source/gui/scripting/JSInterface_IGUIObject.cpp =================================================================== --- source/gui/scripting/JSInterface_IGUIObject.cpp +++ source/gui/scripting/JSInterface_IGUIObject.cpp @@ -124,28 +124,28 @@ return false; } -bool JSI_IGUIObject::setProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool UNUSED(strict), JS::MutableHandleValue vp) +bool JSI_IGUIObject::setProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleValue vp, JS::ObjectOpResult& result) { IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, obj, &JSI_IGUIObject::JSI_class, NULL); if (!e) - return false; + return result.fail(JSMSG_NOT_NONNULL_OBJECT); JSAutoRequest rq(cx); JS::RootedValue idval(cx); if (!JS_IdToValue(cx, id, &idval)) - return false; + return result.fail(JSMSG_NOT_NONNULL_OBJECT); std::string propName; if (!ScriptInterface::FromJSVal(cx, idval, propName)) - return false; + return result.fail(JSMSG_UNDEFINED_PROP); if (propName == "name") { std::string value; if (!ScriptInterface::FromJSVal(cx, vp, value)) - return false; + return result.fail(JSMSG_UNDEFINED_PROP); e->SetName(value); - return true; + return result.succeed(); } JS::RootedObject vpObj(cx); @@ -158,20 +158,20 @@ if (vp.isPrimitive() || vp.isNull() || !JS_ObjectIsFunction(cx, &vp.toObject())) { JS_ReportError(cx, "on- event-handlers must be functions"); - return false; + return result.fail(JSMSG_NOT_FUNCTION); } CStr eventName(CStr(propName.substr(2)).LowerCase()); e->SetScriptHandler(eventName, vpObj); - return true; + return result.succeed(); } if (e->SettingExists(propName)) - return e->m_Settings[propName]->FromJSVal(cx, vp); + return e->m_Settings[propName]->FromJSVal(cx, vp) ? result.succeed() : result.fail(JSMSG_TYPE_ERR_BAD_ARGS); JS_ReportError(cx, "Property '%s' does not exist!", propName.c_str()); - return false; + return result.fail(JSMSG_UNDEFINED_PROP); } void JSI_IGUIObject::init(ScriptInterface& scriptInterface) Index: source/ps/ModIo.cpp =================================================================== --- source/ps/ModIo.cpp +++ source/ps/ModIo.cpp @@ -608,7 +608,8 @@ JS::RootedObject data(cx, dataVal.toObjectOrNull()); u32 length; - if (!JS_IsArrayObject(cx, data) || !JS_GetArrayLength(cx, data, &length) || !length) + bool isArray; + if (!JS_IsArrayObject(cx, data, &isArray) || !isArray || !JS_GetArrayLength(cx, data, &length) || !length) FAIL("data property not an array with at least one element."); // {"id": 42, ...} @@ -679,7 +680,8 @@ JS::RootedObject data(cx, dataVal.toObjectOrNull()); u32 length; - if (!JS_IsArrayObject(cx, data) || !JS_GetArrayLength(cx, data, &length) || !length) + bool isArray; + if (!JS_IsArrayObject(cx, data, &isArray) || !isArray || !JS_GetArrayLength(cx, data, &length) || !length) FAIL("data property not an array with at least one element."); modData.clear(); Index: source/ps/VisualReplay.cpp =================================================================== --- source/ps/VisualReplay.cpp +++ source/ps/VisualReplay.cpp @@ -86,7 +86,8 @@ if (scriptInterface.ParseJSON(cacheStr, &cachedReplays)) { cachedReplaysObject.set(&cachedReplays.toObject()); - if (JS_IsArrayObject(cx, cachedReplaysObject)) + bool isArray; + if (JS_IsArrayObject(cx, cachedReplaysObject, &isArray) && isArray) return true; } Index: source/scriptinterface/ScriptConversions.h =================================================================== --- source/scriptinterface/ScriptConversions.h +++ source/scriptinterface/ScriptConversions.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -52,8 +52,9 @@ if (!v.isObject()) FAIL("Argument must be an array"); + bool isArray; obj = &v.toObject(); - if (!(JS_IsArrayObject(cx, obj) || JS_IsTypedArrayObject(obj))) + if ((!JS_IsArrayObject(cx, obj, &isArray) || !isArray) && !JS_IsTypedArrayObject(obj)) FAIL("Argument must be an array"); u32 length; Index: source/scriptinterface/ScriptEngine.h =================================================================== --- source/scriptinterface/ScriptEngine.h +++ source/scriptinterface/ScriptEngine.h @@ -21,6 +21,8 @@ #include "ScriptTypes.h" #include "ps/Singleton.h" +#include "js/Initialization.h" + /** * A class using the RAII (Resource Acquisition Is Initialization) idiom to manage initialization * and shutdown of the SpiderMonkey script engine. It also keeps a count of active script runtimes Index: source/scriptinterface/ScriptInterface.cpp =================================================================== --- source/scriptinterface/ScriptInterface.cpp +++ source/scriptinterface/ScriptInterface.cpp @@ -352,7 +352,6 @@ JS::RuntimeOptionsRef(m_cx) .setExtraWarnings(true) .setWerror(false) - .setVarObjFix(true) .setStrictMode(true); JS::CompartmentOptions opt; @@ -523,11 +522,11 @@ } JS::RootedObject global(m->m_cx, m->m_glob); - JS::RootedObject obj(m->m_cx, JS_InitClass(m->m_cx, global, JS::NullPtr(), - clasp, - constructor, minArgs, // Constructor, min args - ps, fs, // Properties, methods - static_ps, static_fs)); // Constructor properties, methods + JS::RootedObject obj(m->m_cx, JS_InitClass(m->m_cx, global, nullptr, + clasp, + constructor, minArgs, // Constructor, min args + ps, fs, // Properties, methods + static_ps, static_fs)); // Constructor properties, methods if (obj == NULL) throw PSERROR_Scripting_DefineType_CreationFailed(); @@ -610,7 +609,7 @@ if (!JS_GetOwnPropertyDescriptor(m->m_cx, global, name, &desc)) return false; - if (desc.isReadonly()) + if (!desc.writable()) { if (!replace) { @@ -620,7 +619,7 @@ // This is not supposed to happen, unless the user has called SetProperty with constant = true on the global object // instead of using SetGlobal. - if (desc.isPermanent()) + if (!desc.configurable()) { JS_ReportError(m->m_cx, "The global \"%s\" is permanent and cannot be hotloaded", name); return false; @@ -776,8 +775,8 @@ return true; // reached the end of the prototype chain JS::RootedObject obj(m->m_cx, &objVal.toObject()); - JS::AutoIdArray props(m->m_cx, JS_Enumerate(m->m_cx, obj)); - if (!props) + JS::Rooted props(m->m_cx, JS::IdVector(m->m_cx)); + if (!JS_Enumerate(m->m_cx, obj, &props)) return false; for (size_t i = 0; i < props.length(); ++i) @@ -865,7 +864,7 @@ JS::CompileOptions options(m->m_cx); options.setFileAndLine(filenameStr.c_str(), lineNo); - options.setCompileAndGo(true); + options.setIsRunOnce(true); JS::RootedFunction func(m->m_cx); JS::AutoObjectVector emptyScopeChain(m->m_cx); @@ -874,7 +873,7 @@ return false; JS::RootedValue rval(m->m_cx); - return JS_CallFunction(m->m_cx, JS::NullPtr(), func, JS::HandleValueArray::empty(), &rval); + return JS_CallFunction(m->m_cx, nullptr, func, JS::HandleValueArray::empty(), &rval); } shared_ptr ScriptInterface::CreateRuntime(shared_ptr parentRuntime, int runtimeSize, int heapGrowthBytesGCTrigger) @@ -885,7 +884,6 @@ bool ScriptInterface::LoadGlobalScript(const VfsPath& filename, const std::wstring& code) const { JSAutoRequest rq(m->m_cx); - JS::RootedObject global(m->m_cx, m->m_glob); utf16string codeUtf16(code.begin(), code.end()); uint lineNo = 1; // CompileOptions does not copy the contents of the filename string pointer. @@ -895,14 +893,13 @@ JS::RootedValue rval(m->m_cx); JS::CompileOptions opts(m->m_cx); opts.setFileAndLine(filenameStr.c_str(), lineNo); - return JS::Evaluate(m->m_cx, global, opts, + return JS::Evaluate(m->m_cx, opts, reinterpret_cast(codeUtf16.c_str()), (uint)(codeUtf16.length()), &rval); } bool ScriptInterface::LoadGlobalScriptFile(const VfsPath& path) const { JSAutoRequest rq(m->m_cx); - JS::RootedObject global(m->m_cx, m->m_glob); if (!VfsFileExists(path)) { LOGERROR("File '%s' does not exist", path.string8()); @@ -930,7 +927,7 @@ JS::RootedValue rval(m->m_cx); JS::CompileOptions opts(m->m_cx); opts.setFileAndLine(filenameStr.c_str(), lineNo); - return JS::Evaluate(m->m_cx, global, opts, + return JS::Evaluate(m->m_cx, opts, reinterpret_cast(codeUtf16.c_str()), (uint)(codeUtf16.length()), &rval); } @@ -944,23 +941,21 @@ bool ScriptInterface::Eval_(const char* code, JS::MutableHandleValue rval) const { JSAutoRequest rq(m->m_cx); - JS::RootedObject global(m->m_cx, m->m_glob); utf16string codeUtf16(code, code+strlen(code)); JS::CompileOptions opts(m->m_cx); opts.setFileAndLine("(eval)", 1); - return JS::Evaluate(m->m_cx, global, opts, reinterpret_cast(codeUtf16.c_str()), (uint)codeUtf16.length(), rval); + return JS::Evaluate(m->m_cx, opts, reinterpret_cast(codeUtf16.c_str()), (uint)codeUtf16.length(), rval); } bool ScriptInterface::Eval_(const wchar_t* code, JS::MutableHandleValue rval) const { JSAutoRequest rq(m->m_cx); - JS::RootedObject global(m->m_cx, m->m_glob); utf16string codeUtf16(code, code+wcslen(code)); JS::CompileOptions opts(m->m_cx); opts.setFileAndLine("(eval)", 1); - return JS::Evaluate(m->m_cx, global, opts, reinterpret_cast(codeUtf16.c_str()), (uint)codeUtf16.length(), rval); + return JS::Evaluate(m->m_cx, opts, reinterpret_cast(codeUtf16.c_str()), (uint)codeUtf16.length(), rval); } bool ScriptInterface::ParseJSON(const std::string& string_utf8, JS::MutableHandleValue out) const @@ -1041,7 +1036,7 @@ JSAutoRequest rq(m->m_cx); Stringifier str; JS::RootedValue indentVal(m->m_cx, indent ? JS::Int32Value(2) : JS::UndefinedValue()); - if (!JS_Stringify(m->m_cx, obj, JS::NullPtr(), indentVal, &Stringifier::callback, &str)) + if (!JS_Stringify(m->m_cx, obj, nullptr, indentVal, &Stringifier::callback, &str)) { JS_ClearPendingException(m->m_cx); LOGERROR("StringifyJSON failed"); @@ -1069,7 +1064,7 @@ // Temporary disable the error reporter, so we don't print complaints about cyclic values JSErrorReporter er = JS_SetErrorReporter(m->m_runtime->m_rt, NULL); - bool ok = JS_Stringify(m->m_cx, obj, JS::NullPtr(), indentVal, &Stringifier::callback, &str); + bool ok = JS_Stringify(m->m_cx, obj, nullptr, indentVal, &Stringifier::callback, &str); // Restore error reporter JS_SetErrorReporter(m->m_runtime->m_rt, er); Index: source/scriptinterface/ScriptTypes.h =================================================================== --- source/scriptinterface/ScriptTypes.h +++ source/scriptinterface/ScriptTypes.h @@ -71,7 +71,7 @@ # pragma GCC diagnostic pop #endif -#if MOZJS_MAJOR_VERSION != 38 +#if MOZJS_MAJOR_VERSION != 45 #error Your compiler is trying to use an incorrect major version of the \ SpiderMonkey library. The only version that works is the one in the \ libraries/spidermonkey/ directory, and it will not work with a typical \ @@ -79,7 +79,7 @@ include paths. #endif -#if MOZJS_MINOR_VERSION != 3 +#if MOZJS_MINOR_VERSION != 0 #error Your compiler is trying to use an untested minor version of the \ SpiderMonkey library. If you are a package maintainer, please make sure \ to check very carefully that this version does not change the behaviour \ Index: source/simulation2/components/CCmpAIManager.cpp =================================================================== --- source/simulation2/components/CCmpAIManager.cpp +++ source/simulation2/components/CCmpAIManager.cpp @@ -562,8 +562,9 @@ ENSURE(JS_GetArrayLength(cx, dataObj, &length)); u32 nbytes = (u32)(length * sizeof(NavcellData)); + bool sharedMemory; JS::AutoCheckCannotGC nogc; - memcpy((void*)JS_GetUint16ArrayData(dataObj, nogc), m_PassabilityMap.m_Data, nbytes); + memcpy((void*)JS_GetUint16ArrayData(dataObj, &sharedMemory, nogc), m_PassabilityMap.m_Data, nbytes); } } @@ -591,8 +592,9 @@ ENSURE(JS_GetArrayLength(cx, dataObj, &length)); u32 nbytes = (u32)(length * sizeof(u8)); + bool sharedMemory; JS::AutoCheckCannotGC nogc; - memcpy((void*)JS_GetUint8ArrayData(dataObj, nogc), m_TerritoryMap.m_Data, nbytes); + memcpy((void*)JS_GetUint8ArrayData(dataObj, &sharedMemory, nogc), m_TerritoryMap.m_Data, nbytes); } } Index: source/simulation2/scripting/EngineScriptConversions.cpp =================================================================== --- source/simulation2/scripting/EngineScriptConversions.cpp +++ source/simulation2/scripting/EngineScriptConversions.cpp @@ -241,7 +241,8 @@ // Copy the array data and then remove the no-GC check to allow further changes to the JS data { JS::AutoCheckCannotGC nogc; - memcpy((void*)JS_GetUint8ArrayData(objArr, nogc), val.m_Data, nbytes); + bool sharedMemory; + memcpy((void*)JS_GetUint8ArrayData(objArr, &sharedMemory, nogc), val.m_Data, nbytes); } JS::RootedValue data(cx, JS::ObjectValue(*objArr)); @@ -267,7 +268,8 @@ // Copy the array data and then remove the no-GC check to allow further changes to the JS data { JS::AutoCheckCannotGC nogc; - memcpy((void*)JS_GetUint16ArrayData(objArr, nogc), val.m_Data, nbytes); + bool sharedMemory; + memcpy((void*)JS_GetUint16ArrayData(objArr, &sharedMemory, nogc), val.m_Data, nbytes); } JS::RootedValue data(cx, JS::ObjectValue(*objArr)); @@ -291,7 +293,8 @@ JSAutoRequest rq(cx); JS::RootedObject obj(cx, &v.toObject()); - if (!JS_IsArrayObject(cx, obj)) + bool isArray; + if (!JS_IsArrayObject(cx, obj, &isArray) || !isArray) FAIL("Argument must be an array"); u32 numberOfNodes = 0; Index: source/simulation2/serialization/BinarySerializer.cpp =================================================================== --- source/simulation2/serialization/BinarySerializer.cpp +++ source/simulation2/serialization/BinarySerializer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -99,7 +99,8 @@ } // Arrays are special cases of Object - if (JS_IsArrayObject(cx, obj)) + bool isArray; + if (JS_IsArrayObject(cx, obj, &isArray) && isArray) { m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_ARRAY); // TODO: probably should have a more efficient storage format @@ -119,9 +120,10 @@ m_Serializer.NumberU32_Unbounded("byte offset", JS_GetTypedArrayByteOffset(obj)); m_Serializer.NumberU32_Unbounded("length", JS_GetTypedArrayLength(obj)); + bool sharedMemory; // Now handle its array buffer // this may be a backref, since ArrayBuffers can be shared by multiple views - JS::RootedValue bufferVal(cx, JS::ObjectValue(*JS_GetArrayBufferViewBuffer(cx, obj))); + JS::RootedValue bufferVal(cx, JS::ObjectValue(*JS_GetArrayBufferViewBuffer(cx, obj, &sharedMemory))); HandleScriptVal(bufferVal); break; } @@ -136,7 +138,8 @@ u32 length = JS_GetArrayBufferByteLength(obj); m_Serializer.NumberU32_Unbounded("buffer length", length); JS::AutoCheckCannotGC nogc; - m_Serializer.RawBytes("buffer data", (const u8*)JS_GetArrayBufferData(obj, nogc), length); + bool sharedMemory; + m_Serializer.RawBytes("buffer data", (const u8*)JS_GetArrayBufferData(obj, &sharedMemory, nogc), length); break; } else @@ -145,11 +148,8 @@ const JSClass* jsclass = JS_GetClass(obj); if (!jsclass) throw PSERROR_Serialize_ScriptError("JS_GetClass failed"); -// TODO: Remove this workaround for upstream API breakage when updating SpiderMonkey -// See https://bugzilla.mozilla.org/show_bug.cgi?id=1236373 -#define JSCLASS_CACHED_PROTO_WIDTH js::JSCLASS_CACHED_PROTO_WIDTH + JSProtoKey protokey = JSCLASS_CACHED_PROTO_KEY(jsclass); -#undef JSCLASS_CACHED_PROTO_WIDTH if (protokey == JSProto_Object) { @@ -302,8 +302,8 @@ } // Find all properties (ordered by insertion time) - JS::AutoIdArray ida (cx, JS_Enumerate(cx, obj)); - if (!ida) + JS::Rooted ida(cx, JS::IdVector(cx)); + if (!JS_Enumerate(cx, obj, &ida)) throw PSERROR_Serialize_ScriptError("JS_Enumerate failed"); m_Serializer.NumberU32_Unbounded("num props", (u32)ida.length()); Index: source/simulation2/serialization/StdDeserializer.cpp =================================================================== --- source/simulation2/serialization/StdDeserializer.cpp +++ source/simulation2/serialization/StdDeserializer.cpp @@ -213,7 +213,7 @@ { std::vector propname; ReadStringLatin1("prop name", propname); - JS::RootedValue propval(cx, ReadScriptVal("prop value", JS::NullPtr())); + JS::RootedValue propval(cx, ReadScriptVal("prop value", nullptr)); utf16string prp(propname.begin(), propname.end());; // TODO: Should ask upstream about getting a variant of JS_SetProperty with a length param. @@ -224,7 +224,7 @@ { utf16string propname; ReadStringUTF16("prop name", propname); - JS::RootedValue propval(cx, ReadScriptVal("prop value", JS::NullPtr())); + JS::RootedValue propval(cx, ReadScriptVal("prop value", nullptr)); if (!JS_SetUCProperty(cx, obj, (const char16_t*)propname.data(), propname.length(), propval)) throw PSERROR_Deserialize_ScriptError(); @@ -333,7 +333,7 @@ AddScriptBackref(arrayObj); // Get buffer object - JS::RootedValue bufferVal(cx, ReadScriptVal("buffer", JS::NullPtr())); + JS::RootedValue bufferVal(cx, ReadScriptVal("buffer", nullptr)); if (!bufferVal.isObject()) throw PSERROR_Deserialize_ScriptError(); @@ -405,8 +405,8 @@ for (u32 i=0; i(text.data()), text.length())); + JS::RootedString str(cx, JS_AtomizeAndPinUCStringN(cx, reinterpret_cast(text.data()), text.length())); if (str) { ret.setString(str); @@ -421,7 +421,7 @@ if (!m_Value.empty()) { utf16string text(m_Value.begin(), m_Value.end()); - JS::RootedString str(cx, JS_InternUCStringN(cx, reinterpret_cast(text.data()), text.length())); + JS::RootedString str(cx, JS_AtomizeAndPinUCStringN(cx, reinterpret_cast(text.data()), text.length())); if (!str) { ret.setUndefined();