mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 879079 - Fix some exact rooting static analysis failures under js/src; r=bhackett
--HG-- extra : rebase_source : 3d5181531aef48516f1ec257b674e033a2da2aa6
This commit is contained in:
parent
82ade4173d
commit
a69c96beb2
@ -59,6 +59,8 @@ JS_ComputeThis(JSContext *cx, JS::Value *vp);
|
||||
|
||||
namespace JS {
|
||||
|
||||
extern JS_PUBLIC_DATA(const HandleValue) UndefinedHandleValue;
|
||||
|
||||
/*
|
||||
* JS::CallReceiver encapsulates access to the callee, |this|, and eventual
|
||||
* return value for a function call. The principal way to create a
|
||||
@ -298,6 +300,16 @@ class MOZ_STACK_CLASS CallArgsBase :
|
||||
return i < length() ? this->argv_[i] : UndefinedValue();
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the i-th zero-indexed argument as a handle, or |undefined| if
|
||||
* there's no such argument.
|
||||
*/
|
||||
HandleValue handleOrUndefinedAt(unsigned i) const {
|
||||
return i < length()
|
||||
? HandleValue::fromMarkedLocation(&this->argv_[i])
|
||||
: UndefinedHandleValue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true if the i-th zero-indexed argument is present and is not
|
||||
* |undefined|.
|
||||
|
@ -72,7 +72,7 @@ obj_propertyIsEnumerable(JSContext *cx, unsigned argc, Value *vp)
|
||||
|
||||
/* Step 1. */
|
||||
RootedId id(cx);
|
||||
if (!ValueToId<CanGC>(cx, args.get(0), &id))
|
||||
if (!ValueToId<CanGC>(cx, args.handleOrUndefinedAt(0), &id))
|
||||
return false;
|
||||
|
||||
/* Step 2. */
|
||||
@ -183,7 +183,8 @@ obj_toSource(JSContext *cx, unsigned argc, Value *vp)
|
||||
}
|
||||
|
||||
/* Convert id to a linear string. */
|
||||
JSString *s = ToString<CanGC>(cx, IdToValue(id));
|
||||
RootedValue idv(cx, IdToValue(id));
|
||||
JSString *s = ToString<CanGC>(cx, idv);
|
||||
if (!s)
|
||||
return false;
|
||||
Rooted<JSLinearString*> idstr(cx, s->ensureLinear(cx));
|
||||
@ -380,7 +381,7 @@ DefineAccessor(JSContext *cx, unsigned argc, Value *vp)
|
||||
}
|
||||
|
||||
RootedId id(cx);
|
||||
if (!ValueToId<CanGC>(cx, args[0], &id))
|
||||
if (!ValueToId<CanGC>(cx, args.handleAt(0), &id))
|
||||
return false;
|
||||
|
||||
RootedObject descObj(cx, NewBuiltinClassInstance(cx, &ObjectClass));
|
||||
@ -432,7 +433,7 @@ obj_lookupGetter(JSContext *cx, unsigned argc, Value *vp)
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
RootedId id(cx);
|
||||
if (!ValueToId<CanGC>(cx, args.get(0), &id))
|
||||
if (!ValueToId<CanGC>(cx, args.handleOrUndefinedAt(0), &id))
|
||||
return JS_FALSE;
|
||||
RootedObject obj(cx, ToObject(cx, args.thisv()));
|
||||
if (!obj)
|
||||
@ -468,7 +469,7 @@ obj_lookupSetter(JSContext *cx, unsigned argc, Value *vp)
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
RootedId id(cx);
|
||||
if (!ValueToId<CanGC>(cx, args.get(0), &id))
|
||||
if (!ValueToId<CanGC>(cx, args.handleOrUndefinedAt(0), &id))
|
||||
return JS_FALSE;
|
||||
RootedObject obj(cx, ToObject(cx, args.thisv()));
|
||||
if (!obj)
|
||||
@ -573,7 +574,7 @@ obj_watch(JSContext *cx, unsigned argc, Value *vp)
|
||||
return false;
|
||||
|
||||
RootedId propid(cx);
|
||||
if (!ValueToId<CanGC>(cx, args[0], &propid))
|
||||
if (!ValueToId<CanGC>(cx, args.handleAt(0), &propid))
|
||||
return false;
|
||||
|
||||
RootedObject obj(cx, ToObject(cx, args.thisv()));
|
||||
@ -601,7 +602,7 @@ obj_unwatch(JSContext *cx, unsigned argc, Value *vp)
|
||||
args.rval().setUndefined();
|
||||
RootedId id(cx);
|
||||
if (argc != 0) {
|
||||
if (!ValueToId<CanGC>(cx, args[0], &id))
|
||||
if (!ValueToId<CanGC>(cx, args.handleAt(0), &id))
|
||||
return false;
|
||||
} else {
|
||||
id = JSID_VOID;
|
||||
@ -617,7 +618,7 @@ obj_hasOwnProperty(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
Value idValue = args.get(0);
|
||||
HandleValue idValue = args.handleOrUndefinedAt(0);
|
||||
|
||||
/* Step 1, 2. */
|
||||
jsid id;
|
||||
@ -746,7 +747,7 @@ obj_getOwnPropertyDescriptor(JSContext *cx, unsigned argc, Value *vp)
|
||||
if (!GetFirstArgumentAsObject(cx, args, "Object.getOwnPropertyDescriptor", &obj))
|
||||
return JS_FALSE;
|
||||
RootedId id(cx);
|
||||
if (!ValueToId<CanGC>(cx, args.get(1), &id))
|
||||
if (!ValueToId<CanGC>(cx, args.handleOrUndefinedAt(1), &id))
|
||||
return JS_FALSE;
|
||||
return GetOwnPropertyDescriptor(cx, obj, id, args.rval());
|
||||
}
|
||||
@ -851,7 +852,7 @@ obj_defineProperty(JSContext *cx, unsigned argc, Value *vp)
|
||||
return false;
|
||||
|
||||
RootedId id(cx);
|
||||
if (!ValueToId<CanGC>(cx, args.get(1), &id))
|
||||
if (!ValueToId<CanGC>(cx, args.handleOrUndefinedAt(1), &id))
|
||||
return JS_FALSE;
|
||||
|
||||
const Value descval = args.get(2);
|
||||
|
@ -277,7 +277,7 @@ CompileRegExpObject(JSContext *cx, RegExpObjectBuilder &builder, CallArgs args)
|
||||
|
||||
RegExpFlag flags = RegExpFlag(0);
|
||||
if (args.hasDefined(1)) {
|
||||
RootedString flagStr(cx, ToString<CanGC>(cx, args[1]));
|
||||
RootedString flagStr(cx, ToString<CanGC>(cx, args.handleAt(1)));
|
||||
if (!flagStr)
|
||||
return false;
|
||||
args[1].setString(flagStr);
|
||||
@ -602,7 +602,7 @@ ExecuteRegExp(JSContext *cx, CallArgs args, MatchConduit &matches)
|
||||
RootedObject regexp(cx, &args.thisv().toObject());
|
||||
|
||||
/* Step 2. */
|
||||
RootedString string(cx, ToString<CanGC>(cx, args.get(0)));
|
||||
RootedString string(cx, ToString<CanGC>(cx, args.handleOrUndefinedAt(0)));
|
||||
if (!string)
|
||||
return RegExpRunStatus_Error;
|
||||
|
||||
@ -622,7 +622,7 @@ regexp_exec_impl(JSContext *cx, CallArgs args)
|
||||
* and CreateRegExpMatchResult().
|
||||
*/
|
||||
RootedObject regexp(cx, &args.thisv().toObject());
|
||||
RootedString string(cx, ToString<CanGC>(cx, args.get(0)));
|
||||
RootedString string(cx, ToString<CanGC>(cx, args.handleOrUndefinedAt(0)));
|
||||
if (!string)
|
||||
return false;
|
||||
|
||||
|
@ -6724,11 +6724,13 @@ Parser<ParseHandler>::primaryExpr(TokenKind tt)
|
||||
return null();
|
||||
|
||||
RootedAtom atom(context);
|
||||
Value tmp;
|
||||
for (;;) {
|
||||
TokenKind ltok = tokenStream.getToken(TSF_KEYWORD_IS_NAME);
|
||||
switch (ltok) {
|
||||
case TOK_NUMBER:
|
||||
atom = ToAtom<CanGC>(context, DoubleValue(tokenStream.currentToken().number()));
|
||||
tmp = DoubleValue(tokenStream.currentToken().number());
|
||||
atom = ToAtom<CanGC>(context, HandleValue::fromMarkedLocation(&tmp));
|
||||
if (!atom)
|
||||
return null();
|
||||
pn3 = handler.newNumber(tokenStream.currentToken());
|
||||
@ -6761,7 +6763,8 @@ Parser<ParseHandler>::primaryExpr(TokenKind tt)
|
||||
pn3 = handler.newNumber(index);
|
||||
if (!pn3)
|
||||
return null();
|
||||
atom = ToAtom<CanGC>(context, DoubleValue(index));
|
||||
tmp = DoubleValue(index);
|
||||
atom = ToAtom<CanGC>(context, HandleValue::fromMarkedLocation(&tmp));
|
||||
if (!atom)
|
||||
return null();
|
||||
} else {
|
||||
@ -6771,7 +6774,8 @@ Parser<ParseHandler>::primaryExpr(TokenKind tt)
|
||||
}
|
||||
} else if (tt == TOK_NUMBER) {
|
||||
double number = tokenStream.currentToken().number();
|
||||
atom = ToAtom<CanGC>(context, DoubleValue(number));
|
||||
tmp = DoubleValue(number);
|
||||
atom = ToAtom<CanGC>(context, HandleValue::fromMarkedLocation(&tmp));
|
||||
if (!atom)
|
||||
return null();
|
||||
pn3 = handler.newNumber(tokenStream.currentToken());
|
||||
|
@ -288,6 +288,7 @@ JS_ConvertArgumentsVA(JSContext *cx, unsigned argc, jsval *argv, const char *for
|
||||
double d;
|
||||
JSString *str;
|
||||
RootedObject obj(cx);
|
||||
RootedValue val(cx);
|
||||
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
@ -347,7 +348,8 @@ JS_ConvertArgumentsVA(JSContext *cx, unsigned argc, jsval *argv, const char *for
|
||||
break;
|
||||
case 'S':
|
||||
case 'W':
|
||||
str = ToString<CanGC>(cx, *sp);
|
||||
val = *sp;
|
||||
str = ToString<CanGC>(cx, val);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
*sp = STRING_TO_JSVAL(str);
|
||||
|
@ -138,7 +138,8 @@ DoubleIndexToId(JSContext *cx, double index, MutableHandleId id)
|
||||
if (index == uint32_t(index))
|
||||
return IndexToId(cx, uint32_t(index), id);
|
||||
|
||||
return ValueToId<CanGC>(cx, DoubleValue(index), id);
|
||||
Value tmp = DoubleValue(index);
|
||||
return ValueToId<CanGC>(cx, HandleValue::fromMarkedLocation(&tmp), id);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -350,7 +351,8 @@ DeletePropertyOrThrow(JSContext *cx, HandleObject obj, double index)
|
||||
return true;
|
||||
|
||||
RootedId id(cx);
|
||||
if (!ValueToId<CanGC>(cx, NumberValue(index), &id))
|
||||
RootedValue indexv(cx, NumberValue(index));
|
||||
if (!ValueToId<CanGC>(cx, indexv, &id))
|
||||
return false;
|
||||
return obj->reportNotConfigurable(cx, id, JSREPORT_ERROR);
|
||||
}
|
||||
@ -892,7 +894,7 @@ array_join_sub(JSContext *cx, CallArgs &args, bool locale)
|
||||
// Steps 4 and 5
|
||||
RootedString sepstr(cx, NULL);
|
||||
if (!locale && args.hasDefined(0)) {
|
||||
sepstr = ToString<CanGC>(cx, args[0]);
|
||||
sepstr = ToString<CanGC>(cx, args.handleAt(0));
|
||||
if (!sepstr)
|
||||
return false;
|
||||
}
|
||||
@ -1133,11 +1135,14 @@ InitArrayElements(JSContext *cx, HandleObject obj, uint32_t start, uint32_t coun
|
||||
JS_ASSERT(start == MAX_ARRAY_INDEX + 1);
|
||||
RootedValue value(cx);
|
||||
RootedId id(cx);
|
||||
RootedValue indexv(cx);
|
||||
double index = MAX_ARRAY_INDEX + 1;
|
||||
do {
|
||||
value = *vector++;
|
||||
if (!ValueToId<CanGC>(cx, DoubleValue(index), &id) ||
|
||||
!JSObject::setGeneric(cx, obj, obj, id, &value, true)) {
|
||||
indexv = DoubleValue(index);
|
||||
if (!ValueToId<CanGC>(cx, indexv, &id) ||
|
||||
!JSObject::setGeneric(cx, obj, obj, id, &value, true))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
index += 1;
|
||||
|
@ -235,7 +235,7 @@ AtomizeString(JSContext *cx, JSString *str, js::InternBehavior ib = js::DoNotInt
|
||||
|
||||
template <AllowGC allowGC>
|
||||
inline JSAtom *
|
||||
ToAtom(JSContext *cx, const js::Value &v);
|
||||
ToAtom(JSContext *cx, typename MaybeRooted<Value, allowGC>::HandleType v);
|
||||
|
||||
template<XDRMode mode>
|
||||
bool
|
||||
|
@ -43,7 +43,7 @@ AtomToId(JSAtom *atom)
|
||||
|
||||
template <AllowGC allowGC>
|
||||
inline JSAtom *
|
||||
ToAtom(JSContext *cx, const js::Value &v)
|
||||
ToAtom(JSContext *cx, typename MaybeRooted<Value, allowGC>::HandleType v)
|
||||
{
|
||||
if (!v.isString()) {
|
||||
JSString *str = js::ToStringSlow<allowGC>(cx, v);
|
||||
@ -63,7 +63,8 @@ ToAtom(JSContext *cx, const js::Value &v)
|
||||
|
||||
template <AllowGC allowGC>
|
||||
inline bool
|
||||
ValueToId(JSContext* cx, const Value &v, typename MaybeRooted<jsid, allowGC>::MutableHandleType idp)
|
||||
ValueToId(JSContext* cx, typename MaybeRooted<Value, allowGC>::HandleType v,
|
||||
typename MaybeRooted<jsid, allowGC>::MutableHandleType idp)
|
||||
{
|
||||
int32_t i;
|
||||
if (ValueFitsInInt32(v, &i) && INT_FITS_IN_JSID(i)) {
|
||||
@ -146,7 +147,8 @@ IdToString(JSContext *cx, jsid id)
|
||||
if (JS_LIKELY(JSID_IS_INT(id)))
|
||||
return Int32ToString<CanGC>(cx, JSID_TO_INT(id));
|
||||
|
||||
JSString *str = ToStringSlow<CanGC>(cx, IdToValue(id));
|
||||
RootedValue idv(cx, IdToValue(id));
|
||||
JSString *str = ToStringSlow<CanGC>(cx, idv);
|
||||
if (!str)
|
||||
return NULL;
|
||||
|
||||
|
@ -447,8 +447,10 @@ inline bool
|
||||
CallSetter(JSContext *cx, HandleObject obj, HandleId id, StrictPropertyOp op, unsigned attrs,
|
||||
unsigned shortid, JSBool strict, MutableHandleValue vp)
|
||||
{
|
||||
if (attrs & JSPROP_SETTER)
|
||||
return InvokeGetterOrSetter(cx, obj, CastAsObjectJsval(op), 1, vp.address(), vp.address());
|
||||
if (attrs & JSPROP_SETTER) {
|
||||
RootedValue opv(cx, CastAsObjectJsval(op));
|
||||
return InvokeGetterOrSetter(cx, obj, opv, 1, vp.address(), vp.address());
|
||||
}
|
||||
|
||||
if (attrs & JSPROP_GETTER)
|
||||
return js_ReportGetterOnlyAssignment(cx);
|
||||
|
@ -377,7 +377,7 @@ JSCompartment::wrapId(JSContext *cx, jsid *idp)
|
||||
if (!wrap(cx, &value))
|
||||
return false;
|
||||
RootedId id(cx);
|
||||
if (!ValueToId<CanGC>(cx, value.get(), &id))
|
||||
if (!ValueToId<CanGC>(cx, value, &id))
|
||||
return false;
|
||||
|
||||
*idp = id;
|
||||
|
@ -1210,7 +1210,7 @@ date_parse(JSContext *cx, unsigned argc, Value *vp)
|
||||
return true;
|
||||
}
|
||||
|
||||
JSString *str = ToString<CanGC>(cx, args[0]);
|
||||
JSString *str = ToString<CanGC>(cx, args.handleAt(0));
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
@ -2896,7 +2896,7 @@ date_toLocaleFormat_impl(JSContext *cx, CallArgs args)
|
||||
, args.rval());
|
||||
}
|
||||
|
||||
RootedString fmt(cx, ToString<CanGC>(cx, args[0]));
|
||||
RootedString fmt(cx, ToString<CanGC>(cx, args.handleAt(0)));
|
||||
if (!fmt)
|
||||
return false;
|
||||
|
||||
|
@ -311,7 +311,8 @@ JS_SetWatchPoint(JSContext *cx, JSObject *obj_, jsid id_,
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_WATCH_PROP);
|
||||
return false;
|
||||
} else {
|
||||
if (!ValueToId<CanGC>(cx, IdToValue(id), &propid))
|
||||
RootedValue val(cx, IdToValue(id));
|
||||
if (!ValueToId<CanGC>(cx, val, &propid))
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1022,8 +1023,9 @@ class AutoPropertyDescArray
|
||||
};
|
||||
|
||||
static const char *
|
||||
FormatValue(JSContext *cx, const Value &v, JSAutoByteString &bytes)
|
||||
FormatValue(JSContext *cx, const Value &vArg, JSAutoByteString &bytes)
|
||||
{
|
||||
RootedValue v(cx, vArg);
|
||||
JSString *str = ToString<CanGC>(cx, v);
|
||||
if (!str)
|
||||
return NULL;
|
||||
|
@ -559,7 +559,7 @@ Exception(JSContext *cx, unsigned argc, Value *vp)
|
||||
/* Set the 'message' property. */
|
||||
RootedString message(cx);
|
||||
if (args.hasDefined(0)) {
|
||||
message = ToString<CanGC>(cx, args[0]);
|
||||
message = ToString<CanGC>(cx, args.handleAt(0));
|
||||
if (!message)
|
||||
return false;
|
||||
args[0].setString(message);
|
||||
@ -574,7 +574,7 @@ Exception(JSContext *cx, unsigned argc, Value *vp)
|
||||
RootedScript script(cx, iter.done() ? NULL : iter.script());
|
||||
RootedString filename(cx);
|
||||
if (args.length() > 1) {
|
||||
filename = ToString<CanGC>(cx, args[1]);
|
||||
filename = ToString<CanGC>(cx, args.handleAt(1));
|
||||
if (!filename)
|
||||
return false;
|
||||
args[1].setString(filename);
|
||||
@ -1083,7 +1083,7 @@ js_ReportUncaughtException(JSContext *cx)
|
||||
}
|
||||
|
||||
if (JS_GetProperty(cx, exnObject, filename_str, &roots[4])) {
|
||||
JSString *tmp = ToString<CanGC>(cx, roots[4]);
|
||||
JSString *tmp = ToString<CanGC>(cx, HandleValue::fromMarkedLocation(&roots[4]));
|
||||
if (tmp)
|
||||
filename.encodeLatin1(cx, tmp);
|
||||
}
|
||||
|
@ -1345,7 +1345,7 @@ js::Function(JSContext *cx, unsigned argc, Value *vp)
|
||||
size_t args_length = 0;
|
||||
for (unsigned i = 0; i < n; i++) {
|
||||
/* Collect the lengths for all the function-argument arguments. */
|
||||
arg = ToString<CanGC>(cx, args[i]);
|
||||
arg = ToString<CanGC>(cx, args.handleAt(i));
|
||||
if (!arg)
|
||||
return false;
|
||||
args[i].setString(arg);
|
||||
@ -1465,7 +1465,7 @@ js::Function(JSContext *cx, unsigned argc, Value *vp)
|
||||
if (!args.length())
|
||||
str = cx->runtime->emptyString;
|
||||
else
|
||||
str = ToString<CanGC>(cx, args[args.length() - 1]);
|
||||
str = ToString<CanGC>(cx, args.handleAt(args.length() - 1));
|
||||
if (!str)
|
||||
return false;
|
||||
JSLinearString *linear = str->ensureLinear(cx);
|
||||
|
@ -1092,7 +1092,8 @@ SuppressDeletedPropertyHelper(JSContext *cx, HandleObject obj, StringPredicate p
|
||||
RootedObject obj2(cx);
|
||||
RootedShape prop(cx);
|
||||
RootedId id(cx);
|
||||
if (!ValueToId<CanGC>(cx, StringValue(*idp), &id))
|
||||
RootedValue idv(cx, StringValue(*idp));
|
||||
if (!ValueToId<CanGC>(cx, idv, &id))
|
||||
return false;
|
||||
if (!JSObject::lookupGeneric(cx, proto, id, &obj2, &prop))
|
||||
return false;
|
||||
@ -1223,7 +1224,8 @@ js_IteratorMore(JSContext *cx, HandleObject iterobj, MutableHandleValue rval)
|
||||
if (ni) {
|
||||
JS_ASSERT(!ni->isKeyIter());
|
||||
RootedId id(cx);
|
||||
if (!ValueToId<CanGC>(cx, StringValue(*ni->current()), &id))
|
||||
RootedValue current(cx, StringValue(*ni->current()));
|
||||
if (!ValueToId<CanGC>(cx, current, &id))
|
||||
return false;
|
||||
ni->incCursor();
|
||||
RootedObject obj(cx, ni->obj);
|
||||
|
@ -267,28 +267,28 @@ num_isFinite(JSContext *cx, unsigned argc, Value *vp)
|
||||
static JSBool
|
||||
num_parseFloat(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
JSString *str;
|
||||
double d;
|
||||
const jschar *bp, *end, *ep;
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
if (argc == 0) {
|
||||
vp->setDouble(js_NaN);
|
||||
if (args.length() == 0) {
|
||||
args.rval().setDouble(js_NaN);
|
||||
return JS_TRUE;
|
||||
}
|
||||
str = ToString<CanGC>(cx, vp[2]);
|
||||
JSString *str = ToString<CanGC>(cx, args.handleAt(0));
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
bp = str->getChars(cx);
|
||||
const jschar *bp = str->getChars(cx);
|
||||
if (!bp)
|
||||
return JS_FALSE;
|
||||
end = bp + str->length();
|
||||
const jschar *end = bp + str->length();
|
||||
const jschar *ep;
|
||||
double d;
|
||||
if (!js_strtod(cx, bp, end, &ep, &d))
|
||||
return JS_FALSE;
|
||||
if (ep == bp) {
|
||||
vp->setDouble(js_NaN);
|
||||
args.rval().setDouble(js_NaN);
|
||||
return JS_TRUE;
|
||||
}
|
||||
vp->setNumber(d);
|
||||
args.rval().setDouble(d);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
@ -340,7 +340,7 @@ js::num_parseInt(JSContext *cx, unsigned argc, Value *vp)
|
||||
}
|
||||
|
||||
/* Step 1. */
|
||||
RootedString inputString(cx, ToString<CanGC>(cx, args[0]));
|
||||
RootedString inputString(cx, ToString<CanGC>(cx, args.handleAt(0)));
|
||||
if (!inputString)
|
||||
return false;
|
||||
args[0].setString(inputString);
|
||||
|
@ -634,7 +634,7 @@ js_Stringify(JSContext *cx, MutableHandleValue vp, JSObject *replacer_, Value sp
|
||||
return false;
|
||||
space = NumberValue(d);
|
||||
} else if (ObjectClassIs(spaceObj, ESClass_String, cx)) {
|
||||
JSString *str = ToStringSlow<CanGC>(cx, space);
|
||||
JSString *str = ToStringSlow<CanGC>(cx, spaceRoot);
|
||||
if (!str)
|
||||
return false;
|
||||
space = StringValue(str);
|
||||
@ -834,7 +834,9 @@ js_json_parse(JSContext *cx, unsigned argc, Value *vp)
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
/* Step 1. */
|
||||
JSString *str = (argc >= 1) ? ToString<CanGC>(cx, args[0]) : cx->names().undefined;
|
||||
JSString *str = (args.length() >= 1)
|
||||
? ToString<CanGC>(cx, args.handleAt(0))
|
||||
: cx->names().undefined;
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
|
@ -267,7 +267,8 @@ Shape::dump(JSContext *cx, FILE *fp) const
|
||||
str = JSID_TO_ATOM(propid);
|
||||
} else {
|
||||
JS_ASSERT(JSID_IS_OBJECT(propid));
|
||||
JSString *s = ToStringSlow<CanGC>(cx, IdToValue(propid));
|
||||
RootedValue v(cx, IdToValue(propid));
|
||||
JSString *s = ToStringSlow<CanGC>(cx, v);
|
||||
fputs("object ", fp);
|
||||
str = s ? s->ensureLinear(cx) : NULL;
|
||||
}
|
||||
|
@ -675,7 +675,8 @@ Trap(JSContext *cx, HandleObject handler, HandleValue fval, unsigned argc, Value
|
||||
static bool
|
||||
Trap1(JSContext *cx, HandleObject handler, HandleValue fval, HandleId id, MutableHandleValue rval)
|
||||
{
|
||||
JSString *str = ToString<CanGC>(cx, IdToValue(id));
|
||||
rval.set(IdToValue(id)); // Re-use out-param to avoid Rooted overhead.
|
||||
JSString *str = ToString<CanGC>(cx, rval);
|
||||
if (!str)
|
||||
return false;
|
||||
rval.setString(str);
|
||||
@ -687,7 +688,8 @@ Trap2(JSContext *cx, HandleObject handler, HandleValue fval, HandleId id, Value
|
||||
MutableHandleValue rval)
|
||||
{
|
||||
RootedValue v(cx, v_);
|
||||
JSString *str = ToString<CanGC>(cx, IdToValue(id));
|
||||
rval.set(IdToValue(id)); // Re-use out-param to avoid Rooted overhead.
|
||||
JSString *str = ToString<CanGC>(cx, rval);
|
||||
if (!str)
|
||||
return false;
|
||||
rval.setString(str);
|
||||
@ -948,7 +950,8 @@ ScriptedIndirectProxyHandler::get(JSContext *cx, HandleObject proxy, HandleObjec
|
||||
HandleId id, MutableHandleValue vp)
|
||||
{
|
||||
RootedObject handler(cx, GetIndirectProxyHandlerObject(proxy));
|
||||
JSString *str = ToString<CanGC>(cx, IdToValue(id));
|
||||
RootedValue idv(cx, IdToValue(id));
|
||||
JSString *str = ToString<CanGC>(cx, idv);
|
||||
if (!str)
|
||||
return false;
|
||||
RootedValue value(cx, StringValue(str));
|
||||
@ -967,7 +970,8 @@ ScriptedIndirectProxyHandler::set(JSContext *cx, HandleObject proxy, HandleObjec
|
||||
HandleId id, bool strict, MutableHandleValue vp)
|
||||
{
|
||||
RootedObject handler(cx, GetIndirectProxyHandlerObject(proxy));
|
||||
JSString *str = ToString<CanGC>(cx, IdToValue(id));
|
||||
RootedValue idv(cx, IdToValue(id));
|
||||
JSString *str = ToString<CanGC>(cx, idv);
|
||||
if (!str)
|
||||
return false;
|
||||
RootedValue value(cx, StringValue(str));
|
||||
@ -1338,7 +1342,8 @@ HasOwn(JSContext *cx, HandleObject obj, HandleId id, bool *bp)
|
||||
static bool
|
||||
IdToValue(JSContext *cx, HandleId id, MutableHandleValue value)
|
||||
{
|
||||
JSString *name = ToString<CanGC>(cx, IdToValue(id));
|
||||
value.set(IdToValue(id)); // Re-use out-param to avoid Rooted overhead.
|
||||
JSString *name = ToString<CanGC>(cx, value);
|
||||
if (!name)
|
||||
return false;
|
||||
value.set(StringValue(name));
|
||||
|
@ -2971,13 +2971,15 @@ ASTSerializer::moduleOrFunctionBody(ParseNode *pn, TokenPos *pos, MutableHandleV
|
||||
static JSBool
|
||||
reflect_parse(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
if (argc < 1) {
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
if (args.length() < 1) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_MORE_ARGS_NEEDED,
|
||||
"Reflect.parse", "0", "s");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
RootedString src(cx, ToString<CanGC>(cx, JS_ARGV(cx, vp)[0]));
|
||||
RootedString src(cx, ToString<CanGC>(cx, args.handleAt(0)));
|
||||
if (!src)
|
||||
return JS_FALSE;
|
||||
|
||||
@ -2987,7 +2989,7 @@ reflect_parse(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
|
||||
RootedObject builder(cx);
|
||||
|
||||
RootedValue arg(cx, argc > 1 ? JS_ARGV(cx, vp)[1] : UndefinedValue());
|
||||
RootedValue arg(cx, args.get(1));
|
||||
|
||||
if (!arg.isNullOrUndefined()) {
|
||||
if (!arg.isObject()) {
|
||||
@ -3081,11 +3083,11 @@ reflect_parse(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
|
||||
RootedValue val(cx);
|
||||
if (!serialize.program(pn, &val)) {
|
||||
JS_SET_RVAL(cx, vp, JSVAL_NULL);
|
||||
args.rval().setNull();
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
JS_SET_RVAL(cx, vp, val);
|
||||
args.rval().set(val);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
@ -76,12 +76,11 @@ ArgToRootedString(JSContext *cx, CallArgs &args, unsigned argno)
|
||||
if (argno >= args.length())
|
||||
return cx->names().undefined;
|
||||
|
||||
Value &arg = args[argno];
|
||||
JSString *str = ToString<CanGC>(cx, arg);
|
||||
JSString *str = ToString<CanGC>(cx, args.handleAt(argno));
|
||||
if (!str)
|
||||
return NULL;
|
||||
|
||||
arg = StringValue(str);
|
||||
args[argno] = StringValue(str);
|
||||
return str->ensureLinear(cx);
|
||||
}
|
||||
|
||||
@ -826,8 +825,7 @@ str_localeCompare(JSContext *cx, unsigned argc, Value *vp)
|
||||
if (!str)
|
||||
return false;
|
||||
|
||||
Value thatValue = args.length() > 0 ? args[0] : UndefinedValue();
|
||||
RootedString thatStr(cx, ToString<CanGC>(cx, thatValue));
|
||||
RootedString thatStr(cx, ToString<CanGC>(cx, args.handleOrUndefinedAt(0)));
|
||||
if (!thatStr)
|
||||
return false;
|
||||
|
||||
@ -1720,7 +1718,7 @@ class StringRegExpGuard
|
||||
/* Build RegExp from pattern string. */
|
||||
RootedString opt(cx);
|
||||
if (optarg < args.length()) {
|
||||
opt = ToString<CanGC>(cx, args[optarg]);
|
||||
opt = ToString<CanGC>(cx, args.handleAt(optarg));
|
||||
if (!opt)
|
||||
return false;
|
||||
} else {
|
||||
@ -3181,10 +3179,10 @@ str_concat(JSContext *cx, unsigned argc, Value *vp)
|
||||
return false;
|
||||
|
||||
for (unsigned i = 0; i < args.length(); i++) {
|
||||
JSString *argStr = ToString<NoGC>(cx, args[i]);
|
||||
JSString *argStr = ToString<NoGC>(cx, args.handleAt(i));
|
||||
if (!argStr) {
|
||||
RootedString strRoot(cx, str);
|
||||
argStr = ToString<CanGC>(cx, args[i]);
|
||||
argStr = ToString<CanGC>(cx, args.handleAt(i));
|
||||
if (!argStr)
|
||||
return false;
|
||||
str = strRoot;
|
||||
@ -3508,7 +3506,7 @@ js_String(JSContext *cx, unsigned argc, Value *vp)
|
||||
|
||||
RootedString str(cx);
|
||||
if (args.length() > 0) {
|
||||
str = ToString<CanGC>(cx, args[0]);
|
||||
str = ToString<CanGC>(cx, args.handleAt(0));
|
||||
if (!str)
|
||||
return false;
|
||||
} else {
|
||||
@ -3744,8 +3742,9 @@ template JSFlatString *
|
||||
js_NewStringCopyZ<NoGC>(JSContext *cx, const char *s);
|
||||
|
||||
const char *
|
||||
js_ValueToPrintable(JSContext *cx, const Value &v, JSAutoByteString *bytes, bool asSource)
|
||||
js_ValueToPrintable(JSContext *cx, const Value &vArg, JSAutoByteString *bytes, bool asSource)
|
||||
{
|
||||
RootedValue v(cx, vArg);
|
||||
JSString *str;
|
||||
if (asSource)
|
||||
str = ValueToSource(cx, v);
|
||||
@ -3761,7 +3760,7 @@ js_ValueToPrintable(JSContext *cx, const Value &v, JSAutoByteString *bytes, bool
|
||||
|
||||
template <AllowGC allowGC>
|
||||
JSString *
|
||||
js::ToStringSlow(JSContext *cx, const Value &arg)
|
||||
js::ToStringSlow(JSContext *cx, typename MaybeRooted<Value, allowGC>::HandleType arg)
|
||||
{
|
||||
/* As with ToObjectSlow, callers must verify that |arg| isn't a string. */
|
||||
JS_ASSERT(!arg.isString());
|
||||
@ -3794,10 +3793,10 @@ js::ToStringSlow(JSContext *cx, const Value &arg)
|
||||
}
|
||||
|
||||
template JSString *
|
||||
js::ToStringSlow<CanGC>(JSContext *cx, const Value &arg);
|
||||
js::ToStringSlow<CanGC>(JSContext *cx, HandleValue arg);
|
||||
|
||||
template JSString *
|
||||
js::ToStringSlow<NoGC>(JSContext *cx, const Value &arg);
|
||||
js::ToStringSlow<NoGC>(JSContext *cx, Value arg);
|
||||
|
||||
JSString *
|
||||
js::ValueToSource(JSContext *cx, const Value &v)
|
||||
@ -3817,7 +3816,8 @@ js::ValueToSource(JSContext *cx, const Value &v)
|
||||
|
||||
return js_NewStringCopyN<CanGC>(cx, js_negzero_ucNstr, 2);
|
||||
}
|
||||
return ToString<CanGC>(cx, v);
|
||||
RootedValue vRoot(cx, v);
|
||||
return ToString<CanGC>(cx, vRoot);
|
||||
}
|
||||
|
||||
RootedValue rval(cx, NullValue());
|
||||
|
@ -126,7 +126,7 @@ namespace js {
|
||||
*/
|
||||
template <AllowGC allowGC>
|
||||
extern JSString *
|
||||
ToStringSlow(JSContext *cx, const Value &v);
|
||||
ToStringSlow(JSContext *cx, typename MaybeRooted<Value, allowGC>::HandleType arg);
|
||||
|
||||
/*
|
||||
* Convert the given value to a string. This method includes an inline
|
||||
@ -135,7 +135,7 @@ ToStringSlow(JSContext *cx, const Value &v);
|
||||
*/
|
||||
template <AllowGC allowGC>
|
||||
static JS_ALWAYS_INLINE JSString *
|
||||
ToString(JSContext *cx, const js::Value &v)
|
||||
ToString(JSContext *cx, JS::HandleValue v)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (allowGC) {
|
||||
|
@ -389,7 +389,8 @@ Reify(JSContext *cx, JSCompartment *origin, MutableHandleValue vp)
|
||||
return false;
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
RootedId id(cx);
|
||||
if (!ValueToId<CanGC>(cx, StringValue(ni->begin()[i]), &id))
|
||||
RootedValue v(cx, StringValue(ni->begin()[i]));
|
||||
if (!ValueToId<CanGC>(cx, v, &id))
|
||||
return false;
|
||||
keys.infallibleAppend(id);
|
||||
if (!origin->wrapId(cx, &keys[i]))
|
||||
|
@ -3567,7 +3567,7 @@ GetSelfHostedValue(JSContext *cx, unsigned argc, jsval *vp)
|
||||
"getSelfHostedValue");
|
||||
return false;
|
||||
}
|
||||
RootedAtom srcAtom(cx, ToAtom<CanGC>(cx, args[0]));
|
||||
RootedAtom srcAtom(cx, ToAtom<CanGC>(cx, args.handleAt(0)));
|
||||
if (!srcAtom)
|
||||
return false;
|
||||
RootedPropertyName srcName(cx, srcAtom->asPropertyName());
|
||||
|
@ -112,7 +112,7 @@ ReportObjectRequired(JSContext *cx)
|
||||
}
|
||||
|
||||
bool
|
||||
ValueToIdentifier(JSContext *cx, const Value &v, MutableHandleId id)
|
||||
ValueToIdentifier(JSContext *cx, HandleValue v, MutableHandleId id)
|
||||
{
|
||||
if (!ValueToId<CanGC>(cx, v, id))
|
||||
return false;
|
||||
@ -3247,9 +3247,10 @@ DebuggerScript_getAllOffsets(JSContext *cx, unsigned argc, Value *vp)
|
||||
* Store it in the result array.
|
||||
*/
|
||||
RootedId id(cx);
|
||||
RootedValue v(cx, NumberValue(lineno));
|
||||
offsets = NewDenseEmptyArray(cx);
|
||||
if (!offsets ||
|
||||
!ValueToId<CanGC>(cx, NumberValue(lineno), &id))
|
||||
!ValueToId<CanGC>(cx, v, &id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -4569,7 +4570,7 @@ DebuggerObject_getOwnPropertyDescriptor(JSContext *cx, unsigned argc, Value *vp)
|
||||
THIS_DEBUGOBJECT_OWNER_REFERENT(cx, argc, vp, "getOwnPropertyDescriptor", args, dbg, obj);
|
||||
|
||||
RootedId id(cx);
|
||||
if (!ValueToId<CanGC>(cx, argc >= 1 ? args[0] : UndefinedValue(), &id))
|
||||
if (!ValueToId<CanGC>(cx, args.handleOrUndefinedAt(0), &id))
|
||||
return false;
|
||||
|
||||
/* Bug: This can cause the debuggee to run! */
|
||||
@ -4659,7 +4660,7 @@ DebuggerObject_defineProperty(JSContext *cx, unsigned argc, Value *vp)
|
||||
REQUIRE_ARGC("Debugger.Object.defineProperty", 2);
|
||||
|
||||
RootedId id(cx);
|
||||
if (!ValueToId<CanGC>(cx, args[0], &id))
|
||||
if (!ValueToId<CanGC>(cx, args.handleAt(0), &id))
|
||||
return false;
|
||||
|
||||
const Value &descval = args[1];
|
||||
@ -5302,7 +5303,7 @@ DebuggerEnv_find(JSContext *cx, unsigned argc, Value *vp)
|
||||
THIS_DEBUGENV_OWNER(cx, argc, vp, "find", args, envobj, env, dbg);
|
||||
|
||||
RootedId id(cx);
|
||||
if (!ValueToIdentifier(cx, args[0], &id))
|
||||
if (!ValueToIdentifier(cx, args.handleAt(0), &id))
|
||||
return false;
|
||||
|
||||
{
|
||||
@ -5333,7 +5334,7 @@ DebuggerEnv_getVariable(JSContext *cx, unsigned argc, Value *vp)
|
||||
THIS_DEBUGENV_OWNER(cx, argc, vp, "getVariable", args, envobj, env, dbg);
|
||||
|
||||
RootedId id(cx);
|
||||
if (!ValueToIdentifier(cx, args[0], &id))
|
||||
if (!ValueToIdentifier(cx, args.handleAt(0), &id))
|
||||
return false;
|
||||
|
||||
RootedValue v(cx);
|
||||
@ -5362,7 +5363,7 @@ DebuggerEnv_setVariable(JSContext *cx, unsigned argc, Value *vp)
|
||||
THIS_DEBUGENV_OWNER(cx, argc, vp, "setVariable", args, envobj, env, dbg);
|
||||
|
||||
RootedId id(cx);
|
||||
if (!ValueToIdentifier(cx, args[0], &id))
|
||||
if (!ValueToIdentifier(cx, args.handleAt(0), &id))
|
||||
return false;
|
||||
|
||||
RootedValue v(cx, args[1]);
|
||||
|
@ -1517,8 +1517,7 @@ END_CASE(JSOP_AND)
|
||||
|
||||
#define FETCH_ELEMENT_ID(n, id) \
|
||||
JS_BEGIN_MACRO \
|
||||
const Value &idval_ = regs.sp[n]; \
|
||||
if (!ValueToId<CanGC>(cx, idval_, &id)) \
|
||||
if (!ValueToId<CanGC>(cx, HandleValue::fromMarkedLocation(®s.sp[n]), &id))\
|
||||
goto error; \
|
||||
JS_END_MACRO
|
||||
|
||||
|
@ -121,7 +121,7 @@ intrinsic_AssertionFailed(JSContext *cx, unsigned argc, Value *vp)
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
if (args.length() > 0) {
|
||||
// try to dump the informative string
|
||||
JSString *str = ToString<CanGC>(cx, args[0]);
|
||||
JSString *str = ToString<CanGC>(cx, args.handleAt(0));
|
||||
if (str) {
|
||||
const jschar *chars = str->getChars(cx);
|
||||
if (chars) {
|
||||
|
@ -289,8 +289,10 @@ Shape::getUserId(JSContext *cx, MutableHandleId idp) const
|
||||
#endif
|
||||
if (self->hasShortID()) {
|
||||
int16_t id = self->shortid();
|
||||
if (id < 0)
|
||||
return ValueToId<CanGC>(cx, Int32Value(id), idp);
|
||||
if (id < 0) {
|
||||
RootedValue v(cx, Int32Value(id));
|
||||
return ValueToId<CanGC>(cx, v, idp);
|
||||
}
|
||||
idp.set(INT_TO_JSID(id));
|
||||
} else {
|
||||
idp.set(self->propid());
|
||||
|
Loading…
Reference in New Issue
Block a user