mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-17 05:44:08 -07:00
[SM91] Update to Spidermonkey 91.1.3 APIs
Fixes: #5986 Patch by: @wraitii Comments by: @nwtour, @Stan Differential Revision: https://code.wildfiregames.com/D4428 This was SVN commit r27409.
This commit is contained in:
parent
03c3d2d438
commit
d5db03c303
11 changed files with 49 additions and 42 deletions
|
|
@ -605,7 +605,6 @@ extern_lib_defs = {
|
|||
else
|
||||
if os.istarget("windows") then
|
||||
include_dir = "include-win32"
|
||||
buildoptions { "/FI\"js/RequiredDefines.h\"" }
|
||||
else
|
||||
include_dir = "include-unix"
|
||||
end
|
||||
|
|
@ -626,14 +625,14 @@ extern_lib_defs = {
|
|||
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -170,13 +170,13 @@ protected:
|
|||
|
||||
// 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<JS::PropertyDescriptor> UNUSED(desc)) const override
|
||||
JS::MutableHandle<mozilla::Maybe<JS::PropertyDescriptor>> UNUSED(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<JS::PropertyDescriptor> UNUSED(desc), JS::ObjectOpResult& UNUSED(result)) const override
|
||||
JS::Handle<JS::PropertyDescriptor> UNUSED(desc), JS::ObjectOpResult& UNUSED(result)) const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -89,7 +89,7 @@ IGUIObject* IGUIProxyObject::FromPrivateSlot<IGUIObject>(JSObject* obj)
|
|||
{
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
if (JS_GetClass(obj) != &JSInterface_GUIProxy::ClassDefinition())
|
||||
if (JS::GetClass(obj) != &JSInterface_GUIProxy::ClassDefinition())
|
||||
return nullptr;
|
||||
return UnsafeFromPrivateSlot<IGUIObject>(obj);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -107,7 +107,8 @@ ScriptContext::ScriptContext(int contextSize, int heapGrowthBytesGCTrigger):
|
|||
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 @@ void ScriptContext::UnRegisterRealm(JS::Realm* realm)
|
|||
// 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 @@ void ScriptContext::MaybeIncrementalGC(double delay)
|
|||
#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::MaybeIncrementalGC(double delay)
|
|||
|
||||
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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -105,7 +105,7 @@ template<> bool Script::FromJSVal<std::wstring>(const ScriptRequest& rq, JS::Ha
|
|||
if (!str)
|
||||
FAIL("Argument must be convertible to a string");
|
||||
|
||||
if (JS_StringHasLatin1Chars(str))
|
||||
if (JS::StringHasLatin1Chars(str))
|
||||
{
|
||||
size_t length;
|
||||
JS::AutoCheckCannotGC nogc;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -533,11 +533,11 @@ bool ScriptInterface::SetGlobal_(const char* name, JS::HandleValue value, bool r
|
|||
return false;
|
||||
if (found)
|
||||
{
|
||||
JS::Rooted<JS::PropertyDescriptor> desc(rq.cx);
|
||||
if (!JS_GetOwnPropertyDescriptor(rq.cx, global, name, &desc))
|
||||
JS::Rooted<mozilla::Maybe<JS::PropertyDescriptor>> desc(rq.cx);
|
||||
if (!JS_GetOwnPropertyDescriptor(rq.cx, global, name, &desc) || !desc.isSome())
|
||||
return false;
|
||||
|
||||
if (!desc.writable())
|
||||
if (!desc->writable())
|
||||
{
|
||||
if (!replace)
|
||||
{
|
||||
|
|
@ -547,7 +547,7 @@ bool ScriptInterface::SetGlobal_(const char* name, JS::HandleValue value, bool r
|
|||
|
||||
// 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;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2020 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
|
||||
|
|
@ -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 @@ system-installed version. Make sure you have got all the right files and \
|
|||
include paths.
|
||||
#endif
|
||||
|
||||
#if MOZJS_MINOR_VERSION != 6
|
||||
#if MOZJS_MINOR_VERSION != 13
|
||||
#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 \
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -62,7 +62,7 @@ template<> void Script::ToJSVal<IComponent*>(const ScriptRequest& rq, JS::Mutab
|
|||
return;
|
||||
}
|
||||
|
||||
JS_SetPrivate(obj, static_cast<void*>(val));
|
||||
JS::SetPrivate(obj, static_cast<void*>(val));
|
||||
ret.setObject(*obj);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -219,9 +219,9 @@ void CBinarySerializerScriptImpl::HandleScriptVal(JS::HandleValue val)
|
|||
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 @@ void CBinarySerializerScriptImpl::HandleScriptVal(JS::HandleValue val)
|
|||
JS::RootedValue propval(rq.cx);
|
||||
|
||||
// Forbid getters, which might delete values and mess things up.
|
||||
JS::Rooted<JS::PropertyDescriptor> desc(rq.cx);
|
||||
if (!JS_GetPropertyDescriptorById(rq.cx, obj, id, &desc))
|
||||
JS::Rooted<mozilla::Maybe<JS::PropertyDescriptor>> 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 @@ void CBinarySerializerScriptImpl::HandleScriptVal(JS::HandleValue val)
|
|||
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 @@ void CBinarySerializerScriptImpl::ScriptString(const char* name, JS::HandleStrin
|
|||
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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue