mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1191529 - Remove JSIdArray and AutoIdArray and replace with Rooted<IdVector>; r=mccr8, r=jonco
* * * imported patch 2_remove_AutoIdArray_gk
This commit is contained in:
parent
363d11758a
commit
783b6b9e6c
@ -4516,8 +4516,8 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||
${mozMapType} &mozMap = ${mozMapRef};
|
||||
|
||||
JS::Rooted<JSObject*> mozMapObj(cx, &$${val}.toObject());
|
||||
JS::AutoIdArray ids(cx, JS_Enumerate(cx, mozMapObj));
|
||||
if (!ids) {
|
||||
JS::Rooted<JS::IdVector> ids(cx, JS::IdVector(cx));
|
||||
if (!JS_Enumerate(cx, mozMapObj, &ids)) {
|
||||
$*{exceptionCode}
|
||||
}
|
||||
JS::Rooted<JS::Value> propNameValue(cx);
|
||||
|
@ -245,10 +245,10 @@ nsGeolocationSettings::HandleGeolocationPerOriginSettingsChange(const JS::Value&
|
||||
AutoEntryScript aes(global, "geolocation.app_settings enumeration");
|
||||
aes.TakeOwnershipOfErrorReporting();
|
||||
JSContext *cx = aes.cx();
|
||||
JS::AutoIdArray ids(cx, JS_Enumerate(cx, obj));
|
||||
JS::Rooted<JS::IdVector> ids(cx, JS::IdVector(cx));
|
||||
|
||||
// if we get no ids then the exception list is empty and we can return here.
|
||||
if (!ids) {
|
||||
if (!JS_Enumerate(cx, obj, &ids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1032,8 +1032,8 @@ nsJSObjWrapper::NP_Enumerate(NPObject *npobj, NPIdentifier **idarray,
|
||||
JS::Rooted<JSObject*> jsobj(cx, npjsobj->mJSObj);
|
||||
JSAutoCompartment ac(cx, jsobj);
|
||||
|
||||
JS::AutoIdArray ida(cx, JS_Enumerate(cx, jsobj));
|
||||
if (!ida) {
|
||||
JS::Rooted<JS::IdVector> ida(cx, JS::IdVector(cx));
|
||||
if (!JS_Enumerate(cx, jsobj, &ida)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -729,8 +729,8 @@ JavaScriptShared::Wrap(JSContext* cx, HandleObject aObj, InfallibleTArray<CpowEn
|
||||
if (!aObj)
|
||||
return true;
|
||||
|
||||
AutoIdArray ids(cx, JS_Enumerate(cx, aObj));
|
||||
if (!ids)
|
||||
Rooted<IdVector> ids(cx, IdVector(cx));
|
||||
if (!JS_Enumerate(cx, aObj, &ids))
|
||||
return false;
|
||||
|
||||
RootedId id(cx);
|
||||
|
@ -259,31 +259,6 @@ JSTracer::asCallbackTracer()
|
||||
return static_cast<JS::CallbackTracer*>(this);
|
||||
}
|
||||
|
||||
namespace js {
|
||||
|
||||
// Automates static dispatch for tracing for TraceableContainers.
|
||||
template <typename, typename=void> struct DefaultTracer;
|
||||
|
||||
// The default for POD, non-pointer types is to do nothing.
|
||||
template <typename T>
|
||||
struct DefaultTracer<T, typename mozilla::EnableIf<!mozilla::IsPointer<T>::value &&
|
||||
mozilla::IsPod<T>::value>::Type> {
|
||||
static void trace(JSTracer* trc, T* t, const char* name) {
|
||||
MOZ_ASSERT(mozilla::IsPod<T>::value);
|
||||
MOZ_ASSERT(!mozilla::IsPointer<T>::value);
|
||||
}
|
||||
};
|
||||
|
||||
// The default for non-pod (e.g. struct) types is to call the trace method.
|
||||
template <typename T>
|
||||
struct DefaultTracer<T, typename mozilla::EnableIf<!mozilla::IsPod<T>::value>::Type> {
|
||||
static void trace(JSTracer* trc, T* t, const char* name) {
|
||||
t->trace(trc);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace js
|
||||
|
||||
// The JS_Call*Tracer family of functions traces the given GC thing reference.
|
||||
// This performs the tracing action configured on the given JSTracer:
|
||||
// typically calling the JSTracer::callback or marking the thing as live.
|
||||
@ -366,4 +341,37 @@ extern JS_PUBLIC_API(void)
|
||||
JS_GetTraceThingInfo(char* buf, size_t bufsize, JSTracer* trc,
|
||||
void* thing, JS::TraceKind kind, bool includeDetails);
|
||||
|
||||
namespace js {
|
||||
|
||||
// Automates static dispatch for tracing for TraceableContainers.
|
||||
template <typename, typename=void> struct DefaultTracer;
|
||||
|
||||
// The default for POD, non-pointer types is to do nothing.
|
||||
template <typename T>
|
||||
struct DefaultTracer<T, typename mozilla::EnableIf<!mozilla::IsPointer<T>::value &&
|
||||
mozilla::IsPod<T>::value>::Type> {
|
||||
static void trace(JSTracer* trc, T* t, const char* name) {
|
||||
MOZ_ASSERT(mozilla::IsPod<T>::value);
|
||||
MOZ_ASSERT(!mozilla::IsPointer<T>::value);
|
||||
}
|
||||
};
|
||||
|
||||
// The default for non-pod (e.g. struct) types is to call the trace method.
|
||||
template <typename T>
|
||||
struct DefaultTracer<T, typename mozilla::EnableIf<!mozilla::IsPod<T>::value>::Type> {
|
||||
static void trace(JSTracer* trc, T* t, const char* name) {
|
||||
t->trace(trc);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct DefaultTracer<jsid>
|
||||
{
|
||||
static void trace(JSTracer* trc, jsid* id, const char* name) {
|
||||
JS_CallUnbarrieredIdTracer(trc, id, name);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace js
|
||||
|
||||
#endif /* js_TracingAPI_h */
|
||||
|
@ -36,7 +36,9 @@ typedef AutoVectorRooter<jsid> AutoIdVector;
|
||||
typedef AutoVectorRooter<JSObject*> AutoObjectVector;
|
||||
typedef AutoVectorRooter<JSScript*> AutoVector;
|
||||
|
||||
class AutoIdArray;
|
||||
using ValueVector = js::TraceableVector<JS::Value>;
|
||||
using IdVector = js::TraceableVector<jsid>;
|
||||
using ScriptVector = js::TraceableVector<JSScript*>;
|
||||
|
||||
template <typename T> class AutoVectorRooter;
|
||||
template<typename K, typename V> class AutoHashMapRooter;
|
||||
@ -82,11 +84,9 @@ typedef AutoVectorRooter<jsid> AutoIdVector;
|
||||
typedef AutoVectorRooter<JSObject*> AutoObjectVector;
|
||||
typedef AutoVectorRooter<JSScript*> AutoScriptVector;
|
||||
|
||||
using ValueVector = TraceableVector<JS::Value>;
|
||||
using IdVector = TraceableVector<jsid>;
|
||||
using ScriptVector = TraceableVector<JSScript*>;
|
||||
|
||||
using JS::AutoIdArray;
|
||||
using JS::ValueVector;
|
||||
using JS::IdVector;
|
||||
using JS::ScriptVector;
|
||||
|
||||
using JS::AutoHashMapRooter;
|
||||
using JS::AutoHashSetRooter;
|
||||
|
@ -3261,8 +3261,8 @@ ImplicitConvert(JSContext* cx,
|
||||
if (val.isObject() && !sourceData) {
|
||||
// Enumerate the properties of the object; if they match the struct
|
||||
// specification, convert the fields.
|
||||
AutoIdArray props(cx, JS_Enumerate(cx, valObj));
|
||||
if (!props)
|
||||
Rooted<IdVector> props(cx, IdVector(cx));
|
||||
if (!JS_Enumerate(cx, valObj, &props))
|
||||
return false;
|
||||
|
||||
// Convert into an intermediate, in case of failure.
|
||||
@ -5343,8 +5343,8 @@ ExtractStructField(JSContext* cx, Value val, MutableHandleObject typeObj)
|
||||
}
|
||||
|
||||
RootedObject obj(cx, &val.toObject());
|
||||
AutoIdArray props(cx, JS_Enumerate(cx, obj));
|
||||
if (!props)
|
||||
Rooted<IdVector> props(cx, IdVector(cx));
|
||||
if (!JS_Enumerate(cx, obj, &props))
|
||||
return nullptr;
|
||||
|
||||
// make sure we have one, and only one, property
|
||||
|
@ -82,13 +82,6 @@ MarkExactStackRoots(JSRuntime* rt, JSTracer* trc)
|
||||
MarkExactStackRootsAcrossTypes<PerThreadData*>(&rt->mainThread, trc);
|
||||
}
|
||||
|
||||
void
|
||||
JS::AutoIdArray::trace(JSTracer* trc)
|
||||
{
|
||||
MOZ_ASSERT(tag_ == IDARRAY);
|
||||
TraceRange(trc, idArray->length, idArray->begin(), "JSAutoIdArray.idArray");
|
||||
}
|
||||
|
||||
inline void
|
||||
AutoGCRooter::trace(JSTracer* trc)
|
||||
{
|
||||
@ -97,12 +90,6 @@ AutoGCRooter::trace(JSTracer* trc)
|
||||
frontend::MarkParser(trc, this);
|
||||
return;
|
||||
|
||||
case IDARRAY: {
|
||||
JSIdArray* ida = static_cast<AutoIdArray*>(this)->idArray;
|
||||
TraceRange(trc, ida->length, ida->begin(), "JS::AutoIdArray.idArray");
|
||||
return;
|
||||
}
|
||||
|
||||
case VALVECTOR: {
|
||||
AutoValueVector::VectorImpl& vector = static_cast<AutoValueVector*>(this)->vector;
|
||||
TraceRootRange(trc, vector.length(), vector.begin(), "JS::AutoValueVector.vector");
|
||||
|
@ -1765,25 +1765,6 @@ JS_SetNativeStackQuota(JSRuntime* rt, size_t systemCodeStackSize, size_t trusted
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
JS_PUBLIC_API(int)
|
||||
JS_IdArrayLength(JSContext* cx, JSIdArray* ida)
|
||||
{
|
||||
return ida->length;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(jsid)
|
||||
JS_IdArrayGet(JSContext* cx, JSIdArray* ida, unsigned index)
|
||||
{
|
||||
MOZ_ASSERT(index < unsigned(ida->length));
|
||||
return ida->vector[index];
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_DestroyIdArray(JSContext* cx, JSIdArray* ida)
|
||||
{
|
||||
cx->runtime()->defaultFreeOp()->free_(ida);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_ValueToId(JSContext* cx, HandleValue value, MutableHandleId idp)
|
||||
{
|
||||
@ -3166,18 +3147,19 @@ JS_SetAllNonReservedSlotsToUndefined(JSContext* cx, JSObject* objArg)
|
||||
obj->as<NativeObject>().setSlot(i, UndefinedValue());
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSIdArray*)
|
||||
JS_Enumerate(JSContext* cx, HandleObject obj)
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_Enumerate(JSContext* cx, HandleObject obj, JS::MutableHandle<IdVector> props)
|
||||
{
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
MOZ_ASSERT(props.empty());
|
||||
|
||||
AutoIdVector props(cx);
|
||||
JSIdArray* ida;
|
||||
if (!GetPropertyKeys(cx, obj, JSITER_OWNONLY, &props) || !VectorToIdArray(cx, props, &ida))
|
||||
return nullptr;
|
||||
return ida;
|
||||
AutoIdVector ids(cx);
|
||||
if (!GetPropertyKeys(cx, obj, JSITER_OWNONLY, &ids))
|
||||
return false;
|
||||
|
||||
return props.append(ids.begin(), ids.end());
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(Value)
|
||||
|
@ -1867,64 +1867,6 @@ JS_SetNativeStackQuota(JSRuntime* cx, size_t systemCodeStackSize,
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
extern JS_PUBLIC_API(int)
|
||||
JS_IdArrayLength(JSContext* cx, JSIdArray* ida);
|
||||
|
||||
extern JS_PUBLIC_API(jsid)
|
||||
JS_IdArrayGet(JSContext* cx, JSIdArray* ida, unsigned index);
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_DestroyIdArray(JSContext* cx, JSIdArray* ida);
|
||||
|
||||
namespace JS {
|
||||
|
||||
class AutoIdArray : private AutoGCRooter
|
||||
{
|
||||
public:
|
||||
AutoIdArray(JSContext* cx, JSIdArray* ida
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx, IDARRAY), context(cx), idArray(ida)
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
~AutoIdArray() {
|
||||
if (idArray)
|
||||
JS_DestroyIdArray(context, idArray);
|
||||
}
|
||||
bool operator!() const {
|
||||
return !idArray;
|
||||
}
|
||||
jsid operator[](size_t i) const {
|
||||
MOZ_ASSERT(idArray);
|
||||
return JS_IdArrayGet(context, idArray, unsigned(i));
|
||||
}
|
||||
size_t length() const {
|
||||
return JS_IdArrayLength(context, idArray);
|
||||
}
|
||||
|
||||
friend void AutoGCRooter::trace(JSTracer* trc);
|
||||
|
||||
JSIdArray* steal() {
|
||||
JSIdArray* copy = idArray;
|
||||
idArray = nullptr;
|
||||
return copy;
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void trace(JSTracer* trc);
|
||||
|
||||
private:
|
||||
JSContext* context;
|
||||
JSIdArray* idArray;
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
|
||||
/* No copy or assignment semantics. */
|
||||
AutoIdArray(AutoIdArray& ida) = delete;
|
||||
void operator=(AutoIdArray& ida) = delete;
|
||||
};
|
||||
|
||||
} /* namespace JS */
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_ValueToId(JSContext* cx, JS::HandleValue v, JS::MutableHandleId idp);
|
||||
|
||||
@ -3151,8 +3093,8 @@ JS_CreateMappedArrayBufferContents(int fd, size_t offset, size_t length);
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_ReleaseMappedArrayBufferContents(void* contents, size_t length);
|
||||
|
||||
extern JS_PUBLIC_API(JSIdArray*)
|
||||
JS_Enumerate(JSContext* cx, JS::HandleObject obj);
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_Enumerate(JSContext* cx, JS::HandleObject obj, JS::MutableHandle<JS::IdVector> props);
|
||||
|
||||
extern JS_PUBLIC_API(JS::Value)
|
||||
JS_GetReservedSlot(JSObject* obj, uint32_t index);
|
||||
|
@ -19,16 +19,6 @@
|
||||
class JSAtom;
|
||||
class JSAutoByteString;
|
||||
|
||||
struct JSIdArray {
|
||||
int length;
|
||||
js::HeapId vector[1]; /* actually, length jsid words */
|
||||
|
||||
js::HeapId* begin() { return vector; }
|
||||
const js::HeapId* begin() const { return vector; }
|
||||
js::HeapId* end() { return vector + length; }
|
||||
const js::HeapId* end() const { return vector + length; }
|
||||
};
|
||||
|
||||
namespace js {
|
||||
|
||||
JS_STATIC_ASSERT(sizeof(HashNumber) == 4);
|
||||
|
@ -395,25 +395,6 @@ Snapshot(JSContext* cx, HandleObject pobj_, unsigned flags, AutoIdVector* props)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
js::VectorToIdArray(JSContext* cx, AutoIdVector& props, JSIdArray** idap)
|
||||
{
|
||||
JS_STATIC_ASSERT(sizeof(JSIdArray) > sizeof(jsid));
|
||||
size_t len = props.length();
|
||||
size_t idsz = len * sizeof(jsid);
|
||||
size_t sz = (sizeof(JSIdArray) - sizeof(jsid)) + idsz;
|
||||
JSIdArray* ida = reinterpret_cast<JSIdArray*>(cx->zone()->pod_malloc<uint8_t>(sz));
|
||||
if (!ida)
|
||||
return false;
|
||||
|
||||
ida->length = static_cast<int>(len);
|
||||
jsid* v = props.begin();
|
||||
for (int i = 0; i < ida->length; i++)
|
||||
ida->vector[i].init(v[i]);
|
||||
*idap = ida;
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
js::GetPropertyKeys(JSContext* cx, HandleObject obj, unsigned flags, AutoIdVector* props)
|
||||
{
|
||||
|
@ -146,9 +146,6 @@ class StringIteratorObject : public JSObject
|
||||
static const Class class_;
|
||||
};
|
||||
|
||||
bool
|
||||
VectorToIdArray(JSContext* cx, AutoIdVector& props, JSIdArray** idap);
|
||||
|
||||
bool
|
||||
GetIterator(JSContext* cx, HandleObject obj, unsigned flags, MutableHandleObject objp);
|
||||
|
||||
|
@ -93,7 +93,6 @@ struct JSCrossCompartmentCall;
|
||||
class JSErrorReport;
|
||||
struct JSExceptionState;
|
||||
struct JSFunctionSpec;
|
||||
struct JSIdArray;
|
||||
struct JSLocaleCallbacks;
|
||||
struct JSObjectMap;
|
||||
struct JSPrincipals;
|
||||
@ -218,7 +217,6 @@ class JS_PUBLIC_API(AutoGCRooter)
|
||||
enum {
|
||||
VALARRAY = -2, /* js::AutoValueArray */
|
||||
PARSER = -3, /* js::frontend::Parser */
|
||||
IDARRAY = -6, /* js::AutoIdArray */
|
||||
VALVECTOR = -10, /* js::AutoValueVector */
|
||||
IDVECTOR = -11, /* js::AutoIdVector */
|
||||
OBJVECTOR = -14, /* js::AutoObjectVector */
|
||||
|
@ -4954,8 +4954,8 @@ Help(JSContext* cx, unsigned argc, Value* vp)
|
||||
RootedObject obj(cx);
|
||||
if (args.length() == 0) {
|
||||
RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
|
||||
AutoIdArray ida(cx, JS_Enumerate(cx, global));
|
||||
if (!ida)
|
||||
Rooted<IdVector> ida(cx, IdVector(cx));
|
||||
if (!JS_Enumerate(cx, global, &ida))
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < ida.length(); i++) {
|
||||
|
@ -2836,8 +2836,8 @@ nsXPCComponents_Utils::MakeObjectPropsNormal(HandleValue vobj, JSContext* cx)
|
||||
|
||||
RootedObject obj(cx, js::UncheckedUnwrap(&vobj.toObject()));
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
AutoIdArray ida(cx, JS_Enumerate(cx, obj));
|
||||
if (!ida)
|
||||
Rooted<IdVector> ida(cx, IdVector(cx));
|
||||
if (!JS_Enumerate(cx, obj, &ida))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
RootedId id(cx);
|
||||
|
@ -357,8 +357,8 @@ nsXPCWrappedJSClass::BuildPropertyEnumerator(XPCCallContext& ccx,
|
||||
if (!scriptEval.StartEvaluating(aJSObj))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
AutoIdArray idArray(cx, JS_Enumerate(cx, aJSObj));
|
||||
if (!idArray)
|
||||
Rooted<IdVector> idArray(cx, IdVector(cx));
|
||||
if (!JS_Enumerate(cx, aJSObj, &idArray))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMArray<nsIProperty> propertyArray(idArray.length());
|
||||
|
@ -262,9 +262,8 @@ class NativeJSContainerImpl final
|
||||
sdk::Bundle::LocalRef
|
||||
BundleFromValue(const JS::HandleObject obj)
|
||||
{
|
||||
const JS::AutoIdArray ids(mJSContext,
|
||||
JS_Enumerate(mJSContext, obj));
|
||||
if (!CheckJSCall(!!ids)) {
|
||||
JS::Rooted<JS::IdVector> ids(mJSContext, JS::IdVector(mJSContext));
|
||||
if (!CheckJSCall(JS_Enumerate(mJSContext, obj, &ids))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user