Bug 770759 - Add mutable handles (r=bhackett)

This commit is contained in:
Bill McCloskey 2012-07-04 11:12:16 -07:00
parent e098c2ec02
commit 943f752751
50 changed files with 476 additions and 384 deletions

View File

@ -331,9 +331,9 @@ FieldSetter(JSContext *cx, unsigned argc, JS::Value *vp)
static JSBool
XBLResolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
JSObject **objp)
JSMutableHandleObject objp)
{
*objp = NULL;
objp.set(NULL);
if (!JSID_IS_STRING(id)) {
return true;
@ -387,7 +387,7 @@ XBLResolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
return false;
}
*objp = obj;
objp.set(obj);
return true;
}

View File

@ -5376,7 +5376,7 @@ GetDocument(JSObject *obj)
JSBool
nsWindowSH::GlobalScopePolluterNewResolve(JSContext *cx, JSHandleObject obj,
JSHandleId id, unsigned flags,
JSObject **objp)
JSMutableHandleObject objp)
{
if (flags & (JSRESOLVE_ASSIGNING | JSRESOLVE_QUALIFIED) ||
!JSID_IS_STRING(id)) {
@ -5430,7 +5430,7 @@ nsWindowSH::GlobalScopePolluterNewResolve(JSContext *cx, JSHandleObject obj,
return JS_FALSE;
}
*objp = obj;
objp.set(obj);
}
return JS_TRUE;
@ -7323,9 +7323,11 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
// Resolve special classes.
for (PRUint32 i = 0; i < ArrayLength(sOtherResolveFuncs); i++) {
if (!sOtherResolveFuncs[i](cx, obj, id, flags, objp)) {
JS::RootedObject tmp(cx, *objp);
if (!sOtherResolveFuncs[i](cx, obj, id, flags, &tmp)) {
return NS_ERROR_FAILURE;
}
*objp = tmp;
if (*objp) {
return NS_OK;
}
@ -8965,7 +8967,7 @@ nsHTMLDocumentSH::DocumentAllGetProperty(JSContext *cx, JSHandleObject obj_,
JSBool
nsHTMLDocumentSH::DocumentAllNewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id,
unsigned flags, JSObject **objp)
unsigned flags, JSMutableHandleObject objp)
{
if (flags & JSRESOLVE_ASSIGNING) {
// Nothing to do here if we're assigning
@ -8980,7 +8982,7 @@ nsHTMLDocumentSH::DocumentAllNewResolve(JSContext *cx, JSHandleObject obj, JSHan
JSFunction *fnc = ::JS_DefineFunctionById(cx, obj, id, CallToGetPropMapper,
0, JSPROP_ENUMERATE);
*objp = obj;
objp.set(obj);
return fnc != nsnull;
}
@ -9017,7 +9019,7 @@ nsHTMLDocumentSH::DocumentAllNewResolve(JSContext *cx, JSHandleObject obj, JSHan
if (v != JSVAL_VOID) {
ok = ::JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull, 0);
*objp = obj;
objp.set(obj);
}
return ok;
@ -9164,7 +9166,7 @@ nsHTMLDocumentSH::DocumentAllHelperGetProperty(JSContext *cx, JSHandleObject obj
JSBool
nsHTMLDocumentSH::DocumentAllHelperNewResolve(JSContext *cx, JSHandleObject obj,
JSHandleId id, unsigned flags,
JSObject **objp)
JSMutableHandleObject objp)
{
if (nsDOMClassInfo::sAll_id == id) {
// document.all is resolved for the first time. Define it.
@ -9176,7 +9178,7 @@ nsHTMLDocumentSH::DocumentAllHelperNewResolve(JSContext *cx, JSHandleObject obj,
return JS_FALSE;
}
*objp = helper;
objp.set(helper);
}
}
@ -9187,7 +9189,7 @@ nsHTMLDocumentSH::DocumentAllHelperNewResolve(JSContext *cx, JSHandleObject obj,
JSBool
nsHTMLDocumentSH::DocumentAllTagsNewResolve(JSContext *cx, JSHandleObject obj,
JSHandleId id, unsigned flags,
JSObject **objp)
JSMutableHandleObject objp)
{
if (JSID_IS_STRING(id)) {
nsDocument *doc = GetDocument(obj);
@ -9225,7 +9227,7 @@ nsHTMLDocumentSH::DocumentAllTagsNewResolve(JSContext *cx, JSHandleObject obj,
return JS_FALSE;
}
*objp = obj;
objp.set(obj);
}
}

View File

@ -384,7 +384,7 @@ public:
static JSBool GlobalScopePolluterNewResolve(JSContext *cx, JSHandleObject obj,
JSHandleId id, unsigned flags,
JSObject **objp);
JSMutableHandleObject objp);
static JSBool GlobalScopePolluterGetProperty(JSContext *cx, JSHandleObject obj,
JSHandleId id, jsval *vp);
static JSBool SecurityCheckOnAddDelProp(JSContext *cx, JSHandleObject obj, JSHandleId id,
@ -778,17 +778,17 @@ public:
static JSBool DocumentAllGetProperty(JSContext *cx, JSHandleObject obj, JSHandleId id,
jsval *vp);
static JSBool DocumentAllNewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id,
unsigned flags, JSObject **objp);
unsigned flags, JSMutableHandleObject objp);
static void ReleaseDocument(JSFreeOp *fop, JSObject *obj);
static JSBool CallToGetPropMapper(JSContext *cx, unsigned argc, jsval *vp);
static JSBool DocumentAllHelperGetProperty(JSContext *cx, JSHandleObject obj,
JSHandleId id, jsval *vp);
static JSBool DocumentAllHelperNewResolve(JSContext *cx, JSHandleObject obj,
JSHandleId id, unsigned flags,
JSObject **objp);
JSMutableHandleObject objp);
static JSBool DocumentAllTagsNewResolve(JSContext *cx, JSHandleObject obj,
JSHandleId id, unsigned flags,
JSObject **objp);
JSMutableHandleObject objp);
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, PRUint32 flags,

View File

@ -127,7 +127,7 @@ NPObjWrapper_newEnumerate(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op
static JSBool
NPObjWrapper_NewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
JSObject **objp);
JSMutableHandleObject objp);
static JSBool
NPObjWrapper_Convert(JSContext *cx, JSHandleObject obj, JSType type, jsval *vp);
@ -1596,7 +1596,7 @@ NPObjWrapper_newEnumerate(JSContext *cx, JSHandleObject obj, JSIterateOp enum_op
static JSBool
NPObjWrapper_NewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
JSObject **objp)
JSMutableHandleObject objp)
{
NPObject *npobj = GetNPObject(obj);
@ -1623,7 +1623,7 @@ NPObjWrapper_NewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsign
return JS_FALSE;
}
*objp = obj;
objp.set(obj);
return JS_TRUE;
}
@ -1639,7 +1639,7 @@ NPObjWrapper_NewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsign
JSFunction *fnc = ::JS_DefineFunctionById(cx, obj, id, CallNPMethod, 0,
JSPROP_ENUMERATE);
*objp = obj;
objp.set(obj);
return fnc != nsnull;
}

View File

@ -368,13 +368,13 @@ BEGIN_WORKERS_NAMESPACE
// Entry point for the DOM.
JSBool
ResolveWorkerClasses(JSContext* aCx, JSHandleObject aObj, JSHandleId aId, unsigned aFlags,
JSObject** aObjp)
JSMutableHandleObject aObjp)
{
AssertIsOnMainThread();
// Don't care about assignments, bail now.
if (aFlags & JSRESOLVE_ASSIGNING) {
*aObjp = nsnull;
aObjp.set(nsnull);
return true;
}
@ -418,7 +418,7 @@ ResolveWorkerClasses(JSContext* aCx, JSHandleObject aObj, JSHandleId aId, unsign
if (shouldResolve) {
// Don't do anything if workers are disabled.
if (!isChrome && !Preferences::GetBool(PREF_WORKERS_ENABLED)) {
*aObjp = nsnull;
aObjp.set(nsnull);
return true;
}
@ -440,12 +440,12 @@ ResolveWorkerClasses(JSContext* aCx, JSHandleObject aObj, JSHandleId aId, unsign
return false;
}
*aObjp = aObj;
aObjp.set(aObj);
return true;
}
// Not resolved.
*aObjp = nsnull;
aObjp.set(nsnull);
return true;
}

View File

@ -787,14 +787,14 @@ private:
static JSBool
Resolve(JSContext* aCx, JSHandleObject aObj, JSHandleId aId, unsigned aFlags,
JSObject** aObjp)
JSMutableHandleObject aObjp)
{
JSBool resolved;
if (!JS_ResolveStandardClass(aCx, aObj, aId, &resolved)) {
return false;
}
*aObjp = resolved ? aObj.value() : NULL;
aObjp.set(resolved ? aObj.value() : NULL);
return true;
}

View File

@ -45,7 +45,7 @@ AssertIsOnMainThread()
// All of these are implemented in RuntimeService.cpp
JSBool
ResolveWorkerClasses(JSContext* aCx, JSHandleObject aObj, JSHandleId aId, unsigned aFlags,
JSObject** aObjp);
JSMutableHandleObject aObjp);
void
CancelWorkersForWindow(JSContext* aCx, nsPIDOMWindow* aWindow);

View File

@ -84,7 +84,8 @@ global_enumerate(JSContext *cx, JSHandleObject *obj)
}
static JSBool
global_resolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags, JSObject **objp)
global_resolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
MutableHandleObject objp)
{
#ifdef LAZY_STANDARD_CLASSES
if ((flags & JSRESOLVE_ASSIGNING) == 0) {
@ -93,7 +94,7 @@ global_resolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
if (!JS_ResolveStandardClass(cx, obj, id, &resolved))
return JS_FALSE;
if (resolved) {
*objp = obj;
objp.set(obj);
return JS_TRUE;
}
}
@ -138,7 +139,7 @@ global_resolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
fun = JS_DefineFunction(cx, obj, name, Exec, 0, JSPROP_ENUMERATE);
ok = (fun != NULL);
if (ok)
*objp = obj;
objp.set(obj);
break;
}
}

View File

@ -298,13 +298,13 @@ JSObject_to_PObjectWrapperParent(JSObject* from, PObjectWrapperParent** to)
ObjectWrapperParent::
JSObject_from_PObjectWrapperParent(JSContext* cx,
const PObjectWrapperParent* from,
JSObject** to)
JSMutableHandleObject to)
{
const ObjectWrapperParent* owp =
static_cast<const ObjectWrapperParent*>(from);
*to = owp
? owp->GetJSObject(cx)
: JSVAL_TO_OBJECT(JSVAL_NULL);
to.set(owp
? owp->GetJSObject(cx)
: JSVAL_TO_OBJECT(JSVAL_NULL));
return true;
}
@ -314,7 +314,7 @@ jsval_from_PObjectWrapperParent(JSContext* cx,
const PObjectWrapperParent* from,
jsval* to)
{
JSObject* obj;
JS::RootedObject obj(cx);
if (!JSObject_from_PObjectWrapperParent(cx, from, &obj))
return false;
*to = OBJECT_TO_JSVAL(obj);
@ -544,7 +544,7 @@ ObjectWrapperParent::CPOW_NewEnumerate(JSContext *cx, JSHandleObject obj,
/*static*/ JSBool
ObjectWrapperParent::CPOW_NewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id,
unsigned flags, JSObject **objp)
unsigned flags, JSMutableHandleObject objp)
{
CPOW_LOG(("Calling CPOW_NewResolve (%s)...",
JSVAL_TO_CSTR(cx, id)));
@ -569,9 +569,10 @@ ObjectWrapperParent::CPOW_NewResolve(JSContext *cx, JSHandleObject obj, JSHandle
!JSObject_from_PObjectWrapperParent(cx, out_pobj, objp))
return JS_FALSE;
if (*objp) {
AutoResolveFlag arf(*objp);
JS_DefinePropertyById(cx, *objp, id, JSVAL_VOID, NULL, NULL,
if (objp) {
AutoResolveFlag arf(objp);
JS::RootedObject obj2(cx, objp);
JS_DefinePropertyById(cx, obj2, id, JSVAL_VOID, NULL, NULL,
JSPROP_ENUMERATE);
}
return JS_TRUE;

View File

@ -80,7 +80,7 @@ private:
static JSBool
CPOW_NewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
JSObject **objp);
JSMutableHandleObject objp);
static JSBool
CPOW_Convert(JSContext *cx, JSHandleObject obj, JSType type, jsval *vp);
@ -108,7 +108,7 @@ private:
static bool
JSObject_from_PObjectWrapperParent(JSContext* cx,
const PObjectWrapperParent* from,
JSObject** to);
JSMutableHandleObject to);
static bool
jsval_from_PObjectWrapperParent(JSContext* cx,
const PObjectWrapperParent* from,

View File

@ -124,6 +124,44 @@ typedef Handle<JSString*> HandleString;
typedef Handle<jsid> HandleId;
typedef Handle<Value> HandleValue;
/*
* Similar to a handle, but the underlying storage can be changed. This is
* useful for outparams.
*/
template <typename T>
class MutableHandle
{
public:
template <typename S>
MutableHandle(MutableHandle<S> handle,
typename mozilla::EnableIf<mozilla::IsConvertible<S, T>::value, int>::Type dummy = 0)
{
this->ptr = reinterpret_cast<const T *>(handle.address());
}
template <typename S>
inline
MutableHandle(Rooted<S> *root,
typename mozilla::EnableIf<mozilla::IsConvertible<S, T>::value, int>::Type dummy = 0);
void set(T v) { *ptr = v; }
const T *address() const { return ptr; }
T *address() { return ptr; }
T value() const { return *ptr; }
operator T () const { return value(); }
T operator ->() const { return value(); }
private:
MutableHandle() {}
T *ptr;
};
typedef MutableHandle<JSObject*> MutableHandleObject;
typedef MutableHandle<Value> MutableHandleValue;
template <typename T>
struct RootMethods<T *>
{
@ -209,6 +247,14 @@ Handle<T>::Handle(Rooted<S> &root,
ptr = reinterpret_cast<const T *>(root.address());
}
template<typename T> template <typename S>
inline
MutableHandle<T>::MutableHandle(Rooted<S> *root,
typename mozilla::EnableIf<mozilla::IsConvertible<S, T>::value, int>::Type dummy)
{
ptr = root->address();
}
typedef Rooted<JSObject*> RootedObject;
typedef Rooted<JSFunction*> RootedFunction;
typedef Rooted<JSScript*> RootedScript;

View File

@ -38,7 +38,8 @@ BEGIN_TEST(testLookup_bug522590)
END_TEST(testLookup_bug522590)
JSBool
document_resolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags, JSObject **objp)
document_resolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
JSMutableHandleObject objp)
{
// If id is "all", and we're not detecting, resolve document.all=true.
jsvalRoot v(cx);
@ -51,11 +52,11 @@ document_resolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flag
return false;
if (JS_FlatStringEqualsAscii(flatStr, "all") && !(flags & JSRESOLVE_DETECTING)) {
JSBool ok = JS_DefinePropertyById(cx, obj, id, JSVAL_TRUE, NULL, NULL, 0);
*objp = ok ? obj.value() : NULL;
objp.set(ok ? obj.value() : NULL);
return ok;
}
}
*objp = NULL;
objp.set(NULL);
return true;
}

View File

@ -69,7 +69,7 @@ struct AutoIncrCounters {
};
bool
doResolve(JSObject *obj, jsid id, unsigned flags, JSObject **objp)
doResolve(JSObject *obj, jsid id, unsigned flags, JSMutableHandleObject objp)
{
CHECK_EQUAL(resolveExitCount, 0);
AutoIncrCounters incr(this);
@ -87,12 +87,12 @@ doResolve(JSObject *obj, jsid id, unsigned flags, JSObject **objp)
EVAL("obj2.y = true", &v);
CHECK_SAME(v, JSVAL_TRUE);
CHECK(JS_DefinePropertyById(cx, obj, id, JSVAL_FALSE, NULL, NULL, 0));
*objp = obj;
objp.set(obj);
return true;
}
if (obj == obj2) {
CHECK_EQUAL(resolveEntryCount, 4);
*objp = NULL;
objp.set(NULL);
return true;
}
} else if (JS_FlatStringEqualsAscii(str, "y")) {
@ -103,7 +103,7 @@ doResolve(JSObject *obj, jsid id, unsigned flags, JSObject **objp)
CHECK(JSVAL_IS_VOID(v));
EVAL("obj1.y", &v);
CHECK_SAME(v, JSVAL_ZERO);
*objp = obj;
objp.set(obj);
return true;
}
if (obj == obj1) {
@ -118,7 +118,7 @@ doResolve(JSObject *obj, jsid id, unsigned flags, JSObject **objp)
CHECK(JSVAL_IS_VOID(v));
EVAL("obj1.y = 0", &v);
CHECK_SAME(v, JSVAL_ZERO);
*objp = obj;
objp.set(obj);
return true;
}
}
@ -127,7 +127,8 @@ doResolve(JSObject *obj, jsid id, unsigned flags, JSObject **objp)
}
static JSBool
my_resolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags, JSObject **objp)
my_resolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
JSMutableHandleObject objp)
{
return static_cast<cls_testResolveRecursion *>(JS_GetPrivate(obj))->
doResolve(obj, id, flags, objp);

View File

@ -2130,12 +2130,16 @@ JS_EnumerateResolvedStandardClasses(JSContext *cx, JSObject *obj, JSIdArray *ida
#undef EAGER_ATOM_CLASP
JS_PUBLIC_API(JSBool)
JS_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, JSObject **objp)
JS_GetClassObject(JSContext *cx, JSObject *obj_, JSProtoKey key, JSObject **objp_)
{
AssertNoGC(cx);
CHECK_REQUEST(cx);
RootedObject obj(cx, obj_);
RootedObject objp(cx);
assertSameCompartment(cx, obj);
return js_GetClassObject(cx, obj, key, objp);
bool result = js_GetClassObject(cx, obj, key, &objp);
*objp_ = objp;
return result;
}
JS_PUBLIC_API(JSObject *)
@ -3392,7 +3396,7 @@ JS_DeepFreezeObject(JSContext *cx, JSObject *obj_)
static JSBool
LookupPropertyById(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp, JSProperty **propp)
MutableHandleObject objp, JSProperty **propp)
{
AssertNoGC(cx);
CHECK_REQUEST(cx);
@ -3449,7 +3453,7 @@ JS_LookupPropertyById(JSContext *cx, JSObject *obj_, jsid id_, jsval *vp)
RootedObject obj2(cx);
JSProperty* prop;
return LookupPropertyById(cx, obj, id, JSRESOLVE_QUALIFIED, obj2.address(), &prop) &&
return LookupPropertyById(cx, obj, id, JSRESOLVE_QUALIFIED, &obj2, &prop) &&
LookupResult(cx, obj, obj2, id, prop, vp);
}
@ -3491,8 +3495,8 @@ JS_LookupPropertyWithFlagsById(JSContext *cx, JSObject *obj_, jsid id_, unsigned
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, id);
if (!(obj->isNative()
? LookupPropertyWithFlags(cx, obj, id, flags, objp.address(), &prop)
: obj->lookupGeneric(cx, id, objp.address(), &prop)))
? LookupPropertyWithFlags(cx, obj, id, flags, &objp, &prop)
: obj->lookupGeneric(cx, id, &objp, &prop)))
return false;
if (!LookupResult(cx, obj, objp, id, prop, vp))
@ -3518,7 +3522,7 @@ JS_HasPropertyById(JSContext *cx, JSObject *obj_, jsid id_, JSBool *foundp)
RootedObject obj2(cx);
JSProperty* prop;
JSBool ok = LookupPropertyById(cx, obj, id, JSRESOLVE_QUALIFIED | JSRESOLVE_DETECTING,
obj2.address(), &prop);
&obj2, &prop);
*foundp = (prop != NULL);
return ok;
}
@ -3560,7 +3564,7 @@ JS_AlreadyHasOwnPropertyById(JSContext *cx, JSObject *obj_, jsid id_, JSBool *fo
assertSameCompartment(cx, obj, id);
if (!obj->isNative()) {
JSObject *obj2;
RootedObject obj2(cx);
JSProperty *prop;
if (!LookupPropertyById(cx, obj, id, JSRESOLVE_QUALIFIED | JSRESOLVE_DETECTING,
@ -3835,7 +3839,7 @@ GetPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id, unsigned
RootedObject obj2(cx);
JSProperty *prop;
if (!LookupPropertyById(cx, obj, id, flags, obj2.address(), &prop))
if (!LookupPropertyById(cx, obj, id, flags, &obj2, &prop))
return JS_FALSE;
if (!prop || (own && obj != obj2)) {
@ -3960,7 +3964,7 @@ SetPropertyAttributesById(JSContext *cx, HandleObject obj, HandleId id, unsigned
RootedObject obj2(cx);
JSProperty *prop;
if (!LookupPropertyById(cx, obj, id, JSRESOLVE_QUALIFIED, obj2.address(), &prop))
if (!LookupPropertyById(cx, obj, id, JSRESOLVE_QUALIFIED, &obj2, &prop))
return false;
if (!prop || obj != obj2) {
*foundp = false;

View File

@ -1389,6 +1389,7 @@ JS_STATIC_ASSERT(sizeof(jsval_layout) == sizeof(jsval));
typedef JS::Handle<JSObject*> JSHandleObject;
typedef JS::Handle<jsid> JSHandleId;
typedef JS::MutableHandle<JSObject*> JSMutableHandleObject;
#else
@ -1398,11 +1399,15 @@ typedef JS::Handle<jsid> JSHandleId;
*/
typedef struct { JSObject **_; } JSHandleObject;
typedef struct { JSObject **_; } JSMutableHandleObject;
typedef struct { jsid *_; } JSHandleId;
JSBool JS_CreateHandleObject(JSContext *cx, JSObject *obj, JSHandleObject *phandle);
void JS_DestroyHandleObject(JSContext *cx, JSHandleObject handle);
JSBool JS_CreateMutableHandleObject(JSContext *cx, JSObject *obj, JSMutableHandleObject *phandle);
void JS_DestroyMutableHandleObject(JSContext *cx, JSMutableHandleObject handle);
JSBool JS_CreateHandleId(JSContext *cx, jsid id, JSHandleId *phandle);
void JS_DestroyHandleId(JSContext *cx, JSHandleId handle);
@ -1504,7 +1509,7 @@ typedef JSBool
*/
typedef JSBool
(* JSNewResolveOp)(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
JSObject **objp);
JSMutableHandleObject objp);
/*
* Convert obj to the given type, returning true with the resulting value in

View File

@ -346,7 +346,7 @@ DoGetElement(JSContext *cx, JSObject *obj_, double index, JSBool *hole, Value *v
return JS_TRUE;
}
JSObject *obj2;
RootedObject obj2(cx);
JSProperty *prop;
if (!obj->lookupGeneric(cx, id, &obj2, &prop))
return JS_FALSE;
@ -692,7 +692,7 @@ IsDenseArrayId(JSContext *cx, JSObject *obj, jsid id)
}
static JSBool
array_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, JSObject **objp,
array_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, MutableHandleObject objp,
JSProperty **propp)
{
if (!obj->isDenseArray())
@ -700,13 +700,13 @@ array_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, JSObject **obj
if (IsDenseArrayId(cx, obj, id)) {
*propp = (JSProperty *) 1; /* non-null to indicate found */
*objp = obj;
objp.set(obj);
return JS_TRUE;
}
JSObject *proto = obj->getProto();
if (!proto) {
*objp = NULL;
objp.set(NULL);
*propp = NULL;
return JS_TRUE;
}
@ -714,15 +714,15 @@ array_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, JSObject **obj
}
static JSBool
array_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, JSObject **objp,
JSProperty **propp)
array_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
MutableHandleObject objp, JSProperty **propp)
{
Rooted<jsid> id(cx, NameToId(name));
return array_lookupGeneric(cx, obj, id, objp, propp);
}
static JSBool
array_lookupElement(JSContext *cx, HandleObject obj, uint32_t index, JSObject **objp,
array_lookupElement(JSContext *cx, HandleObject obj, uint32_t index, MutableHandleObject objp,
JSProperty **propp)
{
if (!obj->isDenseArray())
@ -730,20 +730,20 @@ array_lookupElement(JSContext *cx, HandleObject obj, uint32_t index, JSObject **
if (IsDenseArrayIndex(obj, index)) {
*propp = (JSProperty *) 1; /* non-null to indicate found */
*objp = obj;
objp.set(obj);
return true;
}
if (JSObject *proto = obj->getProto())
return proto->lookupElement(cx, index, objp, propp);
*objp = NULL;
objp.set(NULL);
*propp = NULL;
return true;
}
static JSBool
array_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, JSObject **objp,
array_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, MutableHandleObject objp,
JSProperty **propp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
@ -3773,11 +3773,11 @@ NewArray(JSContext *cx, uint32_t length, JSObject *proto_)
}
Rooted<GlobalObject*> parent(cx, parent_);
RootedObject proto(cx, proto_);
if (!proto_ && !FindProto(cx, &ArrayClass, parent, &proto_))
if (!proto && !FindProto(cx, &ArrayClass, parent, &proto))
return NULL;
RootedObject proto(cx, proto_);
RootedTypeObject type(cx);
type = proto->getNewType(cx);

View File

@ -149,16 +149,16 @@ typedef JS::Handle<SpecialId> HandleSpecialId;
/* js::Class operation signatures. */
typedef JSBool
(* LookupGenericOp)(JSContext *cx, HandleObject obj, HandleId id, JSObject **objp,
(* LookupGenericOp)(JSContext *cx, HandleObject obj, HandleId id, MutableHandleObject objp,
JSProperty **propp);
typedef JSBool
(* LookupPropOp)(JSContext *cx, HandleObject obj, HandlePropertyName name, JSObject **objp,
(* LookupPropOp)(JSContext *cx, HandleObject obj, HandlePropertyName name, MutableHandleObject objp,
JSProperty **propp);
typedef JSBool
(* LookupElementOp)(JSContext *cx, HandleObject obj, uint32_t index, JSObject **objp,
(* LookupElementOp)(JSContext *cx, HandleObject obj, uint32_t index, MutableHandleObject objp,
JSProperty **propp);
typedef JSBool
(* LookupSpecialOp)(JSContext *cx, HandleObject obj, HandleSpecialId sid, JSObject **objp,
(* LookupSpecialOp)(JSContext *cx, HandleObject obj, HandleSpecialId sid, MutableHandleObject objp,
JSProperty **propp);
typedef JSBool
(* DefineGenericOp)(JSContext *cx, HandleObject obj, HandleId id, const Value *value,

View File

@ -558,7 +558,7 @@ JSStructuredCloneWriter::write(const Value &v)
* The cost of re-checking could be avoided by using
* NativeIterators.
*/
JSObject *obj2;
RootedObject obj2(context());
JSProperty *prop;
if (!js_HasOwnProperty(context(), obj->getOps()->lookupGeneric, obj, id,
&obj2, &prop)) {

View File

@ -175,8 +175,13 @@ JSCompartment::wrap(JSContext *cx, Value *vp)
return WrapForSameCompartment(cx, obj, vp);
/* Translate StopIteration singleton. */
if (obj->isStopIteration())
return js_FindClassObject(cx, NULL, JSProto_StopIteration, vp);
if (obj->isStopIteration()) {
RootedObject null(cx);
RootedValue vvp(cx, *vp);
bool result = js_FindClassObject(cx, null, JSProto_StopIteration, &vvp);
*vp = vvp;
return result;
}
/* Unwrap the object, but don't unwrap outer windows. */
obj = UnwrapObject(&vp->toObject(), /* stopAtOuter = */ true, &flags);

View File

@ -57,7 +57,7 @@ exn_finalize(FreeOp *fop, JSObject *obj);
static JSBool
exn_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp);
MutableHandleObject objp);
Class js::ErrorClass = {
js_Error_str,
@ -392,7 +392,7 @@ exn_finalize(FreeOp *fop, JSObject *obj)
static JSBool
exn_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp)
MutableHandleObject objp)
{
JSExnPrivate *priv;
JSString *str;
@ -402,7 +402,7 @@ exn_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
jsval v;
unsigned attrs;
*objp = NULL;
objp.set(NULL);
priv = GetExnPrivate(obj);
if (priv && JSID_IS_ATOM(id)) {
str = JSID_TO_STRING(id);
@ -457,7 +457,7 @@ exn_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
define:
if (!JS_DefineProperty(cx, obj, prop, v, NULL, NULL, attrs))
return false;
*objp = obj;
objp.set(obj);
return true;
}
@ -918,7 +918,6 @@ js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp,
const JSErrorFormatString *errorString;
JSExnType exn;
jsval tv[4];
JSObject *errProto;
/*
* Tell our caller to report immediately if this report is just a warning.
@ -964,7 +963,9 @@ js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp,
* exception constructor name in the scope chain of the current context's
* top stack frame, or in the global object if no frame is active.
*/
if (!js_GetClassPrototype(cx, NULL, GetExceptionProtoKey(exn), &errProto))
RootedObject null(cx);
RootedObject errProto(cx);
if (!js_GetClassPrototype(cx, null, GetExceptionProtoKey(exn), &errProto))
return false;
tv[0] = OBJECT_TO_JSVAL(errProto);

View File

@ -256,7 +256,7 @@ ResolveInterpretedFunctionPrototype(JSContext *cx, HandleObject obj)
static JSBool
fun_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp)
MutableHandleObject objp)
{
if (!JSID_IS_ATOM(id))
return true;
@ -282,7 +282,7 @@ fun_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
if (!ResolveInterpretedFunctionPrototype(cx, fun))
return false;
*objp = fun;
objp.set(fun);
return true;
}
@ -300,7 +300,7 @@ fun_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSPROP_PERMANENT | JSPROP_READONLY, 0, 0)) {
return false;
}
*objp = fun;
objp.set(fun);
return true;
}
@ -328,7 +328,7 @@ fun_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
attrs, 0, 0)) {
return false;
}
*objp = fun;
objp.set(fun);
return true;
}
}

View File

@ -1862,8 +1862,9 @@ TypeCompartment::newAllocationSiteTypeObject(JSContext *cx, AllocationSiteKey ke
AllocationSiteTable::AddPtr p = allocationSiteTable->lookupForAdd(key);
JS_ASSERT(!p);
JSObject *proto;
if (!js_GetClassPrototype(cx, key.script->global(), key.kind, &proto, NULL))
RootedObject proto(cx);
RootedObject global(cx, key.script->global());
if (!js_GetClassPrototype(cx, global, key.kind, &proto, NULL))
return NULL;
RootedScript keyScript(cx, key.script);

View File

@ -264,8 +264,9 @@ struct AutoEnterCompilation
inline TypeObject *
GetTypeNewObject(JSContext *cx, JSProtoKey key)
{
JSObject *proto;
if (!js_GetClassPrototype(cx, NULL, key, &proto, NULL))
RootedObject proto(cx);
RootedObject null(cx);
if (!js_GetClassPrototype(cx, null, key, &proto))
return NULL;
return proto->getNewType(cx);
}
@ -502,8 +503,9 @@ TypeScript::SlotTypes(JSScript *script, unsigned slot)
/* static */ inline TypeObject *
TypeScript::StandardType(JSContext *cx, JSScript *script, JSProtoKey key)
{
JSObject *proto;
if (!js_GetClassPrototype(cx, script->global(), key, &proto, NULL))
RootedObject proto(cx);
RootedObject global(cx, script->global());
if (!js_GetClassPrototype(cx, global, key, &proto, NULL))
return NULL;
return proto->getNewType(cx);
}

View File

@ -950,7 +950,8 @@ js::AssertValidPropertyCacheHit(JSContext *cx, JSObject *start_,
RootedPropertyName name(cx, GetNameFromBytecode(cx, script, pc, JSOp(*pc)));
RootedObject start(cx, start_);
JSObject *obj, *pobj;
RootedObject obj(cx);
RootedObject pobj(cx);
JSProperty *prop;
JSBool ok;
@ -1273,7 +1274,7 @@ js::Interpret(JSContext *cx, StackFrame *entryFrame, InterpMode interpMode)
*/
RootedValue rootValue0(cx), rootValue1(cx);
RootedString rootString0(cx), rootString1(cx);
RootedObject rootObject0(cx), rootObject1(cx);
RootedObject rootObject0(cx), rootObject1(cx), rootObject2(cx);
RootedFunction rootFunction0(cx);
RootedTypeObject rootType0(cx);
RootedPropertyName rootName0(cx);
@ -1742,7 +1743,7 @@ BEGIN_CASE(JSOP_IN)
obj = &rref.toObject();
RootedId &id = rootId0;
FETCH_ELEMENT_ID(obj, -2, id);
JSObject *obj2;
RootedObject &obj2 = rootObject1;
JSProperty *prop;
if (!obj->lookupGeneric(cx, id, &obj2, &prop))
goto error;
@ -2201,7 +2202,8 @@ BEGIN_CASE(JSOP_DELNAME)
RootedObject &scopeObj = rootObject0;
scopeObj = cx->stack.currentScriptedScopeChain();
JSObject *obj, *obj2;
RootedObject &obj = rootObject1;
RootedObject &obj2 = rootObject2;
JSProperty *prop;
if (!FindProperty(cx, name, scopeObj, &obj, &obj2, &prop))
goto error;
@ -2547,7 +2549,8 @@ BEGIN_CASE(JSOP_IMPLICITTHIS)
RootedObject &scopeObj = rootObject0;
scopeObj = cx->stack.currentScriptedScopeChain();
JSObject *obj, *obj2;
RootedObject &obj = rootObject1;
RootedObject &obj2 = rootObject2;
JSProperty *prop;
if (!FindPropertyHelper(cx, name, false, scopeObj, &obj, &obj2, &prop))
goto error;
@ -2916,7 +2919,7 @@ BEGIN_CASE(JSOP_DEFFUN)
RootedPropertyName &name = rootName0;
name = fun->atom->asPropertyName();
JSProperty *prop = NULL;
JSObject *pobj;
RootedObject &pobj = rootObject1;
if (!parent->lookupProperty(cx, name, &pobj, &prop))
goto error;
@ -3478,7 +3481,7 @@ BEGIN_CASE(JSOP_BINDXMLNAME)
Value lval;
lval = regs.sp[-1];
JSObject *obj;
RootedObject &obj = rootObject0;
jsid id;
if (!js_FindXMLProperty(cx, lval, &obj, &id))
goto error;
@ -3509,7 +3512,7 @@ BEGIN_CASE(JSOP_XMLNAME)
JS_ASSERT(!script->strictModeCode);
Value lval = regs.sp[-1];
JSObject *obj;
RootedObject &obj = rootObject0;
RootedId &id = rootId0;
if (!js_FindXMLProperty(cx, lval, &obj, id.address()))
goto error;

View File

@ -386,7 +386,7 @@ NameOperation(JSContext *cx, JSScript *script, jsbytecode *pc, Value *vp)
}
JSProperty *prop;
if (!FindPropertyHelper(cx, name, true, obj, obj.address(), obj2.address(), &prop))
if (!FindPropertyHelper(cx, name, true, obj, &obj, &obj2, &prop))
return false;
if (!prop) {
/* Kludge to allow (typeof foo == "undefined") tests. */
@ -425,7 +425,7 @@ DefVarOrConstOperation(JSContext *cx, HandleObject varobj, PropertyName *dn, uns
JS_ASSERT(!varobj->getOps()->defineProperty || varobj->isDebugScope());
JSProperty *prop;
JSObject *obj2;
RootedObject obj2(cx);
if (!varobj->lookupProperty(cx, dn, &obj2, &prop))
return false;

View File

@ -815,10 +815,10 @@ Iterator(JSContext *cx, unsigned argc, Value *vp)
JSBool
js_ThrowStopIteration(JSContext *cx)
{
Value v;
JS_ASSERT(!JS_IsExceptionPending(cx));
if (js_FindClassObject(cx, NULL, JSProto_StopIteration, &v))
RootedValue v(cx);
RootedObject null(cx);
if (js_FindClassObject(cx, null, JSProto_StopIteration, &v))
cx->setPendingException(v);
return JS_FALSE;
}
@ -992,7 +992,7 @@ SuppressDeletedPropertyHelper(JSContext *cx, HandleObject obj, StringPredicate p
*/
if (obj->getProto()) {
JSObject *proto = obj->getProto();
JSObject *obj2;
RootedObject obj2(cx);
JSProperty *prop;
RootedId id(cx);
if (!ValueToId(cx, StringValue(*idp), id.address()))
@ -1770,7 +1770,7 @@ js_InitIteratorClasses(JSContext *cx, JSObject *obj)
* as happens when the StopIteration object is frozen, initializing the
* Iterator class a second time will assert.
*/
JSObject *iter;
RootedObject iter(cx);
if (!js_GetClassObject(cx, global, JSProto_Iterator, &iter))
return NULL;
if (iter)

View File

@ -178,7 +178,7 @@ MarkSharpObjects(JSContext *cx, HandleObject obj, JSIdArray **idap, JSSharpInfo
RootedId id(cx);
for (int i = 0, length = ida->length; i < length; i++) {
id = ida->vector[i];
JSObject *obj2;
RootedObject obj2(cx);
JSProperty *prop;
ok = obj->lookupGeneric(cx, id, &obj2, &prop);
if (!ok)
@ -459,7 +459,7 @@ obj_toSource(JSContext *cx, unsigned argc, Value *vp)
id = ida->vector[i];
JSLinearString *idstr;
JSObject *obj2;
RootedObject obj2(cx);
JSProperty *prop;
if (!obj->lookupGeneric(cx, id, &obj2, &prop))
return false;
@ -1259,7 +1259,7 @@ js_HasOwnPropertyHelper(JSContext *cx, LookupGenericOp lookup, unsigned argc,
RootedObject obj(cx, ToObject(cx, &vp[1]));
if (!obj)
return false;
JSObject *obj2;
RootedObject obj2(cx);
JSProperty *prop;
if (obj->isProxy()) {
bool has;
@ -1276,7 +1276,7 @@ js_HasOwnPropertyHelper(JSContext *cx, LookupGenericOp lookup, unsigned argc,
JSBool
js_HasOwnProperty(JSContext *cx, LookupGenericOp lookup, HandleObject obj, HandleId id,
JSObject **objp, JSProperty **propp)
MutableHandleObject objp, JSProperty **propp)
{
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED | JSRESOLVE_DETECTING);
if (lookup) {
@ -1289,18 +1289,18 @@ js_HasOwnProperty(JSContext *cx, LookupGenericOp lookup, HandleObject obj, Handl
if (!*propp)
return true;
if (*objp == obj)
if (objp == obj)
return true;
JSObject *outer = NULL;
if (JSObjectOp op = (*objp)->getClass()->ext.outerObject) {
Rooted<JSObject*> inner(cx, *objp);
if (JSObjectOp op = objp->getClass()->ext.outerObject) {
Rooted<JSObject*> inner(cx, objp);
outer = op(cx, inner);
if (!outer)
return false;
}
if (outer != *objp)
if (outer != objp)
*propp = NULL;
return true;
}
@ -1346,7 +1346,7 @@ obj_propertyIsEnumerable(JSContext *cx, unsigned argc, Value *vp)
JSBool
js_PropertyIsEnumerable(JSContext *cx, HandleObject obj, HandleId id, Value *vp)
{
JSObject *pobj;
RootedObject pobj(cx);
JSProperty *prop;
if (!obj->lookupGeneric(cx, id, &pobj, &prop))
return false;
@ -1456,7 +1456,7 @@ obj_lookupGetter(JSContext *cx, unsigned argc, Value *vp)
*vp = CastAsObjectJsval(desc.getter);
return JS_TRUE;
}
JSObject *pobj;
RootedObject pobj(cx);
JSProperty *prop;
if (!obj->lookupGeneric(cx, id, &pobj, &prop))
return JS_FALSE;
@ -1491,7 +1491,7 @@ obj_lookupSetter(JSContext *cx, unsigned argc, Value *vp)
*vp = CastAsObjectJsval(desc.setter);
return JS_TRUE;
}
JSObject *pobj;
RootedObject pobj(cx);
JSProperty *prop;
if (!obj->lookupGeneric(cx, id, &pobj, &prop))
return JS_FALSE;
@ -1623,7 +1623,7 @@ GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id, PropertyD
if (obj->isProxy())
return Proxy::getOwnPropertyDescriptor(cx, obj, id, false, desc);
JSObject *pobj;
RootedObject pobj(cx);
JSProperty *prop;
if (!js_HasOwnProperty(cx, obj->getOps()->lookupGeneric, obj, id, &pobj, &prop))
return false;
@ -1664,7 +1664,8 @@ GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id, Value *vp
}
bool
GetFirstArgumentAsObject(JSContext *cx, unsigned argc, Value *vp, const char *method, JSObject **objp)
GetFirstArgumentAsObject(JSContext *cx, unsigned argc, Value *vp, const char *method,
MutableHandleObject objp)
{
if (argc == 0) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_MORE_ARGS_NEEDED,
@ -1683,7 +1684,7 @@ GetFirstArgumentAsObject(JSContext *cx, unsigned argc, Value *vp, const char *me
return false;
}
*objp = &v.toObject();
objp.set(&v.toObject());
return true;
}
@ -1693,7 +1694,7 @@ static JSBool
obj_getOwnPropertyDescriptor(JSContext *cx, unsigned argc, Value *vp)
{
RootedObject obj(cx);
if (!GetFirstArgumentAsObject(cx, argc, vp, "Object.getOwnPropertyDescriptor", obj.address()))
if (!GetFirstArgumentAsObject(cx, argc, vp, "Object.getOwnPropertyDescriptor", &obj))
return JS_FALSE;
RootedId id(cx);
if (!ValueToId(cx, argc >= 2 ? vp[3] : UndefinedValue(), id.address()))
@ -1704,7 +1705,7 @@ obj_getOwnPropertyDescriptor(JSContext *cx, unsigned argc, Value *vp)
static JSBool
obj_keys(JSContext *cx, unsigned argc, Value *vp)
{
JSObject *obj;
RootedObject obj(cx);
if (!GetFirstArgumentAsObject(cx, argc, vp, "Object.keys", &obj))
return false;
@ -1964,7 +1965,7 @@ DefinePropertyOnObject(JSContext *cx, HandleObject obj, HandleId id, const PropD
JSProperty *current;
RootedObject obj2(cx);
JS_ASSERT(!obj->getOps()->lookupGeneric);
if (!js_HasOwnProperty(cx, NULL, obj, id, obj2.address(), &current))
if (!js_HasOwnProperty(cx, NULL, obj, id, &obj2, &current))
return JS_FALSE;
JS_ASSERT(!obj->getOps()->defineProperty);
@ -2342,7 +2343,7 @@ static JSBool
obj_defineProperty(JSContext *cx, unsigned argc, Value *vp)
{
RootedObject obj(cx);
if (!GetFirstArgumentAsObject(cx, argc, vp, "Object.defineProperty", obj.address()))
if (!GetFirstArgumentAsObject(cx, argc, vp, "Object.defineProperty", &obj))
return false;
RootedId id(cx);
@ -2410,7 +2411,7 @@ obj_defineProperties(JSContext *cx, unsigned argc, Value *vp)
{
/* Steps 1 and 7. */
RootedObject obj(cx);
if (!GetFirstArgumentAsObject(cx, argc, vp, "Object.defineProperties", obj.address()))
if (!GetFirstArgumentAsObject(cx, argc, vp, "Object.defineProperties", &obj))
return false;
vp->setObject(*obj);
@ -2489,7 +2490,7 @@ obj_create(JSContext *cx, unsigned argc, Value *vp)
static JSBool
obj_getOwnPropertyNames(JSContext *cx, unsigned argc, Value *vp)
{
JSObject *obj;
RootedObject obj(cx);
if (!GetFirstArgumentAsObject(cx, argc, vp, "Object.getOwnPropertyNames", &obj))
return false;
@ -2526,7 +2527,7 @@ obj_getOwnPropertyNames(JSContext *cx, unsigned argc, Value *vp)
static JSBool
obj_isExtensible(JSContext *cx, unsigned argc, Value *vp)
{
JSObject *obj;
RootedObject obj(cx);
if (!GetFirstArgumentAsObject(cx, argc, vp, "Object.isExtensible", &obj))
return false;
@ -2537,7 +2538,7 @@ obj_isExtensible(JSContext *cx, unsigned argc, Value *vp)
static JSBool
obj_preventExtensions(JSContext *cx, unsigned argc, Value *vp)
{
JSObject *obj;
RootedObject obj(cx);
if (!GetFirstArgumentAsObject(cx, argc, vp, "Object.preventExtensions", &obj))
return false;
@ -2677,7 +2678,7 @@ JSObject::isSealedOrFrozen(JSContext *cx, ImmutabilityType it, bool *resultp)
static JSBool
obj_freeze(JSContext *cx, unsigned argc, Value *vp)
{
JSObject *obj;
RootedObject obj(cx);
if (!GetFirstArgumentAsObject(cx, argc, vp, "Object.freeze", &obj))
return false;
@ -2689,7 +2690,7 @@ obj_freeze(JSContext *cx, unsigned argc, Value *vp)
static JSBool
obj_isFrozen(JSContext *cx, unsigned argc, Value *vp)
{
JSObject *obj;
RootedObject obj(cx);
if (!GetFirstArgumentAsObject(cx, argc, vp, "Object.preventExtensions", &obj))
return false;
@ -2703,7 +2704,7 @@ obj_isFrozen(JSContext *cx, unsigned argc, Value *vp)
static JSBool
obj_seal(JSContext *cx, unsigned argc, Value *vp)
{
JSObject *obj;
RootedObject obj(cx);
if (!GetFirstArgumentAsObject(cx, argc, vp, "Object.seal", &obj))
return false;
@ -2715,7 +2716,7 @@ obj_seal(JSContext *cx, unsigned argc, Value *vp)
static JSBool
obj_isSealed(JSContext *cx, unsigned argc, Value *vp)
{
JSObject *obj;
RootedObject obj(cx);
if (!GetFirstArgumentAsObject(cx, argc, vp, "Object.isSealed", &obj))
return false;
@ -2873,13 +2874,14 @@ js::NewObjectWithGivenProto(JSContext *cx, js::Class *clasp, JSObject *proto_, J
}
JSObject *
js::NewObjectWithClassProto(JSContext *cx, js::Class *clasp, JSObject *proto, JSObject *parent_,
js::NewObjectWithClassProto(JSContext *cx, js::Class *clasp, JSObject *proto_, JSObject *parent_,
gc::AllocKind kind)
{
if (proto)
return NewObjectWithGivenProto(cx, clasp, proto, parent_, kind);
if (proto_)
return NewObjectWithGivenProto(cx, clasp, proto_, parent_, kind);
RootedObject parent(cx, parent_);
RootedObject proto(cx, proto_);
if (CanBeFinalizedInBackground(kind, clasp))
kind = GetBackgroundAllocKind(kind);
@ -3870,7 +3872,7 @@ js_InitClass(JSContext *cx, HandleObject obj, JSObject *protoProto_,
JSProtoKey key = JSCLASS_CACHED_PROTO_KEY(clasp);
if (key != JSProto_Null &&
!protoProto &&
!js_GetClassPrototype(cx, obj, JSProto_Object, protoProto.address())) {
!js_GetClassPrototype(cx, obj, JSProto_Object, &protoProto)) {
return NULL;
}
@ -4266,49 +4268,47 @@ SetProto(JSContext *cx, HandleObject obj, HandleObject proto, bool checkForCycle
}
JSBool
js_GetClassObject(JSContext *cx, JSObject *obj_, JSProtoKey key,
JSObject **objp)
bool
js_GetClassObject(JSContext *cx, HandleObject obj, JSProtoKey key,
MutableHandleObject objp)
{
RootedObject obj(cx, obj_);
obj = &obj->global();
if (!obj->isGlobal()) {
*objp = NULL;
RootedObject global(cx, &obj->global());
if (!global->isGlobal()) {
objp.set(NULL);
return true;
}
Value v = obj->getReservedSlot(key);
Value v = global->getReservedSlot(key);
if (v.isObject()) {
*objp = &v.toObject();
objp.set(&v.toObject());
return true;
}
AutoResolving resolving(cx, obj, NameToId(cx->runtime->atomState.classAtoms[key]));
AutoResolving resolving(cx, global, NameToId(cx->runtime->atomState.classAtoms[key]));
if (resolving.alreadyStarted()) {
/* Already caching id in obj -- suppress recursion. */
*objp = NULL;
/* Already caching id in global -- suppress recursion. */
objp.set(NULL);
return true;
}
JSObject *cobj = NULL;
if (JSClassInitializerOp init = lazy_prototype_init[key]) {
if (!init(cx, obj))
if (!init(cx, global))
return false;
v = obj->getReservedSlot(key);
v = global->getReservedSlot(key);
if (v.isObject())
cobj = &v.toObject();
}
*objp = cobj;
objp.set(cobj);
return true;
}
JSBool
js_FindClassObject(JSContext *cx, JSObject *start, JSProtoKey protoKey,
Value *vp, Class *clasp)
bool
js_FindClassObject(JSContext *cx, HandleObject start, JSProtoKey protoKey,
MutableHandleValue vp, Class *clasp)
{
JSObject *cobj, *pobj;
RootedId id(cx);
JSProperty *prop;
const Shape *shape;
@ -4327,10 +4327,11 @@ js_FindClassObject(JSContext *cx, JSObject *start, JSProtoKey protoKey,
if (protoKey != JSProto_Null) {
JS_ASSERT(JSProto_Null < protoKey);
JS_ASSERT(protoKey < JSProto_LIMIT);
RootedObject cobj(cx);
if (!js_GetClassObject(cx, obj, protoKey, &cobj))
return false;
if (cobj) {
vp->setObject(*cobj);
vp.set(ObjectValue(*cobj));
return JS_TRUE;
}
id = NameToId(cx->runtime->atomState.classAtoms[protoKey]);
@ -4342,18 +4343,19 @@ js_FindClassObject(JSContext *cx, JSObject *start, JSProtoKey protoKey,
}
JS_ASSERT(obj->isNative());
RootedObject pobj(cx);
if (!LookupPropertyWithFlags(cx, obj, id, 0, &pobj, &prop))
return false;
Value v = UndefinedValue();
RootedValue v(cx, UndefinedValue());
if (prop && pobj->isNative()) {
shape = (Shape *) prop;
if (shape->hasSlot()) {
v = pobj->nativeGetSlot(shape->slot());
if (v.isPrimitive())
v.setUndefined();
if (v.reference().isPrimitive())
v.reference().setUndefined();
}
}
*vp = v;
vp.set(v);
return true;
}
@ -4566,7 +4568,6 @@ DefineNativeProperty(JSContext *cx, HandleObject obj, HandleId id, const Value &
*/
RootedShape shape(cx);
if (attrs & (JSPROP_GETTER | JSPROP_SETTER)) {
JSObject *pobj;
JSProperty *prop;
/* Type information for getter/setter properties is unknown. */
@ -4578,6 +4579,7 @@ DefineNativeProperty(JSContext *cx, HandleObject obj, HandleId id, const Value &
* vice versa, finish the job via obj->changeProperty, and refresh the
* property cache line for (obj, id) to map shape.
*/
RootedObject pobj(cx);
if (!baseops::LookupProperty(cx, obj, id, &pobj, &prop))
return NULL;
if (prop && pobj == obj) {
@ -4669,7 +4671,7 @@ DefineNativeProperty(JSContext *cx, HandleObject obj, HandleId id, const Value &
*/
static JSBool
CallResolveOp(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp, JSProperty **propp, bool *recursedp)
MutableHandleObject objp, JSProperty **propp, bool *recursedp)
{
Class *clasp = obj->getClass();
JSResolveOp resolve = clasp->resolve;
@ -4698,7 +4700,7 @@ CallResolveOp(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
flags = js_InferFlags(cx, 0);
RootedObject obj2(cx, NULL);
if (!newresolve(cx, obj, id, flags, obj2.address()))
if (!newresolve(cx, obj, id, flags, &obj2))
return false;
/*
@ -4723,7 +4725,7 @@ CallResolveOp(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
if (!obj->nativeEmpty()) {
if (const Shape *shape = obj->nativeLookup(cx, id)) {
*objp = obj;
objp.set(obj);
*propp = (JSProperty *) shape;
}
}
@ -4733,14 +4735,14 @@ CallResolveOp(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
static JS_ALWAYS_INLINE bool
LookupPropertyWithFlagsInline(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp, JSProperty **propp)
MutableHandleObject objp, JSProperty **propp)
{
/* Search scopes starting with obj and following the prototype link. */
RootedObject current(cx, obj);
while (true) {
const Shape *shape = current->nativeLookup(cx, id);
if (shape) {
*objp = current;
objp.set(current);
*propp = (JSProperty *) shape;
return true;
}
@ -4777,8 +4779,8 @@ LookupPropertyWithFlagsInline(JSContext *cx, HandleObject obj, HandleId id, unsi
* arguments.callee through the delegating |this| object's method
* read barrier.
*/
if (*propp && (*objp)->isNative()) {
while ((proto = proto->getProto()) != *objp)
if (*propp && objp->isNative()) {
while ((proto = proto->getProto()) != objp.value())
JS_ASSERT(proto);
}
#endif
@ -4788,20 +4790,21 @@ LookupPropertyWithFlagsInline(JSContext *cx, HandleObject obj, HandleId id, unsi
current = proto;
}
*objp = NULL;
objp.set(NULL);
*propp = NULL;
return true;
}
JS_FRIEND_API(JSBool)
baseops::LookupProperty(JSContext *cx, HandleObject obj, HandleId id, JSObject **objp,
baseops::LookupProperty(JSContext *cx, HandleObject obj, HandleId id, MutableHandleObject objp,
JSProperty **propp)
{
return LookupPropertyWithFlagsInline(cx, obj, id, cx->resolveFlags, objp, propp);
}
JS_FRIEND_API(JSBool)
baseops::LookupElement(JSContext *cx, HandleObject obj, uint32_t index, JSObject **objp, JSProperty **propp)
baseops::LookupElement(JSContext *cx, HandleObject obj, uint32_t index,
MutableHandleObject objp, JSProperty **propp)
{
RootedId id(cx);
if (!IndexToId(cx, index, id.address()))
@ -4812,7 +4815,7 @@ baseops::LookupElement(JSContext *cx, HandleObject obj, uint32_t index, JSObject
bool
js::LookupPropertyWithFlags(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp, JSProperty **propp)
MutableHandleObject objp, JSProperty **propp)
{
return LookupPropertyWithFlagsInline(cx, obj, id, flags, objp, propp);
}
@ -4820,11 +4823,11 @@ js::LookupPropertyWithFlags(JSContext *cx, HandleObject obj, HandleId id, unsign
bool
js::FindPropertyHelper(JSContext *cx,
HandlePropertyName name, bool cacheResult, HandleObject scopeChain,
JSObject **objp, JSObject **pobjp, JSProperty **propp)
MutableHandleObject objp, MutableHandleObject pobjp, JSProperty **propp)
{
RootedId id(cx, NameToId(name));
JSObject *pobj;
RootedObject pobj(cx);
int scopeIndex;
JSProperty *prop;
@ -4901,8 +4904,8 @@ js::FindPropertyHelper(JSContext *cx,
out:
JS_ASSERT(!!pobj == !!prop);
*objp = obj;
*pobjp = pobj;
objp.set(obj);
pobjp.set(pobj);
*propp = prop;
return true;
}
@ -4913,7 +4916,7 @@ js::FindPropertyHelper(JSContext *cx,
*/
bool
js::FindProperty(JSContext *cx, HandlePropertyName name, HandleObject scopeChain,
JSObject **objp, JSObject **pobjp, JSProperty **propp)
MutableHandleObject objp, MutableHandleObject pobjp, JSProperty **propp)
{
return !!FindPropertyHelper(cx, name, false, scopeChain, objp, pobjp, propp);
}
@ -4940,8 +4943,9 @@ js::FindIdentifierBase(JSContext *cx, HandleObject scopeChain, HandlePropertyNam
*/
for (int scopeIndex = 0;
obj->isGlobal() || IsCacheableNonGlobalScope(obj);
scopeIndex++) {
JSObject *pobj;
scopeIndex++)
{
RootedObject pobj(cx);
JSProperty *prop;
if (!LookupPropertyWithFlags(cx, obj, name.value(), cx->resolveFlags, &pobj, &prop))
return NULL;
@ -4963,7 +4967,7 @@ js::FindIdentifierBase(JSContext *cx, HandleObject scopeChain, HandlePropertyNam
/* Loop until we find a property or reach the global object. */
do {
JSObject *pobj;
RootedObject pobj(cx);
JSProperty *prop;
if (!obj->lookupProperty(cx, name, &pobj, &prop))
return NULL;
@ -5084,7 +5088,7 @@ js_GetPropertyHelperInline(JSContext *cx, HandleObject obj, HandleObject receive
/* This call site is hot -- use the always-inlined variant of LookupPropertyWithFlags(). */
RootedObject obj2(cx);
if (!LookupPropertyWithFlagsInline(cx, obj, id, cx->resolveFlags, obj2.address(), &prop))
if (!LookupPropertyWithFlagsInline(cx, obj, id, cx->resolveFlags, &obj2, &prop))
return false;
if (!prop) {
@ -5196,7 +5200,7 @@ baseops::GetPropertyDefault(JSContext *cx, HandleObject obj, HandleId id, const
{
JSProperty *prop;
RootedObject obj2(cx);
if (!LookupPropertyWithFlags(cx, obj, id, JSRESOLVE_QUALIFIED, obj2.address(), &prop))
if (!LookupPropertyWithFlags(cx, obj, id, JSRESOLVE_QUALIFIED, &obj2, &prop))
return false;
if (!prop) {
@ -5285,7 +5289,6 @@ JSBool
baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id,
unsigned defineHow, Value *vp, JSBool strict)
{
JSObject *pobj;
JSProperty *prop;
unsigned attrs, flags;
int shortid;
@ -5303,6 +5306,7 @@ baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receive
return false;
}
RootedObject pobj(cx);
if (!LookupPropertyWithFlags(cx, obj, id, cx->resolveFlags, &pobj, &prop))
return false;
if (prop) {
@ -5480,7 +5484,7 @@ baseops::SetElementHelper(JSContext *cx, HandleObject obj, HandleObject receiver
JSBool
baseops::GetAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
{
JSObject *nobj;
RootedObject nobj(cx);
JSProperty *prop;
if (!baseops::LookupProperty(cx, obj, id, &nobj, &prop))
return false;
@ -5499,7 +5503,7 @@ baseops::GetAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *a
JSBool
baseops::GetElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp)
{
JSObject *nobj;
RootedObject nobj(cx);
JSProperty *prop;
if (!baseops::LookupElement(cx, obj, index, &nobj, &prop))
return false;
@ -5518,7 +5522,7 @@ baseops::GetElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, u
JSBool
baseops::SetAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
{
JSObject *nobj;
RootedObject nobj(cx);
JSProperty *prop;
if (!baseops::LookupProperty(cx, obj, id, &nobj, &prop))
return false;
@ -5532,7 +5536,7 @@ baseops::SetAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *a
JSBool
baseops::SetElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp)
{
JSObject *nobj;
RootedObject nobj(cx);
JSProperty *prop;
if (!baseops::LookupElement(cx, obj, index, &nobj, &prop))
return false;
@ -5546,12 +5550,12 @@ baseops::SetElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, u
JSBool
baseops::DeleteGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *rval, JSBool strict)
{
JSObject *proto;
JSProperty *prop;
const Shape *shape;
rval->setBoolean(true);
RootedObject proto(cx);
if (!baseops::LookupProperty(cx, obj, id, &proto, &prop))
return false;
if (!prop || proto != obj) {
@ -5772,7 +5776,7 @@ CheckAccess(JSContext *cx, JSObject *obj_, HandleId id, JSAccessMode mode,
break;
default:
if (!obj->lookupGeneric(cx, id, pobj.address(), &prop))
if (!obj->lookupGeneric(cx, id, &pobj, &prop))
return JS_FALSE;
if (!prop) {
if (!writing)
@ -5842,20 +5846,20 @@ js_IsDelegate(JSContext *cx, JSObject *obj, const Value &v)
}
bool
js::FindClassPrototype(JSContext *cx, JSObject *scopeobj, JSProtoKey protoKey,
JSObject **protop, Class *clasp)
js::FindClassPrototype(JSContext *cx, HandleObject scopeobj, JSProtoKey protoKey,
MutableHandleObject protop, Class *clasp)
{
Value v;
RootedValue v(cx);
if (!js_FindClassObject(cx, scopeobj, protoKey, &v, clasp))
return false;
if (IsFunctionObject(v)) {
JSObject *ctor = &v.toObject();
if (!ctor->getProperty(cx, cx->runtime->atomState.classPrototypeAtom, &v))
JSObject *ctor = &v.reference().toObject();
if (!ctor->getProperty(cx, cx->runtime->atomState.classPrototypeAtom, v.address()))
return false;
}
*protop = v.isObject() ? &v.toObject() : NULL;
protop.set(v.reference().isObject() ? &v.reference().toObject() : NULL);
return true;
}
@ -5863,9 +5867,9 @@ js::FindClassPrototype(JSContext *cx, JSObject *scopeobj, JSProtoKey protoKey,
* The first part of this function has been hand-expanded and optimized into
* NewBuiltinClassInstance in jsobjinlines.h.
*/
JSBool
js_GetClassPrototype(JSContext *cx, JSObject *scopeobj, JSProtoKey protoKey,
JSObject **protop, Class *clasp)
bool
js_GetClassPrototype(JSContext *cx, HandleObject scopeobj, JSProtoKey protoKey,
MutableHandleObject protop, Class *clasp)
{
JS_ASSERT(JSProto_Null <= protoKey);
JS_ASSERT(protoKey < JSProto_LIMIT);
@ -5877,13 +5881,13 @@ js_GetClassPrototype(JSContext *cx, JSObject *scopeobj, JSProtoKey protoKey,
} else {
global = GetCurrentGlobal(cx);
if (!global) {
*protop = NULL;
protop.set(NULL);
return true;
}
}
const Value &v = global->getReservedSlot(JSProto_LIMIT + protoKey);
if (v.isObject()) {
*protop = &v.toObject();
protop.set(&v.toObject());
return true;
}
}

View File

@ -98,12 +98,12 @@ namespace baseops {
* return true with both *objp and *propp null.
*/
extern JS_FRIEND_API(JSBool)
LookupProperty(JSContext *cx, HandleObject obj, HandleId id, JSObject **objp,
LookupProperty(JSContext *cx, HandleObject obj, HandleId id, MutableHandleObject objp,
JSProperty **propp);
inline bool
LookupProperty(JSContext *cx, HandleObject obj, PropertyName *name,
JSObject **objp, JSProperty **propp)
MutableHandleObject objp, JSProperty **propp)
{
Rooted<jsid> id(cx, NameToId(name));
return LookupProperty(cx, obj, id, objp, propp);
@ -111,7 +111,7 @@ LookupProperty(JSContext *cx, HandleObject obj, PropertyName *name,
extern JS_FRIEND_API(JSBool)
LookupElement(JSContext *cx, HandleObject obj, uint32_t index,
JSObject **objp, JSProperty **propp);
MutableHandleObject objp, JSProperty **propp);
extern JSBool
DefineGeneric(JSContext *cx, HandleObject obj, HandleId id, const js::Value *value,
@ -785,12 +785,12 @@ struct JSObject : public js::ObjectImpl
/* Clear the scope, making it empty. */
void clear(JSContext *cx);
inline JSBool lookupGeneric(JSContext *cx, js::HandleId id, JSObject **objp, JSProperty **propp);
inline JSBool lookupProperty(JSContext *cx, js::PropertyName *name, JSObject **objp, JSProperty **propp);
inline JSBool lookupGeneric(JSContext *cx, js::HandleId id, js::MutableHandleObject objp, JSProperty **propp);
inline JSBool lookupProperty(JSContext *cx, js::PropertyName *name, js::MutableHandleObject objp, JSProperty **propp);
inline JSBool lookupElement(JSContext *cx, uint32_t index,
JSObject **objp, JSProperty **propp);
js::MutableHandleObject objp, JSProperty **propp);
inline JSBool lookupSpecial(JSContext *cx, js::SpecialId sid,
JSObject **objp, JSProperty **propp);
js::MutableHandleObject objp, JSProperty **propp);
inline JSBool defineGeneric(JSContext *cx, js::HandleId id, const js::Value &value,
JSPropertyOp getter = JS_PropertyStub,
@ -1046,7 +1046,7 @@ js_HasOwnPropertyHelper(JSContext *cx, js::LookupGenericOp lookup, unsigned argc
extern JSBool
js_HasOwnProperty(JSContext *cx, js::LookupGenericOp lookup, js::HandleObject obj, js::HandleId id,
JSObject **objp, JSProperty **propp);
js::MutableHandleObject objp, JSProperty **propp);
extern JSBool
js_PropertyIsEnumerable(JSContext *cx, js::HandleObject obj, js::HandleId id, js::Value *vp);
@ -1092,17 +1092,17 @@ js_PopulateObject(JSContext *cx, js::HandleObject newborn, JSObject *props);
/*
* Fast access to immutable standard objects (constructors and prototypes).
*/
extern JSBool
js_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key,
JSObject **objp);
extern bool
js_GetClassObject(JSContext *cx, js::HandleObject obj, JSProtoKey key,
js::MutableHandleObject objp);
/*
* If protoKey is not JSProto_Null, then clasp is ignored. If protoKey is
* JSProto_Null, clasp must non-null.
*/
extern JSBool
js_FindClassObject(JSContext *cx, JSObject *start, JSProtoKey key,
js::Value *vp, js::Class *clasp = NULL);
bool
js_FindClassObject(JSContext *cx, js::HandleObject start, JSProtoKey protoKey,
js::MutableHandleValue vp, js::Class *clasp = NULL);
// Specialized call for constructing |this| with a known function callee,
// and a known prototype.
@ -1165,11 +1165,11 @@ DefineNativeProperty(JSContext *cx, HandleObject obj, PropertyName *name, const
*/
extern bool
LookupPropertyWithFlags(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp, JSProperty **propp);
js::MutableHandleObject objp, JSProperty **propp);
inline bool
LookupPropertyWithFlags(JSContext *cx, HandleObject obj, PropertyName *name, unsigned flags,
JSObject **objp, JSProperty **propp)
js::MutableHandleObject objp, JSProperty **propp)
{
Rooted<jsid> id(cx, NameToId(name));
return LookupPropertyWithFlags(cx, obj, id, flags, objp, propp);
@ -1208,7 +1208,7 @@ static const unsigned RESOLVE_INFER = 0xffff;
extern bool
FindPropertyHelper(JSContext *cx, HandlePropertyName name,
bool cacheResult, HandleObject scopeChain,
JSObject **objp, JSObject **pobjp, JSProperty **propp);
MutableHandleObject objp, MutableHandleObject pobjp, JSProperty **propp);
/*
* Search for name either on the current scope chain or on the scope chain's
@ -1216,7 +1216,7 @@ FindPropertyHelper(JSContext *cx, HandlePropertyName name,
*/
extern bool
FindProperty(JSContext *cx, HandlePropertyName name, HandleObject scopeChain,
JSObject **objp, JSObject **pobjp, JSProperty **propp);
MutableHandleObject objp, MutableHandleObject pobjp, JSProperty **propp);
extern JSObject *
FindIdentifierBase(JSContext *cx, HandleObject scopeChain, HandlePropertyName name);
@ -1360,9 +1360,9 @@ js_Object(JSContext *cx, unsigned argc, js::Value *vp);
* If protoKey is constant and scope is non-null, use GlobalObject's prototype
* methods instead.
*/
extern JS_FRIEND_API(JSBool)
js_GetClassPrototype(JSContext *cx, JSObject *scope, JSProtoKey protoKey,
JSObject **protop, js::Class *clasp = NULL);
extern JS_FRIEND_API(bool)
js_GetClassPrototype(JSContext *cx, js::HandleObject scopeobj, JSProtoKey protoKey,
js::MutableHandleObject protop, js::Class *clasp = NULL);
namespace js {
@ -1408,7 +1408,8 @@ inline void
DestroyIdArray(FreeOp *fop, JSIdArray *ida);
extern bool
GetFirstArgumentAsObject(JSContext *cx, unsigned argc, Value *vp, const char *method, JSObject **objp);
GetFirstArgumentAsObject(JSContext *cx, unsigned argc, Value *vp, const char *method,
MutableHandleObject objp);
/* Helpers for throwing. These always return false. */
extern bool

View File

@ -926,7 +926,7 @@ JSObject::finish(js::FreeOp *fop)
inline bool
JSObject::hasProperty(JSContext *cx, js::HandleId id, bool *foundp, unsigned flags)
{
JSObject *pobj;
js::RootedObject pobj(cx);
JSProperty *prop;
JSAutoResolveFlags rf(cx, flags);
if (!lookupGeneric(cx, id, &pobj, &prop))
@ -1034,7 +1034,7 @@ JSObject::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf,
}
inline JSBool
JSObject::lookupGeneric(JSContext *cx, js::HandleId id, JSObject **objp, JSProperty **propp)
JSObject::lookupGeneric(JSContext *cx, js::HandleId id, js::MutableHandleObject objp, JSProperty **propp)
{
js::RootedObject self(cx, this);
@ -1045,7 +1045,7 @@ JSObject::lookupGeneric(JSContext *cx, js::HandleId id, JSObject **objp, JSPrope
}
inline JSBool
JSObject::lookupProperty(JSContext *cx, js::PropertyName *name, JSObject **objp, JSProperty **propp)
JSObject::lookupProperty(JSContext *cx, js::PropertyName *name, js::MutableHandleObject objp, JSProperty **propp)
{
js::Rooted<jsid> id(cx, js::NameToId(name));
return lookupGeneric(cx, id, objp, propp);
@ -1097,7 +1097,7 @@ JSObject::defineSpecial(JSContext *cx, js::SpecialId sid, const js::Value &value
}
inline JSBool
JSObject::lookupElement(JSContext *cx, uint32_t index, JSObject **objp, JSProperty **propp)
JSObject::lookupElement(JSContext *cx, uint32_t index, js::MutableHandleObject objp, JSProperty **propp)
{
js::RootedObject self(cx, this);
@ -1106,7 +1106,7 @@ JSObject::lookupElement(JSContext *cx, uint32_t index, JSObject **objp, JSProper
}
inline JSBool
JSObject::lookupSpecial(JSContext *cx, js::SpecialId sid, JSObject **objp, JSProperty **propp)
JSObject::lookupSpecial(JSContext *cx, js::SpecialId sid, js::MutableHandleObject objp, JSProperty **propp)
{
js::Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return lookupGeneric(cx, id, objp, propp);
@ -1153,7 +1153,7 @@ JSObject::getElementIfPresent(JSContext *cx, js::HandleObject receiver, uint32_t
if (!js::IndexToId(cx, index, id.address()))
return false;
JSObject *obj2;
js::RootedObject obj2(cx);
JSProperty *prop;
if (!self->lookupGeneric(cx, id, &obj2, &prop))
return false;
@ -1440,12 +1440,12 @@ GetClassProtoKey(js::Class *clasp)
}
inline bool
FindProto(JSContext *cx, js::Class *clasp, HandleObject parent, JSObject **proto)
FindProto(JSContext *cx, js::Class *clasp, HandleObject parent, MutableHandleObject proto)
{
JSProtoKey protoKey = GetClassProtoKey(clasp);
if (!js_GetClassPrototype(cx, parent, protoKey, proto, clasp))
return false;
if (!(*proto) && !js_GetClassPrototype(cx, parent, JSProto_Object, proto))
if (!proto && !js_GetClassPrototype(cx, parent, JSProto_Object, proto))
return false;
return true;
}
@ -1503,8 +1503,8 @@ GetCurrentGlobal(JSContext *cx)
}
bool
FindClassPrototype(JSContext *cx, JSObject *scope, JSProtoKey protoKey, JSObject **protop,
Class *clasp);
FindClassPrototype(JSContext *cx, HandleObject scope, JSProtoKey protoKey,
MutableHandleObject protop, Class *clasp);
/*
* Create a plain object with the specified type. This bypasses getNewType to

View File

@ -1221,7 +1221,7 @@ proxy_innerObject(JSContext *cx, HandleObject obj)
}
static JSBool
proxy_LookupGeneric(JSContext *cx, HandleObject obj, HandleId id, JSObject **objp,
proxy_LookupGeneric(JSContext *cx, HandleObject obj, HandleId id, MutableHandleObject objp,
JSProperty **propp)
{
bool found;
@ -1230,24 +1230,24 @@ proxy_LookupGeneric(JSContext *cx, HandleObject obj, HandleId id, JSObject **obj
if (found) {
*propp = (JSProperty *)0x1;
*objp = obj;
objp.set(obj);
} else {
*objp = NULL;
objp.set(NULL);
*propp = NULL;
}
return true;
}
static JSBool
proxy_LookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, JSObject **objp,
JSProperty **propp)
proxy_LookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
MutableHandleObject objp, JSProperty **propp)
{
Rooted<jsid> id(cx, NameToId(name));
return proxy_LookupGeneric(cx, obj, id, objp, propp);
}
static JSBool
proxy_LookupElement(JSContext *cx, HandleObject obj, uint32_t index, JSObject **objp,
proxy_LookupElement(JSContext *cx, HandleObject obj, uint32_t index, MutableHandleObject objp,
JSProperty **propp)
{
RootedId id(cx);
@ -1257,7 +1257,8 @@ proxy_LookupElement(JSContext *cx, HandleObject obj, uint32_t index, JSObject **
}
static JSBool
proxy_LookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, JSObject **objp, JSProperty **propp)
proxy_LookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
MutableHandleObject objp, JSProperty **propp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return proxy_LookupGeneric(cx, obj, id, objp, propp);

View File

@ -2838,7 +2838,7 @@ ASTSerializer::literal(ParseNode *pn, Value *dst)
JSObject *re1 = pn->pn_objbox ? pn->pn_objbox->object : NULL;
LOCAL_ASSERT(re1 && re1->isRegExp());
JSObject *proto;
RootedObject proto(cx);
if (!js_GetClassPrototype(cx, cx->fp()->scopeChain(), JSProto_RegExp, &proto))
return false;

View File

@ -636,7 +636,7 @@ struct JSScript : public js::gc::Cell
inline bool hasGlobal() const;
inline bool hasClearedGlobal() const;
inline js::GlobalObject *global() const;
inline js::GlobalObject * global() const;
inline js::types::TypeScriptNesting *nesting() const;
inline void clearNesting();

View File

@ -378,7 +378,7 @@ str_enumerate(JSContext *cx, HandleObject obj)
static JSBool
str_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp)
MutableHandleObject objp)
{
if (!JSID_IS_INT(id))
return JS_TRUE;
@ -394,7 +394,7 @@ str_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
STRING_ELEMENT_ATTRS)) {
return JS_FALSE;
}
*objp = obj;
objp.set(obj);
}
return JS_TRUE;
}

View File

@ -299,11 +299,11 @@ static JSProperty * const PROPERTY_FOUND = reinterpret_cast<JSProperty *>(1);
JSBool
ArrayBufferObject::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
JSObject **objp, JSProperty **propp)
MutableHandleObject objp, JSProperty **propp)
{
if (JSID_IS_ATOM(id, cx->runtime->atomState.byteLengthAtom)) {
*propp = PROPERTY_FOUND;
*objp = getArrayBuffer(obj);
objp.set(getArrayBuffer(obj));
return true;
}
@ -322,14 +322,14 @@ ArrayBufferObject::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId i
return false;
if (*propp != NULL) {
if (*objp == delegate)
*objp = obj;
if (objp.value() == delegate)
objp.set(obj);
return true;
}
JSObject *proto = obj->getProto();
if (!proto) {
*objp = NULL;
objp.set(NULL);
*propp = NULL;
return true;
}
@ -339,7 +339,7 @@ ArrayBufferObject::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId i
JSBool
ArrayBufferObject::obj_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
JSObject **objp, JSProperty **propp)
MutableHandleObject objp, JSProperty **propp)
{
Rooted<jsid> id(cx, NameToId(name));
return obj_lookupGeneric(cx, obj, id, objp, propp);
@ -347,7 +347,7 @@ ArrayBufferObject::obj_lookupProperty(JSContext *cx, HandleObject obj, HandlePro
JSBool
ArrayBufferObject::obj_lookupElement(JSContext *cx, HandleObject obj, uint32_t index,
JSObject **objp, JSProperty **propp)
MutableHandleObject objp, JSProperty **propp)
{
RootedObject delegate(cx, ArrayBufferDelegate(cx, obj));
if (!delegate)
@ -363,22 +363,22 @@ ArrayBufferObject::obj_lookupElement(JSContext *cx, HandleObject obj, uint32_t i
return false;
if (*propp != NULL) {
if (*objp == delegate)
*objp = obj;
if (objp.value() == delegate)
objp.set(obj);
return true;
}
if (JSObject *proto = obj->getProto())
return proto->lookupElement(cx, index, objp, propp);
*objp = NULL;
objp.set(NULL);
*propp = NULL;
return true;
}
JSBool
ArrayBufferObject::obj_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
JSObject **objp, JSProperty **propp)
MutableHandleObject objp, JSProperty **propp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return obj_lookupGeneric(cx, obj, id, objp, propp);
@ -727,7 +727,7 @@ GetProtoForClass(JSContext *cx, Class *clasp)
{
// Pass in the proto from this compartment
Rooted<GlobalObject*> parent(cx, GetCurrentGlobal(cx));
JSObject *proto;
RootedObject proto(cx);
if (!FindProto(cx, clasp, parent, &proto))
return NULL;
return proto;
@ -774,20 +774,20 @@ js::IsDataView(JSObject* obj)
JSBool
TypedArray::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
JSObject **objp, JSProperty **propp)
MutableHandleObject objp, JSProperty **propp)
{
JSObject *tarray = getTypedArray(obj);
JS_ASSERT(tarray);
if (isArrayIndex(cx, tarray, id)) {
*propp = PROPERTY_FOUND;
*objp = obj;
objp.set(obj);
return true;
}
JSObject *proto = obj->getProto();
if (!proto) {
*objp = NULL;
objp.set(NULL);
*propp = NULL;
return true;
}
@ -797,7 +797,7 @@ TypedArray::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
JSBool
TypedArray::obj_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
JSObject **objp, JSProperty **propp)
MutableHandleObject objp, JSProperty **propp)
{
Rooted<jsid> id(cx, NameToId(name));
return obj_lookupGeneric(cx, obj, id, objp, propp);
@ -805,28 +805,28 @@ TypedArray::obj_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyNa
JSBool
TypedArray::obj_lookupElement(JSContext *cx, HandleObject obj, uint32_t index,
JSObject **objp, JSProperty **propp)
MutableHandleObject objp, JSProperty **propp)
{
JSObject *tarray = getTypedArray(obj);
JS_ASSERT(tarray);
if (index < length(tarray)) {
*propp = PROPERTY_FOUND;
*objp = obj;
objp.set(obj);
return true;
}
if (JSObject *proto = obj->getProto())
return proto->lookupElement(cx, index, objp, propp);
*objp = NULL;
objp.set(NULL);
*propp = NULL;
return true;
}
JSBool
TypedArray::obj_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
JSObject **objp, JSProperty **propp)
MutableHandleObject objp, JSProperty **propp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return obj_lookupGeneric(cx, obj, id, objp, propp);
@ -2305,7 +2305,7 @@ DataViewObject::constructWithProto(JSContext *cx, unsigned argc, Value *vp)
// And now mimic class_constructor for everything else, but pass in the proto
args = CallArgsFromVp(argc - 1, vp);
JSObject *bufobj;
RootedObject bufobj(cx);
if (!GetFirstArgumentAsObject(cx, args.length(), args.base(), "DataView constructor", &bufobj))
return false;
return construct(cx, bufobj, args, &proto);
@ -2316,7 +2316,7 @@ DataViewObject::class_constructor(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
JSObject *bufobj;
RootedObject bufobj(cx);
if (!GetFirstArgumentAsObject(cx, args.length(), args.base(), "DataView constructor", &bufobj))
return false;
@ -3251,7 +3251,7 @@ js_InitTypedArrayClasses(JSContext *cx, JSObject *obj)
Rooted<GlobalObject*> global(cx, &obj->asGlobal());
/* Idempotency required: we initialize several things, possibly lazily. */
JSObject *stop;
RootedObject stop(cx);
if (!js_GetClassObject(cx, global, JSProto_ArrayBuffer, &stop))
return NULL;
if (stop)

View File

@ -47,16 +47,16 @@ class ArrayBufferObject : public JSObject
static JSBool
obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
JSObject **objp, JSProperty **propp);
MutableHandleObject objp, JSProperty **propp);
static JSBool
obj_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
JSObject **objp, JSProperty **propp);
MutableHandleObject objp, JSProperty **propp);
static JSBool
obj_lookupElement(JSContext *cx, HandleObject obj, uint32_t index,
JSObject **objp, JSProperty **propp);
MutableHandleObject objp, JSProperty **propp);
static JSBool
obj_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, JSObject **objp,
JSProperty **propp);
obj_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
MutableHandleObject objp, JSProperty **propp);
static JSBool
obj_defineGeneric(JSContext *cx, HandleObject obj, HandleId id, const Value *v,
@ -189,13 +189,13 @@ struct TypedArray {
static Class protoClasses[TYPE_MAX];
static JSBool obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
JSObject **objp, JSProperty **propp);
MutableHandleObject objp, JSProperty **propp);
static JSBool obj_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
JSObject **objp, JSProperty **propp);
MutableHandleObject objp, JSProperty **propp);
static JSBool obj_lookupElement(JSContext *cx, HandleObject obj, uint32_t index,
JSObject **objp, JSProperty **propp);
MutableHandleObject objp, JSProperty **propp);
static JSBool obj_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
JSObject **objp, JSProperty **propp);
MutableHandleObject objp, JSProperty **propp);
static JSBool obj_getGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp);
static JSBool obj_getPropertyAttributes(JSContext *cx, HandleObject obj, HandlePropertyName name, unsigned *attrsp);

View File

@ -1165,7 +1165,6 @@ js::RemapAllWrappersForObject(JSContext *cx, JSObject *oldTarget,
JSObject *newTarget)
{
Value origv = ObjectValue(*oldTarget);
Value targetv = ObjectValue(*newTarget);
AutoValueVector toTransplant(cx);
if (!toTransplant.reserve(cx->runtime->compartments.length()))

View File

@ -493,10 +493,10 @@ NewXMLAttributeName(JSContext *cx, JSLinearString *uri, JSLinearString *prefix,
}
static JSObject *
ConstructObjectWithArguments(JSContext *cx, Class *clasp, JSObject *parent,
ConstructObjectWithArguments(JSContext *cx, Class *clasp,
unsigned argc, jsval *argv)
{
assertSameCompartment(cx, parent, JSValueArray(argv, argc));
assertSameCompartment(cx, JSValueArray(argv, argc));
AutoArrayRooter argtvr(cx, argc, argv);
@ -504,7 +504,8 @@ ConstructObjectWithArguments(JSContext *cx, Class *clasp, JSObject *parent,
/* Protect constructor in case a crazy getter for .prototype uproots it. */
RootedValue value(cx);
if (!js_FindClassObject(cx, parent, protoKey, value.address(), clasp))
RootedObject null(cx);
if (!js_FindClassObject(cx, null, protoKey, &value, clasp))
return NULL;
Value rval;
@ -540,7 +541,7 @@ js_ConstructXMLQNameObject(JSContext *cx, const Value &nsval, const Value &lnval
argv[0] = nsval;
}
argv[1] = lnval;
return ConstructObjectWithArguments(cx, &QNameClass, NULL, 2, argv);
return ConstructObjectWithArguments(cx, &QNameClass, 2, argv);
}
static JSBool
@ -1661,15 +1662,15 @@ fail:
static JSBool
GetXMLSetting(JSContext *cx, const char *name, jsval *vp)
{
jsval v;
if (!js_FindClassObject(cx, NULL, JSProto_XML, &v))
RootedValue v(cx);
RootedObject null(cx);
if (!js_FindClassObject(cx, null, JSProto_XML, &v))
return JS_FALSE;
if (JSVAL_IS_PRIMITIVE(v) || !JSVAL_TO_OBJECT(v)->isFunction()) {
if (v.reference().isPrimitive() || !v.reference().toObject().isFunction()) {
*vp = JSVAL_VOID;
return JS_TRUE;
}
return JS_GetProperty(cx, JSVAL_TO_OBJECT(v), name, vp);
return JS_GetProperty(cx, &v.reference().toObject(), name, vp);
}
static JSBool
@ -2272,7 +2273,7 @@ GetNamespace(JSContext *cx, JSObject *qn, const JSXMLArray<JSObject> *inScopeNSe
if (!match) {
argv[0] = prefix ? STRING_TO_JSVAL(prefix) : JSVAL_VOID;
argv[1] = STRING_TO_JSVAL(uri);
ns = ConstructObjectWithArguments(cx, &NamespaceClass, NULL, 2, argv);
ns = ConstructObjectWithArguments(cx, &NamespaceClass, 2, argv);
if (!ns)
return NULL;
match = ns;
@ -2953,7 +2954,7 @@ ToXMLName(JSContext *cx, jsval v, jsid *funidp)
construct:
v = STRING_TO_JSVAL(name);
obj = ConstructObjectWithArguments(cx, &QNameClass, NULL, 1, &v);
obj = ConstructObjectWithArguments(cx, &QNameClass, 1, &v);
if (!obj)
return NULL;
@ -4631,7 +4632,6 @@ HasSimpleContent(JSXML *xml);
static JSBool
HasFunctionProperty(JSContext *cx, JSObject *obj_, jsid funid_, JSBool *found)
{
JSObject *pobj;
JSProperty *prop;
JSXML *xml;
@ -4640,6 +4640,7 @@ HasFunctionProperty(JSContext *cx, JSObject *obj_, jsid funid_, JSBool *found)
RootedId funid(cx, funid_);
Rooted<JSObject*> obj(cx, obj_);
RootedObject pobj(cx);
if (!baseops::LookupProperty(cx, obj, funid, &pobj, &prop))
return false;
if (!prop) {
@ -4742,7 +4743,8 @@ HasProperty(JSContext *cx, JSObject *obj, jsval id, JSBool *found)
* For a proper solution see bug 355257.
*/
static JSBool
xml_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, JSObject **objp, JSProperty **propp)
xml_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, MutableHandleObject objp,
JSProperty **propp)
{
JSBool found;
JSXML *xml;
@ -4763,7 +4765,7 @@ xml_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, JSObject **objp,
found = HasNamedProperty(xml, qn);
}
if (!found) {
*objp = NULL;
objp.set(NULL);
*propp = NULL;
} else {
const Shape *shape =
@ -4773,27 +4775,27 @@ xml_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, JSObject **objp,
if (!shape)
return JS_FALSE;
*objp = obj;
objp.set(obj);
*propp = (JSProperty *) shape;
}
return JS_TRUE;
}
static JSBool
xml_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, JSObject **objp,
JSProperty **propp)
xml_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
MutableHandleObject objp, JSProperty **propp)
{
Rooted<jsid> id(cx, NameToId(name));
return xml_lookupGeneric(cx, obj, id, objp, propp);
}
static JSBool
xml_lookupElement(JSContext *cx, HandleObject obj, uint32_t index, JSObject **objp,
xml_lookupElement(JSContext *cx, HandleObject obj, uint32_t index, MutableHandleObject objp,
JSProperty **propp)
{
JSXML *xml = reinterpret_cast<JSXML *>(obj->getPrivate());
if (!HasIndexedProperty(xml, index)) {
*objp = NULL;
objp.set(NULL);
*propp = NULL;
return true;
}
@ -4808,13 +4810,14 @@ xml_lookupElement(JSContext *cx, HandleObject obj, uint32_t index, JSObject **ob
if (!shape)
return false;
*objp = obj;
objp.set(obj);
*propp = (JSProperty *) shape;
return true;
}
static JSBool
xml_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, JSObject **objp, JSProperty **propp)
xml_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
MutableHandleObject objp, JSProperty **propp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return xml_lookupGeneric(cx, obj, id, objp, propp);
@ -5419,7 +5422,7 @@ JS_FRIEND_DATA(Class) js::XMLClass = {
};
static JSXML *
StartNonListXMLMethod(JSContext *cx, jsval *vp, JSObject **objp)
StartNonListXMLMethod(JSContext *cx, jsval *vp, MutableHandleObject objp)
{
JSXML *xml;
JSFunction *fun;
@ -5428,24 +5431,24 @@ StartNonListXMLMethod(JSContext *cx, jsval *vp, JSObject **objp)
JS_ASSERT(!JSVAL_IS_PRIMITIVE(*vp));
JS_ASSERT(JSVAL_TO_OBJECT(*vp)->isFunction());
*objp = ToObject(cx, &vp[1]);
if (!*objp)
objp.set(ToObject(cx, &vp[1]));
if (!objp)
return NULL;
if (!(*objp)->isXML()) {
if (!objp->isXML()) {
ReportIncompatibleMethod(cx, CallReceiverFromVp(vp), &XMLClass);
return NULL;
}
xml = (JSXML *) (*objp)->getPrivate();
xml = (JSXML *) objp->getPrivate();
if (!xml || xml->xml_class != JSXML_CLASS_LIST)
return xml;
if (xml->xml_kids.length == 1) {
xml = XMLARRAY_MEMBER(&xml->xml_kids, 0, JSXML);
if (xml) {
*objp = js_GetXMLObject(cx, xml);
if (!*objp)
objp.set(js_GetXMLObject(cx, xml));
if (!objp)
return NULL;
vp[1] = OBJECT_TO_JSVAL(*objp);
vp[1] = OBJECT_TO_JSVAL(objp);
return xml;
}
}
@ -5474,8 +5477,8 @@ StartNonListXMLMethod(JSContext *cx, jsval *vp, JSObject **objp)
return JS_FALSE
#define NON_LIST_XML_METHOD_PROLOG \
RootedObject obj(cx); \
JSXML *xml = StartNonListXMLMethod(cx, vp, obj.address()); \
RootedObject obj(cx); \
JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); \
if (!xml) \
return JS_FALSE; \
JS_ASSERT(xml->xml_class != JSXML_CLASS_LIST)
@ -6688,7 +6691,7 @@ xml_setChildren(JSContext *cx, unsigned argc, jsval *vp)
{
RootedObject obj(cx);
if (!StartNonListXMLMethod(cx, vp, obj.address()))
if (!StartNonListXMLMethod(cx, vp, &obj))
return JS_FALSE;
Rooted<jsid> id(cx, NameToId(cx->runtime->atomState.starAtom));
@ -6757,7 +6760,7 @@ xml_setName(JSContext *cx, unsigned argc, jsval *vp)
}
}
nameqn = ConstructObjectWithArguments(cx, &QNameClass, NULL, 1, &name);
nameqn = ConstructObjectWithArguments(cx, &QNameClass, 1, &name);
if (!nameqn)
return JS_FALSE;
@ -6862,7 +6865,7 @@ xml_setNamespace(JSContext *cx, unsigned argc, jsval *vp)
if (!JSXML_HAS_NAME(xml))
return JS_TRUE;
ns = ConstructObjectWithArguments(cx, &NamespaceClass, NULL, argc == 0 ? 0 : 1, vp + 2);
ns = ConstructObjectWithArguments(cx, &NamespaceClass, argc == 0 ? 0 : 1, vp + 2);
if (!ns)
return JS_FALSE;
vp[0] = OBJECT_TO_JSVAL(ns);
@ -6870,7 +6873,7 @@ xml_setNamespace(JSContext *cx, unsigned argc, jsval *vp)
qnargv[0] = OBJECT_TO_JSVAL(ns);
qnargv[1] = OBJECT_TO_JSVAL(xml->name);
qn = ConstructObjectWithArguments(cx, &QNameClass, NULL, 2, qnargv);
qn = ConstructObjectWithArguments(cx, &QNameClass, 2, qnargv);
if (!qn)
return JS_FALSE;
@ -7612,7 +7615,7 @@ js_GetDefaultXMLNamespace(JSContext *cx, jsval *vp)
obj = tmp;
}
ns = ConstructObjectWithArguments(cx, &NamespaceClass, NULL, 0, NULL);
ns = ConstructObjectWithArguments(cx, &NamespaceClass, 0, NULL);
if (!ns)
return JS_FALSE;
v = OBJECT_TO_JSVAL(ns);
@ -7630,7 +7633,7 @@ js_SetDefaultXMLNamespace(JSContext *cx, const Value &v)
Value argv[2];
argv[0].setString(cx->runtime->emptyString);
argv[1] = v;
JSObject *ns = ConstructObjectWithArguments(cx, &NamespaceClass, NULL, 2, argv);
JSObject *ns = ConstructObjectWithArguments(cx, &NamespaceClass, 2, argv);
if (!ns)
return JS_FALSE;
@ -7733,13 +7736,13 @@ js_GetAnyName(JSContext *cx, jsid *idp)
}
JSBool
js_FindXMLProperty(JSContext *cx, const Value &nameval, JSObject **objp, jsid *idp)
js_FindXMLProperty(JSContext *cx, const Value &nameval, MutableHandleObject objp, jsid *idp)
{
JSObject *nameobj;
jsval v;
JSObject *qn;
RootedId funid(cx);
JSObject *obj, *target, *proto, *pobj;
JSObject *obj, *target, *proto;
JSXML *xml;
JSBool found;
JSProperty *prop;
@ -7748,7 +7751,7 @@ js_FindXMLProperty(JSContext *cx, const Value &nameval, JSObject **objp, jsid *i
nameobj = &nameval.toObject();
if (nameobj->getClass() == &AnyNameClass) {
v = STRING_TO_JSVAL(cx->runtime->atomState.starAtom);
nameobj = ConstructObjectWithArguments(cx, &QNameClass, NULL, 1, &v);
nameobj = ConstructObjectWithArguments(cx, &QNameClass, 1, &v);
if (!nameobj)
return JS_FALSE;
} else {
@ -7784,15 +7787,16 @@ js_FindXMLProperty(JSContext *cx, const Value &nameval, JSObject **objp, jsid *i
}
if (found) {
*idp = OBJECT_TO_JSID(nameobj);
*objp = target;
objp.set(target);
return JS_TRUE;
}
} else if (!JSID_IS_VOID(funid)) {
RootedObject pobj(cx);
if (!target->lookupGeneric(cx, funid, &pobj, &prop))
return JS_FALSE;
if (prop) {
*idp = funid;
*objp = target;
objp.set(target);
return JS_TRUE;
}
}

View File

@ -254,7 +254,8 @@ js_GetAnyName(JSContext *cx, jsid *idp);
* Note: nameval must be either QName, AttributeName, or AnyName.
*/
extern JSBool
js_FindXMLProperty(JSContext *cx, const js::Value &nameval, JSObject **objp, jsid *idp);
js_FindXMLProperty(JSContext *cx, const js::Value &nameval,
js::MutableHandleObject objp, jsid *idp);
extern JSBool
js_GetXMLMethod(JSContext *cx, js::HandleObject obj, jsid id, js::Value *vp);

View File

@ -5070,7 +5070,7 @@ mjit::Compiler::testSingletonProperty(HandleObject obj, HandleId id)
nobj = nobj->getProto();
}
JSObject *holder;
RootedObject holder(cx);
JSProperty *prop = NULL;
if (!obj->lookupGeneric(cx, id, &holder, &prop))
return false;
@ -5145,7 +5145,7 @@ mjit::Compiler::testSingletonPropertyTypes(FrameEntry *top, HandleId id, bool *t
}
RootedObject proto(cx);
if (!js_GetClassPrototype(cx, globalObj, key, proto.address(), NULL))
if (!js_GetClassPrototype(cx, globalObj, key, &proto, NULL))
return false;
return testSingletonProperty(proto, id);

View File

@ -2685,7 +2685,7 @@ mjit::Compiler::jsop_initprop()
return;
}
JSObject *holder;
RootedObject holder(cx);
JSProperty *prop = NULL;
Rooted<jsid> id(cx, NameToId(name));
#ifdef DEBUG

View File

@ -453,7 +453,7 @@ class SetPropCompiler : public PICStubCompiler
if (clasp->ops.setProperty)
return disable("ops set property hook");
JSObject *holder;
RootedObject holder(cx);
JSProperty *prop = NULL;
/* lookupProperty can trigger recompilations. */
@ -652,23 +652,23 @@ IsCacheableProtoChain(JSObject *obj, JSObject *holder)
template <typename IC>
struct GetPropHelper {
// These fields are set in the constructor and describe a property lookup.
JSContext *cx;
JSObject *obj;
JSContext *cx;
RootedObject obj;
RootedPropertyName name;
IC &ic;
VMFrame &f;
IC &ic;
VMFrame &f;
// These fields are set by |bind| and |lookup|. After a call to either
// function, these are set exactly as they are in JSOP_GETPROP or JSOP_NAME.
JSObject *holder;
JSProperty *prop;
RootedObject holder;
JSProperty *prop;
// This field is set by |bind| and |lookup| only if they returned
// Lookup_Cacheable, otherwise it is NULL.
const Shape *shape;
GetPropHelper(JSContext *cx, JSObject *obj, PropertyName *name, IC &ic, VMFrame &f)
: cx(cx), obj(obj), name(cx, name), ic(ic), f(f), holder(NULL), prop(NULL), shape(NULL)
: cx(cx), obj(cx, obj), name(cx, name), ic(ic), f(f), holder(cx), prop(NULL), shape(NULL)
{ }
public:

View File

@ -192,7 +192,7 @@ stubs::ImplicitThis(VMFrame &f, PropertyName *name_)
RootedObject scopeObj(f.cx, f.cx->stack.currentScriptedScopeChain());
RootedPropertyName name(f.cx, name_);
JSObject *obj, *obj2;
RootedObject obj(f.cx), obj2(f.cx);
JSProperty *prop;
if (!FindPropertyHelper(f.cx, name, false, scopeObj, &obj, &obj2, &prop))
THROW();
@ -339,7 +339,7 @@ stubs::DefFun(VMFrame &f, JSFunction *fun_)
/* ES5 10.5 (NB: with subsequent errata). */
PropertyName *name = fun->atom->asPropertyName();
JSProperty *prop = NULL;
JSObject *pobj;
RootedObject pobj(cx);
if (!parent->lookupProperty(cx, name, &pobj, &prop))
THROW();
@ -1338,7 +1338,7 @@ stubs::DelName(VMFrame &f, PropertyName *name_)
RootedObject scopeObj(f.cx, f.cx->stack.currentScriptedScopeChain());
RootedPropertyName name(f.cx, name_);
JSObject *obj, *obj2;
RootedObject obj(f.cx), obj2(f.cx);
JSProperty *prop;
if (!FindProperty(f.cx, name, scopeObj, &obj, &obj2, &prop))
THROW();
@ -1438,7 +1438,7 @@ stubs::In(VMFrame &f)
if (!FetchElementId(f.cx, obj, f.regs.sp[-2], id.address(), &f.regs.sp[-2]))
THROWV(JS_FALSE);
JSObject *obj2;
RootedObject obj2(cx);
JSProperty *prop;
if (!obj->lookupGeneric(cx, id, &obj2, &prop))
THROWV(JS_FALSE);

View File

@ -2489,7 +2489,7 @@ sandbox_enumerate(JSContext *cx, HandleObject obj)
static JSBool
sandbox_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp)
MutableHandleObject objp)
{
jsval v;
JSBool b, resolved;
@ -2502,11 +2502,11 @@ sandbox_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
if (!JS_ResolveStandardClass(cx, obj, id, &resolved))
return false;
if (resolved) {
*objp = obj;
objp.set(obj);
return true;
}
}
*objp = NULL;
objp.set(NULL);
return true;
}
@ -2687,14 +2687,14 @@ ShapeOf(JSContext *cx, unsigned argc, JS::Value *vp)
*/
static JSBool
CopyProperty(JSContext *cx, HandleObject obj, HandleObject referent, HandleId id,
unsigned lookupFlags, JSObject **objp)
unsigned lookupFlags, MutableHandleObject objp)
{
JSProperty *prop;
PropertyDescriptor desc;
unsigned propFlags = 0;
JSObject *obj2;
RootedObject obj2(cx);
*objp = NULL;
objp.set(NULL);
if (referent->isNative()) {
if (!LookupPropertyWithFlags(cx, referent, id, lookupFlags, &obj2, &prop))
return false;
@ -2726,7 +2726,7 @@ CopyProperty(JSContext *cx, HandleObject obj, HandleObject referent, HandleId id
} else {
if (!referent->lookupGeneric(cx, id, objp, &prop))
return false;
if (*objp != referent)
if (objp != referent)
return true;
if (!referent->getGeneric(cx, id, &desc.value) ||
!referent->getGenericAttributes(cx, id, &desc.attrs)) {
@ -2738,13 +2738,14 @@ CopyProperty(JSContext *cx, HandleObject obj, HandleObject referent, HandleId id
desc.shortid = 0;
}
*objp = obj;
objp.set(obj);
return !!DefineNativeProperty(cx, obj, id, desc.value, desc.getter, desc.setter,
desc.attrs, propFlags, desc.shortid);
}
static JSBool
resolver_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags, JSObject **objp)
resolver_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
MutableHandleObject objp)
{
jsval v = JS_GetReservedSlot(obj, 0);
Rooted<JSObject*> vobj(cx, &v.toObject());
@ -2759,7 +2760,7 @@ resolver_enumerate(JSContext *cx, HandleObject obj)
AutoIdArray ida(cx, JS_Enumerate(cx, referent));
bool ok = !!ida;
JSObject *ignore;
RootedObject ignore(cx);
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);
@ -3961,7 +3962,7 @@ its_enumerate(JSContext *cx, HandleObject obj, JSIterateOp enum_op,
static JSBool
its_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp)
MutableHandleObject objp)
{
if (its_noisy) {
IdStringifier idString(cx, id);
@ -4275,7 +4276,7 @@ global_enumerate(JSContext *cx, HandleObject obj)
static JSBool
global_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp)
MutableHandleObject objp)
{
#ifdef LAZY_STANDARD_CLASSES
JSBool resolved;
@ -4283,7 +4284,7 @@ global_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
if (!JS_ResolveStandardClass(cx, obj, id, &resolved))
return false;
if (resolved) {
*objp = obj;
objp.set(obj);
return true;
}
#endif
@ -4330,7 +4331,7 @@ global_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSPROP_ENUMERATE);
ok = (fun != NULL);
if (ok)
*objp = obj;
objp.set(obj);
break;
}
}
@ -4424,7 +4425,7 @@ env_enumerate(JSContext *cx, HandleObject obj)
static JSBool
env_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp)
MutableHandleObject objp)
{
JSString *valstr;
const char *name, *value;
@ -4446,7 +4447,7 @@ env_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
NULL, NULL, JSPROP_ENUMERATE)) {
return false;
}
*objp = obj;
objp.set(obj);
}
return true;
}

View File

@ -208,9 +208,9 @@ ArgSetter(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, Value *vp
static JSBool
args_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
JSObject **objp)
MutableHandleObject objp)
{
*objp = NULL;
objp.set(NULL);
Rooted<NormalArgumentsObject*> argsobj(cx, &obj->asNormalArguments());
@ -236,7 +236,7 @@ args_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
if (!baseops::DefineGeneric(cx, argsobj, id, &undef, ArgGetter, ArgSetter, attrs))
return JS_FALSE;
*objp = argsobj;
objp.set(argsobj);
return true;
}
@ -258,7 +258,7 @@ args_enumerate(JSContext *cx, HandleObject obj)
? NameToId(cx->runtime->atomState.calleeAtom)
: INT_TO_JSID(i);
JSObject *pobj;
RootedObject pobj(cx);
JSProperty *prop;
if (!baseops::LookupProperty(cx, argsobj, id, &pobj, &prop))
return false;
@ -320,9 +320,10 @@ StrictArgSetter(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, Val
}
static JSBool
strictargs_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags, JSObject **objp)
strictargs_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
MutableHandleObject objp)
{
*objp = NULL;
objp.set(NULL);
Rooted<StrictArgumentsObject*> argsobj(cx, &obj->asStrictArguments());
@ -354,7 +355,7 @@ strictargs_resolve(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
if (!baseops::DefineGeneric(cx, argsobj, id, &undef, getter, setter, attrs))
return false;
*objp = argsobj;
objp.set(argsobj);
return true;
}
@ -367,7 +368,7 @@ strictargs_enumerate(JSContext *cx, HandleObject obj)
* Trigger reflection in strictargs_resolve using a series of
* js_LookupProperty calls.
*/
JSObject *pobj;
RootedObject pobj(cx);
JSProperty *prop;
RootedId id(cx);

View File

@ -4414,7 +4414,7 @@ DebuggerEnv_find(JSContext *cx, unsigned argc, Value *vp)
/* This can trigger resolve hooks. */
ErrorCopier ec(ac, dbg->toJSObject());
JSProperty *prop = NULL;
JSObject *pobj;
RootedObject pobj(cx);
for (; env && !prop; env = env->enclosingScope()) {
if (!env->lookupGeneric(cx, id, &pobj, &prop))
return false;

View File

@ -514,7 +514,7 @@ js::GetOwnProperty(JSContext *cx, Handle<ObjectImpl*> obj, PropertyId pid_, unsi
if (clasp->flags & JSCLASS_NEW_RESOLVE) {
Rooted<JSObject*> obj2(cx, NULL);
JSNewResolveOp op = reinterpret_cast<JSNewResolveOp>(resolve);
if (!op(cx, robj, id, resolveFlags, obj2.address()))
if (!op(cx, robj, id, resolveFlags, &obj2))
return false;
} else {
if (!resolve(cx, robj, id))

View File

@ -350,20 +350,22 @@ WithObject::create(JSContext *cx, HandleObject proto, HandleObject enclosing, ui
}
static JSBool
with_LookupGeneric(JSContext *cx, HandleObject obj, HandleId id, JSObject **objp, JSProperty **propp)
with_LookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
MutableHandleObject objp, JSProperty **propp)
{
return obj->asWith().object().lookupGeneric(cx, id, objp, propp);
}
static JSBool
with_LookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, JSObject **objp, JSProperty **propp)
with_LookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
MutableHandleObject objp, JSProperty **propp)
{
Rooted<jsid> id(cx, NameToId(name));
return with_LookupGeneric(cx, obj, id, objp, propp);
}
static JSBool
with_LookupElement(JSContext *cx, HandleObject obj, uint32_t index, JSObject **objp,
with_LookupElement(JSContext *cx, HandleObject obj, uint32_t index, MutableHandleObject objp,
JSProperty **propp)
{
RootedId id(cx);
@ -373,7 +375,8 @@ 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)
with_LookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
MutableHandleObject objp, JSProperty **propp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return with_LookupGeneric(cx, obj, id, objp, propp);

View File

@ -901,7 +901,7 @@ env_enumerate(JSContext *cx, JSHandleObject obj)
static JSBool
env_resolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
JSObject **objp)
JSMutableHandleObject objp)
{
JSString *idstr, *valstr;
@ -927,7 +927,7 @@ env_resolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
NULL, NULL, JSPROP_ENUMERATE)) {
return false;
}
*objp = obj;
objp.set(obj);
}
return true;
}

View File

@ -37,7 +37,7 @@ NS_IMETHODIMP
BackstagePass::NewResolve(nsIXPConnectWrappedNative *wrapper,
JSContext * cx, JSObject * obj_,
jsid id_, PRUint32 flags,
JSObject * *objp, bool *_retval)
JSObject * *objp_, bool *_retval)
{
JS::RootedObject obj(cx, obj_);
JS::RootedId id(cx, id_);
@ -45,15 +45,19 @@ BackstagePass::NewResolve(nsIXPConnectWrappedNative *wrapper,
JSBool resolved;
*_retval = !!JS_ResolveStandardClass(cx, obj, id, &resolved);
if (!*_retval)
return NS_OK;
if (resolved) {
*objp = obj;
if (!*_retval) {
*objp_ = nsnull;
return NS_OK;
}
*_retval = !!ResolveWorkerClasses(cx, obj, id, flags, objp);
if (resolved) {
*objp_ = obj;
return NS_OK;
}
JS::RootedObject objp(cx, *objp_);
*_retval = !!ResolveWorkerClasses(cx, obj, id, flags, &objp);
*objp_ = objp;
return NS_OK;
}

View File

@ -1004,7 +1004,7 @@ XPC_WN_Helper_Finalize(js::FreeOp *fop, JSObject *obj)
static JSBool
XPC_WN_Helper_NewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsigned flags,
JSObject **objp)
JSMutableHandleObject objp)
{
nsresult rv = NS_OK;
bool retval = true;
@ -1025,7 +1025,7 @@ XPC_WN_Helper_NewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsig
return Throw(rv, cx);
if (obj2FromScriptable)
*objp = obj2FromScriptable;
objp.set(obj2FromScriptable);
return retval;
}
@ -1059,7 +1059,7 @@ XPC_WN_Helper_NewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsig
}
if (obj2FromScriptable) {
*objp = obj2FromScriptable;
objp.set(obj2FromScriptable);
} else if (wrapper->HasMutatedSet()) {
// We are here if scriptable did not resolve this property and
// it *might* be in the instance set but not the proto set.
@ -1096,7 +1096,7 @@ XPC_WN_Helper_NewResolve(JSContext *cx, JSHandleObject obj, JSHandleId id, unsig
enumFlag, &resolved);
(void)ccx.SetResolvingWrapper(oldResolvingWrapper);
if (retval && resolved)
*objp = obj;
objp.set(obj);
}
}