Back out 2fe1b4d570df for obvious browser-build bustage, less-obvious shell build bustage. r=ಠ_ಠ

This commit is contained in:
Jeff Walden 2012-06-20 15:49:56 -07:00
parent a60cb0b983
commit af77cfc42f
41 changed files with 458 additions and 671 deletions

View File

@ -155,8 +155,8 @@ JSFunctionSpec MapObject::methods[] = {
JSObject *
MapObject::initClass(JSContext *cx, JSObject *obj)
{
Rooted<GlobalObject*> global(cx, &obj->asGlobal());
return InitClass(cx, global, &class_, JSProto_Map, construct, methods);
return InitClass(cx, Rooted<GlobalObject*>(cx, &obj->asGlobal()),
&class_, JSProto_Map, construct, methods);
}
void
@ -348,8 +348,8 @@ JSFunctionSpec SetObject::methods[] = {
JSObject *
SetObject::initClass(JSContext *cx, JSObject *obj)
{
Rooted<GlobalObject*> global(cx, &obj->asGlobal());
return InitClass(cx, global, &class_, JSProto_Set, construct, methods);
return InitClass(cx, Rooted<GlobalObject*>(cx, &obj->asGlobal()),
&class_, JSProto_Set, construct, methods);
}
void

View File

@ -23,8 +23,8 @@ class RegExpMatchBuilder
JSContext * const cx;
RootedObject array;
bool setProperty(Handle<PropertyName*> name, Value v) {
return !!baseops::DefineProperty(cx, array, name, &v,
bool setProperty(JSAtom *name, Value v) {
return !!baseops::DefineProperty(cx, array, RootedId(cx, AtomToId(name)), &v,
JS_PropertyStub, JS_StrictPropertyStub, JSPROP_ENUMERATE);
}
@ -38,14 +38,12 @@ class RegExpMatchBuilder
}
bool setIndex(int index) {
Rooted<PropertyName*> name(cx, cx->runtime->atomState.indexAtom);
return setProperty(name, Int32Value(index));
return setProperty(cx->runtime->atomState.indexAtom, Int32Value(index));
}
bool setInput(JSString *str) {
JS_ASSERT(str);
Rooted<PropertyName*> name(cx, cx->runtime->atomState.inputAtom);
return setProperty(name, StringValue(str));
return setProperty(cx->runtime->atomState.inputAtom, StringValue(str));
}
};
@ -196,8 +194,8 @@ CompileRegExpObject(JSContext *cx, RegExpObjectBuilder &builder, CallArgs args)
{
if (args.length() == 0) {
RegExpStatics *res = cx->regExpStatics();
Rooted<PropertyName*> empty(cx, cx->runtime->emptyString);
RegExpObject *reobj = builder.build(empty, res->getFlags());
RegExpObject *reobj = builder.build(RootedAtom(cx, cx->runtime->emptyString),
res->getFlags());
if (!reobj)
return false;
args.rval() = ObjectValue(*reobj);
@ -244,8 +242,7 @@ CompileRegExpObject(JSContext *cx, RegExpObjectBuilder &builder, CallArgs args)
if (!sourceObj.getProperty(cx, cx->runtime->atomState.sourceAtom, &v))
return false;
Rooted<JSAtom*> sourceAtom(cx, &v.toString()->asAtom());
RegExpObject *reobj = builder.build(sourceAtom, flags);
RegExpObject *reobj = builder.build(RootedAtom(cx, &v.toString()->asAtom()), flags);
if (!reobj)
return false;
@ -465,8 +462,7 @@ js_InitRegExpClass(JSContext *cx, JSObject *obj)
proto->setPrivate(NULL);
RegExpObjectBuilder builder(cx, &proto->asRegExp());
Rooted<PropertyName*> empty(cx, cx->runtime->emptyString);
if (!builder.build(empty, RegExpFlag(0)))
if (!builder.build(RootedAtom(cx, cx->runtime->emptyString), RegExpFlag(0)))
return NULL;
if (!DefinePropertiesAndBrand(cx, proto, NULL, regexp_methods))

View File

@ -5614,8 +5614,8 @@ EmitObject(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
if (obj) {
JS_ASSERT(!obj->inDictionaryMode());
Rooted<jsid> id(cx, AtomToId(pn3->pn_atom));
if (!DefineNativeProperty(cx, obj, id, UndefinedValue(), NULL, NULL,
if (!DefineNativeProperty(cx, obj, RootedId(cx, AtomToId(pn3->pn_atom)),
UndefinedValue(), NULL, NULL,
JSPROP_ENUMERATE, 0, 0))
{
return false;

View File

@ -540,8 +540,7 @@ BindLocalVariable(JSContext *cx, TreeContext *tc, ParseNode *pn, BindingKind kin
JS_ASSERT(kind == VARIABLE || kind == CONSTANT);
unsigned index = tc->sc->bindings.numVars();
Rooted<JSAtom*> atom(cx, pn->pn_atom);
if (!tc->sc->bindings.add(cx, atom, kind))
if (!tc->sc->bindings.add(cx, RootedAtom(cx, pn->pn_atom), kind))
return false;
if (!pn->pn_cookie.set(cx, tc->staticLevel, index))
@ -605,7 +604,7 @@ Parser::functionBody(FunctionBodyType type)
if (!CheckStrictParameters(context, this))
return NULL;
Rooted<PropertyName*> arguments(context, context->runtime->atomState.argumentsAtom);
Rooted<PropertyName*> const arguments(context, context->runtime->atomState.argumentsAtom);
/*
* Non-top-level functions use JSOP_DEFFUN which is a dynamic scope
@ -6852,8 +6851,8 @@ Parser::primaryExpr(TokenKind tt, bool afterDoubleDot)
pn->pn_xflags |= PNX_NONCONST;
/* NB: Getter function in { get x(){} } is unnamed. */
Rooted<PropertyName*> funName(context, NULL);
pn2 = functionDef(funName, op == JSOP_GETTER ? Getter : Setter, Expression);
pn2 = functionDef(RootedPropertyName(context, NULL),
op == JSOP_GETTER ? Getter : Setter, Expression);
if (!pn2)
return NULL;
TokenPos pos = {begin, pn2->pn_pos.end};

View File

@ -96,7 +96,7 @@ class Handle
* Construct a handle from an explicitly rooted location. This is the
* normal way to create a handle, and normally happens implicitly.
*/
template <typename S> inline Handle(Rooted<S> &root);
template <typename S> inline Handle(const Rooted<S> &root);
const T *address() const { return ptr; }
T value() const { return *ptr; }
@ -163,6 +163,15 @@ class Rooted
Rooted(JSContext *cx) { init(cx, RootMethods<T>::initial()); }
Rooted(JSContext *cx, T initial) { init(cx, initial); }
/*
* This method is only necessary due to an obscure C++98 requirement (that
* there be an accessible, usable copy constructor when passing a temporary
* to an implicitly-called constructor for use with a const-ref parameter).
* (Head spinning yet?) We can remove this when we build the JS engine
* with -std=c++11.
*/
operator Handle<T> () const { return Handle<T>(*this); }
~Rooted()
{
#if defined(JSGC_ROOT_ANALYSIS) || defined(JSGC_USE_EXACT_ROOTING)
@ -208,7 +217,7 @@ class Rooted
template<typename T> template <typename S>
inline
Handle<T>::Handle(Rooted<S> &root)
Handle<T>::Handle(const Rooted<S> &root)
{
testAssign<S>();
ptr = reinterpret_cast<const T *>(root.address());

View File

@ -1779,8 +1779,7 @@ JS_InitStandardClasses(JSContext *cx, JSObject *obj)
assertSameCompartment(cx, obj);
Rooted<GlobalObject*> global(cx, &obj->global());
return GlobalObject::initStandardClasses(cx, global);
return GlobalObject::initStandardClasses(cx, Rooted<GlobalObject*>(cx, &obj->global()));
}
#define CLASP(name) (&name##Class)
@ -3144,7 +3143,7 @@ JS_ConvertStub(JSContext *cx, JSHandleObject obj, JSType type, jsval *vp)
{
JS_ASSERT(type != JSTYPE_OBJECT && type != JSTYPE_FUNCTION);
JS_ASSERT(obj);
return DefaultValue(cx, obj, type, vp);
return DefaultValue(cx, RootedObject(cx, obj), type, vp);
}
JS_PUBLIC_API(JSObject *)
@ -3232,15 +3231,12 @@ JS_GetPrototype(JSObject *obj)
}
JS_PUBLIC_API(JSBool)
JS_SetPrototype(JSContext *cx, JSObject *obj_, JSObject *proto_)
JS_SetPrototype(JSContext *cx, JSObject *obj, JSObject *proto)
{
AssertNoGC(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj_, proto_);
Rooted<JSObject*> obj(cx, obj_);
Rooted<JSObject*> proto(cx, proto_);
return SetProto(cx, obj, proto, JS_FALSE);
assertSameCompartment(cx, obj, proto);
return SetProto(cx, RootedObject(cx, obj), RootedObject(cx, proto), JS_FALSE);
}
JS_PUBLIC_API(JSObject *)
@ -3251,17 +3247,14 @@ JS_GetParent(JSObject *obj)
}
JS_PUBLIC_API(JSBool)
JS_SetParent(JSContext *cx, JSObject *obj_, JSObject *parent_)
JS_SetParent(JSContext *cx, JSObject *obj, JSObject *parent)
{
AssertNoGC(cx);
CHECK_REQUEST(cx);
JS_ASSERT(!obj_->isScope());
JS_ASSERT(parent_ || !obj_->getParent());
assertSameCompartment(cx, obj_, parent_);
Rooted<JSObject*> obj(cx, obj_);
Rooted<JSObject*> parent(cx, parent_);
return JSObject::setParent(cx, obj, parent);
JS_ASSERT(!obj->isScope());
JS_ASSERT(parent || !obj->getParent());
assertSameCompartment(cx, obj, parent);
return JSObject::setParent(cx, RootedObject(cx, obj), RootedObject(cx, parent));
}
JS_PUBLIC_API(JSObject *)
@ -3811,15 +3804,12 @@ JS_DefineUCPropertyWithTinyId(JSContext *cx, JSObject *obj, const jschar *name,
}
JS_PUBLIC_API(JSBool)
JS_DefineOwnProperty(JSContext *cx, JSObject *obj_, jsid id_, jsval descriptor, JSBool *bp)
JS_DefineOwnProperty(JSContext *cx, JSObject *obj, jsid id, jsval descriptor, JSBool *bp)
{
AssertNoGC(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj_, id_, descriptor);
Rooted<JSObject*> obj(cx, obj_);
Rooted<jsid> id(cx, id_);
return js_DefineOwnProperty(cx, obj, id, descriptor, bp);
assertSameCompartment(cx, obj, id, descriptor);
return js_DefineOwnProperty(cx, RootedObject(cx, obj), RootedId(cx, id), descriptor, bp);
}
JS_PUBLIC_API(JSObject *)
@ -3995,14 +3985,11 @@ JS_GetUCPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj,
}
JS_PUBLIC_API(JSBool)
JS_GetOwnPropertyDescriptor(JSContext *cx, JSObject *obj_, jsid id_, jsval *vp)
JS_GetOwnPropertyDescriptor(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
{
AssertNoGC(cx);
CHECK_REQUEST(cx);
Rooted<JSObject*> obj(cx, obj_);
Rooted<jsid> id(cx, id_);
return GetOwnPropertyDescriptor(cx, obj, id, vp);
return GetOwnPropertyDescriptor(cx, RootedObject(cx, obj), RootedId(cx, id), vp);
}
static JSBool
@ -4031,8 +4018,7 @@ JS_SetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name,
unsigned attrs, JSBool *foundp)
{
JSAtom *atom = js_Atomize(cx, name, strlen(name));
Rooted<jsid> id(cx, AtomToId(atom));
return atom && SetPropertyAttributesById(cx, obj, id, attrs, foundp);
return atom && SetPropertyAttributesById(cx, obj, RootedId(cx, AtomToId(atom)), attrs, foundp);
}
JS_PUBLIC_API(JSBool)
@ -4040,8 +4026,7 @@ JS_SetUCPropertyAttributes(JSContext *cx, JSObject *obj, const jschar *name, siz
unsigned attrs, JSBool *foundp)
{
JSAtom *atom = js_AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen));
Rooted<jsid> id(cx, AtomToId(atom));
return atom && SetPropertyAttributesById(cx, obj, id, attrs, foundp);
return atom && SetPropertyAttributesById(cx, obj, RootedId(cx, AtomToId(atom)), attrs, foundp);
}
JS_PUBLIC_API(JSBool)
@ -4065,11 +4050,9 @@ JS_ForwardGetPropertyTo(JSContext *cx, JSObject *obj, jsid id_, JSObject *onBeha
}
JS_PUBLIC_API(JSBool)
JS_GetPropertyByIdDefault(JSContext *cx, JSObject *obj_, jsid id_, jsval def, jsval *vp)
JS_GetPropertyByIdDefault(JSContext *cx, JSObject *obj, jsid id, jsval def, jsval *vp)
{
Rooted<JSObject*> obj(cx, obj_);
Rooted<jsid> id(cx, id_);
return baseops::GetPropertyDefault(cx, obj, id, def, vp);
return baseops::GetPropertyDefault(cx, RootedObject(cx, obj), RootedId(cx, id), def, vp);
}
JS_PUBLIC_API(JSBool)
@ -4201,10 +4184,8 @@ JS_DeletePropertyById2(JSContext *cx, JSObject *obj, jsid id, jsval *rval)
assertSameCompartment(cx, obj, id);
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED);
if (JSID_IS_SPECIAL(id)) {
Rooted<SpecialId> sid(cx, JSID_TO_SPECIALID(id));
return obj->deleteSpecial(cx, sid, rval, false);
}
if (JSID_IS_SPECIAL(id))
return obj->deleteSpecial(cx, Rooted<SpecialId>(cx, JSID_TO_SPECIALID(id)), rval, false);
return obj->deleteByValue(cx, IdToValue(id), rval, false);
}
@ -4450,14 +4431,12 @@ JS_NextProperty(JSContext *cx, JSObject *iterobj, jsid *idp)
}
JS_PUBLIC_API(JSObject *)
JS_NewElementIterator(JSContext *cx, JSObject *obj_)
JS_NewElementIterator(JSContext *cx, JSObject *obj)
{
AssertNoGC(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj_);
Rooted<JSObject*> obj(cx, obj_);
return ElementIteratorObject::create(cx, obj);
assertSameCompartment(cx, obj);
return ElementIteratorObject::create(cx, RootedObject(cx, obj));
}
JS_PUBLIC_API(JSObject *)
@ -4749,8 +4728,6 @@ JS_DefineFunctions(JSContext *cx, JSObject *obj_, JSFunctionSpec *fs)
if (!atom)
return JS_FALSE;
Rooted<jsid> id(cx, AtomToId(atom));
/*
* Define a generic arity N+1 static method for the arity N prototype
* method if flags contains JSFUN_GENERIC_NATIVE.
@ -4763,8 +4740,11 @@ JS_DefineFunctions(JSContext *cx, JSObject *obj_, JSFunctionSpec *fs)
}
flags &= ~JSFUN_GENERIC_NATIVE;
fun = js_DefineFunction(cx, ctor, id, js_generic_native_method_dispatcher,
fs->nargs + 1, flags, JSFunction::ExtendedFinalizeKind);
fun = js_DefineFunction(cx, ctor, RootedId(cx, AtomToId(atom)),
js_generic_native_method_dispatcher,
fs->nargs + 1,
flags,
JSFunction::ExtendedFinalizeKind);
if (!fun)
return JS_FALSE;
@ -4775,7 +4755,8 @@ JS_DefineFunctions(JSContext *cx, JSObject *obj_, JSFunctionSpec *fs)
fun->setExtendedSlot(0, PrivateValue(fs));
}
fun = js_DefineFunction(cx, obj, id, fs->call, fs->nargs, flags);
fun = js_DefineFunction(cx, obj,
RootedId(cx, AtomToId(atom)), fs->call, fs->nargs, flags);
if (!fun)
return JS_FALSE;
}
@ -4795,8 +4776,7 @@ JS_DefineFunction(JSContext *cx, JSObject *obj_, const char *name, JSNative call
JSAtom *atom = js_Atomize(cx, name, strlen(name));
if (!atom)
return NULL;
Rooted<jsid> id(cx, AtomToId(atom));
return js_DefineFunction(cx, obj, id, call, nargs, attrs);
return js_DefineFunction(cx, obj, RootedId(cx, AtomToId(atom)), call, nargs, attrs);
}
JS_PUBLIC_API(JSFunction *)
@ -4813,8 +4793,7 @@ JS_DefineUCFunction(JSContext *cx, JSObject *obj_,
JSAtom *atom = js_AtomizeChars(cx, name, AUTO_NAMELEN(name, namelen));
if (!atom)
return NULL;
Rooted<jsid> id(cx, AtomToId(atom));
return js_DefineFunction(cx, obj, id, call, nargs, attrs);
return js_DefineFunction(cx, obj, RootedId(cx, AtomToId(atom)), call, nargs, attrs);
}
extern JS_PUBLIC_API(JSFunction *)
@ -5189,10 +5168,11 @@ CompileUCFunctionForPrincipalsCommon(JSContext *cx, JSObject *obj_,
return NULL;
}
if (obj && funAtom) {
Rooted<jsid> id(cx, AtomToId(funAtom));
if (!obj->defineGeneric(cx, id, ObjectValue(*fun), NULL, NULL, JSPROP_ENUMERATE))
return NULL;
if (obj && funAtom &&
!obj->defineGeneric(cx, RootedId(cx, AtomToId(funAtom)), ObjectValue(*fun), NULL, NULL,
JSPROP_ENUMERATE))
{
return NULL;
}
return fun;
@ -5491,11 +5471,8 @@ JS_CallFunctionName(JSContext *cx, JSObject *obj_, const char *name, unsigned ar
Value v;
JSAtom *atom = js_Atomize(cx, name, strlen(name));
if (!atom)
return false;
Rooted<jsid> id(cx, AtomToId(atom));
return GetMethod(cx, obj, id, 0, &v) &&
return atom &&
GetMethod(cx, obj, RootedId(cx, AtomToId(atom)), 0, &v) &&
Invoke(cx, ObjectOrNullValue(obj), v, argc, argv, rval);
}
@ -5874,9 +5851,7 @@ JS_ConcatStrings(JSContext *cx, JSString *left, JSString *right)
{
AssertNoGC(cx);
CHECK_REQUEST(cx);
Rooted<JSString*> lstr(cx, left);
Rooted<JSString*> rstr(cx, right);
return js_ConcatStrings(cx, lstr, rstr);
return js_ConcatStrings(cx, RootedString(cx, left), RootedString(cx, right));
}
JS_PUBLIC_API(const jschar *)

View File

@ -716,8 +716,7 @@ static JSBool
array_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, JSObject **objp,
JSProperty **propp)
{
Rooted<jsid> id(cx, NameToId(name));
return array_lookupGeneric(cx, obj, id, objp, propp);
return array_lookupGeneric(cx, obj, RootedId(cx, NameToId(name)), objp, propp);
}
static JSBool
@ -745,8 +744,7 @@ static JSBool
array_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, JSObject **objp,
JSProperty **propp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return array_lookupGeneric(cx, obj, id, objp, propp);
return array_lookupGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), objp, propp);
}
JSBool
@ -777,10 +775,8 @@ array_getProperty(JSContext *cx, HandleObject obj, HandleObject receiver, Handle
return true;
}
if (!obj->isDenseArray()) {
Rooted<jsid> id(cx, NameToId(name));
return baseops::GetProperty(cx, obj, receiver, id, vp);
}
if (!obj->isDenseArray())
return baseops::GetProperty(cx, obj, receiver, RootedId(cx, NameToId(name)), vp);
JSObject *proto = obj->getProto();
if (!proto) {
@ -825,8 +821,7 @@ array_getSpecial(JSContext *cx, HandleObject obj, HandleObject receiver, HandleS
return true;
}
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return baseops::GetProperty(cx, obj, receiver, id, vp);
return baseops::GetProperty(cx, obj, receiver, RootedId(cx, SPECIALID_TO_JSID(sid)), vp);
}
static JSBool
@ -838,9 +833,9 @@ array_getGeneric(JSContext *cx, HandleObject obj, HandleObject receiver, HandleI
if (IsDefinitelyIndex(idval, &index))
return array_getElement(cx, obj, receiver, index, vp);
Rooted<SpecialId> sid(cx);
if (ValueIsSpecial(obj, &idval, sid.address(), cx))
return array_getSpecial(cx, obj, receiver, sid, vp);
SpecialId sid;
if (ValueIsSpecial(obj, &idval, &sid, cx))
return array_getSpecial(cx, obj, receiver, Rooted<SpecialId>(cx, sid), vp);
JSAtom *atom = ToAtom(cx, idval);
if (!atom)
@ -849,8 +844,7 @@ array_getGeneric(JSContext *cx, HandleObject obj, HandleObject receiver, HandleI
if (atom->isIndex(&index))
return array_getElement(cx, obj, receiver, index, vp);
Rooted<PropertyName*> name(cx, atom->asPropertyName());
return array_getProperty(cx, obj, receiver, name, vp);
return array_getProperty(cx, obj, receiver, RootedPropertyName(cx, atom->asPropertyName()), vp);
}
static JSBool
@ -910,8 +904,7 @@ array_setGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *vp, JSBool
static JSBool
array_setProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *vp, JSBool strict)
{
Rooted<jsid> id(cx, NameToId(name));
return array_setGeneric(cx, obj, id, vp, strict);
return array_setGeneric(cx, obj, RootedId(cx, NameToId(name)), vp, strict);
}
static JSBool
@ -956,8 +949,7 @@ array_setElement(JSContext *cx, HandleObject obj, uint32_t index, Value *vp, JSB
static JSBool
array_setSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *vp, JSBool strict)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return array_setGeneric(cx, obj, id, vp, strict);
return array_setGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), vp, strict);
}
JSBool
@ -990,7 +982,7 @@ array_defineGeneric(JSContext *cx, HandleObject obj, HandleId id, const Value *v
return JS_TRUE;
if (!obj->isDenseArray())
return baseops::DefineGeneric(cx, obj, id, value, getter, setter, attrs);
return baseops::DefineProperty(cx, obj, id, value, getter, setter, attrs);
do {
uint32_t i = 0; // init to shut GCC up
@ -1016,15 +1008,14 @@ array_defineGeneric(JSContext *cx, HandleObject obj, HandleId id, const Value *v
if (!JSObject::makeDenseArraySlow(cx, obj))
return false;
return baseops::DefineGeneric(cx, obj, id, value, getter, setter, attrs);
return baseops::DefineProperty(cx, obj, id, value, getter, setter, attrs);
}
static JSBool
array_defineProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, const Value *value,
JSPropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
Rooted<jsid> id(cx, NameToId(name));
return array_defineGeneric(cx, obj, id, value, getter, setter, attrs);
return array_defineGeneric(cx, obj, RootedId(cx, NameToId(name)), value, getter, setter, attrs);
}
namespace js {
@ -1072,8 +1063,8 @@ static JSBool
array_defineSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return array_defineGeneric(cx, obj, id, value, getter, setter, attrs);
return array_defineGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)),
value, getter, setter, attrs);
}
static JSBool
@ -1164,7 +1155,7 @@ array_deleteElement(JSContext *cx, HandleObject obj, uint32_t index, Value *rval
obj->setDenseArrayElement(index, MagicValue(JS_ARRAY_HOLE));
}
if (!js_SuppressDeletedElement(cx, obj, index))
if (!js_SuppressDeletedElement(cx, RootedObject(cx, obj), index))
return false;
rval->setBoolean(true);
@ -1713,8 +1704,7 @@ array_toLocaleString(JSContext *cx, unsigned argc, Value *vp)
* Passing comma here as the separator. Need a way to get a
* locale-specific version.
*/
Rooted<JSString*> none(cx, NULL);
return array_toString_sub(cx, obj, JS_TRUE, none, args);
return array_toString_sub(cx, obj, JS_TRUE, RootedString(cx), args);
}
static inline bool
@ -2395,7 +2385,7 @@ NewbornArrayPushImpl(JSContext *cx, HandleObject obj, const Value &v)
/* This can happen in one evil case. See bug 630377. */
RootedId id(cx);
return IndexToId(cx, length, id.address()) &&
baseops::DefineGeneric(cx, obj, id, &v, NULL, NULL, JSPROP_ENUMERATE);
baseops::DefineProperty(cx, obj, id, &v, NULL, NULL, JSPROP_ENUMERATE);
}
JS_ASSERT(obj->isDenseArray());

View File

@ -657,7 +657,7 @@ struct JSRuntime : js::RuntimeFriendFields
js::Value negativeInfinityValue;
js::Value positiveInfinityValue;
js::PropertyName *emptyString;
JSAtom *emptyString;
/* List of active contexts sharing this runtime. */
JSCList contextList;

View File

@ -167,7 +167,7 @@ JSCompartment::wrap(JSContext *cx, Value *vp)
/* Unwrap incoming objects. */
if (vp->isObject()) {
Rooted<JSObject*> obj(cx, &vp->toObject());
JSObject *obj = &vp->toObject();
if (obj->compartment() == this)
return WrapForSameCompartment(cx, obj, vp);
@ -194,7 +194,7 @@ JSCompartment::wrap(JSContext *cx, Value *vp)
#ifdef DEBUG
{
JSObject *outer = GetOuterObject(cx, obj);
JSObject *outer = GetOuterObject(cx, RootedObject(cx, obj));
JS_ASSERT(outer && outer == obj);
}
#endif

View File

@ -2699,8 +2699,8 @@ js_InitDateClass(JSContext *cx, JSObject *obj)
RootedId toUTCStringId(cx, NameToId(cx->runtime->atomState.toUTCStringAtom));
RootedId toGMTStringId(cx, NameToId(cx->runtime->atomState.toGMTStringAtom));
if (!baseops::GetProperty(cx, dateProto, toUTCStringId, &toUTCStringFun) ||
!baseops::DefineGeneric(cx, dateProto, toGMTStringId, &toUTCStringFun,
JS_PropertyStub, JS_StrictPropertyStub, 0))
!baseops::DefineProperty(cx, dateProto, toGMTStringId, &toUTCStringFun,
JS_PropertyStub, JS_StrictPropertyStub, 0))
{
return NULL;
}

View File

@ -783,8 +783,7 @@ GetPropertyDesc(JSContext *cx, JSObject *obj_, Shape *shape, JSPropertyDesc *pd)
lastException = cx->getPendingException();
cx->clearPendingException();
Rooted<jsid> id(cx, shape->propid());
if (!baseops::GetProperty(cx, obj, id, &pd->value)) {
if (!baseops::GetProperty(cx, obj, RootedId(cx, shape->propid()), &pd->value)) {
if (!cx->isExceptionPending()) {
pd->flags = JSPD_ERROR;
pd->value = JSVAL_VOID;

View File

@ -269,8 +269,7 @@ InitExnPrivate(JSContext *cx, HandleObject exnObject, HandleString message,
if (checkAccess && i.isNonEvalFunctionFrame()) {
Value v = NullValue();
RootedId callerid(cx, NameToId(cx->runtime->atomState.callerAtom));
Rooted<JSObject*> obj(cx, i.callee());
if (!checkAccess(cx, obj, callerid, JSACC_READ, &v))
if (!checkAccess(cx, RootedObject(cx, i.callee()), callerid, JSACC_READ, &v))
break;
}

View File

@ -231,8 +231,8 @@ JS_DefineFunctionsWithHelp(JSContext *cx, JSObject *obj_, const JSFunctionSpecWi
return false;
RootedFunction fun(cx);
Rooted<jsid> id(cx, AtomToId(atom));
fun = js_DefineFunction(cx, obj, id, fs->call, fs->nargs, fs->flags);
fun = js_DefineFunction(cx, obj, RootedId(cx, AtomToId(atom)),
fs->call, fs->nargs, fs->flags);
if (!fun)
return false;
@ -338,8 +338,9 @@ js::DefineFunctionWithReserved(JSContext *cx, JSObject *obj_, const char *name,
JSAtom *atom = js_Atomize(cx, name, strlen(name));
if (!atom)
return NULL;
Rooted<jsid> id(cx, AtomToId(atom));
return js_DefineFunction(cx, obj, id, call, nargs, attrs, JSFunction::ExtendedFinalizeKind);
return js_DefineFunction(cx, obj, RootedId(cx, AtomToId(atom)),
call, nargs, attrs,
JSFunction::ExtendedFinalizeKind);
}
JS_FRIEND_API(JSFunction *)

View File

@ -426,8 +426,7 @@ js::CloneInterpretedFunction(JSContext *cx, JSFunction *srcFun)
if (!clone->clearType(cx))
return NULL;
Rooted<JSScript*> srcScript(cx, srcFun->script());
JSScript *clonedScript = CloneScript(cx, srcScript);
JSScript *clonedScript = CloneScript(cx, RootedScript(cx, srcFun->script()));
if (!clonedScript)
return NULL;

View File

@ -206,8 +206,7 @@ CloneFunctionObjectIfNotSingleton(JSContext *cx, HandleFunction fun, HandleObjec
* with its type in existence.
*/
if (fun->hasSingletonType()) {
Rooted<JSObject*> obj(cx, SkipScopeParent(parent));
if (!JSObject::setParent(cx, fun, obj))
if (!JSObject::setParent(cx, fun, RootedObject(cx, SkipScopeParent(parent))))
return NULL;
fun->setEnvironment(parent);
return fun;
@ -231,9 +230,10 @@ CloneFunctionObject(JSContext *cx, HandleFunction fun)
if (fun->hasSingletonType())
return fun;
Rooted<JSObject*> env(cx, fun->environment());
Rooted<JSObject*> proto(cx, fun->getProto());
return js_CloneFunctionObject(cx, fun, env, proto, JSFunction::ExtendedFinalizeKind);
return js_CloneFunctionObject(cx, fun,
RootedObject(cx, fun->environment()),
RootedObject(cx, fun->getProto()),
JSFunction::ExtendedFinalizeKind);
}
} /* namespace js */

View File

@ -1682,8 +1682,8 @@ TypeSet::isOwnProperty(JSContext *cx, TypeObject *object, bool configurable)
*/
if (object->flags & OBJECT_FLAG_NEW_SCRIPT_REGENERATE) {
if (object->newScript) {
Rooted<TypeObject*> typeObj(cx, object);
CheckNewScriptProperties(cx, typeObj, object->newScript->fun);
CheckNewScriptProperties(cx, RootedTypeObject(cx, object),
object->newScript->fun);
} else {
JS_ASSERT(object->flags & OBJECT_FLAG_NEW_SCRIPT_CLEARED);
object->flags &= ~OBJECT_FLAG_NEW_SCRIPT_REGENERATE;

View File

@ -537,8 +537,7 @@ js::LooselyEqual(JSContext *cx, const Value &lval, const Value &rval, bool *resu
if (JSEqualityOp eq = l->getClass()->ext.equality) {
JSBool res;
Rooted<JSObject*> lobj(cx, l);
if (!eq(cx, lobj, &rval, &res))
if (!eq(cx, RootedObject(cx, l), &rval, &res))
return false;
*result = !!res;
return true;
@ -984,8 +983,7 @@ IteratorMore(JSContext *cx, JSObject *iterobj, bool *cond, Value *rval)
return true;
}
}
Rooted<JSObject*> iobj(cx, iterobj);
if (!js_IteratorMore(cx, iobj, rval))
if (!js_IteratorMore(cx, RootedObject(cx, iterobj), rval))
return false;
*cond = rval->isTrue();
return true;

View File

@ -125,8 +125,7 @@ ValuePropertyBearer(JSContext *cx, StackFrame *fp, const Value &v, int spindex)
}
inline bool
NativeGet(JSContext *cx, Handle<JSObject*> obj, Handle<JSObject*> pobj, const Shape *shape,
unsigned getHow, Value *vp)
NativeGet(JSContext *cx, JSObject *obj, JSObject *pobj, const Shape *shape, unsigned getHow, Value *vp)
{
if (shape->isDataDescriptor() && shape->hasDefaultGetter()) {
/* Fast path for Object instance properties. */
@ -212,9 +211,9 @@ GetPropertyOperation(JSContext *cx, jsbytecode *pc, const Value &lval, Value *vp
return false;
PropertyCacheEntry *entry;
Rooted<JSObject*> obj2(cx);
JSObject *obj2;
PropertyName *name;
JS_PROPERTY_CACHE(cx).test(cx, pc, obj.reference(), obj2.reference(), entry, name);
JS_PROPERTY_CACHE(cx).test(cx, pc, obj.reference(), obj2, entry, name);
if (!name) {
AssertValidPropertyCacheHit(cx, obj, obj2, entry);
if (!NativeGet(cx, obj, obj2, entry->prop, JSGET_CACHE_RESULT, vp))
@ -337,9 +336,9 @@ NameOperation(JSContext *cx, jsbytecode *pc, Value *vp)
obj = &obj->global();
PropertyCacheEntry *entry;
Rooted<JSObject*> obj2(cx);
JSObject *obj2;
RootedPropertyName name(cx);
JS_PROPERTY_CACHE(cx).test(cx, pc, obj.reference(), obj2.reference(), entry, name.reference());
JS_PROPERTY_CACHE(cx).test(cx, pc, obj.reference(), obj2, entry, name.reference());
if (!name) {
AssertValidPropertyCacheHit(cx, obj, obj2, entry);
if (!NativeGet(cx, obj, obj2, entry->prop, 0, vp))
@ -348,7 +347,7 @@ NameOperation(JSContext *cx, jsbytecode *pc, Value *vp)
}
JSProperty *prop;
if (!FindPropertyHelper(cx, name, true, obj, obj.address(), obj2.address(), &prop))
if (!FindPropertyHelper(cx, name, true, obj, obj.address(), &obj2, &prop))
return false;
if (!prop) {
/* Kludge to allow (typeof foo == "undefined") tests. */
@ -365,12 +364,11 @@ NameOperation(JSContext *cx, jsbytecode *pc, Value *vp)
/* Take the slow path if prop was not found in a native object. */
if (!obj->isNative() || !obj2->isNative()) {
Rooted<jsid> id(cx, NameToId(name));
if (!obj->getGeneric(cx, id, vp))
if (!obj->getGeneric(cx, RootedId(cx, NameToId(name)), vp))
return false;
} else {
Shape *shape = (Shape *)prop;
Rooted<JSObject*> normalized(cx, obj);
JSObject *normalized = obj;
if (normalized->getClass() == &WithClass && !shape->hasDefaultGetter())
normalized = &normalized->asWith().object();
if (!NativeGet(cx, normalized, obj2, shape, 0, vp))

View File

@ -84,21 +84,19 @@ Class js::ObjectClass = {
};
JS_FRIEND_API(JSObject *)
JS_ObjectToInnerObject(JSContext *cx, JSObject *obj_)
JS_ObjectToInnerObject(JSContext *cx, JSObject *obj)
{
if (!obj_) {
if (!obj) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INACTIVE);
return NULL;
}
Rooted<JSObject*> obj(cx, obj_);
return GetInnerObject(cx, obj);
return GetInnerObject(cx, RootedObject(cx, obj));
}
JS_FRIEND_API(JSObject *)
JS_ObjectToOuterObject(JSContext *cx, JSObject *obj_)
JS_ObjectToOuterObject(JSContext *cx, JSObject *obj)
{
Rooted<JSObject*> obj(cx, obj_);
return GetOuterObject(cx, obj);
return GetOuterObject(cx, RootedObject(cx, obj));
}
#if JS_HAS_OBJ_PROTO_PROP
@ -203,8 +201,7 @@ MarkSharpObjects(JSContext *cx, HandleObject obj, JSIdArray **idap, JSSharpInfo
if (hasSetter) {
/* Mark the getter, then set val to setter. */
if (hasGetter && value.isObject()) {
Rooted<JSObject*> vobj(cx, &value.toObject());
ok = MarkSharpObjects(cx, vobj, NULL, NULL);
ok = MarkSharpObjects(cx, RootedObject(cx, &value.toObject()), NULL, NULL);
if (!ok)
break;
}
@ -214,12 +211,11 @@ MarkSharpObjects(JSContext *cx, HandleObject obj, JSIdArray **idap, JSSharpInfo
if (!ok)
break;
}
if (value.isObject()) {
Rooted<JSObject*> vobj(cx, &value.toObject());
if (!MarkSharpObjects(cx, vobj, NULL, NULL)) {
ok = false;
break;
}
if (value.isObject() &&
!MarkSharpObjects(cx, RootedObject(cx, &value.toObject()), NULL, NULL))
{
ok = false;
break;
}
}
if (!ok || !idap)
@ -706,10 +702,8 @@ AssertInnerizedScopeChain(JSContext *cx, JSObject &scopeobj)
{
#ifdef DEBUG
for (JSObject *o = &scopeobj; o; o = o->enclosingScope()) {
if (JSObjectOp op = o->getClass()->ext.innerObject) {
Rooted<JSObject*> obj(cx, o);
JS_ASSERT(op(cx, obj) == o);
}
if (JSObjectOp op = o->getClass()->ext.innerObject)
JS_ASSERT(op(cx, RootedObject(cx, o)) == o);
}
#endif
}
@ -1090,11 +1084,9 @@ JSBool
eval(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (!WarnOnTooManyArgs(cx, args))
return false;
Rooted<GlobalObject*> global(cx, &args.callee().global());
return EvalKernel(cx, args, INDIRECT_EVAL, NULL, global);
return WarnOnTooManyArgs(cx, args) &&
EvalKernel(cx, args, INDIRECT_EVAL, NULL,
RootedObject(cx, &args.callee().global()));
}
bool
@ -1294,8 +1286,7 @@ js_HasOwnProperty(JSContext *cx, LookupGenericOp lookup, HandleObject obj, Handl
JSObject *outer = NULL;
if (JSObjectOp op = (*objp)->getClass()->ext.outerObject) {
Rooted<JSObject*> inner(cx, *objp);
outer = op(cx, inner);
outer = op(cx, RootedObject(cx, *objp));
if (!outer)
return false;
}
@ -1979,9 +1970,9 @@ DefinePropertyOnObject(JSContext *cx, HandleObject obj, HandleId id, const PropD
if (desc.isGenericDescriptor() || desc.isDataDescriptor()) {
JS_ASSERT(!obj->getOps()->defineProperty);
Value v = desc.hasValue() ? desc.value() : UndefinedValue();
return baseops::DefineGeneric(cx, obj, id, &v,
JS_PropertyStub, JS_StrictPropertyStub,
desc.attributes());
return baseops::DefineProperty(cx, obj, id, &v,
JS_PropertyStub, JS_StrictPropertyStub,
desc.attributes());
}
JS_ASSERT(desc.isAccessorDescriptor());
@ -1996,8 +1987,8 @@ DefinePropertyOnObject(JSContext *cx, HandleObject obj, HandleId id, const PropD
return JS_FALSE;
Value tmp = UndefinedValue();
return baseops::DefineGeneric(cx, obj, id, &tmp,
desc.getter(), desc.setter(), desc.attributes());
return baseops::DefineProperty(cx, obj, id, &tmp,
desc.getter(), desc.setter(), desc.attributes());
}
/* 8.12.9 steps 5-6 (note 5 is merely a special case of 6). */
@ -2247,7 +2238,7 @@ DefinePropertyOnObject(JSContext *cx, HandleObject obj, HandleId id, const PropD
return false;
}
return baseops::DefineGeneric(cx, obj, id, &v, getter, setter, attrs);
return baseops::DefineProperty(cx, obj, id, &v, getter, setter, attrs);
}
static JSBool
@ -2391,7 +2382,7 @@ DefineProperties(JSContext *cx, HandleObject obj, JSObject *props)
bool dummy;
for (size_t i = 0, len = ids.length(); i < len; i++) {
if (!DefineProperty(cx, obj, Handle<jsid>::fromMarkedLocation(&ids[i]), descs[i], true, &dummy))
if (!DefineProperty(cx, obj, RootedId(cx, ids[i]), descs[i], true, &dummy))
return false;
}
@ -3182,9 +3173,9 @@ JSObject::deleteByValue(JSContext *cx, const Value &property, Value *rval, bool
return deleteElement(cx, index, rval, strict);
Value propval = property;
Rooted<SpecialId> sid(cx);
if (ValueIsSpecial(this, &propval, sid.address(), cx))
return deleteSpecial(cx, sid, rval, strict);
SpecialId sid;
if (ValueIsSpecial(this, &propval, &sid, cx))
return deleteSpecial(cx, Rooted<SpecialId>(cx, sid), rval, strict);
RootedObject self(cx, this);
@ -3195,8 +3186,7 @@ JSObject::deleteByValue(JSContext *cx, const Value &property, Value *rval, bool
if (name->isIndex(&index))
return self->deleteElement(cx, index, rval, false);
Rooted<PropertyName*> propname(cx, name->asPropertyName());
return self->deleteProperty(cx, propname, rval, false);
return self->deleteProperty(cx, RootedPropertyName(cx, name->asPropertyName()), rval, false);
}
JS_FRIEND_API(bool)
@ -3227,8 +3217,7 @@ JS_CopyPropertiesFrom(JSContext *cx, JSObject *target, JSObject *obj)
Value v = shape->hasSlot() ? obj->getSlot(shape->slot()) : UndefinedValue();
if (!cx->compartment->wrap(cx, &v))
return false;
Rooted<jsid> id(cx, shape->propid());
if (!target->defineGeneric(cx, id, v, getter, setter, attrs))
if (!target->defineGeneric(cx, RootedId(cx, shape->propid()), v, getter, setter, attrs))
return false;
}
return true;
@ -3967,16 +3956,15 @@ JSObject::growSlots(JSContext *cx, uint32_t oldCount, uint32_t newCount)
gc::AllocKind kind = type()->newScript->allocKind;
unsigned newScriptSlots = gc::GetGCKindSlots(kind);
if (newScriptSlots == numFixedSlots() && gc::TryIncrementAllocKind(&kind)) {
Rooted<TypeObject*> typeObj(cx, type());
JSObject *obj = NewReshapedObject(cx, typeObj,
JSObject *obj = NewReshapedObject(cx, RootedTypeObject(cx, type()),
getParent(), kind,
typeObj->newScript->shape);
type()->newScript->shape);
if (!obj)
return false;
typeObj->newScript->allocKind = kind;
typeObj->newScript->shape = obj->lastProperty();
typeObj->markStateChange(cx);
type()->newScript->allocKind = kind;
type()->newScript->shape = obj->lastProperty();
type()->markStateChange(cx);
}
}
@ -4488,7 +4476,7 @@ js_AddNativeProperty(JSContext *cx, HandleObject obj, jsid id_,
}
JSBool
baseops::DefineGeneric(JSContext *cx, HandleObject obj, HandleId id, const Value *value,
baseops::DefineProperty(JSContext *cx, HandleObject obj, HandleId id, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
return !!DefineNativeProperty(cx, obj, id, *value, getter, setter, attrs, 0, 0);
@ -4498,14 +4486,14 @@ JSBool
baseops::DefineElement(JSContext *cx, HandleObject obj, uint32_t index, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
Rooted<jsid> id(cx);
if (index <= JSID_INT_MAX) {
id = INT_TO_JSID(index);
return !!DefineNativeProperty(cx, obj, id, *value, getter, setter, attrs, 0, 0);
return !!DefineNativeProperty(cx, obj, RootedId(cx, INT_TO_JSID(index)), *value,
getter, setter, attrs, 0, 0);
}
AutoRooterGetterSetter gsRoot(cx, attrs, &getter, &setter);
RootedId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
@ -4524,8 +4512,7 @@ CallAddPropertyHook(JSContext *cx, Class *clasp, HandleObject obj, HandleShape s
if (clasp->addProperty != JS_PropertyStub) {
Value nominal = *vp;
Rooted<jsid> id(cx, shape->propid());
if (!CallJSPropertyOp(cx, clasp->addProperty, obj, id, vp))
if (!CallJSPropertyOp(cx, clasp->addProperty, obj, RootedId(cx, shape->propid()), vp))
return false;
if (*vp != nominal) {
if (shape->hasSlot())
@ -4978,7 +4965,7 @@ js::FindIdentifierBase(JSContext *cx, HandleObject scopeChain, HandlePropertyNam
}
static JS_ALWAYS_INLINE JSBool
js_NativeGetInline(JSContext *cx, Handle<JSObject*> receiver, JSObject *obj, JSObject *pobj,
js_NativeGetInline(JSContext *cx, JSObject *receiver, JSObject *obj, JSObject *pobj,
const Shape *shape, unsigned getHow, Value *vp)
{
JS_ASSERT(pobj->isNative());
@ -5005,7 +4992,7 @@ js_NativeGetInline(JSContext *cx, Handle<JSObject*> receiver, JSObject *obj, JSO
Rooted<const Shape*> shapeRoot(cx, shape);
RootedObject pobjRoot(cx, pobj);
if (!shape->get(cx, receiver, obj, pobj, vp))
if (!shape->get(cx, RootedObject(cx, receiver), obj, pobj, vp))
return false;
/* Update slotful shapes according to the value produced by the getter. */
@ -5016,15 +5003,14 @@ js_NativeGetInline(JSContext *cx, Handle<JSObject*> receiver, JSObject *obj, JSO
}
JSBool
js_NativeGet(JSContext *cx, Handle<JSObject*> obj, Handle<JSObject*> pobj, const Shape *shape,
unsigned getHow, Value *vp)
js_NativeGet(JSContext *cx, JSObject *obj, JSObject *pobj, const Shape *shape, unsigned getHow,
Value *vp)
{
return js_NativeGetInline(cx, obj, obj, pobj, shape, getHow, vp);
}
JSBool
js_NativeSet(JSContext *cx, Handle<JSObject*> obj, const Shape *shape, bool added, bool strict,
Value *vp)
js_NativeSet(JSContext *cx, JSObject *obj, const Shape *shape, bool added, bool strict, Value *vp)
{
AddTypePropertyId(cx, obj, shape->propid(), *vp);
@ -5052,7 +5038,7 @@ js_NativeSet(JSContext *cx, Handle<JSObject*> obj, const Shape *shape, bool adde
Rooted<const Shape *> shapeRoot(cx, shape);
int32_t sample = cx->runtime->propertyRemovals;
if (!shapeRoot->set(cx, obj, strict, vp))
if (!shapeRoot->set(cx, RootedObject(cx, obj), strict, vp))
return false;
/*
@ -5270,9 +5256,8 @@ bool
JSObject::callMethod(JSContext *cx, HandleId id, unsigned argc, Value *argv, Value *vp)
{
Value fval;
Rooted<JSObject*> obj(cx, this);
return GetMethod(cx, obj, id, 0, &fval) &&
Invoke(cx, ObjectValue(*obj), fval, argc, argv, vp);
return GetMethod(cx, RootedObject(cx, this), id, 0, &fval) &&
Invoke(cx, ObjectValue(*this), fval, argc, argv, vp);
}
JSBool
@ -5583,8 +5568,7 @@ baseops::DeleteGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *rval
JSBool
baseops::DeleteProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *rval, JSBool strict)
{
Rooted<jsid> id(cx, NameToId(name));
return baseops::DeleteGeneric(cx, obj, id, rval, strict);
return baseops::DeleteGeneric(cx, obj, RootedId(cx, NameToId(name)), rval, strict);
}
JSBool
@ -5599,8 +5583,7 @@ baseops::DeleteElement(JSContext *cx, HandleObject obj, uint32_t index, Value *r
JSBool
baseops::DeleteSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *rval, JSBool strict)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return baseops::DeleteGeneric(cx, obj, id, rval, strict);
return baseops::DeleteGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), rval, strict);
}
namespace js {
@ -5627,9 +5610,9 @@ HasDataProperty(JSContext *cx, HandleObject obj, jsid id, Value *vp)
* or steps 3-4.
*/
static bool
MaybeCallMethod(JSContext *cx, HandleObject obj, Handle<jsid> id, Value *vp)
MaybeCallMethod(JSContext *cx, HandleObject obj, jsid id, Value *vp)
{
if (!GetMethod(cx, obj, id, 0, vp))
if (!GetMethod(cx, obj, RootedId(cx, id), 0, vp))
return false;
if (!js_IsCallable(*vp)) {
*vp = ObjectValue(*obj);
@ -5646,58 +5629,49 @@ DefaultValue(JSContext *cx, HandleObject obj, JSType hint, Value *vp)
JS_ASSERT(!obj->isXML());
#endif
Rooted<jsid> id(cx);
Class *clasp = obj->getClass();
if (hint == JSTYPE_STRING) {
id = NameToId(cx->runtime->atomState.toStringAtom);
/* Optimize (new String(...)).toString(). */
if (clasp == &StringClass) {
if (ClassMethodIsNative(cx, obj, &StringClass, id, js_str_toString)) {
*vp = StringValue(obj->asString().unbox());
return true;
}
if (clasp == &StringClass &&
ClassMethodIsNative(cx, obj,
&StringClass,
RootedId(cx, NameToId(cx->runtime->atomState.toStringAtom)),
js_str_toString)) {
*vp = StringValue(obj->asString().unbox());
return true;
}
if (!MaybeCallMethod(cx, obj, id, vp))
if (!MaybeCallMethod(cx, obj, NameToId(cx->runtime->atomState.toStringAtom), vp))
return false;
if (vp->isPrimitive())
return true;
id = NameToId(cx->runtime->atomState.valueOfAtom);
if (!MaybeCallMethod(cx, obj, id, vp))
if (!MaybeCallMethod(cx, obj, NameToId(cx->runtime->atomState.valueOfAtom), vp))
return false;
if (vp->isPrimitive())
return true;
} else {
/* Optimize new String(...).valueOf(). */
if (clasp == &StringClass) {
id = NameToId(cx->runtime->atomState.valueOfAtom);
if (ClassMethodIsNative(cx, obj, &StringClass, id, js_str_toString)) {
*vp = StringValue(obj->asString().unbox());
return true;
}
/* Optimize (new String(...)).valueOf(). */
if ((clasp == &StringClass &&
ClassMethodIsNative(cx, obj, &StringClass,
RootedId(cx, NameToId(cx->runtime->atomState.valueOfAtom)),
js_str_toString)) ||
(clasp == &NumberClass &&
ClassMethodIsNative(cx, obj, &NumberClass,
RootedId(cx, NameToId(cx->runtime->atomState.valueOfAtom)),
js_num_valueOf))) {
*vp = obj->isString()
? StringValue(obj->asString().unbox())
: NumberValue(obj->asNumber().unbox());
return true;
}
/* Optimize new Number(...).valueOf(). */
if (clasp == &NumberClass) {
id = NameToId(cx->runtime->atomState.valueOfAtom);
if (ClassMethodIsNative(cx, obj, &NumberClass, id, js_num_valueOf)) {
*vp = NumberValue(obj->asNumber().unbox());
return true;
}
}
id = NameToId(cx->runtime->atomState.valueOfAtom);
if (!MaybeCallMethod(cx, obj, id, vp))
if (!MaybeCallMethod(cx, obj, NameToId(cx->runtime->atomState.valueOfAtom), vp))
return false;
if (vp->isPrimitive())
return true;
id = NameToId(cx->runtime->atomState.toStringAtom);
if (!MaybeCallMethod(cx, obj, id, vp))
if (!MaybeCallMethod(cx, obj, NameToId(cx->runtime->atomState.toStringAtom), vp))
return false;
if (vp->isPrimitive())
return true;
@ -5894,10 +5868,8 @@ js_GetClassPrototype(JSContext *cx, JSObject *scopeobj, JSProtoKey protoKey,
JSObject *
PrimitiveToObject(JSContext *cx, const Value &v)
{
if (v.isString()) {
Rooted<JSString*> str(cx, v.toString());
return StringObject::create(cx, str);
}
if (v.isString())
return StringObject::create(cx, RootedString(cx, v.toString()));
if (v.isNumber())
return NumberObject::create(cx, v.toNumber());

View File

@ -105,8 +105,7 @@ inline bool
LookupProperty(JSContext *cx, HandleObject obj, PropertyName *name,
JSObject **objp, JSProperty **propp)
{
Rooted<jsid> id(cx, NameToId(name));
return LookupProperty(cx, obj, id, objp, propp);
return LookupProperty(cx, obj, RootedId(cx, NameToId(name)), objp, propp);
}
extern JS_FRIEND_API(JSBool)
@ -114,17 +113,9 @@ LookupElement(JSContext *cx, HandleObject obj, uint32_t index,
JSObject **objp, JSProperty **propp);
extern JSBool
DefineGeneric(JSContext *cx, HandleObject obj, HandleId id, const js::Value *value,
DefineProperty(JSContext *cx, HandleObject obj, HandleId id, const js::Value *value,
JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs);
inline JSBool
DefineProperty(JSContext *cx, HandleObject obj, PropertyName *name, const js::Value *value,
JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs)
{
Rooted<jsid> id(cx, NameToId(name));
return DefineGeneric(cx, obj, id, value, getter, setter, attrs);
}
extern JSBool
DefineElement(JSContext *cx, HandleObject obj, uint32_t index, const js::Value *value,
JSPropertyOp getter, JSStrictPropertyOp setter, unsigned attrs);
@ -158,8 +149,7 @@ inline bool
SetPropertyHelper(JSContext *cx, HandleObject obj, PropertyName *name, unsigned defineHow,
Value *vp, JSBool strict)
{
Rooted<jsid> id(cx, NameToId(name));
return SetPropertyHelper(cx, obj, id, defineHow, vp, strict);
return SetPropertyHelper(cx, obj, RootedId(cx, NameToId(name)), defineHow, vp, strict);
}
extern JSBool
@ -1151,8 +1141,8 @@ DefineNativeProperty(JSContext *cx, HandleObject obj, PropertyName *name, const
PropertyOp getter, StrictPropertyOp setter, unsigned attrs,
unsigned flags, int shortid, unsigned defineHow = 0)
{
Rooted<jsid> id(cx, NameToId(name));
return DefineNativeProperty(cx, obj, id, value, getter, setter, attrs, flags,
return DefineNativeProperty(cx, obj, RootedId(cx, NameToId(name)),
value, getter, setter, attrs, flags,
shortid, defineHow);
}
@ -1167,8 +1157,7 @@ inline bool
LookupPropertyWithFlags(JSContext *cx, HandleObject obj, PropertyName *name, unsigned flags,
JSObject **objp, JSProperty **propp)
{
Rooted<jsid> id(cx, NameToId(name));
return LookupPropertyWithFlags(cx, obj, id, flags, objp, propp);
return LookupPropertyWithFlags(cx, obj, RootedId(cx, NameToId(name)), flags, objp, propp);
}
/*
@ -1232,11 +1221,11 @@ const unsigned JSGET_CACHE_RESULT = 1; // from a caching interpreter opcode
* scope containing shape unlocked.
*/
extern JSBool
js_NativeGet(JSContext *cx, js::Handle<JSObject*> obj, js::Handle<JSObject*> pobj,
const js::Shape *shape, unsigned getHow, js::Value *vp);
js_NativeGet(JSContext *cx, JSObject *obj, JSObject *pobj, const js::Shape *shape, unsigned getHow,
js::Value *vp);
extern JSBool
js_NativeSet(JSContext *cx, js::Handle<JSObject*> obj, const js::Shape *shape, bool added,
js_NativeSet(JSContext *cx, JSObject *obj, const js::Shape *shape, bool added,
bool strict, js::Value *vp);
namespace js {
@ -1265,8 +1254,7 @@ GetMethod(JSContext *cx, HandleObject obj, HandleId id, unsigned getHow, Value *
inline bool
GetMethod(JSContext *cx, HandleObject obj, PropertyName *name, unsigned getHow, Value *vp)
{
Rooted<jsid> id(cx, NameToId(name));
return GetMethod(cx, obj, id, getHow, vp);
return GetMethod(cx, obj, RootedId(cx, NameToId(name)), getHow, vp);
}
/*

View File

@ -54,8 +54,7 @@ inline bool
JSObject::enumerate(JSContext *cx, JSIterateOp iterop, js::Value *statep, jsid *idp)
{
JSNewEnumerateOp op = getOps()->enumerate;
js::Rooted<JSObject*> obj(cx, this);
return (op ? op : JS_EnumerateState)(cx, obj, iterop, statep, idp);
return (op ? op : JS_EnumerateState)(cx, js::RootedObject(cx, this), iterop, statep, idp);
}
inline bool
@ -77,16 +76,14 @@ inline JSType
JSObject::typeOf(JSContext *cx)
{
js::TypeOfOp op = getOps()->typeOf;
js::Rooted<JSObject*> obj(cx, this);
return (op ? op : js::baseops::TypeOf)(cx, obj);
return (op ? op : js::baseops::TypeOf)(cx, js::RootedObject(cx, this));
}
inline JSObject *
JSObject::thisObject(JSContext *cx)
{
JSObjectOp op = getOps()->thisObject;
js::Rooted<JSObject*> obj(cx, this);
return op ? op(cx, obj) : this;
return op ? op(cx, js::RootedObject(cx, this)) : this;
}
inline JSBool
@ -94,15 +91,15 @@ JSObject::setGeneric(JSContext *cx, js::HandleId id, js::Value *vp, JSBool stric
{
if (getOps()->setGeneric)
return nonNativeSetProperty(cx, id, vp, strict);
js::Rooted<JSObject*> obj(cx, this);
return js::baseops::SetPropertyHelper(cx, obj, id, 0, vp, strict);
return js::baseops::SetPropertyHelper(cx,
js::RootedObject(cx, this),
id, 0, vp, strict);
}
inline JSBool
JSObject::setProperty(JSContext *cx, js::PropertyName *name, js::Value *vp, JSBool strict)
{
js::Rooted<jsid> id(cx, js::NameToId(name));
return setGeneric(cx, id, vp, strict);
return setGeneric(cx, js::RootedId(cx, js::NameToId(name)), vp, strict);
}
inline JSBool
@ -110,15 +107,13 @@ JSObject::setElement(JSContext *cx, uint32_t index, js::Value *vp, JSBool strict
{
if (getOps()->setElement)
return nonNativeSetElement(cx, index, vp, strict);
js::Rooted<JSObject*> obj(cx, this);
return js::baseops::SetElementHelper(cx, obj, index, 0, vp, strict);
return js::baseops::SetElementHelper(cx, js::RootedObject(cx, this), index, 0, vp, strict);
}
inline JSBool
JSObject::setSpecial(JSContext *cx, js::SpecialId sid, js::Value *vp, JSBool strict)
{
js::Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return setGeneric(cx, id, vp, strict);
return setGeneric(cx, js::RootedId(cx, SPECIALID_TO_JSID(sid)), vp, strict);
}
inline JSBool
@ -126,30 +121,26 @@ JSObject::setGenericAttributes(JSContext *cx, js::HandleId id, unsigned *attrsp)
{
js::types::MarkTypePropertyConfigured(cx, this, id);
js::GenericAttributesOp op = getOps()->setGenericAttributes;
js::Rooted<JSObject*> obj(cx, this);
return (op ? op : js::baseops::SetAttributes)(cx, obj, id, attrsp);
return (op ? op : js::baseops::SetAttributes)(cx, js::RootedObject(cx, this), id, attrsp);
}
inline JSBool
JSObject::setPropertyAttributes(JSContext *cx, js::PropertyName *name, unsigned *attrsp)
{
js::Rooted<jsid> id(cx, js::NameToId(name));
return setGenericAttributes(cx, id, attrsp);
return setGenericAttributes(cx, js::RootedId(cx, js::NameToId(name)), attrsp);
}
inline JSBool
JSObject::setElementAttributes(JSContext *cx, uint32_t index, unsigned *attrsp)
{
js::ElementAttributesOp op = getOps()->setElementAttributes;
js::Rooted<JSObject*> obj(cx, this);
return (op ? op : js::baseops::SetElementAttributes)(cx, obj, index, attrsp);
return (op ? op : js::baseops::SetElementAttributes)(cx, js::RootedObject(cx, this), index, attrsp);
}
inline JSBool
JSObject::setSpecialAttributes(JSContext *cx, js::SpecialId sid, unsigned *attrsp)
{
js::Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return setGenericAttributes(cx, id, attrsp);
return setGenericAttributes(cx, js::RootedId(cx, SPECIALID_TO_JSID(sid)), attrsp);
}
inline bool
@ -177,22 +168,19 @@ JSObject::getGeneric(JSContext *cx, js::HandleObject receiver, js::HandleId id,
inline JSBool
JSObject::getProperty(JSContext *cx, js::HandleObject receiver, js::PropertyName *name, js::Value *vp)
{
js::Rooted<jsid> id(cx, js::NameToId(name));
return getGeneric(cx, receiver, id, vp);
return getGeneric(cx, receiver, js::RootedId(cx, js::NameToId(name)), vp);
}
inline JSBool
JSObject::getGeneric(JSContext *cx, js::HandleId id, js::Value *vp)
{
js::Rooted<JSObject*> obj(cx, this);
return getGeneric(cx, obj, id, vp);
return getGeneric(cx, js::RootedObject(cx, this), id, vp);
}
inline JSBool
JSObject::getProperty(JSContext *cx, js::PropertyName *name, js::Value *vp)
{
js::Rooted<jsid> id(cx, js::NameToId(name));
return getGeneric(cx, id, vp);
return getGeneric(cx, js::RootedId(cx, js::NameToId(name)), vp);
}
inline bool
@ -202,8 +190,7 @@ JSObject::deleteProperty(JSContext *cx, js::HandlePropertyName name, js::Value *
js::types::AddTypePropertyId(cx, this, id, js::types::Type::UndefinedType());
js::types::MarkTypePropertyConfigured(cx, this, id);
js::DeletePropertyOp op = getOps()->deleteProperty;
js::Rooted<JSObject*> obj(cx, this);
return (op ? op : js::baseops::DeleteProperty)(cx, obj, name, rval, strict);
return (op ? op : js::baseops::DeleteProperty)(cx, js::RootedObject(cx, this), name, rval, strict);
}
inline bool
@ -227,8 +214,7 @@ JSObject::deleteSpecial(JSContext *cx, js::HandleSpecialId sid, js::Value *rval,
js::types::AddTypePropertyId(cx, this, id, js::types::Type::UndefinedType());
js::types::MarkTypePropertyConfigured(cx, this, id);
js::DeleteSpecialOp op = getOps()->deleteSpecial;
js::Rooted<JSObject*> obj(cx, this);
return (op ? op : js::baseops::DeleteSpecial)(cx, obj, sid, rval, strict);
return (op ? op : js::baseops::DeleteSpecial)(cx, js::RootedObject(cx, this), sid, rval, strict);
}
inline void
@ -1040,8 +1026,7 @@ JSObject::lookupGeneric(JSContext *cx, js::HandleId id, JSObject **objp, JSPrope
inline JSBool
JSObject::lookupProperty(JSContext *cx, js::PropertyName *name, JSObject **objp, JSProperty **propp)
{
js::Rooted<jsid> id(cx, js::NameToId(name));
return lookupGeneric(cx, id, objp, propp);
return lookupGeneric(cx, js::RootedId(cx, js::NameToId(name)), objp, propp);
}
inline JSBool
@ -1054,7 +1039,7 @@ JSObject::defineGeneric(JSContext *cx, js::HandleId id, const js::Value &value,
JS_ASSERT(!(attrs & JSPROP_NATIVE_ACCESSORS));
js::DefineGenericOp op = getOps()->defineGeneric;
return (op ? op : js::baseops::DefineGeneric)(cx, self, id, &value, getter, setter, attrs);
return (op ? op : js::baseops::DefineProperty)(cx, self, id, &value, getter, setter, attrs);
}
inline JSBool
@ -1063,8 +1048,7 @@ JSObject::defineProperty(JSContext *cx, js::PropertyName *name, const js::Value
JSStrictPropertyOp setter /* = JS_StrictPropertyStub */,
unsigned attrs /* = JSPROP_ENUMERATE */)
{
js::Rooted<jsid> id(cx, js::NameToId(name));
return defineGeneric(cx, id, value, getter, setter, attrs);
return defineGeneric(cx, js::RootedId(cx, js::NameToId(name)), value, getter, setter, attrs);
}
inline JSBool
@ -1085,8 +1069,7 @@ JSObject::defineSpecial(JSContext *cx, js::SpecialId sid, const js::Value &value
JSStrictPropertyOp setter /* = JS_StrictPropertyStub */,
unsigned attrs /* = JSPROP_ENUMERATE */)
{
js::Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return defineGeneric(cx, id, value, getter, setter, attrs);
return defineGeneric(cx, js::RootedId(cx, SPECIALID_TO_JSID(sid)), value, getter, setter, attrs);
}
inline JSBool
@ -1101,8 +1084,7 @@ JSObject::lookupElement(JSContext *cx, uint32_t index, JSObject **objp, JSProper
inline JSBool
JSObject::lookupSpecial(JSContext *cx, js::SpecialId sid, JSObject **objp, JSProperty **propp)
{
js::Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return lookupGeneric(cx, id, objp, propp);
return lookupGeneric(cx, js::RootedId(cx, SPECIALID_TO_JSID(sid)), objp, propp);
}
inline JSBool
@ -1123,8 +1105,7 @@ JSObject::getElement(JSContext *cx, js::HandleObject receiver, uint32_t index, j
inline JSBool
JSObject::getElement(JSContext *cx, uint32_t index, js::Value *vp)
{
js::Rooted<JSObject*> obj(cx, this);
return getElement(cx, obj, index, vp);
return getElement(cx, js::RootedObject(cx, this), index, vp);
}
inline JSBool
@ -1164,23 +1145,20 @@ JSObject::getElementIfPresent(JSContext *cx, js::HandleObject receiver, uint32_t
inline JSBool
JSObject::getSpecial(JSContext *cx, js::HandleObject receiver, js::SpecialId sid, js::Value *vp)
{
js::Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return getGeneric(cx, receiver, id, vp);
return getGeneric(cx, receiver, js::RootedId(cx, SPECIALID_TO_JSID(sid)), vp);
}
inline JSBool
JSObject::getGenericAttributes(JSContext *cx, js::HandleId id, unsigned *attrsp)
{
js::GenericAttributesOp op = getOps()->getGenericAttributes;
js::Rooted<JSObject*> obj(cx, this);
return (op ? op : js::baseops::GetAttributes)(cx, obj, id, attrsp);
return (op ? op : js::baseops::GetAttributes)(cx, js::RootedObject(cx, this), id, attrsp);
}
inline JSBool
JSObject::getPropertyAttributes(JSContext *cx, js::PropertyName *name, unsigned *attrsp)
{
js::Rooted<jsid> id(cx, js::NameToId(name));
return getGenericAttributes(cx, id, attrsp);
return getGenericAttributes(cx, js::RootedId(cx, js::NameToId(name)), attrsp);
}
inline JSBool
@ -1195,8 +1173,7 @@ JSObject::getElementAttributes(JSContext *cx, uint32_t index, unsigned *attrsp)
inline JSBool
JSObject::getSpecialAttributes(JSContext *cx, js::SpecialId sid, unsigned *attrsp)
{
js::Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return getGenericAttributes(cx, id, attrsp);
return getGenericAttributes(cx, js::RootedId(cx, SPECIALID_TO_JSID(sid)), attrsp);
}
inline bool

View File

@ -280,8 +280,7 @@ PreprocessValue(JSContext *cx, JSObject *holder, KeyType key, Value *vp, Stringi
if (vp->isObject()) {
Value toJSON;
RootedId id(cx, NameToId(cx->runtime->atomState.toJSONAtom));
Rooted<JSObject*> obj(cx, &vp->toObject());
if (!GetMethod(cx, obj, id, 0, &toJSON))
if (!GetMethod(cx, RootedObject(cx, &vp->toObject()), id, 0, &toJSON))
return false;
if (js_IsCallable(toJSON)) {
@ -856,8 +855,7 @@ Revive(JSContext *cx, const Value &reviver, Value *vp)
if (!obj->defineProperty(cx, cx->runtime->atomState.emptyAtom, *vp))
return false;
Rooted<jsid> id(cx, NameToId(cx->runtime->atomState.emptyAtom));
return Walk(cx, obj, id, reviver, vp);
return Walk(cx, obj, RootedId(cx, NameToId(cx->runtime->atomState.emptyAtom)), reviver, vp);
}
namespace js {

View File

@ -549,8 +549,7 @@ JSONParser::parse(Value *vp)
case FinishArrayElement: {
Value v = valueStack.popCopy();
Rooted<JSObject*> obj(cx, &valueStack.back().toObject());
if (!js_NewbornArrayPush(cx, obj, v))
if (!js_NewbornArrayPush(cx, RootedObject(cx, &valueStack.back().toObject()), v))
return false;
token = advanceAfterArrayElement();
if (token == Comma) {

View File

@ -310,8 +310,7 @@ bool
BaseProxyHandler::defaultValue(JSContext *cx, JSObject *proxy, JSType hint,
Value *vp)
{
Rooted<JSObject*> obj(cx, proxy);
return DefaultValue(cx, obj, hint, vp);
return DefaultValue(cx, RootedObject(cx, proxy), hint, vp);
}
bool
@ -398,14 +397,14 @@ IndirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy,
}
bool
IndirectProxyHandler::defineProperty(JSContext *cx, JSObject *proxy, jsid id_,
IndirectProxyHandler::defineProperty(JSContext *cx, JSObject *proxy, jsid id,
PropertyDescriptor *desc)
{
RootedObject obj(cx, GetProxyTargetObject(proxy));
Rooted<jsid> id(cx, id_);
Rooted<Value> v(cx, desc->value);
return CheckDefineProperty(cx, obj, id, v, desc->getter, desc->setter, desc->attrs) &&
JS_DefinePropertyById(cx, obj, id, v, desc->getter, desc->setter, desc->attrs);
return CheckDefineProperty(cx, obj, RootedId(cx, id), RootedValue(cx, desc->value),
desc->getter, desc->setter, desc->attrs) &&
JS_DefinePropertyById(cx, obj, id, desc->value, desc->getter, desc->setter,
desc->attrs);
}
bool
@ -524,25 +523,25 @@ IndirectProxyHandler::defaultValue(JSContext *cx, JSObject *proxy, JSType hint,
bool
IndirectProxyHandler::iteratorNext(JSContext *cx, JSObject *proxy, Value *vp)
{
Rooted<JSObject*> target(cx, GetProxyTargetObject(proxy));
if (!js_IteratorMore(cx, target, vp))
if (!js_IteratorMore(cx, RootedObject(cx, GetProxyTargetObject(proxy)),
vp))
return false;
if (vp->toBoolean()) {
*vp = cx->iterValue;
cx->iterValue = UndefinedValue();
} else {
*vp = MagicValue(JS_NO_ITER_VALUE);
}
cx->iterValue.setUndefined();
} else
vp->setMagic(JS_NO_ITER_VALUE);
return true;
}
DirectProxyHandler::DirectProxyHandler(void *family)
: IndirectProxyHandler(family)
DirectProxyHandler::DirectProxyHandler(void *family) :
IndirectProxyHandler(family)
{
}
bool
DirectProxyHandler::has(JSContext *cx, JSObject *proxy, jsid id, bool *bp)
DirectProxyHandler::has(JSContext *cx, JSObject *proxy, jsid id,
bool *bp)
{
JSBool found;
if (!JS_HasPropertyById(cx, GetProxyTargetObject(proxy), id, &found))
@ -591,8 +590,8 @@ bool
DirectProxyHandler::iterate(JSContext *cx, JSObject *proxy, unsigned flags,
Value *vp)
{
Rooted<JSObject*> target(cx, GetProxyTargetObject(proxy));
return GetIterator(cx, target, flags, vp);
return GetIterator(cx, RootedObject(cx, GetProxyTargetObject(proxy)),
flags, vp);
}
static bool
@ -600,8 +599,7 @@ GetTrap(JSContext *cx, JSObject *handler, PropertyName *name, Value *fvalp)
{
JS_CHECK_RECURSION(cx, return false);
Rooted<PropertyName*> propname(cx, name);
return handler->getProperty(cx, propname, fvalp);
return handler->getGeneric(cx, RootedId(cx, NameToId(name)), fvalp);
}
static bool
@ -1245,8 +1243,7 @@ static JSBool
proxy_LookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, JSObject **objp,
JSProperty **propp)
{
Rooted<jsid> id(cx, NameToId(name));
return proxy_LookupGeneric(cx, obj, id, objp, propp);
return proxy_LookupGeneric(cx, obj, RootedId(cx, NameToId(name)), objp, propp);
}
static JSBool
@ -1262,8 +1259,7 @@ proxy_LookupElement(JSContext *cx, HandleObject obj, uint32_t index, JSObject **
static JSBool
proxy_LookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, JSObject **objp, JSProperty **propp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return proxy_LookupGeneric(cx, obj, id, objp, propp);
return proxy_LookupGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), objp, propp);
}
static JSBool
@ -1284,8 +1280,7 @@ static JSBool
proxy_DefineProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
Rooted<jsid> id(cx, NameToId(name));
return proxy_DefineGeneric(cx, obj, id, value, getter, setter, attrs);
return proxy_DefineGeneric(cx, obj, RootedId(cx, NameToId(name)), value, getter, setter, attrs);
}
static JSBool
@ -1302,8 +1297,8 @@ static JSBool
proxy_DefineSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, const Value *value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return proxy_DefineGeneric(cx, obj, id, value, getter, setter, attrs);
return proxy_DefineGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)),
value, getter, setter, attrs);
}
static JSBool
@ -1315,8 +1310,7 @@ proxy_GetGeneric(JSContext *cx, HandleObject obj, HandleObject receiver, HandleI
static JSBool
proxy_GetProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandlePropertyName name, Value *vp)
{
Rooted<jsid> id(cx, NameToId(name));
return proxy_GetGeneric(cx, obj, receiver, id, vp);
return proxy_GetGeneric(cx, obj, receiver, RootedId(cx, NameToId(name)), vp);
}
static JSBool
@ -1338,8 +1332,7 @@ proxy_GetElementIfPresent(JSContext *cx, HandleObject obj, HandleObject receiver
static JSBool
proxy_GetSpecial(JSContext *cx, HandleObject obj, HandleObject receiver, HandleSpecialId sid, Value *vp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return proxy_GetGeneric(cx, obj, receiver, id, vp);
return proxy_GetGeneric(cx, obj, receiver, RootedId(cx, SPECIALID_TO_JSID(sid)), vp);
}
static JSBool
@ -1351,8 +1344,7 @@ proxy_SetGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *vp, JSBool
static JSBool
proxy_SetProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *vp, JSBool strict)
{
Rooted<jsid> id(cx, NameToId(name));
return proxy_SetGeneric(cx, obj, id, vp, strict);
return proxy_SetGeneric(cx, obj, RootedId(cx, NameToId(name)), vp, strict);
}
static JSBool
@ -1367,8 +1359,7 @@ proxy_SetElement(JSContext *cx, HandleObject obj, uint32_t index, Value *vp, JSB
static JSBool
proxy_SetSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *vp, JSBool strict)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return proxy_SetGeneric(cx, obj, id, vp, strict);
return proxy_SetGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), vp, strict);
}
static JSBool
@ -1384,8 +1375,7 @@ proxy_GetGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigne
static JSBool
proxy_GetPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp)
{
Rooted<jsid> id(cx, NameToId(name));
return proxy_GetGenericAttributes(cx, obj, id, attrsp);
return proxy_GetGenericAttributes(cx, obj, RootedId(cx, NameToId(name)), attrsp);
}
static JSBool
@ -1400,8 +1390,7 @@ proxy_GetElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsi
static JSBool
proxy_GetSpecialAttributes(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return proxy_GetGenericAttributes(cx, obj, id, attrsp);
return proxy_GetGenericAttributes(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), attrsp);
}
static JSBool
@ -1418,8 +1407,7 @@ proxy_SetGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigne
static JSBool
proxy_SetPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp)
{
Rooted<jsid> id(cx, NameToId(name));
return proxy_SetGenericAttributes(cx, obj, id, attrsp);
return proxy_SetGenericAttributes(cx, obj, RootedId(cx, NameToId(name)), attrsp);
}
static JSBool
@ -1434,8 +1422,7 @@ proxy_SetElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsi
static JSBool
proxy_SetSpecialAttributes(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return proxy_SetGenericAttributes(cx, obj, id, attrsp);
return proxy_SetGenericAttributes(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), attrsp);
}
static JSBool
@ -1452,8 +1439,7 @@ proxy_DeleteGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *rval, J
static JSBool
proxy_DeleteProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *rval, JSBool strict)
{
Rooted<jsid> id(cx, NameToId(name));
return proxy_DeleteGeneric(cx, obj, id, rval, strict);
return proxy_DeleteGeneric(cx, obj, RootedId(cx, NameToId(name)), rval, strict);
}
static JSBool
@ -1468,8 +1454,7 @@ proxy_DeleteElement(JSContext *cx, HandleObject obj, uint32_t index, Value *rval
static JSBool
proxy_DeleteSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *rval, JSBool strict)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return proxy_DeleteGeneric(cx, obj, id, rval, strict);
return proxy_DeleteGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), rval, strict);
}
static void

View File

@ -1013,9 +1013,7 @@ JSObject::shadowingShapeChange(JSContext *cx, const Shape &shape)
bool
JSObject::clearParent(JSContext *cx)
{
Rooted<JSObject*> obj(cx, this);
Rooted<JSObject*> newParent(cx, NULL);
return setParent(cx, obj, newParent);
return setParent(cx, RootedObject(cx, this), RootedObject(cx));
}
/* static */ bool

View File

@ -1745,8 +1745,7 @@ js::CloneScript(JSContext *cx, HandleScript src)
for (unsigned i = 0; i < names.length(); ++i) {
if (JSAtom *atom = names[i].maybeAtom) {
Rooted<JSAtom*> root(cx, atom);
if (!bindings.add(cx, root, names[i].kind))
if (!bindings.add(cx, RootedAtom(cx, atom), names[i].kind))
return NULL;
} else {
uint16_t _;

View File

@ -175,8 +175,7 @@ class Bindings
}
bool addDestructuring(JSContext *cx, uint16_t *slotp) {
*slotp = nargs;
Rooted<JSAtom*> atom(cx, NULL);
return add(cx, atom, ARGUMENT);
return add(cx, RootedAtom(cx), ARGUMENT);
}
void noteDup() { hasDup_ = true; }

View File

@ -428,13 +428,15 @@ ThisToStringForStringProto(JSContext *cx, CallReceiver call)
if (call.thisv().isObject()) {
RootedObject obj(cx, &call.thisv().toObject());
if (obj->isString()) {
Rooted<jsid> id(cx, NameToId(cx->runtime->atomState.toStringAtom));
if (ClassMethodIsNative(cx, obj, &StringClass, id, js_str_toString)) {
JSString *str = obj->asString().unbox();
call.thisv().setString(str);
return str;
}
if (obj->isString() &&
ClassMethodIsNative(cx, obj,
&StringClass,
RootedId(cx, NameToId(cx->runtime->atomState.toStringAtom)),
js_str_toString))
{
JSString *str = obj->asString().unbox();
call.thisv().setString(str);
return str;
}
} else if (call.thisv().isNullOrUndefined()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_CANT_CONVERT_TO,
@ -1982,7 +1984,7 @@ BuildFlatReplacement(JSContext *cx, HandleString textstr, HandleString repstr,
return false;
}
} else {
if (!builder.append(str))
if (!builder.append(RootedString(cx, str)))
return false;
}
pos += str->length();
@ -3063,9 +3065,8 @@ js_InitStringClass(JSContext *cx, JSObject *obj)
Rooted<GlobalObject*> global(cx, &obj->asGlobal());
Rooted<JSString*> empty(cx, cx->runtime->emptyString);
RootedObject proto(cx, global->createBlankPrototype(cx, &StringClass));
if (!proto || !proto->asString().init(cx, empty))
if (!proto || !proto->asString().init(cx, RootedString(cx, cx->runtime->emptyString)))
return NULL;
/* Now create the String function. */
@ -3285,8 +3286,7 @@ js_ValueToSource(JSContext *cx, const Value &v)
Value rval = NullValue();
Value fval;
RootedId id(cx, NameToId(cx->runtime->atomState.toSourceAtom));
Rooted<JSObject*> obj(cx, &v.toObject());
if (!GetMethod(cx, obj, id, 0, &fval))
if (!GetMethod(cx, RootedObject(cx, &v.toObject()), id, 0, &fval))
return NULL;
if (js_IsCallable(fval)) {
if (!Invoke(cx, v, fval, 0, NULL, &rval))

View File

@ -349,8 +349,7 @@ JSBool
ArrayBufferObject::obj_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
JSObject **objp, JSProperty **propp)
{
Rooted<jsid> id(cx, NameToId(name));
return obj_lookupGeneric(cx, obj, id, objp, propp);
return obj_lookupGeneric(cx, obj, RootedId(cx, NameToId(name)), objp, propp);
}
JSBool
@ -388,8 +387,7 @@ JSBool
ArrayBufferObject::obj_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
JSObject **objp, JSProperty **propp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return obj_lookupGeneric(cx, obj, id, objp, propp);
return obj_lookupGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), objp, propp);
}
JSBool
@ -404,7 +402,7 @@ ArrayBufferObject::obj_defineGeneric(JSContext *cx, HandleObject obj, HandleId i
RootedObject delegate(cx, DelegateObject(cx, obj));
if (!delegate)
return false;
return baseops::DefineGeneric(cx, delegate, id, v, getter, setter, attrs);
return baseops::DefineProperty(cx, delegate, id, v, getter, setter, attrs);
}
JSBool
@ -412,8 +410,7 @@ ArrayBufferObject::obj_defineProperty(JSContext *cx, HandleObject obj,
HandlePropertyName name, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
Rooted<jsid> id(cx, NameToId(name));
return obj_defineGeneric(cx, obj, id, v, getter, setter, attrs);
return obj_defineGeneric(cx, obj, RootedId(cx, NameToId(name)), v, getter, setter, attrs);
}
JSBool
@ -432,8 +429,8 @@ JSBool
ArrayBufferObject::obj_defineSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return obj_defineGeneric(cx, obj, id, v, getter, setter, attrs);
return obj_defineGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)),
v, getter, setter, attrs);
}
JSBool
@ -477,8 +474,7 @@ ArrayBufferObject::obj_getProperty(JSContext *cx, HandleObject obj,
nobj = DelegateObject(cx, nobj);
if (!nobj)
return false;
Rooted<jsid> id(cx, NameToId(name));
return baseops::GetProperty(cx, nobj, receiver, id, vp);
return baseops::GetProperty(cx, nobj, receiver, RootedId(cx, NameToId(name)), vp);
}
JSBool
@ -507,8 +503,7 @@ JSBool
ArrayBufferObject::obj_getSpecial(JSContext *cx, HandleObject obj,
HandleObject receiver, HandleSpecialId sid, Value *vp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return obj_getGeneric(cx, obj, receiver, id, vp);
return obj_getGeneric(cx, obj, receiver, RootedId(cx, SPECIALID_TO_JSID(sid)), vp);
}
JSBool
@ -553,8 +548,7 @@ ArrayBufferObject::obj_setGeneric(JSContext *cx, HandleObject obj, HandleId id,
obj->reportNotExtensible(cx);
return false;
}
Rooted<JSObject*> newProto(cx, vp->toObjectOrNull());
if (!SetProto(cx, obj, newProto, true)) {
if (!SetProto(cx, obj, RootedObject(cx, vp->toObjectOrNull()), true)) {
// this can be caused for example by setting x.__proto__ = x
// restore delegate prototype chain
SetProto(cx, delegate, oldDelegateProto, true);
@ -571,8 +565,7 @@ JSBool
ArrayBufferObject::obj_setProperty(JSContext *cx, HandleObject obj,
HandlePropertyName name, Value *vp, JSBool strict)
{
Rooted<jsid> id(cx, NameToId(name));
return obj_setGeneric(cx, obj, id, vp, strict);
return obj_setGeneric(cx, obj, RootedId(cx, NameToId(name)), vp, strict);
}
JSBool
@ -590,8 +583,7 @@ JSBool
ArrayBufferObject::obj_setSpecial(JSContext *cx, HandleObject obj,
HandleSpecialId sid, Value *vp, JSBool strict)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return obj_setGeneric(cx, obj, id, vp, strict);
return obj_setGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), vp, strict);
}
JSBool
@ -613,8 +605,7 @@ JSBool
ArrayBufferObject::obj_getPropertyAttributes(JSContext *cx, HandleObject obj,
HandlePropertyName name, unsigned *attrsp)
{
Rooted<jsid> id(cx, NameToId(name));
return obj_getGenericAttributes(cx, obj, id, attrsp);
return obj_getGenericAttributes(cx, obj, RootedId(cx, NameToId(name)), attrsp);
}
JSBool
@ -631,8 +622,7 @@ JSBool
ArrayBufferObject::obj_getSpecialAttributes(JSContext *cx, HandleObject obj,
HandleSpecialId sid, unsigned *attrsp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return obj_getGenericAttributes(cx, obj, id, attrsp);
return obj_getGenericAttributes(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), attrsp);
}
JSBool
@ -655,8 +645,7 @@ JSBool
ArrayBufferObject::obj_setPropertyAttributes(JSContext *cx, HandleObject obj,
HandlePropertyName name, unsigned *attrsp)
{
Rooted<jsid> id(cx, NameToId(name));
return obj_setGenericAttributes(cx, obj, id, attrsp);
return obj_setGenericAttributes(cx, obj, RootedId(cx, NameToId(name)), attrsp);
}
JSBool
@ -673,8 +662,7 @@ JSBool
ArrayBufferObject::obj_setSpecialAttributes(JSContext *cx, HandleObject obj,
HandleSpecialId sid, unsigned *attrsp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return obj_setGenericAttributes(cx, obj, id, attrsp);
return obj_setGenericAttributes(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), attrsp);
}
JSBool
@ -871,8 +859,7 @@ JSBool
TypedArray::obj_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
JSObject **objp, JSProperty **propp)
{
Rooted<jsid> id(cx, NameToId(name));
return obj_lookupGeneric(cx, obj, id, objp, propp);
return obj_lookupGeneric(cx, obj, RootedId(cx, NameToId(name)), objp, propp);
}
JSBool
@ -900,8 +887,7 @@ JSBool
TypedArray::obj_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
JSObject **objp, JSProperty **propp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return obj_lookupGeneric(cx, obj, id, objp, propp);
return obj_lookupGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), objp, propp);
}
JSBool
@ -930,8 +916,7 @@ TypedArray::obj_getElementAttributes(JSContext *cx, HandleObject obj, uint32_t i
JSBool
TypedArray::obj_getSpecialAttributes(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return obj_getGenericAttributes(cx, obj, id, attrsp);
return obj_getGenericAttributes(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), attrsp);
}
JSBool
@ -1121,9 +1106,9 @@ class TypedArrayTemplate
if (IsDefinitelyIndex(idval, &index))
return obj_getElement(cx, obj, receiver, index, vp);
Rooted<SpecialId> sid(cx);
if (ValueIsSpecial(obj, &idval, sid.address(), cx))
return obj_getSpecial(cx, obj, receiver, sid, vp);
SpecialId sid;
if (ValueIsSpecial(obj, &idval, &sid, cx))
return obj_getSpecial(cx, obj, receiver, Rooted<SpecialId>(cx, sid), vp);
JSAtom *atom = ToAtom(cx, idval);
if (!atom)
@ -1132,8 +1117,7 @@ class TypedArrayTemplate
if (atom->isIndex(&index))
return obj_getElement(cx, obj, receiver, index, vp);
Rooted<PropertyName*> name(cx, atom->asPropertyName());
return obj_getProperty(cx, obj, receiver, name, vp);
return obj_getProperty(cx, obj, receiver, RootedPropertyName(cx, atom->asPropertyName()), vp);
}
static JSBool
@ -1251,8 +1235,7 @@ class TypedArrayTemplate
static JSBool
obj_setProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *vp, JSBool strict)
{
Rooted<jsid> id(cx, NameToId(name));
return obj_setGeneric(cx, obj, id, vp, strict);
return obj_setGeneric(cx, obj, RootedId(cx, NameToId(name)), vp, strict);
}
static JSBool
@ -1277,8 +1260,7 @@ class TypedArrayTemplate
static JSBool
obj_setSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *vp, JSBool strict)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return obj_setGeneric(cx, obj, id, vp, strict);
return obj_setGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), vp, strict);
}
static JSBool
@ -1296,8 +1278,7 @@ class TypedArrayTemplate
obj_defineProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
Rooted<jsid> id(cx, NameToId(name));
return obj_defineGeneric(cx, obj, id, v, getter, setter, attrs);
return obj_defineGeneric(cx, obj, RootedId(cx, NameToId(name)), v, getter, setter, attrs);
}
static JSBool
@ -1312,8 +1293,7 @@ class TypedArrayTemplate
obj_defineSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return obj_defineGeneric(cx, obj, id, v, getter, setter, attrs);
return obj_defineGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), v, getter, setter, attrs);
}
static JSBool
@ -1557,8 +1537,7 @@ class TypedArrayTemplate
}
}
Rooted<JSObject*> proto(cx, NULL);
return fromBuffer(cx, dataObj, byteOffset, length, proto);
return fromBuffer(cx, dataObj, byteOffset, length, RootedObject(cx));
}
/* subarray(start[, end]) */
@ -2914,19 +2893,15 @@ JSFunctionSpec _typedArray::jsfuncs[] = { \
MOZ_ASSERT(nelements <= INT32_MAX); \
return TypedArrayTemplate<NativeType>::fromLength(cx, nelements); \
} \
JS_FRIEND_API(JSObject *) JS_New ## Name ## ArrayFromArray(JSContext *cx, JSObject *other_)\
JS_FRIEND_API(JSObject *) JS_New ## Name ## ArrayFromArray(JSContext *cx, JSObject *other) \
{ \
Rooted<JSObject*> other(cx, other_); \
return TypedArrayTemplate<NativeType>::fromArray(cx, other); \
return TypedArrayTemplate<NativeType>::fromArray(cx, RootedObject(cx, other)); \
} \
JS_FRIEND_API(JSObject *) JS_New ## Name ## ArrayWithBuffer(JSContext *cx, \
JSObject *arrayBuffer_, uint32_t byteoffset, int32_t length) \
JSObject *arrayBuffer, uint32_t byteoffset, int32_t length) \
{ \
MOZ_ASSERT(byteoffset <= INT32_MAX); \
Rooted<JSObject*> arrayBuffer(cx, arrayBuffer_); \
Rooted<JSObject*> proto(cx, NULL); \
return TypedArrayTemplate<NativeType>::fromBuffer(cx, arrayBuffer, byteoffset, length, \
proto); \
return TypedArrayTemplate<NativeType>::fromBuffer(cx, RootedObject(cx, arrayBuffer), byteoffset, length, RootedObject(cx)); \
} \
JS_FRIEND_API(JSBool) JS_Is ## Name ## Array(JSObject *obj, JSContext *cx) \
{ \

View File

@ -177,20 +177,17 @@ DirectWrapper::hasOwn(JSContext *cx, JSObject *wrapper, jsid id, bool *bp)
}
bool
DirectWrapper::get(JSContext *cx, JSObject *wrapper, JSObject *receiver_, jsid id_, Value *vp)
DirectWrapper::get(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id, Value *vp)
{
vp->setUndefined(); // default result if we refuse to perform this action
Rooted<JSObject*> receiver(cx, receiver_);
Rooted<jsid> id(cx, id_);
GET(wrappedObject(wrapper)->getGeneric(cx, receiver, id, vp));
GET(wrappedObject(wrapper)->getGeneric(cx, RootedObject(cx, receiver), RootedId(cx, id), vp));
}
bool
DirectWrapper::set(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id_, bool strict,
DirectWrapper::set(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id, bool strict,
Value *vp)
{
Rooted<jsid> id(cx, id_);
SET(wrappedObject(wrapper)->setGeneric(cx, id, vp, strict));
SET(wrappedObject(wrapper)->setGeneric(cx, RootedId(cx, id), vp, strict));
}
bool
@ -206,8 +203,7 @@ DirectWrapper::iterate(JSContext *cx, JSObject *wrapper, unsigned flags, Value *
{
vp->setUndefined(); // default result if we refuse to perform this action
const jsid id = JSID_VOID;
Rooted<JSObject*> wrapped(cx, wrappedObject(wrapper));
GET(GetIterator(cx, wrapped, flags, vp));
GET(GetIterator(cx, RootedObject(cx, wrappedObject(wrapper)), flags, vp));
}
bool
@ -419,8 +415,7 @@ ErrorCopier::~ErrorCopier()
if (exc.isObject() && exc.toObject().isError() && exc.toObject().getPrivate()) {
cx->clearPendingException();
ac.leave();
Rooted<JSObject*> errObj(cx, &exc.toObject());
JSObject *copyobj = js_CopyErrorObject(cx, errObj, scope);
JSObject *copyobj = js_CopyErrorObject(cx, RootedObject(cx, &exc.toObject()), scope);
if (copyobj)
cx->setPendingException(ObjectValue(*copyobj));
}

View File

@ -386,8 +386,7 @@ ConvertQNameToString(JSContext *cx, JSObject *obj)
if (!str)
return NULL;
}
Rooted<JSString*> localName(cx, obj->getQNameLocalName());
str = js_ConcatStrings(cx, str, localName);
str = js_ConcatStrings(cx, str, RootedString(cx, obj->getQNameLocalName()));
if (!str)
return NULL;
@ -4000,8 +3999,7 @@ PutProperty(JSContext *cx, HandleObject obj_, HandleId id_, JSBool strict, jsval
* Note that rxml can't be null here, because target
* and targetprop are non-null.
*/
Rooted<JSObject*> robj(cx, rxml->object);
ok = GetProperty(cx, robj, id, &attrval);
ok = GetProperty(cx, RootedObject(cx, rxml->object), id, &attrval);
if (!ok)
goto out;
if (JSVAL_IS_PRIMITIVE(attrval)) /* no such attribute */
@ -4565,8 +4563,7 @@ ResolveValue(JSContext *cx, JSXML *list, JSXML **result)
return JS_FALSE;
RootedId id(cx, OBJECT_TO_JSID(targetprop));
Rooted<JSObject*> baseObj(cx, base->object);
if (!GetProperty(cx, baseObj, id, &tv))
if (!GetProperty(cx, RootedObject(cx, base->object), id, &tv))
return JS_FALSE;
target = (JSXML *) JSVAL_TO_OBJECT(tv)->getPrivate();
@ -4576,9 +4573,9 @@ ResolveValue(JSContext *cx, JSXML *list, JSXML **result)
return JS_TRUE;
}
tv = STRING_TO_JSVAL(cx->runtime->emptyString);
if (!PutProperty(cx, baseObj, id, false, &tv))
if (!PutProperty(cx, RootedObject(cx, base->object), id, false, &tv))
return JS_FALSE;
if (!GetProperty(cx, baseObj, id, &tv))
if (!GetProperty(cx, RootedObject(cx, base->object), id, &tv))
return JS_FALSE;
target = (JSXML *) JSVAL_TO_OBJECT(tv)->getPrivate();
}
@ -4640,18 +4637,17 @@ static JSBool
HasSimpleContent(JSXML *xml);
static JSBool
HasFunctionProperty(JSContext *cx, JSObject *obj_, jsid funid_, JSBool *found)
HasFunctionProperty(JSContext *cx, JSObject *obj, jsid funid_, JSBool *found)
{
JSObject *pobj;
JSProperty *prop;
JSXML *xml;
JS_ASSERT(obj_->getClass() == &XMLClass);
JS_ASSERT(obj->getClass() == &XMLClass);
RootedId funid(cx, funid_);
Rooted<JSObject*> obj(cx, obj_);
if (!baseops::LookupProperty(cx, obj, funid, &pobj, &prop))
if (!baseops::LookupProperty(cx, RootedObject(cx, obj), funid, &pobj, &prop))
return false;
if (!prop) {
xml = (JSXML *) obj->getPrivate();
@ -4794,8 +4790,7 @@ static JSBool
xml_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, JSObject **objp,
JSProperty **propp)
{
Rooted<jsid> id(cx, NameToId(name));
return xml_lookupGeneric(cx, obj, id, objp, propp);
return xml_lookupGeneric(cx, obj, RootedId(cx, NameToId(name)), objp, propp);
}
static JSBool
@ -4814,8 +4809,9 @@ xml_lookupElement(JSContext *cx, HandleObject obj, uint32_t index, JSObject **ob
return false;
const Shape *shape =
js_AddNativeProperty(cx, obj, id, GetProperty, PutProperty, SHAPE_INVALID_SLOT,
JSPROP_ENUMERATE, 0, 0);
js_AddNativeProperty(cx, RootedObject(cx, obj), id, GetProperty, PutProperty,
SHAPE_INVALID_SLOT, JSPROP_ENUMERATE,
0, 0);
if (!shape)
return false;
@ -4827,8 +4823,7 @@ xml_lookupElement(JSContext *cx, HandleObject obj, uint32_t index, JSObject **ob
static JSBool
xml_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, JSObject **objp, JSProperty **propp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return xml_lookupGeneric(cx, obj, id, objp, propp);
return xml_lookupGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), objp, propp);
}
static JSBool
@ -4838,7 +4833,7 @@ xml_defineGeneric(JSContext *cx, HandleObject obj, HandleId id, const Value *v,
if (IsFunctionObject(*v) || getter || setter ||
(attrs & JSPROP_ENUMERATE) == 0 ||
(attrs & (JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_SHARED))) {
return baseops::DefineGeneric(cx, obj, id, v, getter, setter, attrs);
return baseops::DefineProperty(cx, obj, id, v, getter, setter, attrs);
}
jsval tmp = *v;
@ -4849,8 +4844,7 @@ static JSBool
xml_defineProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
Rooted<jsid> id(cx, NameToId(name));
return xml_defineGeneric(cx, obj, id, v, getter, setter, attrs);
return xml_defineGeneric(cx, obj, RootedId(cx, NameToId(name)), v, getter, setter, attrs);
}
static JSBool
@ -4867,8 +4861,7 @@ static JSBool
xml_defineSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, const Value *v,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return xml_defineGeneric(cx, obj, id, v, getter, setter, attrs);
return xml_defineGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), v, getter, setter, attrs);
}
static JSBool
@ -4885,8 +4878,7 @@ xml_getGeneric(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId
static JSBool
xml_getProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandlePropertyName name, Value *vp)
{
Rooted<jsid> id(cx, NameToId(name));
return xml_getGeneric(cx, obj, receiver, id, vp);
return xml_getGeneric(cx, obj, receiver, RootedId(cx, NameToId(name)), vp);
}
static JSBool
@ -4901,8 +4893,7 @@ xml_getElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t
static JSBool
xml_getSpecial(JSContext *cx, HandleObject obj, HandleObject receiver, HandleSpecialId sid, Value *vp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return xml_getGeneric(cx, obj, receiver, id, vp);
return xml_getGeneric(cx, obj, receiver, RootedId(cx, SPECIALID_TO_JSID(sid)), vp);
}
static JSBool
@ -4914,8 +4905,7 @@ xml_setGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *vp, JSBool s
static JSBool
xml_setProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *vp, JSBool strict)
{
Rooted<jsid> id(cx, NameToId(name));
return xml_setGeneric(cx, obj, id, vp, strict);
return xml_setGeneric(cx, obj, RootedId(cx, NameToId(name)), vp, strict);
}
static JSBool
@ -4930,8 +4920,7 @@ xml_setElement(JSContext *cx, HandleObject obj, uint32_t index, Value *vp, JSBoo
static JSBool
xml_setSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *vp, JSBool strict)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return xml_setGeneric(cx, obj, id, vp, strict);
return xml_setGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), vp, strict);
}
static JSBool
@ -4948,8 +4937,7 @@ xml_getGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned
static JSBool
xml_getPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp)
{
Rooted<jsid> id(cx, NameToId(name));
return xml_getGenericAttributes(cx, obj, id, attrsp);
return xml_getGenericAttributes(cx, obj, RootedId(cx, NameToId(name)), attrsp);
}
static JSBool
@ -4964,8 +4952,7 @@ xml_getElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsign
static JSBool
xml_getSpecialAttributes(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return xml_getGenericAttributes(cx, obj, id, attrsp);
return xml_getGenericAttributes(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), attrsp);
}
static JSBool
@ -4986,8 +4973,7 @@ xml_setGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned
static JSBool
xml_setPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp)
{
Rooted<jsid> id(cx, NameToId(name));
return xml_setGenericAttributes(cx, obj, id, attrsp);
return xml_setGenericAttributes(cx, obj, RootedId(cx, NameToId(name)), attrsp);
}
static JSBool
@ -5002,8 +4988,7 @@ xml_setElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsign
static JSBool
xml_setSpecialAttributes(JSContext *cx, HandleObject obj, HandleSpecialId sid, unsigned *attrsp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return xml_setGenericAttributes(cx, obj, id, attrsp);
return xml_setGenericAttributes(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), attrsp);
}
static JSBool
@ -5052,8 +5037,7 @@ xml_deleteGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *rval, JSB
static JSBool
xml_deleteProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *rval, JSBool strict)
{
Rooted<jsid> id(cx, NameToId(name));
return xml_deleteGeneric(cx, obj, id, rval, strict);
return xml_deleteGeneric(cx, obj, RootedId(cx, NameToId(name)), rval, strict);
}
static JSBool
@ -5086,8 +5070,7 @@ xml_deleteElement(JSContext *cx, HandleObject obj, uint32_t index, Value *rval,
static JSBool
xml_deleteSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *rval, JSBool strict)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return xml_deleteGeneric(cx, obj, id, rval, strict);
return xml_deleteGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), rval, strict);
}
static JSString *
@ -5228,20 +5211,19 @@ again:
* 11.2.2.1 Step 3(d) onward.
*/
JSBool
js_GetXMLMethod(JSContext *cx, HandleObject obj, jsid id_, Value *vp)
js_GetXMLMethod(JSContext *cx, HandleObject obj, jsid id, Value *vp)
{
JS_ASSERT(obj->isXML());
Rooted<jsid> id(cx, id_);
if (JSID_IS_OBJECT(id))
js_GetLocalNameFromFunctionQName(JSID_TO_OBJECT(id), id.address(), cx);
js_GetLocalNameFromFunctionQName(JSID_TO_OBJECT(id), &id, cx);
/*
* As our callers have a bad habit of passing a pointer to an unrooted
* local value as vp, we use a proper root here.
*/
AutoValueRooter tvr(cx);
JSBool ok = GetXMLFunction(cx, obj, id, tvr.addr());
JSBool ok = GetXMLFunction(cx, obj, RootedId(cx, id), tvr.addr());
*vp = tvr.value();
return ok;
}
@ -5520,6 +5502,10 @@ xml_addNamespace(JSContext *cx, unsigned argc, jsval *vp)
static JSBool
xml_appendChild(JSContext *cx, unsigned argc, jsval *vp)
{
jsval v;
JSObject *vobj;
JSXML *vxml;
NON_LIST_XML_METHOD_PROLOG;
xml = CHECK_COPY_ON_WRITE(cx, xml, obj);
if (!xml)
@ -5529,21 +5515,20 @@ xml_appendChild(JSContext *cx, unsigned argc, jsval *vp)
if (!js_GetAnyName(cx, name.address()))
return JS_FALSE;
Value v;
if (!GetProperty(cx, obj, name, &v))
return JS_FALSE;
JS_ASSERT(!JSVAL_IS_PRIMITIVE(v));
Rooted<JSObject*> vobj(cx, &v.toObject());
vobj = JSVAL_TO_OBJECT(v);
JS_ASSERT(vobj->isXML());
JSXML *vxml = (JSXML *) vobj->getPrivate();
vxml = (JSXML *) vobj->getPrivate();
JS_ASSERT(vxml->xml_class == JSXML_CLASS_LIST);
if (!IndexToId(cx, vxml->xml_kids.length, name.address()))
return JS_FALSE;
*vp = (argc != 0) ? vp[2] : JSVAL_VOID;
if (!PutProperty(cx, vobj, name, false, vp))
if (!PutProperty(cx, RootedObject(cx, JSVAL_TO_OBJECT(v)), name, false, vp))
return JS_FALSE;
*vp = OBJECT_TO_JSVAL(obj);
@ -5629,7 +5614,7 @@ ValueToIdForXML(JSContext *cx, jsval v, jsid *idp)
}
static JSBool
xml_child_helper(JSContext *cx, JSObject *obj_, JSXML *xml, jsval name,
xml_child_helper(JSContext *cx, JSObject *obj, JSXML *xml, jsval name,
jsval *rval)
{
bool isIndex;
@ -5640,8 +5625,6 @@ xml_child_helper(JSContext *cx, JSObject *obj_, JSXML *xml, jsval name,
/* ECMA-357 13.4.4.6 */
JS_ASSERT(xml->xml_class != JSXML_CLASS_LIST);
Rooted<JSObject*> obj(cx, obj_);
if (!IdValIsIndex(cx, name, &index, &isIndex))
return JS_FALSE;
@ -5666,7 +5649,7 @@ xml_child_helper(JSContext *cx, JSObject *obj_, JSXML *xml, jsval name,
if (!ValueToIdForXML(cx, name, id.address()))
return JS_FALSE;
return GetProperty(cx, obj, id, rval);
return GetProperty(cx, RootedObject(cx, obj), id, rval);
}
/* XML and XMLList */
@ -6351,11 +6334,9 @@ xml_normalize_helper(JSContext *cx, JSObject *obj, JSXML *xml)
} else if (kid->xml_class == JSXML_CLASS_TEXT) {
while (i + 1 < n &&
(kid2 = XMLARRAY_MEMBER(&xml->xml_kids, i + 1, JSXML)) &&
kid2->xml_class == JSXML_CLASS_TEXT)
{
Rooted<JSString*> lstr(cx, kid->xml_value);
Rooted<JSString*> rstr(cx, kid2->xml_value);
str = js_ConcatStrings(cx, lstr, rstr);
kid2->xml_class == JSXML_CLASS_TEXT) {
str = js_ConcatStrings(cx, RootedString(cx, kid->xml_value),
RootedString(cx, kid2->xml_value));
if (!str)
return JS_FALSE;
NormalizingDelete(cx, xml, i + 1);
@ -6702,9 +6683,8 @@ xml_setChildren(JSContext *cx, unsigned argc, jsval *vp)
if (!StartNonListXMLMethod(cx, vp, obj.address()))
return JS_FALSE;
Rooted<jsid> id(cx, NameToId(cx->runtime->atomState.starAtom));
*vp = argc != 0 ? vp[2] : JSVAL_VOID; /* local root */
if (!PutProperty(cx, obj, id, false, vp))
if (!PutProperty(cx, obj, RootedId(cx, NameToId(cx->runtime->atomState.starAtom)), false, vp))
return JS_FALSE;
*vp = OBJECT_TO_JSVAL(obj);

View File

@ -4822,29 +4822,27 @@ mjit::Compiler::jsop_getprop(PropertyName *name, JSValueType knownType,
bool testObject;
JSObject *singleton =
(*PC == JSOP_GETPROP || *PC == JSOP_CALLPROP) ? pushedSingleton(0) : NULL;
if (singleton && singleton->isFunction() && !hasTypeBarriers(PC)) {
Rooted<jsid> id(cx, NameToId(name));
if (testSingletonPropertyTypes(top, id, &testObject)) {
if (testObject) {
Jump notObject = frame.testObject(Assembler::NotEqual, top);
stubcc.linkExit(notObject, Uses(1));
stubcc.leave();
stubcc.masm.move(ImmPtr(name), Registers::ArgReg1);
OOL_STUBCALL(stubs::GetProp, REJOIN_FALLTHROUGH);
testPushedType(REJOIN_FALLTHROUGH, -1);
}
frame.pop();
frame.push(ObjectValue(*singleton));
if (script->hasScriptCounts && cx->typeInferenceEnabled())
bumpPropCount(PC, PCCounts::PROP_STATIC);
if (testObject)
stubcc.rejoin(Changes(1));
return true;
if (singleton && singleton->isFunction() && !hasTypeBarriers(PC) &&
testSingletonPropertyTypes(top, RootedId(cx, NameToId(name)), &testObject)) {
if (testObject) {
Jump notObject = frame.testObject(Assembler::NotEqual, top);
stubcc.linkExit(notObject, Uses(1));
stubcc.leave();
stubcc.masm.move(ImmPtr(name), Registers::ArgReg1);
OOL_STUBCALL(stubs::GetProp, REJOIN_FALLTHROUGH);
testPushedType(REJOIN_FALLTHROUGH, -1);
}
frame.pop();
frame.push(ObjectValue(*singleton));
if (script->hasScriptCounts && cx->typeInferenceEnabled())
bumpPropCount(PC, PCCounts::PROP_STATIC);
if (testObject)
stubcc.rejoin(Changes(1));
return true;
}
/* Check if this is a property access we can make a loop invariant entry for. */
@ -5121,8 +5119,7 @@ mjit::Compiler::testSingletonPropertyTypes(FrameEntry *top, HandleId id, bool *t
JS_ASSERT_IF(top->isTypeKnown(), top->isType(JSVAL_TYPE_OBJECT));
types::TypeObject *object = types->getTypeObject(0);
if (object && object->proto) {
Rooted<JSObject*> proto(cx, object->proto);
if (!testSingletonProperty(proto, id))
if (!testSingletonProperty(RootedObject(cx, object->proto), id))
return false;
types->addFreeze(cx);
@ -5199,13 +5196,12 @@ mjit::Compiler::jsop_getprop_dispatch(PropertyName *name)
if (ownTypes->isOwnProperty(cx, object, false))
return false;
Rooted<JSObject*> proto(cx, object->proto);
if (!testSingletonProperty(proto, id))
if (!testSingletonProperty(RootedObject(cx, object->proto), id))
return false;
if (proto->getType(cx)->unknownProperties())
if (object->proto->getType(cx)->unknownProperties())
return false;
types::TypeSet *protoTypes = proto->type()->getProperty(cx, id, false);
types::TypeSet *protoTypes = object->proto->type()->getProperty(cx, id, false);
if (!protoTypes)
return false;
JSObject *singleton = protoTypes->getSingleton(cx);
@ -6259,12 +6255,9 @@ mjit::Compiler::jsop_getgname(uint32_t index)
/* Optimize singletons like Math for JSOP_CALLPROP. */
JSObject *obj = pushedSingleton(0);
if (obj && !hasTypeBarriers(PC)) {
Rooted<jsid> id(cx, NameToId(name));
if (testSingletonProperty(globalObj, id)) {
frame.push(ObjectValue(*obj));
return true;
}
if (obj && !hasTypeBarriers(PC) && testSingletonProperty(globalObj, RootedId(cx, NameToId(name)))) {
frame.push(ObjectValue(*obj));
return true;
}
jsid id = NameToId(name);

View File

@ -2655,11 +2655,11 @@ mjit::Compiler::jsop_initprop()
JSObject *holder;
JSProperty *prop = NULL;
Rooted<jsid> id(cx, NameToId(name));
#ifdef DEBUG
bool res =
#endif
LookupPropertyWithFlags(cx, baseobj, id, JSRESOLVE_QUALIFIED, &holder, &prop);
LookupPropertyWithFlags(cx, baseobj, RootedId(cx, NameToId(name)),
JSRESOLVE_QUALIFIED, &holder, &prop);
JS_ASSERT(res && prop && holder == baseobj);
RegisterID objReg = frame.copyDataIntoReg(obj);

View File

@ -1665,7 +1665,7 @@ class ScopeNameCompiler : public PICStubCompiler
bool retrieve(Value *vp, PICInfo::Kind kind)
{
JSObject *obj = getprop.obj;
Rooted<JSObject*> holder(cx, getprop.holder);
JSObject *holder = getprop.holder;
const JSProperty *prop = getprop.prop;
if (!prop) {
@ -1690,7 +1690,7 @@ class ScopeNameCompiler : public PICStubCompiler
}
const Shape *shape = getprop.shape;
Rooted<JSObject*> normalized(cx, obj);
JSObject *normalized = obj;
if (obj->isWith() && !shape->hasDefaultGetter())
normalized = &obj->asWith().object();
NATIVE_GET(cx, normalized, holder, shape, 0, vp, return false);
@ -2437,8 +2437,7 @@ GetElementIC::attachTypedArray(VMFrame &f, JSObject *obj, const Value &v, jsid i
disable(f, "generated typed array stub");
// Fetch the value as expected of Lookup_Cacheable for GetElement.
Rooted<jsid> idRoot(cx, id);
if (!obj->getGeneric(cx, idRoot, vp))
if (!obj->getGeneric(cx, RootedId(cx, id), vp))
return Lookup_Error;
return Lookup_Cacheable;
@ -2505,11 +2504,11 @@ ic::GetElement(VMFrame &f, ic::GetElementIC *ic)
}
#endif
Rooted<jsid> id(cx);
jsid id;
if (idval.isInt32() && INT_FITS_IN_JSID(idval.toInt32())) {
id = INT_TO_JSID(idval.toInt32());
} else {
if (!InternNonIntElementId(cx, obj, idval, id.address()))
if (!InternNonIntElementId(cx, obj, idval, &id))
THROW();
}
@ -2528,7 +2527,7 @@ ic::GetElement(VMFrame &f, ic::GetElementIC *ic)
}
}
if (!obj->getGeneric(cx, id, &f.regs.sp[-2]))
if (!obj->getGeneric(cx, RootedId(cx, id), &f.regs.sp[-2]))
THROW();
#if JS_HAS_NO_SUCH_METHOD

View File

@ -52,10 +52,10 @@ using namespace js::types;
using namespace JSC;
void JS_FASTCALL
stubs::BindName(VMFrame &f, PropertyName *name_)
stubs::BindName(VMFrame &f, PropertyName *name)
{
Rooted<PropertyName*> name(f.cx, name_);
JSObject *obj = FindIdentifierBase(f.cx, f.fp()->scopeChain(), name);
JSObject *obj = FindIdentifierBase(f.cx, f.fp()->scopeChain(),
RootedPropertyName(f.cx, name));
if (!obj)
THROW();
f.regs.sp[0].setObject(*obj);
@ -505,8 +505,7 @@ StubEqualityOp(VMFrame &f)
JSObject *l = &lval.toObject(), *r = &rval.toObject();
if (JSEqualityOp eq = l->getClass()->ext.equality) {
JSBool equal;
Rooted<JSObject*> lobj(cx, l);
if (!eq(cx, lobj, &rval, &equal))
if (!eq(cx, RootedObject(cx, l), &rval, &equal))
return false;
cond = !!equal == EQ;
} else {
@ -887,8 +886,7 @@ stubs::NewInitObject(VMFrame &f, JSObject *baseobj)
JSObject *obj;
if (baseobj) {
Rooted<JSObject*> base(cx, baseobj);
obj = CopyInitializerObject(cx, base);
obj = CopyInitializerObject(cx, RootedObject(cx, baseobj));
} else {
gc::AllocKind kind = GuessObjectGCKind(0);
obj = NewBuiltinClassInstance(cx, &ObjectClass, kind);
@ -1067,8 +1065,8 @@ stubs::IterMore(VMFrame &f)
JS_ASSERT(f.regs.sp[-1].isObject());
Value v;
Rooted<JSObject*> iterobj(f.cx, &f.regs.sp[-1].toObject());
if (!js_IteratorMore(f.cx, iterobj, &v))
JSObject *iterobj = &f.regs.sp[-1].toObject();
if (!js_IteratorMore(f.cx, RootedObject(f.cx, iterobj), &v))
THROWV(JS_FALSE);
return v.toBoolean();
@ -1402,8 +1400,9 @@ stubs::DefVarOrConst(VMFrame &f, PropertyName *dn)
if (JSOp(*f.regs.pc) == JSOP_DEFCONST)
attrs |= JSPROP_READONLY;
Rooted<JSObject*> varobj(f.cx, &f.fp()->varObj());
if (!DefVarOrConstOperation(f.cx, varobj, dn, attrs))
JSObject &obj = f.fp()->varObj();
if (!DefVarOrConstOperation(f.cx, RootedObject(f.cx, &obj), dn, attrs))
THROW();
}

View File

@ -2782,8 +2782,7 @@ static JSBool
resolver_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags, JSObject **objp)
{
jsval v = JS_GetReservedSlot(obj, 0);
Rooted<JSObject*> vobj(cx, &v.toObject());
return CopyProperty(cx, obj, vobj, id, flags, objp);
return CopyProperty(cx, obj, RootedObject(cx, JSVAL_TO_OBJECT(v)), id, flags, objp);
}
static JSBool
@ -2795,10 +2794,8 @@ resolver_enumerate(JSContext *cx, HandleObject obj)
AutoIdArray ida(cx, JS_Enumerate(cx, referent));
bool ok = !!ida;
JSObject *ignore;
for (size_t i = 0; ok && i < ida.length(); i++) {
Rooted<jsid> id(cx, ida[i]);
ok = CopyProperty(cx, obj, referent, id, JSRESOLVE_QUALIFIED, &ignore);
}
for (size_t i = 0; ok && i < ida.length(); i++)
ok = CopyProperty(cx, obj, referent, RootedId(cx, ida[i]), JSRESOLVE_QUALIFIED, &ignore);
return ok;
}
@ -3150,13 +3147,13 @@ Parent(JSContext *cx, unsigned argc, jsval *vp)
return false;
}
Rooted<JSObject*> parent(cx, JS_GetParent(&v.toObject()));
JSObject *parent = JS_GetParent(JSVAL_TO_OBJECT(v));
*vp = OBJECT_TO_JSVAL(parent);
/* Outerize if necessary. Embrace the ugliness! */
if (parent) {
if (JSObjectOp op = parent->getClass()->ext.outerObject)
*vp = OBJECT_TO_JSVAL(op(cx, parent));
*vp = OBJECT_TO_JSVAL(op(cx, RootedObject(cx, parent)));
}
return true;

View File

@ -552,8 +552,7 @@ FindReferences(JSContext *cx, unsigned argc, jsval *vp)
/* Given the reversed map, find the referents of target. */
ReferenceFinder finder(cx, reverser);
Rooted<JSObject*> targetObj(cx, &target.toObject());
JSObject *references = finder.findReferences(targetObj);
JSObject *references = finder.findReferences(RootedObject(cx, &target.toObject()));
if (!references)
return false;

View File

@ -203,7 +203,7 @@ ArgSetter(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, Value *vp
*/
RootedValue value(cx);
return baseops::DeleteGeneric(cx, obj, id, value.address(), false) &&
baseops::DefineGeneric(cx, obj, id, vp, NULL, NULL, JSPROP_ENUMERATE);
baseops::DefineProperty(cx, obj, id, vp, NULL, NULL, JSPROP_ENUMERATE);
}
static JSBool
@ -233,7 +233,7 @@ args_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
}
Value undef = UndefinedValue();
if (!baseops::DefineGeneric(cx, argsobj, id, &undef, ArgGetter, ArgSetter, attrs))
if (!baseops::DefineProperty(cx, argsobj, id, &undef, ArgGetter, ArgSetter, attrs))
return JS_FALSE;
*objp = argsobj;
@ -282,8 +282,7 @@ NormalArgumentsObject::optimizedGetElem(JSContext *cx, StackFrame *fp, const Val
if (!proto)
return false;
Rooted<jsid> root(cx, id);
return proto->getGeneric(cx, root, vp);
return proto->getGeneric(cx, RootedId(cx, id), vp);
}
static JSBool
@ -397,7 +396,7 @@ strictargs_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
}
Value undef = UndefinedValue();
if (!baseops::DefineGeneric(cx, argsobj, id, &undef, getter, setter, attrs))
if (!baseops::DefineProperty(cx, argsobj, id, &undef, getter, setter, attrs))
return false;
*objp = argsobj;

View File

@ -840,7 +840,7 @@ Debugger::parseResumptionValue(AutoCompartment &ac, bool ok, const Value &rv, Va
/* Check that rv is {return: val} or {throw: val}. */
JSContext *cx = ac.context;
Rooted<JSObject*> obj(cx);
JSObject *obj;
const Shape *shape;
jsid returnId = NameToId(cx->runtime->atomState.returnAtom);
jsid throwId = NameToId(cx->runtime->atomState.throwAtom);
@ -878,13 +878,11 @@ CallMethodIfPresent(JSContext *cx, HandleObject obj, const char *name, int argc,
{
rval->setUndefined();
JSAtom *atom = js_Atomize(cx, name, strlen(name));
if (!atom)
return false;
Rooted<jsid> id(cx, AtomToId(atom));
Value fval;
return GetMethod(cx, obj, id, 0, &fval) &&
(!js_IsCallable(fval) || Invoke(cx, ObjectValue(*obj), fval, argc, argv, rval));
return atom &&
GetMethod(cx, obj, RootedId(cx, AtomToId(atom)), 0, &fval) &&
(!js_IsCallable(fval) ||
Invoke(cx, ObjectValue(*obj), fval, argc, argv, rval));
}
JSTrapStatus
@ -1130,8 +1128,7 @@ Debugger::onTrap(JSContext *cx, Value *vp)
if (!dbg->getScriptFrame(cx, fp, &argv[0]))
return dbg->handleUncaughtException(ac, vp, false);
Value rv;
Rooted<JSObject*> handler(cx, bp->handler);
bool ok = CallMethodIfPresent(cx, handler, "hit", 1, argv, &rv);
bool ok = CallMethodIfPresent(cx, RootedObject(cx, bp->handler), "hit", 1, argv, &rv);
JSTrapStatus st = dbg->parseResumptionValue(ac, ok, rv, vp, true);
if (st != JSTRAP_CONTINUE)
return st;
@ -2322,8 +2319,7 @@ Debugger::findScripts(JSContext *cx, unsigned argc, Value *vp)
result->ensureDenseArrayInitializedLength(cx, 0, scripts.length());
for (size_t i = 0; i < scripts.length(); i++) {
JSObject *scriptObject =
dbg->wrapScript(cx, Handle<JSScript*>::fromMarkedLocation(&scripts[i]));
JSObject *scriptObject = dbg->wrapScript(cx, Rooted<JSScript*>(cx, scripts[i]));
if (!scriptObject)
return false;
result->setDenseArrayElement(i, ObjectValue(*scriptObject));
@ -2541,13 +2537,11 @@ DebuggerScript_getChildScripts(JSContext *cx, unsigned argc, Value *vp)
* It is not really a child script of this script, so skip it.
*/
ObjectArray *objects = script->objects();
Rooted<JSScript*> script(cx);
for (uint32_t i = script->savedCallerFun ? 1 : 0; i < objects->length; i++) {
JSObject *obj = objects->vector[i];
if (obj->isFunction()) {
JSFunction *fun = static_cast<JSFunction *>(obj);
script = fun->script();
JSObject *s = dbg->wrapScript(cx, script);
JSObject *s = dbg->wrapScript(cx, Rooted<JSScript*>(cx, fun->script()));
if (!s || !js_NewbornArrayPush(cx, result, ObjectValue(*s)))
return false;
}
@ -3214,7 +3208,7 @@ DebuggerFrame_getArguments(JSContext *cx, unsigned argc, Value *vp)
SetReservedSlot(argsobj, JSSLOT_DEBUGARGUMENTS_FRAME, ObjectValue(*thisobj));
JS_ASSERT(fp->numActualArgs() <= 0x7fffffff);
unsigned fargc = fp->numActualArgs();
int32_t fargc = int32_t(fp->numActualArgs());
if (!DefineNativeProperty(cx, argsobj, cx->runtime->atomState.lengthAtom,
Int32Value(fargc), NULL, NULL,
JSPROP_PERMANENT | JSPROP_READONLY, 0, 0))
@ -3222,16 +3216,12 @@ DebuggerFrame_getArguments(JSContext *cx, unsigned argc, Value *vp)
return false;
}
Rooted<jsid> id(cx);
for (unsigned i = 0; i < fargc; i++) {
for (int32_t i = 0; i < fargc; i++) {
RootedFunction getobj(cx);
getobj = js_NewFunction(cx, NULL, DebuggerArguments_getArg, 0, 0, global, NULL,
JSFunction::ExtendedFinalizeKind);
if (!getobj)
return false;
id = INT_TO_JSID(i);
if (!getobj ||
!DefineNativeProperty(cx, argsobj, id, UndefinedValue(),
!DefineNativeProperty(cx, argsobj, RootedId(cx, INT_TO_JSID(i)), UndefinedValue(),
JS_DATA_TO_FUNC_PTR(PropertyOp, getobj.reference()), NULL,
JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_GETTER, 0, 0))
{
@ -3257,8 +3247,7 @@ DebuggerFrame_getScript(JSContext *cx, unsigned argc, Value *vp)
if (fp->isFunctionFrame() && !fp->isEvalFrame()) {
JSFunction &callee = fp->callee();
if (callee.isInterpreted()) {
Rooted<JSScript*> script(cx, callee.script());
scriptObject = debug->wrapScript(cx, script);
scriptObject = debug->wrapScript(cx, Rooted<JSScript*>(cx, callee.script()));
if (!scriptObject)
return false;
}
@ -3267,8 +3256,8 @@ DebuggerFrame_getScript(JSContext *cx, unsigned argc, Value *vp)
* We got eval, JS_Evaluate*, or JS_ExecuteScript non-function script
* frames.
*/
Rooted<JSScript*> script(cx, fp->script());
scriptObject = debug->wrapScript(cx, script);
JSScript *script = fp->script();
scriptObject = debug->wrapScript(cx, Rooted<JSScript*>(cx, script));
if (!scriptObject)
return false;
}
@ -3458,8 +3447,7 @@ DebuggerFrameEval(JSContext *cx, unsigned argc, Value *vp, EvalBindingsMode mode
}
for (size_t i = 0; i < keys.length(); i++) {
Value *valp = &values[i];
if (!bindingsobj->getGeneric(cx, bindingsobj,
Handle<jsid>::fromMarkedLocation(&keys[i]), valp) ||
if (!bindingsobj->getGeneric(cx, bindingsobj, RootedId(cx, keys[i]), valp) ||
!dbg->unwrapDebuggeeValue(cx, valp))
{
return false;
@ -3728,8 +3716,7 @@ DebuggerObject_getScript(JSContext *cx, unsigned argc, Value *vp)
return true;
}
Rooted<JSScript*> script(cx, fun->script());
JSObject *scriptObject = dbg->wrapScript(cx, script);
JSObject *scriptObject = dbg->wrapScript(cx, Rooted<JSScript*>(cx, fun->script()));
if (!scriptObject)
return false;
@ -3932,11 +3919,8 @@ DebuggerObject_defineProperties(JSContext *cx, unsigned argc, Value *vp)
ErrorCopier ec(ac, dbg->toJSObject());
for (size_t i = 0; i < n; i++) {
bool dummy;
if (!DefineProperty(cx, obj, Handle<jsid>::fromMarkedLocation(&rewrappedIds[i]),
rewrappedDescs[i], true, &dummy))
{
if (!DefineProperty(cx, obj, RootedId(cx, rewrappedIds[i]), rewrappedDescs[i], true, &dummy))
return false;
}
}
}

View File

@ -97,16 +97,14 @@ RegExpObjectBuilder::clone(Handle<RegExpObject *> other, Handle<RegExpObject *>
RegExpFlag staticsFlags = res->getFlags();
if ((origFlags & staticsFlags) != staticsFlags) {
RegExpFlag newFlags = RegExpFlag(origFlags | staticsFlags);
Rooted<JSAtom *> source(cx, other->getSource());
return build(source, newFlags);
return build(Rooted<JSAtom *>(cx, other->getSource()), newFlags);
}
RegExpGuard g;
if (!other->getShared(cx, &g))
return NULL;
Rooted<JSAtom *> source(cx, other->getSource());
return build(source, *g);
return build(RootedAtom(cx, other->getSource()), *g);
}
/* MatchPairs */
@ -620,12 +618,14 @@ RegExpCompartment::get(JSContext *cx, JSAtom *atom, JSString *opt, RegExpGuard *
/* Functions */
JSObject *
js::CloneRegExpObject(JSContext *cx, JSObject *obj_, JSObject *proto_)
js::CloneRegExpObject(JSContext *cx, JSObject *obj, JSObject *proto)
{
JS_ASSERT(obj->isRegExp());
JS_ASSERT(proto->isRegExp());
RegExpObjectBuilder builder(cx);
Rooted<RegExpObject*> regex(cx, &obj_->asRegExp());
Rooted<RegExpObject*> proto(cx, &proto_->asRegExp());
return builder.clone(regex, proto);
return builder.clone(Rooted<RegExpObject*>(cx, &obj->asRegExp()),
Rooted<RegExpObject*>(cx, &proto->asRegExp()));
}
bool

View File

@ -119,8 +119,7 @@ CallObject::create(JSContext *cx, JSScript *script, HandleObject enclosing, Hand
*/
if (&enclosing->global() != obj->getParent()) {
JS_ASSERT(obj->getParent() == NULL);
Rooted<GlobalObject*> global(cx, &enclosing->global());
if (!JSObject::setParent(cx, obj, global))
if (!JSObject::setParent(cx, obj, RootedObject(cx, &enclosing->global())))
return NULL;
}
@ -159,8 +158,7 @@ CallObject::createForFunction(JSContext *cx, StackFrame *fp)
}
RootedScript script(cx, fp->script());
Rooted<JSFunction*> callee(cx, &fp->callee());
CallObject *callobj = create(cx, script, scopeChain, callee);
CallObject *callobj = create(cx, script, scopeChain, RootedFunction(cx, &fp->callee()));
if (!callobj)
return NULL;
@ -214,8 +212,7 @@ CallObject::createForStrictEval(JSContext *cx, StackFrame *fp)
JS_ASSERT(cx->fp() == fp);
JS_ASSERT(cx->regs().pc == fp->script()->code);
Rooted<JSFunction*> callee(cx, NULL);
return create(cx, fp->script(), fp->scopeChain(), callee);
return create(cx, fp->script(), fp->scopeChain(), RootedFunction(cx));
}
JSBool
@ -306,8 +303,8 @@ DeclEnvObject::create(JSContext *cx, StackFrame *fp)
return NULL;
Rooted<jsid> id(cx, AtomToId(fp->fun()->atom));
if (!DefineNativeProperty(cx, obj, id, ObjectValue(fp->callee()), NULL, NULL,
if (!DefineNativeProperty(cx, obj, RootedId(cx, AtomToId(fp->fun()->atom)),
ObjectValue(fp->callee()), NULL, NULL,
JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_READONLY,
0, 0)) {
return NULL;
@ -357,8 +354,7 @@ with_LookupGeneric(JSContext *cx, HandleObject obj, HandleId id, JSObject **objp
static JSBool
with_LookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, JSObject **objp, JSProperty **propp)
{
Rooted<jsid> id(cx, NameToId(name));
return with_LookupGeneric(cx, obj, id, objp, propp);
return with_LookupGeneric(cx, obj, RootedId(cx, NameToId(name)), objp, propp);
}
static JSBool
@ -374,8 +370,7 @@ with_LookupElement(JSContext *cx, HandleObject obj, uint32_t index, JSObject **o
static JSBool
with_LookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, JSObject **objp, JSProperty **propp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return with_LookupGeneric(cx, obj, id, objp, propp);
return with_LookupGeneric(cx, obj, RootedId(cx, SPECIALID_TO_JSID(sid)), objp, propp);
}
static JSBool
@ -387,8 +382,7 @@ with_GetGeneric(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId
static JSBool
with_GetProperty(JSContext *cx, HandleObject obj, HandleObject receiver, HandlePropertyName name, Value *vp)
{
Rooted<jsid> id(cx, NameToId(name));
return with_GetGeneric(cx, obj, receiver, id, vp);
return with_GetGeneric(cx, obj, receiver, RootedId(cx, NameToId(name)), vp);
}
static JSBool
@ -403,8 +397,7 @@ with_GetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t
static JSBool
with_GetSpecial(JSContext *cx, HandleObject obj, HandleObject receiver, HandleSpecialId sid, Value *vp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return with_GetGeneric(cx, obj, receiver, id, vp);
return with_GetGeneric(cx, obj, receiver, RootedId(cx, SPECIALID_TO_JSID(sid)), vp);
}
static JSBool
@ -594,8 +587,7 @@ ClonedBlockObject::create(JSContext *cx, Handle<StaticBlockObject *> block, Stac
/* Set the parent if necessary, as for call objects. */
if (&fp->global() != obj->getParent()) {
JS_ASSERT(obj->getParent() == NULL);
Rooted<GlobalObject*> global(cx, &fp->global());
if (!JSObject::setParent(cx, obj, global))
if (!JSObject::setParent(cx, obj, RootedObject(cx, &fp->global())))
return NULL;
}
@ -1333,21 +1325,18 @@ class DebugScopeProxy : public BaseProxyHandler
if (handleUnaliasedAccess(cx, scope, id, GET, vp))
return true;
Rooted<ScopeObject*> scopeObj(cx, &scope);
Rooted<jsid> idRoot(cx, id);
return scope.getGeneric(cx, scopeObj, idRoot, vp);
return scope.getGeneric(cx, RootedObject(cx, &scope), RootedId(cx, id), vp);
}
bool set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id_, bool strict,
bool set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, bool strict,
Value *vp) MOZ_OVERRIDE
{
ScopeObject &scope = proxy->asDebugScope().scope();
if (handleUnaliasedAccess(cx, scope, id_, SET, vp))
if (handleUnaliasedAccess(cx, scope, id, SET, vp))
return true;
Rooted<jsid> id(cx, id_);
return scope.setGeneric(cx, id, vp, strict);
return scope.setGeneric(cx, RootedId(cx, id), vp, strict);
}
bool defineProperty(JSContext *cx, JSObject *proxy, jsid id, PropertyDescriptor *desc) MOZ_OVERRIDE