Index: build/premake/extern_libs5.lua =================================================================== --- build/premake/extern_libs5.lua +++ build/premake/extern_libs5.lua @@ -625,14 +625,14 @@ end else filter { "Debug", "action:vs*" } - links { "mozjs78-ps-debug" } - links { "mozjs78-ps-rust-debug" } + links { "mozjs91-ps-debug" } + links { "mozjs91-ps-rust-debug" } filter { "Debug", "action:not vs*" } - links { "mozjs78-ps-debug" } - links { "mozjs78-ps-rust" } + links { "mozjs91-ps-debug" } + links { "mozjs91-ps-rust" } filter { "Release" } - links { "mozjs78-ps-release" } - links { "mozjs78-ps-rust" } + links { "mozjs91-ps-release" } + links { "mozjs91-ps-rust" } filter { } add_source_lib_paths("spidermonkey") end Index: libraries/source/spidermonkey/FixFpNormIssue.diff =================================================================== --- /dev/null +++ libraries/source/spidermonkey/FixFpNormIssue.diff @@ -0,0 +1,110 @@ +--- a/modules/fdlibm/src/math_private.h ++++ b/modules/fdlibm/src/math_private.h +@@ -30,8 +30,13 @@ + * Adapted from https://github.com/freebsd/freebsd-src/search?q=__double_t + */ + ++#if defined __FLT_EVAL_METHOD__ && (__FLT_EVAL_METHOD__ == 2) ++typedef long double __double_t; ++#else + typedef double __double_t; ++#endif + typedef __double_t double_t; ++typedef float __float_t; + + /* + * The original fdlibm code used statements like: +@@ -630,6 +634,53 @@ + return ((double)(x + 0x1.8p52) - 0x1.8p52); + } + ++static inline float ++rnintf(__float_t x) ++{ ++ /* ++ * As for rnint(), except we could just call that to handle the ++ * extra precision case, usually without losing efficiency. ++ */ ++ return ((float)(x + 0x1.8p23F) - 0x1.8p23F); ++} ++ ++#ifdef LDBL_MANT_DIG ++/* ++ * The complications for extra precision are smaller for rnintl() since it ++ * can safely assume that the rounding precision has been increased from ++ * its default to FP_PE on x86. We don't exploit that here to get small ++ * optimizations from limiting the rangle to double. We just need it for ++ * the magic number to work with long doubles. ld128 callers should use ++ * rnint() instead of this if possible. ld80 callers should prefer ++ * rnintl() since for amd64 this avoids swapping the register set, while ++ * for i386 it makes no difference (assuming FP_PE), and for other arches ++ * it makes little difference. ++ */ ++ ++static inline long double ++rnintl(long double x) ++{ ++ /* The WRAPPED__CONCAT() macro below is required for non-FreeBSD targets ++ which don't have a multi-level CONCAT macro implementation. On those ++ targets the hexadecimal floating-point values being created don't expand ++ properly resulting in code that cannot be compiled. ++ ++ The extra level provided by this macro should not affect FreeBSD, should ++ this code be used there. ++ ++ See the following for more details: ++ ++ https://gcc.gnu.org/onlinedocs/gcc-3.0.1/cpp_3.html#SEC32 ++ https://sources.debian.org/src/glibc/2.32-3/misc/sys/cdefs.h/ ++ https://github.com/freebsd/freebsd-src/blob/main/sys/sys/cdefs.h ++ */ ++ #define WRAPPED__CONCAT(x,y) __CONCAT(x,y) ++ ++ return (x + WRAPPED__CONCAT(0x1.8p, LDBL_MANT_DIG) / 2 - ++ WRAPPED__CONCAT(0x1.8p, LDBL_MANT_DIG) / 2); ++} ++#endif /* LDBL_MANT_DIG */ ++ + /* + * irint() and i64rint() give the same result as casting to their integer + * return type provided their arg is a floating point integer. They can +@@ -646,6 +697,39 @@ + #define irint(x) ((int)(x)) + #endif + ++#define i64rint(x) ((int64_t)(x)) /* only needed for ld128 so not opt. */ ++ ++#if defined(__i386__) && defined(__GNUCLIKE_ASM) ++static __inline int ++irintf(float x) ++{ ++ int n; ++ ++ __asm("fistl %0" : "=m" (n) : "t" (x)); ++ return (n); ++} ++ ++static __inline int ++irintd(double x) ++{ ++ int n; ++ ++ __asm("fistl %0" : "=m" (n) : "t" (x)); ++ return (n); ++} ++#endif ++ ++#if (defined(__amd64__) || defined(__i386__)) && defined(__GNUCLIKE_ASM) ++static __inline int ++irintl(long double x) ++{ ++ int n; ++ ++ __asm("fistl %0" : "=m" (n) : "t" (x)); ++ return (n); ++} ++#endif ++ + #ifdef DEBUG + #if defined(__amd64__) || defined(__i386__) + #define breakpoint() asm("int $3") Index: libraries/source/spidermonkey/FixMozglue.diff =================================================================== --- libraries/source/spidermonkey/FixMozglue.diff +++ libraries/source/spidermonkey/FixMozglue.diff @@ -1,47 +1,16 @@ -diff --git a/js/src/build/moz.build b/js/src/build/moz.build -index b311e9549fed..55f26497ec8d 100644 ---- a/js/src/build/moz.build -+++ b/js/src/build/moz.build -@@ -10,9 +10,7 @@ CONFIGURE_SUBST_FILES += [ - ] - - LIBRARY_DEFINES['EXPORT_JS_API'] = True -- --if not CONFIG['JS_STANDALONE']: -- LIBRARY_DEFINES['MOZ_HAS_MOZGLUE'] = True -+LIBRARY_DEFINES['MOZ_HAS_MOZGLUE'] = True - - # JavaScript must be built shared, even for static builds, as it is used by - # other modules which are always built shared. Failure to do so results in -diff --git a/mozglue/build/moz.build b/mozglue/build/moz.build -index ab0cff86fafc..d8bcead49deb 100644 ---- a/mozglue/build/moz.build -+++ b/mozglue/build/moz.build -@@ -9,6 +9,7 @@ - # If this is ever changed, update MOZ_SHARED_MOZGLUE in browser/installer/Makefile.in - if CONFIG['JS_STANDALONE'] and not CONFIG['MOZ_MEMORY']: - Library('mozglue') -+ FINAL_LIBRARY = 'js' - elif CONFIG['OS_TARGET'] in ('WINNT', 'Darwin', 'Android'): - SharedLibrary('mozglue') - else: -diff --git a/config/makefiles/target_binaries.mk b/config/makefiles/target_binaries.mk -index 31b2c4367e94..a7f9037dfd54 100644 -diff --git a/js/src/moz.build b/js/src/moz.build -index 9c2ab1e1ac18..7444259bca6a 100755 --- a/js/src/moz.build +++ b/js/src/moz.build -@@ -50,7 +50,12 @@ with Files('builtin/intl/*'): - if CONFIG['ENABLE_WASM_CRANELIFT']: - CONFIGURE_SUBST_FILES += ['rust/extra-bindgen-flags'] +@@ -50,9 +50,12 @@ + if CONFIG["ENABLE_WASM_CRANELIFT"]: + CONFIGURE_SUBST_FILES += ["rust/extra-bindgen-flags"] --if not CONFIG['JS_DISABLE_SHELL']: -+if CONFIG['JS_STANDALONE'] and CONFIG['JS_DISABLE_SHELL']: -+ DIRS += [ -+ 'rust', -+ ] ++DIRS += [ ++ "rust" ++] + -+elif not CONFIG['JS_DISABLE_SHELL']: + if not CONFIG["JS_DISABLE_SHELL"]: DIRS += [ - 'rust', - 'shell', +- "rust", + "shell", + ] + Index: libraries/source/spidermonkey/FixRustLinkage.diff =================================================================== --- /dev/null +++ libraries/source/spidermonkey/FixRustLinkage.diff @@ -0,0 +1,16 @@ +--- a/js/src/moz.build ++++ b/js/src/moz.build +@@ -50,9 +50,12 @@ + if CONFIG["ENABLE_WASM_CRANELIFT"]: + CONFIGURE_SUBST_FILES += ["rust/extra-bindgen-flags"] + ++DIRS += [ ++ "rust" ++] ++ + if not CONFIG["JS_DISABLE_SHELL"]: + DIRS += [ +- "rust", + "shell", + ] + Index: libraries/source/spidermonkey/FixWindowsDLL.diff =================================================================== --- /dev/null +++ libraries/source/spidermonkey/FixWindowsDLL.diff @@ -0,0 +1,11 @@ +--- a/mozglue/moz.build ++++ b/mozglue/moz.build +@@ -13,7 +13,7 @@ + if CONFIG["MOZ_WIDGET_TOOLKIT"] == "android": + DIRS += ["android"] + +-if CONFIG["OS_TARGET"] == "WINNT": ++if CONFIG["OS_TARGET"] == "WINNT" and not CONFIG["JS_STANDALONE"]: + DIRS += ["dllservices"] + + DIRS += [ Index: libraries/source/spidermonkey/FixWindowsLibNames.diff =================================================================== --- /dev/null +++ libraries/source/spidermonkey/FixWindowsLibNames.diff @@ -0,0 +1,16 @@ +--- a/js/src/old-configure ++++ b/js/src/old-configure +@@ -7035,10 +7035,10 @@ + + + +-if test -n "$JS_STANDALONE"; then +-JS_LIBRARY_NAME="mozjs-$MOZILLA_SYMBOLVERSION" ++if test -n "$MOZ_DEBUG"; then ++JS_LIBRARY_NAME="mozjs$MOZILLA_SYMBOLVERSION-ps-debug" + else +-JS_LIBRARY_NAME="mozjs" ++JS_LIBRARY_NAME="mozjs$MOZILLA_SYMBOLVERSION-ps-release" + fi + JS_CONFIG_LIBS="$NSPR_LIBS $LIBS" + if test -n "$GNU_CC"; then Index: libraries/source/spidermonkey/README.txt =================================================================== --- libraries/source/spidermonkey/README.txt +++ libraries/source/spidermonkey/README.txt @@ -28,16 +28,20 @@ We provide precompiled binaries for Windows. If you still need to build on Windows, here's a short guide. -The basic idea is to follow the instructions to build Firefox: -https://firefox-source-docs.mozilla.org/setup/windows_build.html#mozillabuild -And after running "mach boostrap", run ./build.sh +In the Visual Studio Installer: +- Install Clang, Clang-CL -The customised option (which I used): -- Install mozilla-build per the instructions above -- Install rust (make sure to add it to your PATH) -- Open Powershell and run "rustup install i686-pc-windows-msvc" and "rustup install x86_64-pc-windows-msvc" -- Install LLVM 8 prebuilt binaries from https://releases.llvm.org somewhere. -- From powershell, run ". C:/mozilla-build/start-shell.bat", cd to 0ad/libraries/source/spidermonkey and then run "./build.sh" -- This will fail. Edit build.sh to not rebuild (REBUILD=false) -- Edit the build/moz.configure/toolchain.configure file to have your LLVM/bin folder in the `toolchain_search_path`. I added the path directly to the bootstrapped variable L721 -- Rerun build.sh. It should run. +Install Rust from the official website. + +Download & install Mozilla Build from [here](https://ftp.mozilla.org/pub/mozilla/libraries/win32/MozillaBuildSetup-Latest.exe). +In Mozilla build run: +rustup target add i686-pc-windows-msvc +rustup target add x86_64-pc-windows-msvc + +From powershell, run the following commands. +They will start a mozbuild shell, setup LLVM_LOCATION (may vary), +then run the build. +. C:/mozilla-build/start-shell.bat +LLVM_LOCATION="/c/PROGRA~1/MICROS~1/2017/Community/VC/Tools/Llvm/x64/bin/" +export PATH="$PATH:$LLVM_LOCATION" +cd "/libraries/source/spidermonkey" &&".\build.sh" Index: libraries/source/spidermonkey/build.sh =================================================================== --- libraries/source/spidermonkey/build.sh +++ libraries/source/spidermonkey/build.sh @@ -3,10 +3,10 @@ set -e # This should match the version in config/milestone.txt -FOLDER="mozjs-78.6.0" +FOLDER="mozjs-91.5.0" # If same-version changes are needed, increment this. -LIB_VERSION="78.6.0+3" -LIB_NAME="mozjs78-ps" +LIB_VERSION="91.5.0+0" +LIB_NAME="mozjs91-ps" # Since this script is called by update-workspaces.sh, we want to quickly # avoid doing any work if SpiderMonkey is already built and up-to-date. @@ -33,6 +33,7 @@ # Standalone SpiderMonkey can not use jemalloc (see https://bugzilla.mozilla.org/show_bug.cgi?id=1465038) # Jitspew doesn't compile on VS17 in the zydis disassembler - since we don't use it, deactivate it. +# Trace-logging doesn't compile for now. CONF_OPTS="--disable-tests --disable-jemalloc --disable-js-shell @@ -40,6 +41,14 @@ --enable-shared-js --disable-jitspew" +if [ -n "$PROFILE" ]; then + CONF_OPTS="$CONF_OPTS --enable-profiling + --enable-perf + --enable-instruments + --enable-jitspew + --with-jitreport-granularity=3" +fi + if [ "${OS}" = "Windows_NT" ] then CONF_OPTS="${CONF_OPTS} --with-visual-studio-version=2017 --target=i686" @@ -95,13 +104,13 @@ then # Delete the existing directory to avoid conflicts and extract the tarball rm -rf "$FOLDER" - if [ ! -e "${FOLDER}.tar.bz2" ]; + if [ ! -e "${FOLDER}.tar.xz" ]; then # The tarball is committed to svn, but it's useful to let jenkins download it (when testing upgrade scripts). - download="$(command -v wget || echo "curl -L -o "${FOLDER}.tar.bz2"")" - $download "https://github.com/wraitii/spidermonkey-tarballs/releases/download/v78.6.0/${FOLDER}.tar.bz2" + download="$(command -v wget || echo "curl -L -o "${FOLDER}.tar.xz"")" + $download "https://github.com/wraitii/spidermonkey-tarballs/releases/download/${FOLDER}/${FOLDER}.tar.xz" fi - tar xjf "${FOLDER}.tar.bz2" + tar xfJ "${FOLDER}.tar.xz" # Clean up header files that may be left over by earlier versions of SpiderMonkey rm -rf include-unix-debug @@ -110,8 +119,6 @@ # Apply patches cd "$FOLDER" . ../patch.sh - # Copy a more recent autoconf config.guess to handle ARM macs properly. - cp -f ../config.guess build/autoconf/ # Prevent complaining that configure is outdated. touch ./js/src/configure else @@ -122,10 +129,8 @@ if [ "$(uname -s)" != "FreeBSD" ]; then mkdir -p build-debug cd build-debug - # SM configure checks for autoconf, but we don't actually need it. - # To avoid a dependency, pass something arbitrary (it does need to be an actual program). # llvm-objdump is searched for with the complete name, not simply 'objdump', account for that. - CXXFLAGS="${CXXFLAGS}" ../js/src/configure AUTOCONF="ls" \ + CXXFLAGS="${CXXFLAGS}" ../js/src/configure \ LLVM_OBJDUMP="${LLVM_OBJDUMP}" \ ${CONF_OPTS} \ --enable-debug \ @@ -137,7 +142,7 @@ mkdir -p build-release cd build-release -CXXFLAGS="${CXXFLAGS}" ../js/src/configure AUTOCONF="ls" \ +CXXFLAGS="${CXXFLAGS}" ../js/src/configure \ LLVM_OBJDUMP="${LLVM_OBJDUMP}" \ ${CONF_OPTS} \ --enable-optimize Index: libraries/source/spidermonkey/patch.sh =================================================================== --- libraries/source/spidermonkey/patch.sh +++ libraries/source/spidermonkey/patch.sh @@ -1,73 +1,25 @@ #!/bin/sh +set -ev + # Apply patches if needed # This script gets called from build.sh. -# SM78 fails to create virtual envs on macs with python > 3.7 -# Unfortunately, 3.7 is mostly unavailable on ARM macs. -# Therefore, replace the custom script with a more up-to-date version from pip -# if python is detected to be newer than 3.7. -if [ "$(uname -s)" = "Darwin" ]; -then - PYTHON_MINOR_VERSION="$(python3 -c 'import sys; print(sys.version_info.minor)')" - if [ "$PYTHON_MINOR_VERSION" -gt 7 ]; - then - # SM actually uses features from the full-fledged virtualenv package - # and not just venv, so install it to be safe. - # Install it locally to not pollute anything. - pip3 install --upgrade -t virtualenv virtualenv - export PYTHONPATH="$(pwd)/virtualenv:$PYTHONPATH" - patch -p1 < ../FixVirtualEnv.diff - fi -fi - -# Mozglue symbols need to be linked against static builds. +# The rust code is only linked if the JS Shell is enabled, +# which fails now that rust is required in all cases. # https://bugzilla.mozilla.org/show_bug.cgi?id=1588340 -patch -p1 < ../FixMozglue.diff +patch -p1 < ../FixRustLinkage.diff -# Update library names to have separate debug/release libraries. -patch -p1 < ../RenameLibs.diff +# dllservices is not needed in JS Standalone, but is linked, +# and the files aren't bundled so this fails. +# https://bugzilla.mozilla.org/show_bug.cgi?id=1749306 +patch -p1 < ../FixWindowsDLL.diff -# Fix ~SharedArrayRawBufferRefs symbol not found. -# See https://bugzilla.mozilla.org/show_bug.cgi?id=1644600 -# Many thanks to bellaz89 for finding this and reporting it -patch -p1 < ../FixSharedArray.diff +# On windows, we need to differente debug/release library names. +patch -p1 < ../FixWindowsLibNames.diff -# Fix public export on MSVC (C2487) -# https://bugzilla.mozilla.org/show_bug.cgi?id=1614243 -# (mentionned in the comments, no patch/commit found) -patch -p1 < ../FixPublicExport.diff +# There is an issue on 32-bit linux builds sometimes. +# NB: the patch here is Comment 21 modified by Comment 25 +# but that seems to imperfectly fix the issue with GCC. +# https://bugzilla.mozilla.org/show_bug.cgi?id=1729459 +patch -p1 < ../FixFpNormIssue.diff -# Fix Rooted not working on VS17 -# https://bugzilla.mozilla.org/show_bug.cgi?id=1679736 -# (Landed in 85) -patch -p1 < ../FixMSVCRootedVoid.diff - -# Two SDK-related issues. -# -ftrivial-auto-var-init is clang 8, -# but apple-clang 10.0.0 (the maximum in 10.13) -# doesn't actually have it, so patch it out. -# Secondly, there is a 'max SDK version' in SM, -# which is set to 10.15.4 in SM78. -# Upstream has changed this to 10.11 at the moment, -# so this patches it to an arbitrarily high Mac OS 11 -patch -p1 < ../FixMacBuild.diff - -# Fix FP access breaking compilation on RPI3+ -# https://bugzilla.mozilla.org/show_bug.cgi?id=1526653 -# https://bugzilla.mozilla.org/show_bug.cgi?id=1536491 -patch -p1 < ../FixRpiUnalignedFpAccess.diff - -# Bug 1684261 upstreamed from 78.8: https://hg.mozilla.org/releases/mozilla-esr78/rev/0e8f444683cb -# Note that this isn't quite the upstream patch to match our version. -patch -p1 < ../FixRust150.diff - -# Patch those separately, as they might interfere with normal behaviour. -if [ "$(uname -s)" = "FreeBSD" ]; -then - # https://svnweb.freebsd.org/ports/head/lang/spidermonkey78/files/patch-js_moz.configure?view=log - patch -p1 < ../FixFreeBSDReadlineDetection.diff - # https://svnweb.freebsd.org/ports/head/lang/spidermonkey78/files/patch-third__party_rust_cc_.cargo-checksum.json?view=log - patch -p1 < ../FixFreeBSDCargoChecksum.diff - # https://svnweb.freebsd.org/ports/head/lang/spidermonkey78/files/patch-third__party_rust_cc_src_lib.rs?view=log - patch -p1 < ../FixFreeBSDRustThirdPartyOSDetection.diff -fi Index: source/gui/Scripting/JSInterface_GUIProxy.h =================================================================== --- source/gui/Scripting/JSInterface_GUIProxy.h +++ source/gui/Scripting/JSInterface_GUIProxy.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -170,13 +170,13 @@ // The JS code will see undefined when querying a property descriptor. virtual bool getOwnPropertyDescriptor(JSContext* UNUSED(cx), JS::HandleObject UNUSED(proxy), JS::HandleId UNUSED(id), - JS::MutableHandle UNUSED(desc)) const override + JS::MutableHandle> desc) const override { return true; } // Throw an exception is JS code attempts defining a property. virtual bool defineProperty(JSContext* UNUSED(cx), JS::HandleObject UNUSED(proxy), JS::HandleId UNUSED(id), - JS::Handle UNUSED(desc), JS::ObjectOpResult& UNUSED(result)) const override + JS::Handle UNUSED(desc), JS::ObjectOpResult& UNUSED(result)) const override { return false; } Index: source/gui/Scripting/JSInterface_GUIProxy_impl.h =================================================================== --- source/gui/Scripting/JSInterface_GUIProxy_impl.h +++ source/gui/Scripting/JSInterface_GUIProxy_impl.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -88,7 +88,7 @@ { if (!obj) return nullptr; - if (JS_GetClass(obj) != &JSInterface_GUIProxy::ClassDefinition()) + if (JS::GetClass(obj) != &JSInterface_GUIProxy::ClassDefinition()) return nullptr; return UnsafeFromPrivateSlot(obj); } Index: source/scriptinterface/ScriptContext.cpp =================================================================== --- source/scriptinterface/ScriptContext.cpp +++ source/scriptinterface/ScriptContext.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -107,7 +107,8 @@ JS::SetGCSliceCallback(m_cx, GCSliceCallbackHook); JS_SetGCParameter(m_cx, JSGC_MAX_BYTES, m_ContextSize); - JS_SetGCParameter(m_cx, JSGC_MODE, JSGC_MODE_INCREMENTAL); + JS_SetGCParameter(m_cx, JSGC_INCREMENTAL_GC_ENABLED, true); + JS_SetGCParameter(m_cx, JSGC_PER_ZONE_GC_ENABLED, false); JS_SetOffthreadIonCompilationEnabled(m_cx, true); @@ -143,7 +144,7 @@ // Schedule the zone for GC, which will destroy the realm. if (JS::IsIncrementalGCInProgress(m_cx)) JS::FinishIncrementalGC(m_cx, JS::GCReason::API); - JS::PrepareZoneForGC(js::GetRealmZone(realm)); + JS::PrepareZoneForGC(m_cx, js::GetRealmZone(realm)); m_Realms.remove(realm); } @@ -241,7 +242,7 @@ #endif PrepareZonesForIncrementalGC(); if (!JS::IsIncrementalGCInProgress(m_cx)) - JS::StartIncrementalGC(m_cx, GC_NORMAL, JS::GCReason::API, GCSliceTimeBudget); + JS::StartIncrementalGC(m_cx, JS::GCOptions::Normal, JS::GCReason::API, GCSliceTimeBudget); else JS::IncrementalGCSlice(m_cx, JS::GCReason::API, GCSliceTimeBudget); } @@ -252,14 +253,16 @@ void ScriptContext::ShrinkingGC() { - JS_SetGCParameter(m_cx, JSGC_MODE, JSGC_MODE_ZONE); + JS_SetGCParameter(m_cx, JSGC_INCREMENTAL_GC_ENABLED, false); + JS_SetGCParameter(m_cx, JSGC_PER_ZONE_GC_ENABLED, true); JS::PrepareForFullGC(m_cx); - JS::NonIncrementalGC(m_cx, GC_SHRINK, JS::GCReason::API); - JS_SetGCParameter(m_cx, JSGC_MODE, JSGC_MODE_INCREMENTAL); + JS::NonIncrementalGC(m_cx, JS::GCOptions::Shrink, JS::GCReason::API); + JS_SetGCParameter(m_cx, JSGC_INCREMENTAL_GC_ENABLED, true); + JS_SetGCParameter(m_cx, JSGC_PER_ZONE_GC_ENABLED, false); } void ScriptContext::PrepareZonesForIncrementalGC() const { for (JS::Realm* const& realm : m_Realms) - JS::PrepareZoneForGC(js::GetRealmZone(realm)); + JS::PrepareZoneForGC(m_cx, js::GetRealmZone(realm)); } Index: source/scriptinterface/ScriptConversions.cpp =================================================================== --- source/scriptinterface/ScriptConversions.cpp +++ source/scriptinterface/ScriptConversions.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -105,7 +105,7 @@ if (!str) FAIL("Argument must be convertible to a string"); - if (JS_StringHasLatin1Chars(str)) + if (JS::StringHasLatin1Chars(str)) { size_t length; JS::AutoCheckCannotGC nogc; Index: source/scriptinterface/ScriptExtraHeaders.h =================================================================== --- source/scriptinterface/ScriptExtraHeaders.h +++ source/scriptinterface/ScriptExtraHeaders.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -60,6 +60,10 @@ #include "js/Proxy.h" #include "js/Warnings.h" +#include "js/experimental/TypedData.h" + +#include "js/friend/ErrorMessages.h" + #undef signbit #if MSC_VERSION Index: source/scriptinterface/ScriptInterface.cpp =================================================================== --- source/scriptinterface/ScriptInterface.cpp +++ source/scriptinterface/ScriptInterface.cpp @@ -508,11 +508,11 @@ return false; if (found) { - JS::Rooted desc(rq.cx); - if (!JS_GetOwnPropertyDescriptor(rq.cx, global, name, &desc)) + JS::Rooted> desc(rq.cx); + if (!JS_GetOwnPropertyDescriptor(rq.cx, global, name, &desc) || !desc.isSome()) return false; - if (!desc.writable()) + if (!desc->writable()) { if (!replace) { @@ -522,7 +522,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.configurable()) + if (!desc->configurable()) { ScriptException::Raise(rq, "The global \"%s\" is permanent and cannot be hotloaded", name); return false; Index: source/scriptinterface/ScriptTypes.h =================================================================== --- source/scriptinterface/ScriptTypes.h +++ source/scriptinterface/ScriptTypes.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -73,7 +73,7 @@ # pragma GCC diagnostic pop #endif -#if MOZJS_MAJOR_VERSION != 78 +#if MOZJS_MAJOR_VERSION != 91 #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 \ @@ -81,7 +81,7 @@ include paths. #endif -#if MOZJS_MINOR_VERSION != 6 +#if MOZJS_MINOR_VERSION != 5 #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/scripting/EngineScriptConversions.cpp =================================================================== --- source/simulation2/scripting/EngineScriptConversions.cpp +++ source/simulation2/scripting/EngineScriptConversions.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -62,7 +62,7 @@ return; } - JS_SetPrivate(obj, static_cast(val)); + JS::SetPrivate(obj, static_cast(val)); ret.setObject(*obj); } Index: source/simulation2/serialization/BinarySerializer.cpp =================================================================== --- source/simulation2/serialization/BinarySerializer.cpp +++ source/simulation2/serialization/BinarySerializer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -219,9 +219,9 @@ else { // Find type of object - const JSClass* jsclass = JS_GetClass(obj); + const JSClass* jsclass = JS::GetClass(obj); if (!jsclass) - throw PSERROR_Serialize_ScriptError("JS_GetClass failed"); + throw PSERROR_Serialize_ScriptError("JS::GetClass failed"); JSProtoKey protokey = JSCLASS_CACHED_PROTO_KEY(jsclass); @@ -321,10 +321,11 @@ JS::RootedValue propval(rq.cx); // Forbid getters, which might delete values and mess things up. - JS::Rooted desc(rq.cx); - if (!JS_GetPropertyDescriptorById(rq.cx, obj, id, &desc)) + JS::Rooted> desc(rq.cx); + JS::RootedObject holder(rq.cx); + if (!JS_GetPropertyDescriptorById(rq.cx, obj, id, &desc, &holder)) throw PSERROR_Serialize_ScriptError("JS_GetPropertyDescriptorById failed"); - if (desc.hasGetterObject()) + if (desc.isSome() && desc->hasGetter()) throw PSERROR_Serialize_ScriptError("Cannot serialize property getters"); // Get the property name as a string @@ -354,7 +355,7 @@ JS::RootedString string(rq.cx, JS_GetFunctionId(func)); if (string) { - if (JS_StringHasLatin1Chars(string)) + if (JS::StringHasLatin1Chars(string)) { size_t length; JS::AutoCheckCannotGC nogc; @@ -440,7 +441,7 @@ size_t length; JS::AutoCheckCannotGC nogc; // Serialize strings directly as UTF-16 or Latin1, to avoid expensive encoding conversions - bool isLatin1 = JS_StringHasLatin1Chars(string); + bool isLatin1 = JS::StringHasLatin1Chars(string); m_Serializer.Bool("isLatin1", isLatin1); if (isLatin1) { Index: source/simulation2/serialization/StdDeserializer.cpp =================================================================== --- source/simulation2/serialization/StdDeserializer.cpp +++ source/simulation2/serialization/StdDeserializer.cpp @@ -282,7 +282,7 @@ JS::RootedObject obj(rq.cx); if (!JS::Construct(rq.cx, protoval, JS::HandleValueArray(val), &obj)) - throw PSERROR_Deserialize_ScriptError("JS_New failed"); + throw PSERROR_Deserialize_ScriptError("JS::Construct failed"); AddScriptBackref(obj); return JS::ObjectValue(*obj); } @@ -301,7 +301,7 @@ JS::RootedObject obj(rq.cx); if (!JS::Construct(rq.cx, protoval, JS::HandleValueArray(val), &obj)) - throw PSERROR_Deserialize_ScriptError("JS_New failed"); + throw PSERROR_Deserialize_ScriptError("JS::Construct failed"); AddScriptBackref(obj); return JS::ObjectValue(*obj); } @@ -318,7 +318,7 @@ JS::RootedObject obj(rq.cx); if (!JS::Construct(rq.cx, protoval, JS::HandleValueArray(val), &obj)) - throw PSERROR_Deserialize_ScriptError("JS_New failed"); + throw PSERROR_Deserialize_ScriptError("JS::Construct failed"); AddScriptBackref(obj); return JS::ObjectValue(*obj); }