Bug 772303 - Add missing roots for analysis builds; r=bhackett

--HG--
extra : rebase_source : 2a644e24073fa5c7a655e3322c5379009b2f7181
This commit is contained in:
Terrence Cole 2012-08-03 09:41:00 -07:00
parent aa93634107
commit f9cf9a58c5
13 changed files with 36 additions and 22 deletions

View File

@ -170,7 +170,7 @@ EvalKernel(JSContext *cx, const CallArgs &args, EvalType evalType, StackFrame *c
args.rval().set(args[0]);
return true;
}
JSString *str = args[0].toString();
RootedString str(cx, args[0].toString());
// ES5 15.1.2.1 steps 2-8.

View File

@ -3965,7 +3965,7 @@ JS_DefineObject(JSContext *cx, JSObject *objArg, const char *name, JSClass *jscl
if (!clasp)
clasp = &ObjectClass; /* default class is Object */
JSObject *nobj = NewObjectWithClassProto(cx, clasp, proto, obj);
RootedObject nobj(cx, NewObjectWithClassProto(cx, clasp, proto, obj));
if (!nobj)
return NULL;
@ -4356,15 +4356,17 @@ JS_SetElement(JSContext *cx, JSObject *objArg, uint32_t index, jsval *vp)
JS_PUBLIC_API(JSBool)
JS_SetProperty(JSContext *cx, JSObject *objArg, const char *name, jsval *vp)
{
RootedObject obj(cx, objArg);
JSAtom *atom = js_Atomize(cx, name, strlen(name));
return atom && JS_SetPropertyById(cx, objArg, AtomToId(atom), vp);
return atom && JS_SetPropertyById(cx, obj, AtomToId(atom), vp);
}
JS_PUBLIC_API(JSBool)
JS_SetUCProperty(JSContext *cx, JSObject *objArg, const jschar *name, size_t namelen, jsval *vp)
{
RootedObject obj(cx, objArg);
JSAtom *atom = js_AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen));
return atom && JS_SetPropertyById(cx, objArg, AtomToId(atom), vp);
return atom && JS_SetPropertyById(cx, obj, AtomToId(atom), vp);
}
JS_PUBLIC_API(JSBool)

View File

@ -3708,7 +3708,7 @@ NewArray(JSContext *cx, uint32_t length, RawObject protoArg)
Rooted<GlobalObject*> parent(cx, parent_);
RootedObject proto(cx, protoArg);
if (protoArg)
PoisonPtr(reinterpret_cast<uintptr_t *>(protoArg));
PoisonPtr(&protoArg);
if (!proto && !FindProto(cx, &ArrayClass, parent, &proto))
return NULL;

View File

@ -2590,7 +2590,7 @@ static JSBool
date_toJSON(JSContext *cx, unsigned argc, Value *vp)
{
/* Step 1. */
JSObject *obj = ToObject(cx, &vp[1]);
RootedObject obj(cx, ToObject(cx, &vp[1]));
if (!obj)
return false;

View File

@ -383,7 +383,7 @@ js::num_parseInt(JSContext *cx, unsigned argc, Value *vp)
}
/* Step 1. */
JSString *inputString = ToString(cx, args[0]);
RootedString inputString(cx, ToString(cx, args[0]));
if (!inputString)
return false;
args[0].setString(inputString);

View File

@ -335,6 +335,7 @@ obj_toSource(JSContext *cx, unsigned argc, Value *vp)
size_t vlength;
Value *val;
JSString *gsop[2];
SkipRoot skipGsop(cx, &gsop, 2);
JS_CHECK_RECURSION(cx, return JS_FALSE);

View File

@ -261,9 +261,9 @@ class KeyStringifier<uint32_t> {
};
template<>
class KeyStringifier<jsid> {
class KeyStringifier<HandleId> {
public:
static JSString *toString(JSContext *cx, jsid id) {
static JSString *toString(JSContext *cx, HandleId id) {
return IdToString(cx, id);
}
};
@ -274,9 +274,9 @@ class KeyStringifier<jsid> {
*/
template<typename KeyType>
static bool
PreprocessValue(JSContext *cx, JSObject *holder, KeyType key, MutableHandleValue vp, StringifyContext *scx)
PreprocessValue(JSContext *cx, HandleObject holder, KeyType key, MutableHandleValue vp, StringifyContext *scx)
{
JSString *keyStr = NULL;
RootedString keyStr(cx);
/* Step 2. */
if (vp.get().isObject()) {
@ -417,7 +417,7 @@ JO(JSContext *cx, HandleObject obj, StringifyContext *scx)
RootedValue outputValue(cx);
if (!obj->getGeneric(cx, id, &outputValue))
return false;
if (!PreprocessValue(cx, obj, id.get(), &outputValue, scx))
if (!PreprocessValue(cx, obj, HandleId(id), &outputValue, scx))
return false;
if (IsFilteredValue(outputValue))
continue;
@ -737,7 +737,7 @@ js_Stringify(JSContext *cx, MutableHandleValue vp, JSObject *replacer_, Value sp
if (!scx.init())
return false;
if (!PreprocessValue(cx, wrapper, emptyId.get(), vp, &scx))
if (!PreprocessValue(cx, wrapper, HandleId(emptyId), vp, &scx))
return false;
if (IsFilteredValue(vp))
return true;
@ -747,7 +747,7 @@ js_Stringify(JSContext *cx, MutableHandleValue vp, JSObject *replacer_, Value sp
/* ES5 15.12.2 Walk. */
static bool
Walk(JSContext *cx, HandleObject holder, HandleId name, const Value &reviver, MutableHandleValue vp)
Walk(JSContext *cx, HandleObject holder, HandleId name, HandleValue reviver, MutableHandleValue vp)
{
JS_CHECK_RECURSION(cx, return false);
@ -830,7 +830,7 @@ Walk(JSContext *cx, HandleObject holder, HandleId name, const Value &reviver, Mu
}
/* Step 3. */
JSString *key = IdToString(cx, name);
RootedString key(cx, IdToString(cx, name));
if (!key)
return false;
@ -850,7 +850,7 @@ Walk(JSContext *cx, HandleObject holder, HandleId name, const Value &reviver, Mu
}
static bool
Revive(JSContext *cx, const Value &reviver, MutableHandleValue vp)
Revive(JSContext *cx, HandleValue reviver, MutableHandleValue vp)
{
RootedObject obj(cx, NewBuiltinClassInstance(cx, &ObjectClass));
if (!obj)

View File

@ -743,7 +743,7 @@ ArrayToIdVector(JSContext *cx, const Value &array, AutoIdVector &props)
if (array.isPrimitive())
return true;
JSObject *obj = &array.toObject();
RootedObject obj(cx, &array.toObject());
uint32_t length;
if (!js_GetLengthProperty(cx, obj, &length))
return false;

View File

@ -111,8 +111,10 @@ Bindings::lookup(JSContext *cx, PropertyName *name) const
if (!lastBinding)
return BindingIter::Init(this, NULL);
const Bindings *self = this;
SkipRoot skipSelf(cx, &self);
Shape **_;
return BindingIter::Init(this, Shape::search(cx, lastBinding, NameToId(name), &_));
return BindingIter::Init(self, Shape::search(cx, lastBinding, NameToId(name), &_));
}
unsigned

View File

@ -1186,6 +1186,7 @@ str_indexOf(JSContext *cx, unsigned argc, Value *vp)
uint32_t patlen = patstr->length();
const jschar *pat = patstr->chars();
SkipRoot skipPat(cx, &pat);
uint32_t start;
if (args.length() > 1) {

View File

@ -1821,8 +1821,9 @@ class TypedArrayTemplate
* are treated identically.
*/
if (v.isPrimitive() && !v.isMagic() && !v.isUndefined()) {
RootedValue primitive(cx, v);
double dval;
JS_ALWAYS_TRUE(ToNumber(cx, v, &dval));
JS_ALWAYS_TRUE(ToNumber(cx, primitive, &dval));
return nativeFromDouble(dval);
}
@ -1845,6 +1846,7 @@ class TypedArrayTemplate
JS_ASSERT(ar->getArrayLength() == len);
const Value *src = ar->getDenseArrayElements();
SkipRoot skipSrc(cx, &src);
/*
* It is valid to skip the hole check here because nativeFromValue
@ -2429,6 +2431,7 @@ DataViewObject::write(JSContext *cx, Handle<DataViewObject*> obj,
}
uint8_t *data;
SkipRoot skipData(cx, &data);
if (!getDataPointer(cx, obj, args, sizeof(NativeType), &data))
return false;

View File

@ -159,11 +159,12 @@ DataViewObject::is(const Value &v)
inline DataViewObject *
DataViewObject::create(JSContext *cx, uint32_t byteOffset, uint32_t byteLength,
Handle<ArrayBufferObject*> arrayBuffer, JSObject *proto)
Handle<ArrayBufferObject*> arrayBuffer, JSObject *protoArg)
{
JS_ASSERT(byteOffset <= INT32_MAX);
JS_ASSERT(byteLength <= INT32_MAX);
RootedObject proto(cx, protoArg);
RootedObject obj(cx, NewBuiltinClassInstance(cx, &DataViewClass));
if (!obj)
return NULL;

View File

@ -581,10 +581,14 @@ CrossCompartmentWrapper::hasOwn(JSContext *cx, JSObject *wrapper, jsid id, bool
}
bool
CrossCompartmentWrapper::get(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id, Value *vp)
CrossCompartmentWrapper::get(JSContext *cx, JSObject *wrapperArg, JSObject *receiverArg,
jsid idArg, Value *vp)
{
RootedObject wrapper(cx, wrapperArg);
RootedObject receiver(cx, receiverArg);
RootedId id(cx, idArg);
PIERCE(cx, wrapper, GET,
call.destination->wrap(cx, &receiver) && call.destination->wrapId(cx, &id),
call.destination->wrap(cx, receiver.address()) && call.destination->wrapId(cx, id.address()),
DirectWrapper::get(cx, wrapper, receiver, id, vp),
cx->compartment->wrap(cx, vp));
}