Page MenuHomeWildfire Games

[SM52] Spidermonkey Upgrade 2/2 : Various API updates for compatibility.
ClosedPublic

Authored by wraitii on Nov 11 2020, 8:20 PM.

Details

Reviewers
None
Commits
rP24203: [SM52 2/2] Update to Spidermonkey 52 APIs.
Trac Tickets
#4893
Summary

WINDOWS -> you need to apply this patch and download binaries: https://github.com/wraitii/0ad/commit/ae17fb71a142ceb3858d19a1d676fd33d9f099d9

I'm bundling this as a single diff on Phabricator, but it's several commits on the branch.
Not sure yet how to commit it, Some diffs are small and they are all required to compile on SM52.

Changes:

  • InformalValueTypeName is back in the API, so remove our implementation.
  • Stop using JSRuntime entirely in favour of JSContext*
  • JSPropertyDescriptor is renamed.
  • CompartmentOptions are tweaked slightly (no functional changes)
  • JS::Construct - API update.
  • JSClass split - API update.
  • a js.msg error message was removed, and so was changed.
  • Tests fix: fix comparison of union instances
  • disable warning in spidermonkey Vector.h
  • Update error reporting to SM52 (minor API updates)
  • StructuredClone upgrade (minor API updates overall)
  • Ignore warnings about unused return values (would come from OOM, which isn't recoverable)

Patches by @Itms
Part of the SM52 migration, this is the last step.

Test Plan

Compile and run.

Event Timeline

wraitii created this revision.Nov 11 2020, 8:20 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/3490/display/redirect

wraitii retitled this revision from [SM52] Spidermonkey Upgrade 1/2 : Various API updates for compatibility. to [SM52] Spidermonkey Upgrade 2/2 : Various API updates for compatibility..Nov 11 2020, 8:21 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/1838/display/redirect

wraitii requested review of this revision.Nov 11 2020, 8:21 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/2937/display/redirect

wraitii updated this revision to Diff 13950.Nov 15 2020, 7:33 PM

Rebased. Won't run on CI for now. Needs testing on windows and linux.

(for windows, see Summary to fetch binaries)

Owners added a subscriber: Restricted Owners Package.Nov 15 2020, 7:33 PM
wraitii edited the summary of this revision. (Show Details)Nov 15 2020, 7:36 PM

Build failure - The Moirai have given mortals hearts that can endure.

builderr-debug-macos.txt
In file included from ../../../source/network/NetClientTurnManager.cppIn file included from ../../../source/network/NetClient.cpp:20:
In file included from ../../../source/network/NetClient.h:24:
:20:
In file included from ../../../source/scriptinterface/ScriptInterface.h:334:37: ../../../source/network/NetClientTurnManager.h:21:
In file included from error: ../../../source/simulation2/system/TurnManager.h:use of undeclared identifier 'JSStructuredCloneData'
22:
In file included from ../../../source/simulation2/helpers/SimulationCommand.h:21:
../../../source/scriptinterface/ScriptInterface.h:334:37        using StructuredClone = shared_ptr<JSStructuredCloneData>;
                                           ^
: error: use of undeclared identifier 'JSStructuredCloneData'
        using StructuredClone = shared_ptr<JSStructuredCloneData>;
                                           ^
../../../source/scriptinterface/ScriptInterface.h:336:2: error: unknown type name 'StructuredClone'
        StructuredClone WriteStructuredClone(JS::HandleValue v, bool sameThread) const;
        ^
../../../source/scriptinterface/ScriptInterface.h:336:2: error: unknown type name 'StructuredClone'
        StructuredClone WriteStructuredClone(JS::HandleValue v, bool sameThread) const;
        ^
../../../source/scriptinterface/ScriptInterface.h:337:33: error: unknown type name 'StructuredClone'
        void ReadStructuredClone(const StructuredClone& ptr, JS::MutableHandleValue ret) const;
                                       ^
../../../source/scriptinterface/ScriptInterface.h:337:33: error: unknown type name 'StructuredClone'
        void ReadStructuredClone(const StructuredClone& ptr, JS::MutableHandleValue ret) const;
                                       ^
In file included from ../../../source/network/NetMessageSim.cpp:23:
../../../source/scriptinterface/ScriptInterface.h:334:37: error: use of undeclared identifier 'JSStructuredCloneData'
        using StructuredClone = shared_ptr<JSStructuredCloneData>;
                                           ^
../../../source/scriptinterface/ScriptInterface.h:336:2: error: unknown type name 'StructuredClone'
        StructuredClone WriteStructuredClone(JS::HandleValue v, bool sameThread) const;
        ^
../../../source/scriptinterface/ScriptInterface.h:337:33: error: unknown type name 'StructuredClone'
        void ReadStructuredClone(const StructuredClone& ptr, JS::MutableHandleValue ret) const;
                                       ^
In file included from ../../../source/network/NetMessage.cpp:24:
In file included from ../../../source/simulation2/Simulation2.h:22:
In file included from ../../../source/simulation2/helpers/SimulationCommand.h:21:
../../../source/scriptinterface/ScriptInterface.h:334:37: error: use of undeclared identifier 'JSStructuredCloneData'
        using StructuredClone = shared_ptr<JSStructuredCloneData>;
                                           ^
../../../source/scriptinterface/ScriptInterface.h:336:2: error: unknown type name 'StructuredClone'
        StructuredClone WriteStructuredClone(JS::HandleValue v, bool sameThread) const;
        ^
../../../source/network/NetClient.cpp:83:2: error: no matching function for call to 'JS_AddExtraGCRootsTracer'
        JS_AddExtraGCRootsTracer(GetScriptInterface().GetGeneralJSContext(), CNetClient::Trace, this);
        ^~~~~~~~~~~~~~~~~~~~~~~~
../../../source/scriptinterface/ScriptInterface.h:337:33: error: unknown type name 'StructuredClone'
        void ReadStructuredClone(const StructuredClone& ptr, JS::MutableHandleValue ret) const;
                                       ^
../../../libraries/source/spidermonkey/include-unix-debug/jsapi.h:1631:1: note: candidate function not viable: cannot convert argument of incomplete type 'JSContext *' to 'JSRuntime *'
JS_AddExtraGCRootsTracer(JSRuntime* rt, JSTraceDataOp traceOp, void* data);
^
../../../source/network/NetClient.cpp:147:2: error: no matching function for call to 'JS_RemoveExtraGCRootsTracer'
        JS_RemoveExtraGCRootsTracer(GetScriptInterface().GetGeneralJSContext(), CNetClient::Trace, this);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../libraries/source/spidermonkey/include-unix-debug/jsapi.h:1635:1: note: candidate function not viable: cannot convert argument of incomplete type 'JSContext *' to 'JSRuntime *'
JS_RemoveExtraGCRootsTracer(JSRuntime* rt, JSTraceDataOp traceOp, void* data);
^
3 errors generated.
make[1]: *** [obj/network_Debug/NetMessageSim.o] Error 1
make[1]: *** Waiting for unfinished jobs....
3 errors generated.
make[1]: *** [obj/network_Debug/NetMessage.o] Error 1
3 errors generated.
make[1]: *** [obj/network_Debug/NetClientTurnManager.o] Error 1
5 errors generated.
make[1]: *** [obj/network_Debug/NetClient.o] Error 1
make: *** [network] Error 2

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/1911/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/3571/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/3010/display/redirect

Stan added a subscriber: Stan.Nov 16 2020, 6:59 PM
Stan added inline comments.
source/gui/ObjectBases/IGUIObject.cpp
405

What does this return? If it's a boolean we could check and logwarnings ?
We have a macro for this UNUSED2 or something

source/gui/Scripting/JSInterface_IGUIObject.cpp
178

Why can't we use JSMSG_TYPE_ERR_BAD_ARGS anymore?

source/ps/Mod.cpp
31

Rebase?

source/scriptinterface/NativeWrapperDefns.h
183

UNUSED(2) here and below.

source/scriptinterface/ScriptContext.cpp
107

Why is not done? Is it hard to do? We should get all the help we can :)

185

That's a bit inconsistent cout and printf

wraitii updated this revision to Diff 13993.Nov 17 2020, 1:35 PM

Incorporate all changes to test CI runs.

Owners added a subscriber: Restricted Owners Package.Nov 17 2020, 1:35 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/3058/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

builderr-debug-macos.txt
../../../source/simulation2/scripting/JSInterface_Simulation.cpp:153:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CFixedVector2D(-halfSize.X, -halfSize.Y),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
fatal error: fatal errorfatal error: : file '/Users/wfg/Jenkins/workspace/macos-differential/build/workspaces/gcc/../../../libraries/osx/sdl2/include/SDL2/close_code.h' has been modified since the precompiled header 'obj/engine_Debug/precompiled.h.gch' was built
fatal error: file '/Users/wfg/Jenkins/workspace/macos-differential/build/workspaces/gcc/../../../libraries/osx/sdl2/include/SDL2/close_code.h' has been modified since the precompiled header 'obj/engine_Debug/precompiled.h.gch' was built
notefile '/Users/wfg/Jenkins/workspace/macos-differential/build/workspaces/gcc/../../../libraries/osx/sdl2/include/SDL2/close_code.h' has been modified since the precompiled header 'obj/engine_Debug/precompiled.h.gch' was built: 
note: please rebuild precompiled header 'obj/engine_Debug/precompiled.h.gch'notefile '/Users/wfg/Jenkins/workspace/macos-differential/build/workspaces/gcc/../../../libraries/osx/sdl2/include/SDL2/close_code.h' has been modified since the precompiled header 'obj/engine_Debug/precompiled.h.gch' was built
please rebuild precompiled header 'obj/engine_Debug/precompiled.h.gch'
: 
please rebuild precompiled header 'obj/engine_Debug/precompiled.h.gch'
note: please rebuild precompiled header 'obj/engine_Debug/precompiled.h.gch'
1 error generated.
1 error generated.
make[1]: *** [obj/engine_Debug/JSInterface_Network.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [obj/engine_Debug/JSInterface_L10n.o] Error 1
1 error generated.
make[1]: *** [obj/engine_Debug/CConsole.o] Error 1
1 error generated.
make[1]: *** [obj/engine_Debug/L10n.o] Error 1
make: *** [engine] Error 2

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/1946/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/3605/display/redirect

Build ran on rerun on CI. MacOS passes. Stan & myself have tested windows. I'm merging this tomorrow I think.

wraitii added inline comments.Nov 17 2020, 5:02 PM
source/gui/ObjectBases/IGUIObject.cpp
405

It returns a boolean on failure. Failure means OOM, and we can't really do anything useful in that case.

I'm not sure the macro is obviously better here.

source/gui/Scripting/JSInterface_IGUIObject.cpp
178

Cause it's not there anymore :p

source/ps/Mod.cpp
31

I don't believe it's needed anymore.

source/scriptinterface/ScriptContext.cpp
107

This is probably a todo from 2007 or so... TBH I should just drop the TODO. We can't recover from this.

Merging this later today.

wraitii updated this revision to Diff 14015.Nov 18 2020, 12:41 PM

Whole-thing-but-the-binaries for the sake of sanity testing before merging.

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/3076/display/redirect

Successful build - Chance fights ever on the side of the prudent.

builderr-debug-macos.txt
../../../source/simulation2/scripting/JSInterface_Simulation.cpp:153:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CFixedVector2D(-halfSize.X, -halfSize.Y),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../../source/graphics/tests/test_Camera.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/graphics/tests/test_Camera.h:168:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CVector3D(-101.0f, -101.0f, 101.0f),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../../source/simulation2/tests/test_SerializeTemplates.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/simulation2/tests/test_SerializeTemplates.h:39:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        3, 0, 1, 4, 1, 5
                        ^~~~~~~~~~~~~~~~
                        {               }
1 warning generated.
builderr-release-macos.txt
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libnetwork.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/liblobby.a(precompiled.o) has no symbols
../../../source/simulation2/scripting/JSInterface_Simulation.cpp:153:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CFixedVector2D(-halfSize.X, -halfSize.Y),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libsimulation2.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libscriptinterface.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libengine.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgraphics.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libatlas.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgui.a(precompiled.o) has no symbols
In file included from ../../../source/graphics/tests/test_Camera.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/graphics/tests/test_Camera.h:168:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CVector3D(-101.0f, -101.0f, 101.0f),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../../source/simulation2/tests/test_SerializeTemplates.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/simulation2/tests/test_SerializeTemplates.h:39:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        3, 0, 1, 4, 1, 5
                        ^~~~~~~~~~~~~~~~
                        {               }
1 warning generated.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/1966/display/redirect

Stan added a comment.Nov 18 2020, 1:23 PM

Update all the headers...

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/3625/display/redirect

This revision was not accepted when it landed; it landed in state Needs Review.Nov 18 2020, 3:39 PM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.