Index: build/premake/extern_libs5.lua =================================================================== --- build/premake/extern_libs5.lua +++ build/premake/extern_libs5.lua @@ -626,7 +626,7 @@ compile_settings = function() if _OPTIONS["with-system-mozjs"] then if not _OPTIONS["android"] then - pkgconfig.add_includes("mozjs-91") + pkgconfig.add_includes("mozjs-102") end else if os.istarget("windows") then @@ -653,20 +653,20 @@ link_settings = function() if _OPTIONS["with-system-mozjs"] then if _OPTIONS["android"] then - links { "mozjs-91" } + links { "mozjs-102" } else - pkgconfig.add_links("mozjs-91") + pkgconfig.add_links("mozjs-102") end else filter { "Debug", "action:vs*" } - links { "mozjs91-ps-debug" } - links { "mozjs91-ps-rust-debug" } + links { "mozjs102-ps-debug" } + links { "mozjs102-ps-rust-debug" } filter { "Debug", "action:not vs*" } - links { "mozjs91-ps-debug" } - links { "mozjs91-ps-rust" } + links { "mozjs102-ps-debug" } + links { "mozjs102-ps-rust" } filter { "Release" } - links { "mozjs91-ps-release" } - links { "mozjs91-ps-rust" } + links { "mozjs102-ps-release" } + links { "mozjs102-ps-rust" } filter { } add_source_lib_paths("spidermonkey") end 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-91.13.1" +FOLDER="mozjs-102.12.0" # If same-version changes are needed, increment this. -LIB_VERSION="91.13.1+1" -LIB_NAME="mozjs91-ps" +LIB_VERSION="102.12.0+0" +LIB_NAME="mozjs102-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. Index: libraries/source/spidermonkey/patch.sh =================================================================== --- libraries/source/spidermonkey/patch.sh +++ libraries/source/spidermonkey/patch.sh @@ -23,16 +23,6 @@ patch -p1 < ../FixFpNormIssue.diff fi -if [ "$OS" = "Darwin" ] -then - # The bundled virtualenv version is not working on MacOS - # with recent homebrew and needs to be upgraded. - # Install it locally to not pollute anything. - pip3 install --upgrade -t virtualenv virtualenv - export PYTHONPATH="$(pwd)/virtualenv:$PYTHONPATH" - patch -p1 < ../FixVirtualEnv.diff -fi - if [ "$OS" = "Linux" ] then # Use sysconfig instead of distutils with the bundled virtualenv @@ -46,10 +36,3 @@ # This will prevent bug 1739486 from happening on Fedora patch -p1 < ../FixFedoraVirtualEnv.diff fi - -# Python >= 3.11 support -PYTHON_MINOR_VERSION="$(python3 -c 'import sys; print(sys.version_info.minor)')" -if [ "$PYTHON_MINOR_VERSION" -ge 11 ]; -then - patch -p1 < ../FixUnicodePython311.diff -fi Index: source/gui/Scripting/JSInterface_GUISize.cpp =================================================================== --- source/gui/Scripting/JSInterface_GUISize.cpp +++ source/gui/Scripting/JSInterface_GUISize.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2023 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -30,7 +30,7 @@ JSClassOps JSI_GUISize::JSI_classops = { nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, JSI_GUISize::construct, nullptr }; Index: source/ps/XMB/XMBStorage.cpp =================================================================== --- source/ps/XMB/XMBStorage.cpp +++ source/ps/XMB/XMBStorage.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 Wildfire Games. +/* Copyright (C) 2023 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -293,11 +293,6 @@ switch (JS_TypeOfValue(rq.cx, value)) { case JSTYPE_UNDEFINED: - case JSTYPE_NULL: - { - writeBuffer.Append("\0\0\0\0", 4); - break; - } case JSTYPE_OBJECT: { if (!Script::HasProperty(rq, value, "_string")) Index: source/ps/scripting/JSInterface_VFS.cpp =================================================================== --- source/ps/scripting/JSInterface_VFS.cpp +++ source/ps/scripting/JSInterface_VFS.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 Wildfire Games. +/* Copyright (C) 2023 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -82,7 +82,7 @@ filename_array(rq.cx), cur_idx(0) { - filename_array = JS::NewArrayObject(rq.cx, JS::HandleValueArray::empty()); + filename_array = JS::NewArrayObject(rq.cx, 0); } }; Index: source/scriptinterface/Object.h =================================================================== --- source/scriptinterface/Object.h +++ source/scriptinterface/Object.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2023 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -41,7 +41,7 @@ JS::RootedObject object(rq.cx, &obj.toObject()); if constexpr (std::is_same_v) { - JS::RootedId id(rq.cx, INT_TO_JSID(name)); + JS::RootedId id(rq.cx, JS::PropertyKey::Int(name)); return JS_GetPropertyById(rq.cx, object, id, out); } else if constexpr (std::is_same_v) @@ -108,7 +108,7 @@ JS::RootedObject object(rq.cx, &obj.toObject()); if constexpr (std::is_same_v) { - JS::RootedId id(rq.cx, INT_TO_JSID(name)); + JS::RootedId id(rq.cx, JS::PropertyKey::Int(name)); return JS_DefinePropertyById(rq.cx, object, id, value, attrs); } else if constexpr (std::is_same_v) @@ -157,7 +157,7 @@ JS::RootedObject obj(rq.cx, &objVal.toObject()); - if (deep) + if (deep && false) // TODO: figure out why deep freezing bugs out. return JS_DeepFreezeObject(rq.cx, obj); else return JS_FreezeObject(rq.cx, obj); Index: source/scriptinterface/ScriptContext.cpp =================================================================== --- source/scriptinterface/ScriptContext.cpp +++ source/scriptinterface/ScriptContext.cpp @@ -161,7 +161,7 @@ // The sweeping actually frees memory and it does this in a background thread (if JS_USE_HELPER_THREADS is set). // While the sweeping is happening we already run scripts again and produce new garbage. - const int GCSliceTimeBudget = 30; // Milliseconds an incremental slice is allowed to run + const js::SliceBudget GCSliceTimeBudget = js::SliceBudget(js::TimeBudget(30)); // Milliseconds an incremental slice is allowed to run // Have a minimum time in seconds to wait between GC slices and before starting a new GC to distribute the GC // load and to hopefully make it unnoticeable for the player. This value should be high enough to distribute Index: source/scriptinterface/ScriptInterface.h =================================================================== --- source/scriptinterface/ScriptInterface.h +++ source/scriptinterface/ScriptInterface.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 Wildfire Games. +/* Copyright (C) 2023 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -227,7 +227,7 @@ template static T* GetPrivate(const ScriptRequest& rq, JS::HandleObject thisobj, JSClass* jsClass) { - T* value = static_cast(JS_GetInstancePrivate(rq.cx, thisobj, jsClass, nullptr)); + T* value = static_cast(JS::GetReservedSlot(thisobj, 0)); if (value == nullptr) ScriptException::Raise(rq, "Private data of the given object is null!"); @@ -249,7 +249,7 @@ } JS::RootedObject thisObj(rq.cx, &callArgs.thisv().toObject()); - T* value = static_cast(JS_GetInstancePrivate(rq.cx, thisObj, jsClass, &callArgs)); + T* value = JS::GetMaybePtrFromReservedSlot(thisObj, 0); if (value == nullptr) ScriptException::Raise(rq, "Private data of the given object is null!"); Index: source/scriptinterface/ScriptInterface.cpp =================================================================== --- source/scriptinterface/ScriptInterface.cpp +++ source/scriptinterface/ScriptInterface.cpp @@ -106,7 +106,7 @@ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, nullptr, nullptr, + nullptr, nullptr, JS_GlobalObjectTraceHook }; Index: source/scriptinterface/ScriptTypes.h =================================================================== --- source/scriptinterface/ScriptTypes.h +++ source/scriptinterface/ScriptTypes.h @@ -21,6 +21,10 @@ #define JSGC_GENERATIONAL 1 #define JSGC_USE_EXACT_ROOTING 1 +#ifdef DEBUG +#define MOZ_DIAGNOSTIC_ASSERT_ENABLED +#endif + #ifdef _WIN32 # define XP_WIN # ifndef WIN32 @@ -73,7 +77,7 @@ # pragma GCC diagnostic pop #endif -#if MOZJS_MAJOR_VERSION != 91 +#if MOZJS_MAJOR_VERSION != 102 #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 +85,7 @@ include paths. #endif -#if MOZJS_MINOR_VERSION != 13 +#if MOZJS_MINOR_VERSION != 12 #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 @@ -62,7 +62,7 @@ return; } - JS::SetPrivate(obj, static_cast(val)); + JS::SetReservedSlot(obj, 0, JS::PrivateValue(val)); ret.setObject(*obj); } Index: source/simulation2/serialization/BinarySerializer.cpp =================================================================== --- source/simulation2/serialization/BinarySerializer.cpp +++ source/simulation2/serialization/BinarySerializer.cpp @@ -81,11 +81,6 @@ m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_VOID); break; } - case JSTYPE_NULL: // This type is never actually returned (it's a JS2 feature) - { - m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_NULL); - break; - } case JSTYPE_OBJECT: { if (val.isNull()) Index: source/simulation2/system/InterfaceScripted.h =================================================================== --- source/simulation2/system/InterfaceScripted.h +++ source/simulation2/system/InterfaceScripted.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2023 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ #define BEGIN_INTERFACE_WRAPPER(iname) \ JSClass class_ICmp##iname = { \ - "ICmp" #iname, JSCLASS_HAS_PRIVATE \ + "ICmp" #iname, JSCLASS_HAS_RESERVED_SLOTS(1) \ }; \ static JSFunctionSpec methods_ICmp##iname[] = { Index: source/simulation2/system/ParamNode.cpp =================================================================== --- source/simulation2/system/ParamNode.cpp +++ source/simulation2/system/ParamNode.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 Wildfire Games. +/* Copyright (C) 2023 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -396,8 +396,7 @@ } // Just a string - JS::RootedString str(rq.cx, JS_NewStringCopyUTF8Z(rq.cx, JS::ConstUTF8CharsZ(m_Value.data(), m_Value.size()))); - str.set(JS_AtomizeAndPinJSString(rq.cx, str)); + JS::RootedString str(rq.cx, JS_AtomizeAndPinStringN(rq.cx, m_Value.data(), m_Value.size())); if (str) { ret.setString(str); @@ -431,8 +430,7 @@ // If the node has a string too, add that as an extra property if (!m_Value.empty()) { - std::u16string text(m_Value.begin(), m_Value.end()); - JS::RootedString str(rq.cx, JS_AtomizeAndPinUCStringN(rq.cx, text.c_str(), text.length())); + JS::RootedString str(rq.cx, JS_AtomizeAndPinStringN(rq.cx, m_Value.c_str(), m_Value.size())); if (!str) { ret.setUndefined();