Bug 771026 - Replace JSProperty with Shape (r=bhackett)

This commit is contained in:
Bill McCloskey 2012-07-04 19:34:06 -07:00
parent 252cf2ecc5
commit ab72b4aa50
25 changed files with 249 additions and 264 deletions

View File

@ -3397,7 +3397,7 @@ JS_DeepFreezeObject(JSContext *cx, JSObject *obj_)
static JSBool
LookupPropertyById(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape propp)
{
AssertNoGC(cx);
CHECK_REQUEST(cx);
@ -3411,17 +3411,15 @@ LookupPropertyById(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
static JSBool
LookupResult(JSContext *cx, HandleObject obj, HandleObject obj2, jsid id,
JSProperty* prop, Value *vp)
HandleShape shape, Value *vp)
{
if (!prop) {
if (!shape) {
/* XXX bad API: no way to tell "not defined" from "void value" */
vp->setUndefined();
return JS_TRUE;
}
if (obj2->isNative()) {
Shape *shape = (Shape *) prop;
/* Peek at the native property's slot value, without doing a Get. */
if (shape->hasSlot()) {
*vp = obj2->nativeGetSlot(shape->slot());
@ -3452,7 +3450,7 @@ JS_LookupPropertyById(JSContext *cx, JSObject *obj_, jsid id_, jsval *vp)
RootedId id(cx, id_);
RootedObject obj(cx, obj_);
RootedObject obj2(cx);
JSProperty* prop;
RootedShape prop(cx);
return LookupPropertyById(cx, obj, id, JSRESOLVE_QUALIFIED, &obj2, &prop) &&
LookupResult(cx, obj, obj2, id, prop, vp);
@ -3490,7 +3488,7 @@ JS_LookupPropertyWithFlagsById(JSContext *cx, JSObject *obj_, jsid id_, unsigned
RootedObject obj(cx, obj_);
RootedObject objp(cx, *objp_);
RootedId id(cx, id_);
JSProperty* prop;
RootedShape prop(cx);
AssertNoGC(cx);
CHECK_REQUEST(cx);
@ -3521,7 +3519,7 @@ JS_HasPropertyById(JSContext *cx, JSObject *obj_, jsid id_, JSBool *foundp)
RootedObject obj(cx, obj_);
RootedId id(cx, id_);
RootedObject obj2(cx);
JSProperty* prop;
RootedShape prop(cx);
JSBool ok = LookupPropertyById(cx, obj, id, JSRESOLVE_QUALIFIED | JSRESOLVE_DETECTING,
&obj2, &prop);
*foundp = (prop != NULL);
@ -3566,7 +3564,7 @@ JS_AlreadyHasOwnPropertyById(JSContext *cx, JSObject *obj_, jsid id_, JSBool *fo
if (!obj->isNative()) {
RootedObject obj2(cx);
JSProperty *prop;
RootedShape prop(cx);
if (!LookupPropertyById(cx, obj, id, JSRESOLVE_QUALIFIED | JSRESOLVE_DETECTING,
&obj2, &prop)) {
@ -3838,12 +3836,12 @@ GetPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id, unsigned
JSBool own, PropertyDescriptor *desc)
{
RootedObject obj2(cx);
JSProperty *prop;
RootedShape shape(cx);
if (!LookupPropertyById(cx, obj, id, flags, &obj2, &prop))
if (!LookupPropertyById(cx, obj, id, flags, &obj2, &shape))
return JS_FALSE;
if (!prop || (own && obj != obj2)) {
if (!shape || (own && obj != obj2)) {
desc->obj = NULL;
desc->attrs = 0;
desc->getter = NULL;
@ -3854,7 +3852,6 @@ GetPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id, unsigned
desc->obj = obj2;
if (obj2->isNative()) {
Shape *shape = (Shape *) prop;
desc->attrs = shape->attributes();
desc->getter = shape->getter();
desc->setter = shape->setter();
@ -3963,15 +3960,14 @@ static JSBool
SetPropertyAttributesById(JSContext *cx, HandleObject obj, HandleId id, unsigned attrs, JSBool *foundp)
{
RootedObject obj2(cx);
JSProperty *prop;
RootedShape shape(cx);
if (!LookupPropertyById(cx, obj, id, JSRESOLVE_QUALIFIED, &obj2, &prop))
if (!LookupPropertyById(cx, obj, id, JSRESOLVE_QUALIFIED, &obj2, &shape))
return false;
if (!prop || obj != obj2) {
if (!shape || obj != obj2) {
*foundp = false;
return true;
}
Shape *shape = (Shape *) prop;
JSBool ok = obj->isNative()
? obj->changePropertyAttributes(cx, shape, attrs)
: obj->setGenericAttributes(cx, id, &attrs);

View File

@ -347,7 +347,7 @@ DoGetElement(JSContext *cx, JSObject *obj_, double index, JSBool *hole, Value *v
}
RootedObject obj2(cx);
JSProperty *prop;
RootedShape prop(cx);
if (!obj->lookupGeneric(cx, id, &obj2, &prop))
return JS_FALSE;
if (!prop) {
@ -692,14 +692,14 @@ IsDenseArrayId(JSContext *cx, JSObject *obj, jsid id)
}
static JSBool
array_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, MutableHandleObject objp,
JSProperty **propp)
array_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
MutableHandleObject objp, MutableHandleShape propp)
{
if (!obj->isDenseArray())
return baseops::LookupProperty(cx, obj, id, objp, propp);
if (IsDenseArrayId(cx, obj, id)) {
*propp = (JSProperty *) 1; /* non-null to indicate found */
MarkNonNativePropertyFound(obj, propp);
objp.set(obj);
return JS_TRUE;
}
@ -707,7 +707,7 @@ array_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, MutableHandleO
JSObject *proto = obj->getProto();
if (!proto) {
objp.set(NULL);
*propp = NULL;
propp.set(NULL);
return JS_TRUE;
}
return proto->lookupGeneric(cx, id, objp, propp);
@ -715,21 +715,21 @@ array_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, MutableHandleO
static JSBool
array_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape 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, MutableHandleObject objp,
JSProperty **propp)
array_lookupElement(JSContext *cx, HandleObject obj, uint32_t index,
MutableHandleObject objp, MutableHandleShape propp)
{
if (!obj->isDenseArray())
return baseops::LookupElement(cx, obj, index, objp, propp);
if (IsDenseArrayIndex(obj, index)) {
*propp = (JSProperty *) 1; /* non-null to indicate found */
MarkNonNativePropertyFound(obj, propp);
objp.set(obj);
return true;
}
@ -738,13 +738,13 @@ array_lookupElement(JSContext *cx, HandleObject obj, uint32_t index, MutableHand
return proto->lookupElement(cx, index, objp, propp);
objp.set(NULL);
*propp = NULL;
propp.set(NULL);
return true;
}
static JSBool
array_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, MutableHandleObject objp,
JSProperty **propp)
array_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
MutableHandleObject objp, MutableHandleShape propp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return array_lookupGeneric(cx, obj, id, objp, propp);

View File

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

View File

@ -559,7 +559,7 @@ JSStructuredCloneWriter::write(const Value &v)
* NativeIterators.
*/
RootedObject obj2(context());
JSProperty *prop;
RootedShape prop(context());
if (!js_HasOwnProperty(context(), obj->getOps()->lookupGeneric, obj, id,
&obj2, &prop)) {
return false;

View File

@ -954,7 +954,7 @@ js::AssertValidPropertyCacheHit(JSContext *cx, JSObject *start_,
RootedObject obj(cx);
RootedObject pobj(cx);
JSProperty *prop;
RootedShape prop(cx);
JSBool ok;
if (JOF_OPMODE(*pc) == JOF_NAME)
@ -967,9 +967,7 @@ js::AssertValidPropertyCacheHit(JSContext *cx, JSObject *start_,
JS_PROPERTY_CACHE(cx).restore(&savedEntry);
JS_ASSERT(prop);
JS_ASSERT(pobj == found);
Shape *shape = (Shape *) prop;
JS_ASSERT(entry->prop == shape);
JS_ASSERT(entry->prop == prop);
}
#endif /* DEBUG && !JS_THREADSAFE */
@ -1281,6 +1279,7 @@ js::Interpret(JSContext *cx, StackFrame *entryFrame, InterpMode interpMode)
RootedTypeObject rootType0(cx);
RootedPropertyName rootName0(cx);
RootedId rootId0(cx);
RootedShape rootShape0(cx);
if (rt->profilingScripts)
ENABLE_INTERRUPTS();
@ -1746,7 +1745,7 @@ BEGIN_CASE(JSOP_IN)
RootedId &id = rootId0;
FETCH_ELEMENT_ID(obj, -2, id);
RootedObject &obj2 = rootObject1;
JSProperty *prop;
RootedShape &prop = rootShape0;
if (!obj->lookupGeneric(cx, id, &obj2, &prop))
goto error;
bool cond = prop != NULL;
@ -2206,7 +2205,7 @@ BEGIN_CASE(JSOP_DELNAME)
RootedObject &obj = rootObject1;
RootedObject &obj2 = rootObject2;
JSProperty *prop;
RootedShape &prop = rootShape0;
if (!FindProperty(cx, name, scopeObj, &obj, &obj2, &prop))
goto error;
@ -2553,7 +2552,7 @@ BEGIN_CASE(JSOP_IMPLICITTHIS)
RootedObject &obj = rootObject1;
RootedObject &obj2 = rootObject2;
JSProperty *prop;
RootedShape &prop = rootShape0;
if (!FindPropertyHelper(cx, name, false, scopeObj, &obj, &obj2, &prop))
goto error;
@ -2920,9 +2919,9 @@ BEGIN_CASE(JSOP_DEFFUN)
/* ES5 10.5 (NB: with subsequent errata). */
RootedPropertyName &name = rootName0;
name = fun->atom->asPropertyName();
JSProperty *prop = NULL;
RootedShape &shape = rootShape0;
RootedObject &pobj = rootObject1;
if (!parent->lookupProperty(cx, name, &pobj, &prop))
if (!parent->lookupProperty(cx, name, &pobj, &shape))
goto error;
RootedValue &rval = rootValue0;
@ -2930,7 +2929,7 @@ BEGIN_CASE(JSOP_DEFFUN)
do {
/* Steps 5d, 5f. */
if (!prop || pobj != parent) {
if (!shape || pobj != parent) {
if (!parent->defineProperty(cx, name, rval,
JS_PropertyStub, JS_StrictPropertyStub, attrs))
{
@ -2941,7 +2940,6 @@ BEGIN_CASE(JSOP_DEFFUN)
/* Step 5e. */
JS_ASSERT(parent->isNative());
Shape *shape = reinterpret_cast<Shape *>(prop);
if (parent->isGlobal()) {
if (shape->configurable()) {
if (!parent->defineProperty(cx, name, rval,

View File

@ -385,10 +385,10 @@ NameOperation(JSContext *cx, JSScript *script, jsbytecode *pc, Value *vp)
return true;
}
JSProperty *prop;
if (!FindPropertyHelper(cx, name, true, obj, &obj, &obj2, &prop))
RootedShape shape(cx);
if (!FindPropertyHelper(cx, name, true, obj, &obj, &obj2, &shape))
return false;
if (!prop) {
if (!shape) {
/* Kludge to allow (typeof foo == "undefined") tests. */
JSOp op2 = JSOp(pc[JSOP_NAME_LENGTH]);
if (op2 == JSOP_TYPEOF) {
@ -401,13 +401,12 @@ NameOperation(JSContext *cx, JSScript *script, jsbytecode *pc, Value *vp)
return false;
}
/* Take the slow path if prop was not found in a native object. */
/* Take the slow path if shape was not found in a native object. */
if (!obj->isNative() || !obj2->isNative()) {
Rooted<jsid> id(cx, NameToId(name));
if (!obj->getGeneric(cx, id, vp))
return false;
} else {
Shape *shape = (Shape *)prop;
Rooted<JSObject*> normalized(cx, obj);
if (normalized->getClass() == &WithClass && !shape->hasDefaultGetter())
normalized = &normalized->asWith().object();
@ -424,7 +423,7 @@ DefVarOrConstOperation(JSContext *cx, HandleObject varobj, PropertyName *dn, uns
JS_ASSERT(varobj->isVarObj());
JS_ASSERT(!varobj->getOps()->defineProperty || varobj->isDebugScope());
JSProperty *prop;
RootedShape prop(cx);
RootedObject obj2(cx);
if (!varobj->lookupProperty(cx, dn, &obj2, &prop))
return false;

View File

@ -993,7 +993,7 @@ SuppressDeletedPropertyHelper(JSContext *cx, HandleObject obj, StringPredicate p
if (obj->getProto()) {
JSObject *proto = obj->getProto();
RootedObject obj2(cx);
JSProperty *prop;
RootedShape prop(cx);
RootedId id(cx);
if (!ValueToId(cx, StringValue(*idp), id.address()))
return false;
@ -1002,7 +1002,7 @@ SuppressDeletedPropertyHelper(JSContext *cx, HandleObject obj, StringPredicate p
if (prop) {
unsigned attrs;
if (obj2->isNative())
attrs = ((Shape *) prop)->attributes();
attrs = prop->attributes();
else if (!obj2->getGenericAttributes(cx, id, &attrs))
return false;

View File

@ -179,7 +179,7 @@ MarkSharpObjects(JSContext *cx, HandleObject obj, JSIdArray **idap, JSSharpInfo
for (int i = 0, length = ida->length; i < length; i++) {
id = ida->vector[i];
RootedObject obj2(cx);
JSProperty *prop;
RootedShape prop(cx);
ok = obj->lookupGeneric(cx, id, &obj2, &prop);
if (!ok)
break;
@ -460,7 +460,7 @@ obj_toSource(JSContext *cx, unsigned argc, Value *vp)
JSLinearString *idstr;
RootedObject obj2(cx);
JSProperty *prop;
RootedShape prop(cx);
if (!obj->lookupGeneric(cx, id, &obj2, &prop))
return false;
@ -807,7 +807,7 @@ js_HasOwnPropertyHelper(JSContext *cx, LookupGenericOp lookup, unsigned argc,
if (!obj)
return false;
RootedObject obj2(cx);
JSProperty *prop;
RootedShape prop(cx);
if (obj->isProxy()) {
bool has;
if (!Proxy::hasOwn(cx, obj, id, &has))
@ -823,7 +823,7 @@ js_HasOwnPropertyHelper(JSContext *cx, LookupGenericOp lookup, unsigned argc,
JSBool
js_HasOwnProperty(JSContext *cx, LookupGenericOp lookup, HandleObject obj, HandleId id,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape propp)
{
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED | JSRESOLVE_DETECTING);
if (lookup) {
@ -833,7 +833,7 @@ js_HasOwnProperty(JSContext *cx, LookupGenericOp lookup, HandleObject obj, Handl
if (!baseops::LookupProperty(cx, obj, id, objp, propp))
return false;
}
if (!*propp)
if (!propp)
return true;
if (objp == obj)
@ -848,7 +848,7 @@ js_HasOwnProperty(JSContext *cx, LookupGenericOp lookup, HandleObject obj, Handl
}
if (outer != objp)
*propp = NULL;
propp.set(NULL);
return true;
}
@ -894,7 +894,7 @@ JSBool
js_PropertyIsEnumerable(JSContext *cx, HandleObject obj, HandleId id, Value *vp)
{
RootedObject pobj(cx);
JSProperty *prop;
RootedShape prop(cx);
if (!obj->lookupGeneric(cx, id, &pobj, &prop))
return false;
@ -1004,13 +1004,12 @@ obj_lookupGetter(JSContext *cx, unsigned argc, Value *vp)
return JS_TRUE;
}
RootedObject pobj(cx);
JSProperty *prop;
if (!obj->lookupGeneric(cx, id, &pobj, &prop))
RootedShape shape(cx);
if (!obj->lookupGeneric(cx, id, &pobj, &shape))
return JS_FALSE;
vp->setUndefined();
if (prop) {
if (shape) {
if (pobj->isNative()) {
Shape *shape = (Shape *) prop;
if (shape->hasGetterValue())
*vp = shape->getterValue();
}
@ -1039,13 +1038,12 @@ obj_lookupSetter(JSContext *cx, unsigned argc, Value *vp)
return JS_TRUE;
}
RootedObject pobj(cx);
JSProperty *prop;
if (!obj->lookupGeneric(cx, id, &pobj, &prop))
RootedShape shape(cx);
if (!obj->lookupGeneric(cx, id, &pobj, &shape))
return JS_FALSE;
vp->setUndefined();
if (prop) {
if (shape) {
if (pobj->isNative()) {
Shape *shape = (Shape *) prop;
if (shape->hasSetterValue())
*vp = shape->setterValue();
}
@ -1171,17 +1169,16 @@ GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id, PropertyD
return Proxy::getOwnPropertyDescriptor(cx, obj, id, false, desc);
RootedObject pobj(cx);
JSProperty *prop;
if (!js_HasOwnProperty(cx, obj->getOps()->lookupGeneric, obj, id, &pobj, &prop))
RootedShape shape(cx);
if (!js_HasOwnProperty(cx, obj->getOps()->lookupGeneric, obj, id, &pobj, &shape))
return false;
if (!prop) {
if (!shape) {
desc->obj = NULL;
return true;
}
bool doGet = true;
if (pobj->isNative()) {
Shape *shape = (Shape *) prop;
desc->attrs = shape->attributes();
if (desc->attrs & (JSPROP_GETTER | JSPROP_SETTER)) {
doGet = false;
@ -1509,16 +1506,16 @@ DefinePropertyOnObject(JSContext *cx, HandleObject obj, HandleId id, const PropD
bool throwError, bool *rval)
{
/* 8.12.9 step 1. */
JSProperty *current;
RootedShape shape(cx);
RootedObject obj2(cx);
JS_ASSERT(!obj->getOps()->lookupGeneric);
if (!js_HasOwnProperty(cx, NULL, obj, id, &obj2, &current))
if (!js_HasOwnProperty(cx, NULL, obj, id, &obj2, &shape))
return JS_FALSE;
JS_ASSERT(!obj->getOps()->defineProperty);
/* 8.12.9 steps 2-4. */
if (!current) {
if (!shape) {
if (!obj->isExtensible())
return Reject(cx, obj, JSMSG_OBJECT_NOT_EXTENSIBLE, throwError, rval);
@ -1553,7 +1550,6 @@ DefinePropertyOnObject(JSContext *cx, HandleObject obj, HandleId id, const PropD
JS_ASSERT(obj == obj2);
Rooted<Shape *> shape(cx, reinterpret_cast<Shape *>(current));
do {
if (desc.isAccessorDescriptor()) {
if (!shape->isAccessorDescriptor())
@ -3857,9 +3853,6 @@ js_FindClassObject(JSContext *cx, HandleObject start, JSProtoKey protoKey,
MutableHandleValue vp, Class *clasp)
{
RootedId id(cx);
JSProperty *prop;
Shape *shape;
RootedObject obj(cx);
if (start) {
@ -3891,11 +3884,11 @@ js_FindClassObject(JSContext *cx, HandleObject start, JSProtoKey protoKey,
JS_ASSERT(obj->isNative());
RootedObject pobj(cx);
if (!LookupPropertyWithFlags(cx, obj, id, 0, &pobj, &prop))
RootedShape shape(cx);
if (!LookupPropertyWithFlags(cx, obj, id, 0, &pobj, &shape))
return false;
RootedValue v(cx, UndefinedValue());
if (prop && pobj->isNative()) {
shape = (Shape *) prop;
if (shape && pobj->isNative()) {
if (shape->hasSlot()) {
v = pobj->nativeGetSlot(shape->slot());
if (v.get().isPrimitive())
@ -4115,8 +4108,6 @@ DefineNativeProperty(JSContext *cx, HandleObject obj, HandleId id, const Value &
*/
RootedShape shape(cx);
if (attrs & (JSPROP_GETTER | JSPROP_SETTER)) {
JSProperty *prop;
/* Type information for getter/setter properties is unknown. */
AddTypePropertyId(cx, obj, id, types::Type::UnknownType());
MarkTypePropertyConfigured(cx, obj, id);
@ -4127,10 +4118,10 @@ DefineNativeProperty(JSContext *cx, HandleObject obj, HandleId id, const Value &
* property cache line for (obj, id) to map shape.
*/
RootedObject pobj(cx);
if (!baseops::LookupProperty(cx, obj, id, &pobj, &prop))
RootedShape shape(cx);
if (!baseops::LookupProperty(cx, obj, id, &pobj, &shape))
return NULL;
if (prop && pobj == obj) {
shape = (Shape *) prop;
if (shape && pobj == obj) {
if (shape->isAccessorDescriptor()) {
shape = obj->changeProperty(cx, shape, attrs,
JSPROP_GETTER | JSPROP_SETTER,
@ -4218,7 +4209,7 @@ DefineNativeProperty(JSContext *cx, HandleObject obj, HandleId id, const Value &
*/
static JSBool
CallResolveOp(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
MutableHandleObject objp, JSProperty **propp, bool *recursedp)
MutableHandleObject objp, MutableHandleShape propp, bool *recursedp)
{
Class *clasp = obj->getClass();
JSResolveOp resolve = clasp->resolve;
@ -4239,7 +4230,7 @@ CallResolveOp(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
}
*recursedp = false;
*propp = NULL;
propp.set(NULL);
if (clasp->flags & JSCLASS_NEW_RESOLVE) {
JSNewResolveOp newresolve = reinterpret_cast<JSNewResolveOp>(resolve);
@ -4273,7 +4264,7 @@ CallResolveOp(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
if (!obj->nativeEmpty()) {
if (Shape *shape = obj->nativeLookup(cx, id)) {
objp.set(obj);
*propp = (JSProperty *) shape;
propp.set(shape);
}
}
@ -4282,7 +4273,7 @@ CallResolveOp(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
static JS_ALWAYS_INLINE bool
LookupPropertyWithFlagsInline(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape propp)
{
/* Search scopes starting with obj and following the prototype link. */
RootedObject current(cx, obj);
@ -4290,7 +4281,7 @@ LookupPropertyWithFlagsInline(JSContext *cx, HandleObject obj, HandleId id, unsi
Shape *shape = current->nativeLookup(cx, id);
if (shape) {
objp.set(current);
*propp = (JSProperty *) shape;
propp.set(shape);
return true;
}
@ -4301,7 +4292,7 @@ LookupPropertyWithFlagsInline(JSContext *cx, HandleObject obj, HandleId id, unsi
return false;
if (recursed)
break;
if (*propp) {
if (propp) {
/*
* For stats we do not recalculate protoIndex even if it was
* resolved on some other object.
@ -4326,7 +4317,7 @@ LookupPropertyWithFlagsInline(JSContext *cx, HandleObject obj, HandleId id, unsi
* arguments.callee through the delegating |this| object's method
* read barrier.
*/
if (*propp && objp->isNative()) {
if (propp && objp->isNative()) {
while ((proto = proto->getProto()) != objp)
JS_ASSERT(proto);
}
@ -4338,20 +4329,20 @@ LookupPropertyWithFlagsInline(JSContext *cx, HandleObject obj, HandleId id, unsi
}
objp.set(NULL);
*propp = NULL;
propp.set(NULL);
return true;
}
JS_FRIEND_API(JSBool)
baseops::LookupProperty(JSContext *cx, HandleObject obj, HandleId id, MutableHandleObject objp,
JSProperty **propp)
MutableHandleShape propp)
{
return LookupPropertyWithFlagsInline(cx, obj, id, cx->resolveFlags, objp, propp);
}
JS_FRIEND_API(JSBool)
baseops::LookupElement(JSContext *cx, HandleObject obj, uint32_t index,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape propp)
{
RootedId id(cx);
if (!IndexToId(cx, index, id.address()))
@ -4362,7 +4353,7 @@ baseops::LookupElement(JSContext *cx, HandleObject obj, uint32_t index,
bool
js::LookupPropertyWithFlags(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape propp)
{
return LookupPropertyWithFlagsInline(cx, obj, id, flags, objp, propp);
}
@ -4370,13 +4361,14 @@ js::LookupPropertyWithFlags(JSContext *cx, HandleObject obj, HandleId id, unsign
bool
js::FindPropertyHelper(JSContext *cx,
HandlePropertyName name, bool cacheResult, HandleObject scopeChain,
MutableHandleObject objp, MutableHandleObject pobjp, JSProperty **propp)
MutableHandleObject objp, MutableHandleObject pobjp,
MutableHandleShape propp)
{
RootedId id(cx, NameToId(name));
RootedObject pobj(cx);
int scopeIndex;
JSProperty *prop;
RootedShape prop(cx);
/* Scan entries on the scope chain that we can cache across. */
RootedObject obj(cx, scopeChain);
@ -4416,8 +4408,7 @@ js::FindPropertyHelper(JSContext *cx,
* non-native prototype.
*/
if (cacheResult && pobj->isNative()) {
JS_PROPERTY_CACHE(cx).fill(cx, scopeChain, scopeIndex, pobj,
(Shape *) prop);
JS_PROPERTY_CACHE(cx).fill(cx, scopeChain, scopeIndex, pobj, prop);
}
goto out;
@ -4453,7 +4444,7 @@ js::FindPropertyHelper(JSContext *cx,
JS_ASSERT(!!pobj == !!prop);
objp.set(obj);
pobjp.set(pobj);
*propp = prop;
propp.set(prop);
return true;
}
@ -4463,7 +4454,7 @@ js::FindPropertyHelper(JSContext *cx,
*/
bool
js::FindProperty(JSContext *cx, HandlePropertyName name, HandleObject scopeChain,
MutableHandleObject objp, MutableHandleObject pobjp, JSProperty **propp)
MutableHandleObject objp, MutableHandleObject pobjp, MutableHandleShape propp)
{
return !!FindPropertyHelper(cx, name, false, scopeChain, objp, pobjp, propp);
}
@ -4493,16 +4484,16 @@ js::FindIdentifierBase(JSContext *cx, HandleObject scopeChain, HandlePropertyNam
scopeIndex++)
{
RootedObject pobj(cx);
JSProperty *prop;
if (!LookupPropertyWithFlags(cx, obj, name, cx->resolveFlags, &pobj, &prop))
RootedShape shape(cx);
if (!LookupPropertyWithFlags(cx, obj, name, cx->resolveFlags, &pobj, &shape))
return NULL;
if (prop) {
if (shape) {
if (!pobj->isNative()) {
JS_ASSERT(obj->isGlobal());
return obj;
}
JS_ASSERT_IF(obj->isScope(), pobj->getClass() == obj->getClass());
JS_PROPERTY_CACHE(cx).fill(cx, scopeChain, scopeIndex, pobj, (Shape *) prop);
JS_PROPERTY_CACHE(cx).fill(cx, scopeChain, scopeIndex, pobj, shape);
return obj;
}
@ -4515,10 +4506,10 @@ js::FindIdentifierBase(JSContext *cx, HandleObject scopeChain, HandlePropertyNam
/* Loop until we find a property or reach the global object. */
do {
RootedObject pobj(cx);
JSProperty *prop;
if (!obj->lookupProperty(cx, name, &pobj, &prop))
RootedShape shape(cx);
if (!obj->lookupProperty(cx, name, &pobj, &shape))
return NULL;
if (prop)
if (shape)
break;
/*
@ -4629,16 +4620,15 @@ static JS_ALWAYS_INLINE JSBool
js_GetPropertyHelperInline(JSContext *cx, HandleObject obj, HandleObject receiver, jsid id_,
uint32_t getHow, Value *vp)
{
JSProperty *prop;
RootedId id(cx, id_);
/* This call site is hot -- use the always-inlined variant of LookupPropertyWithFlags(). */
RootedObject obj2(cx);
if (!LookupPropertyWithFlagsInline(cx, obj, id, cx->resolveFlags, &obj2, &prop))
RootedShape shape(cx);
if (!LookupPropertyWithFlagsInline(cx, obj, id, cx->resolveFlags, &obj2, &shape))
return false;
if (!prop) {
if (!shape) {
vp->setUndefined();
if (!CallJSPropertyOp(cx, obj->getClass()->getProperty, obj, id, vp))
@ -4706,8 +4696,6 @@ js_GetPropertyHelperInline(JSContext *cx, HandleObject obj, HandleObject receive
: obj2->getGeneric(cx, id, vp);
}
Shape *shape = (Shape *) prop;
if (getHow & JSGET_CACHE_RESULT)
JS_PROPERTY_CACHE(cx).fill(cx, obj, 0, obj2, shape);
@ -4745,7 +4733,7 @@ baseops::GetElement(JSContext *cx, HandleObject obj, HandleObject receiver, uint
JSBool
baseops::GetPropertyDefault(JSContext *cx, HandleObject obj, HandleId id, const Value &def, Value *vp)
{
JSProperty *prop;
RootedShape prop(cx);
RootedObject obj2(cx);
if (!LookupPropertyWithFlags(cx, obj, id, JSRESOLVE_QUALIFIED, &obj2, &prop))
return false;
@ -4836,7 +4824,6 @@ JSBool
baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id,
unsigned defineHow, Value *vp, JSBool strict)
{
JSProperty *prop;
unsigned attrs, flags;
int shortid;
Class *clasp;
@ -4854,9 +4841,10 @@ baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receive
}
RootedObject pobj(cx);
if (!LookupPropertyWithFlags(cx, obj, id, cx->resolveFlags, &pobj, &prop))
RootedShape shape(cx);
if (!LookupPropertyWithFlags(cx, obj, id, cx->resolveFlags, &pobj, &shape))
return false;
if (prop) {
if (shape) {
if (!pobj->isNative()) {
if (pobj->isProxy()) {
AutoPropertyDescriptorRooter pd(cx);
@ -4878,7 +4866,7 @@ baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receive
}
}
prop = NULL;
shape = NULL;
}
} else {
/* We should never add properties to lexical blocks. */
@ -4891,8 +4879,6 @@ baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receive
}
}
RootedShape shape(cx, (Shape *) prop);
/*
* Now either shape is null, meaning id was not found in obj or one of its
* prototypes; or shape is non-null, meaning id was found directly in pobj.
@ -5032,17 +5018,16 @@ JSBool
baseops::GetAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
{
RootedObject nobj(cx);
JSProperty *prop;
if (!baseops::LookupProperty(cx, obj, id, &nobj, &prop))
RootedShape shape(cx);
if (!baseops::LookupProperty(cx, obj, id, &nobj, &shape))
return false;
if (!prop) {
if (!shape) {
*attrsp = 0;
return true;
}
if (!nobj->isNative())
return nobj->getGenericAttributes(cx, id, attrsp);
Shape *shape = (Shape *)prop;
*attrsp = shape->attributes();
return true;
}
@ -5051,17 +5036,16 @@ JSBool
baseops::GetElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp)
{
RootedObject nobj(cx);
JSProperty *prop;
if (!baseops::LookupElement(cx, obj, index, &nobj, &prop))
RootedShape shape(cx);
if (!baseops::LookupElement(cx, obj, index, &nobj, &shape))
return false;
if (!prop) {
if (!shape) {
*attrsp = 0;
return true;
}
if (!nobj->isNative())
return nobj->getElementAttributes(cx, index, attrsp);
Shape *shape = (Shape *)prop;
*attrsp = shape->attributes();
return true;
}
@ -5070,13 +5054,13 @@ JSBool
baseops::SetAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
{
RootedObject nobj(cx);
JSProperty *prop;
if (!baseops::LookupProperty(cx, obj, id, &nobj, &prop))
RootedShape shape(cx);
if (!baseops::LookupProperty(cx, obj, id, &nobj, &shape))
return false;
if (!prop)
if (!shape)
return true;
return nobj->isNative()
? nobj->changePropertyAttributes(cx, (Shape *) prop, *attrsp)
? nobj->changePropertyAttributes(cx, shape, *attrsp)
: nobj->setGenericAttributes(cx, id, attrsp);
}
@ -5084,28 +5068,26 @@ JSBool
baseops::SetElementAttributes(JSContext *cx, HandleObject obj, uint32_t index, unsigned *attrsp)
{
RootedObject nobj(cx);
JSProperty *prop;
if (!baseops::LookupElement(cx, obj, index, &nobj, &prop))
RootedShape shape(cx);
if (!baseops::LookupElement(cx, obj, index, &nobj, &shape))
return false;
if (!prop)
if (!shape)
return true;
return nobj->isNative()
? nobj->changePropertyAttributes(cx, (Shape *) prop, *attrsp)
? nobj->changePropertyAttributes(cx, shape, *attrsp)
: nobj->setElementAttributes(cx, index, attrsp);
}
JSBool
baseops::DeleteGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *rval, JSBool strict)
{
JSProperty *prop;
Shape *shape;
rval->setBoolean(true);
RootedObject proto(cx);
if (!baseops::LookupProperty(cx, obj, id, &proto, &prop))
RootedShape shape(cx);
if (!baseops::LookupProperty(cx, obj, id, &proto, &shape))
return false;
if (!prop || proto != obj) {
if (!shape || proto != obj) {
/*
* If no property, or the property comes from a prototype, call the
* class's delProperty hook, passing rval as the result parameter.
@ -5113,7 +5095,6 @@ baseops::DeleteGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *rval
return CallJSPropertyOp(cx, obj->getClass()->delProperty, obj, id, rval);
}
shape = (Shape *)prop;
if (!shape->configurable()) {
if (strict)
return obj->reportNotConfigurable(cx, id);
@ -5305,9 +5286,6 @@ CheckAccess(JSContext *cx, JSObject *obj_, HandleId id, JSAccessMode mode,
Value *vp, unsigned *attrsp)
{
JSBool writing;
JSProperty *prop;
Shape *shape;
RootedObject obj(cx, obj_), pobj(cx);
while (JS_UNLIKELY(obj->isWith()))
@ -5323,9 +5301,10 @@ CheckAccess(JSContext *cx, JSObject *obj_, HandleId id, JSAccessMode mode,
break;
default:
if (!obj->lookupGeneric(cx, id, &pobj, &prop))
RootedShape shape(cx);
if (!obj->lookupGeneric(cx, id, &pobj, &shape))
return JS_FALSE;
if (!prop) {
if (!shape) {
if (!writing)
vp->setUndefined();
*attrsp = 0;
@ -5341,7 +5320,6 @@ CheckAccess(JSContext *cx, JSObject *obj_, HandleId id, JSAccessMode mode,
break;
}
shape = (Shape *)prop;
*attrsp = shape->attributes();
if (!writing) {
if (shape->hasSlot())

View File

@ -99,11 +99,11 @@ namespace baseops {
*/
extern JS_FRIEND_API(JSBool)
LookupProperty(JSContext *cx, HandleObject obj, HandleId id, MutableHandleObject objp,
JSProperty **propp);
MutableHandleShape propp);
inline bool
LookupProperty(JSContext *cx, HandleObject obj, PropertyName *name,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape 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,
MutableHandleObject objp, JSProperty **propp);
MutableHandleObject objp, MutableHandleShape propp);
extern JSBool
DefineGeneric(JSContext *cx, HandleObject obj, HandleId id, const js::Value *value,
@ -785,12 +785,14 @@ struct JSObject : public js::ObjectImpl
/* Clear the scope, making it empty. */
void clear(JSContext *cx);
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 lookupGeneric(JSContext *cx, js::HandleId id,
js::MutableHandleObject objp, js::MutableHandleShape propp);
inline JSBool lookupProperty(JSContext *cx, js::PropertyName *name,
js::MutableHandleObject objp, js::MutableHandleShape propp);
inline JSBool lookupElement(JSContext *cx, uint32_t index,
js::MutableHandleObject objp, JSProperty **propp);
js::MutableHandleObject objp, js::MutableHandleShape propp);
inline JSBool lookupSpecial(JSContext *cx, js::SpecialId sid,
js::MutableHandleObject objp, JSProperty **propp);
js::MutableHandleObject objp, js::MutableHandleShape propp);
inline JSBool defineGeneric(JSContext *cx, js::HandleId id, const js::Value &value,
JSPropertyOp getter = JS_PropertyStub,
@ -1046,7 +1048,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,
js::MutableHandleObject objp, JSProperty **propp);
js::MutableHandleObject objp, js::MutableHandleShape propp);
extern JSBool
js_PropertyIsEnumerable(JSContext *cx, js::HandleObject obj, js::HandleId id, js::Value *vp);
@ -1165,11 +1167,11 @@ DefineNativeProperty(JSContext *cx, HandleObject obj, PropertyName *name, const
*/
extern bool
LookupPropertyWithFlags(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
js::MutableHandleObject objp, JSProperty **propp);
js::MutableHandleObject objp, js::MutableHandleShape propp);
inline bool
LookupPropertyWithFlags(JSContext *cx, HandleObject obj, PropertyName *name, unsigned flags,
js::MutableHandleObject objp, JSProperty **propp)
js::MutableHandleObject objp, js::MutableHandleShape propp)
{
Rooted<jsid> id(cx, NameToId(name));
return LookupPropertyWithFlags(cx, obj, id, flags, objp, propp);
@ -1208,7 +1210,7 @@ static const unsigned RESOLVE_INFER = 0xffff;
extern bool
FindPropertyHelper(JSContext *cx, HandlePropertyName name,
bool cacheResult, HandleObject scopeChain,
MutableHandleObject objp, MutableHandleObject pobjp, JSProperty **propp);
MutableHandleObject objp, MutableHandleObject pobjp, MutableHandleShape propp);
/*
* Search for name either on the current scope chain or on the scope chain's
@ -1216,7 +1218,7 @@ FindPropertyHelper(JSContext *cx, HandlePropertyName name,
*/
extern bool
FindProperty(JSContext *cx, HandlePropertyName name, HandleObject scopeChain,
MutableHandleObject objp, MutableHandleObject pobjp, JSProperty **propp);
MutableHandleObject objp, MutableHandleObject pobjp, MutableHandleShape propp);
extern JSObject *
FindIdentifierBase(JSContext *cx, HandleObject scopeChain, HandlePropertyName name);

View File

@ -927,7 +927,7 @@ inline bool
JSObject::hasProperty(JSContext *cx, js::HandleId id, bool *foundp, unsigned flags)
{
js::RootedObject pobj(cx);
JSProperty *prop;
js::RootedShape prop(cx);
JSAutoResolveFlags rf(cx, flags);
if (!lookupGeneric(cx, id, &pobj, &prop))
return false;
@ -1034,7 +1034,8 @@ JSObject::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf,
}
inline JSBool
JSObject::lookupGeneric(JSContext *cx, js::HandleId id, js::MutableHandleObject objp, JSProperty **propp)
JSObject::lookupGeneric(JSContext *cx, js::HandleId id,
js::MutableHandleObject objp, js::MutableHandleShape propp)
{
js::RootedObject self(cx, this);
@ -1045,7 +1046,8 @@ JSObject::lookupGeneric(JSContext *cx, js::HandleId id, js::MutableHandleObject
}
inline JSBool
JSObject::lookupProperty(JSContext *cx, js::PropertyName *name, js::MutableHandleObject objp, JSProperty **propp)
JSObject::lookupProperty(JSContext *cx, js::PropertyName *name,
js::MutableHandleObject objp, js::MutableHandleShape propp)
{
js::Rooted<jsid> id(cx, js::NameToId(name));
return lookupGeneric(cx, id, objp, propp);
@ -1097,7 +1099,8 @@ JSObject::defineSpecial(JSContext *cx, js::SpecialId sid, const js::Value &value
}
inline JSBool
JSObject::lookupElement(JSContext *cx, uint32_t index, js::MutableHandleObject objp, JSProperty **propp)
JSObject::lookupElement(JSContext *cx, uint32_t index,
js::MutableHandleObject objp, js::MutableHandleShape propp)
{
js::RootedObject self(cx, this);
@ -1106,7 +1109,8 @@ JSObject::lookupElement(JSContext *cx, uint32_t index, js::MutableHandleObject o
}
inline JSBool
JSObject::lookupSpecial(JSContext *cx, js::SpecialId sid, js::MutableHandleObject objp, JSProperty **propp)
JSObject::lookupSpecial(JSContext *cx, js::SpecialId sid,
js::MutableHandleObject objp, js::MutableHandleShape propp)
{
js::Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return lookupGeneric(cx, id, objp, propp);
@ -1154,7 +1158,7 @@ JSObject::getElementIfPresent(JSContext *cx, js::HandleObject receiver, uint32_t
return false;
js::RootedObject obj2(cx);
JSProperty *prop;
js::RootedShape prop(cx);
if (!self->lookupGeneric(cx, id, &obj2, &prop))
return false;

View File

@ -1221,34 +1221,34 @@ proxy_innerObject(JSContext *cx, HandleObject obj)
}
static JSBool
proxy_LookupGeneric(JSContext *cx, HandleObject obj, HandleId id, MutableHandleObject objp,
JSProperty **propp)
proxy_LookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
MutableHandleObject objp, MutableHandleShape propp)
{
bool found;
if (!Proxy::has(cx, obj, id, &found))
return false;
if (found) {
*propp = (JSProperty *)0x1;
MarkNonNativePropertyFound(obj, propp);
objp.set(obj);
} else {
objp.set(NULL);
*propp = NULL;
propp.set(NULL);
}
return true;
}
static JSBool
proxy_LookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape 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, MutableHandleObject objp,
JSProperty **propp)
proxy_LookupElement(JSContext *cx, HandleObject obj, uint32_t index,
MutableHandleObject objp, MutableHandleShape propp)
{
RootedId id(cx);
if (!IndexToId(cx, index, id.address()))
@ -1258,7 +1258,7 @@ proxy_LookupElement(JSContext *cx, HandleObject obj, uint32_t index, MutableHand
static JSBool
proxy_LookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape propp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return proxy_LookupGeneric(cx, obj, id, objp, propp);

View File

@ -51,7 +51,6 @@ typedef struct JSArgumentFormatMap JSArgumentFormatMap;
typedef struct JSGCThing JSGCThing;
typedef struct JSGenerator JSGenerator;
typedef struct JSNativeEnumerator JSNativeEnumerator;
typedef struct JSProperty JSProperty;
typedef struct JSSharpObjectMap JSSharpObjectMap;
typedef struct JSTryNote JSTryNote;
@ -225,6 +224,8 @@ typedef JS::Handle<types::TypeObject*> HandleTypeObject;
typedef JS::Handle<JSAtom*> HandleAtom;
typedef JS::Handle<PropertyName*> HandlePropertyName;
typedef JS::MutableHandle<Shape*> MutableHandleShape;
typedef JS::Rooted<Shape*> RootedShape;
typedef JS::Rooted<BaseShape*> RootedBaseShape;
typedef JS::Rooted<types::TypeObject*> RootedTypeObject;

View File

@ -1393,3 +1393,16 @@ JSCompartment::sweepInitialShapeTable()
}
}
}
/*
* Property lookup hooks on non-native objects are required to return a non-NULL
* shape to signify that the property has been found. The actual shape returned
* is arbitrary, and it should never be read from. We use the non-native
* object's shape_ field, since it is readily available.
*/
void
js::MarkNonNativePropertyFound(HandleObject obj, MutableHandleShape propp)
{
propp.set(obj->lastProperty());
}

View File

@ -1162,6 +1162,9 @@ Shape::searchNoAllocation(JSContext *cx, Shape *start, jsid id)
}
#endif /* DEBUG */
void
MarkNonNativePropertyFound(HandleObject obj, MutableHandleShape propp);
} // namespace js
#ifdef _MSC_VER

View File

@ -295,14 +295,12 @@ ArrayBufferObject::obj_trace(JSTracer *trc, JSObject *obj)
}
}
static JSProperty * const PROPERTY_FOUND = reinterpret_cast<JSProperty *>(1);
JSBool
ArrayBufferObject::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape propp)
{
if (JSID_IS_ATOM(id, cx->runtime->atomState.byteLengthAtom)) {
*propp = PROPERTY_FOUND;
MarkNonNativePropertyFound(obj, propp);
objp.set(getArrayBuffer(obj));
return true;
}
@ -321,7 +319,7 @@ ArrayBufferObject::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId i
if (!delegateResult)
return false;
if (*propp != NULL) {
if (propp) {
if (objp == delegate)
objp.set(obj);
return true;
@ -330,7 +328,7 @@ ArrayBufferObject::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId i
JSObject *proto = obj->getProto();
if (!proto) {
objp.set(NULL);
*propp = NULL;
propp.set(NULL);
return true;
}
@ -339,7 +337,7 @@ ArrayBufferObject::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId i
JSBool
ArrayBufferObject::obj_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape propp)
{
Rooted<jsid> id(cx, NameToId(name));
return obj_lookupGeneric(cx, obj, id, objp, propp);
@ -347,7 +345,7 @@ ArrayBufferObject::obj_lookupProperty(JSContext *cx, HandleObject obj, HandlePro
JSBool
ArrayBufferObject::obj_lookupElement(JSContext *cx, HandleObject obj, uint32_t index,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape propp)
{
RootedObject delegate(cx, ArrayBufferDelegate(cx, obj));
if (!delegate)
@ -362,7 +360,7 @@ ArrayBufferObject::obj_lookupElement(JSContext *cx, HandleObject obj, uint32_t i
if (!delegate->lookupElement(cx, index, objp, propp))
return false;
if (*propp != NULL) {
if (propp) {
if (objp == delegate)
objp.set(obj);
return true;
@ -372,13 +370,13 @@ ArrayBufferObject::obj_lookupElement(JSContext *cx, HandleObject obj, uint32_t i
return proto->lookupElement(cx, index, objp, propp);
objp.set(NULL);
*propp = NULL;
propp.set(NULL);
return true;
}
JSBool
ArrayBufferObject::obj_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape propp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return obj_lookupGeneric(cx, obj, id, objp, propp);
@ -774,13 +772,13 @@ js::IsDataView(JSObject* obj)
JSBool
TypedArray::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape propp)
{
JSObject *tarray = getTypedArray(obj);
JS_ASSERT(tarray);
if (isArrayIndex(cx, tarray, id)) {
*propp = PROPERTY_FOUND;
MarkNonNativePropertyFound(obj, propp);
objp.set(obj);
return true;
}
@ -788,7 +786,7 @@ TypedArray::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
JSObject *proto = obj->getProto();
if (!proto) {
objp.set(NULL);
*propp = NULL;
propp.set(NULL);
return true;
}
@ -797,7 +795,7 @@ TypedArray::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
JSBool
TypedArray::obj_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape propp)
{
Rooted<jsid> id(cx, NameToId(name));
return obj_lookupGeneric(cx, obj, id, objp, propp);
@ -805,13 +803,13 @@ TypedArray::obj_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyNa
JSBool
TypedArray::obj_lookupElement(JSContext *cx, HandleObject obj, uint32_t index,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape propp)
{
JSObject *tarray = getTypedArray(obj);
JS_ASSERT(tarray);
if (index < length(tarray)) {
*propp = PROPERTY_FOUND;
MarkNonNativePropertyFound(obj, propp);
objp.set(obj);
return true;
}
@ -820,13 +818,13 @@ TypedArray::obj_lookupElement(JSContext *cx, HandleObject obj, uint32_t index,
return proto->lookupElement(cx, index, objp, propp);
objp.set(NULL);
*propp = NULL;
propp.set(NULL);
return true;
}
JSBool
TypedArray::obj_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape propp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return obj_lookupGeneric(cx, obj, id, objp, propp);

View File

@ -47,16 +47,16 @@ class ArrayBufferObject : public JSObject
static JSBool
obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
MutableHandleObject objp, JSProperty **propp);
MutableHandleObject objp, MutableHandleShape propp);
static JSBool
obj_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
MutableHandleObject objp, JSProperty **propp);
MutableHandleObject objp, MutableHandleShape propp);
static JSBool
obj_lookupElement(JSContext *cx, HandleObject obj, uint32_t index,
MutableHandleObject objp, JSProperty **propp);
MutableHandleObject objp, MutableHandleShape propp);
static JSBool
obj_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
MutableHandleObject objp, JSProperty **propp);
MutableHandleObject objp, MutableHandleShape 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,
MutableHandleObject objp, JSProperty **propp);
MutableHandleObject objp, MutableHandleShape propp);
static JSBool obj_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
MutableHandleObject objp, JSProperty **propp);
MutableHandleObject objp, MutableHandleShape propp);
static JSBool obj_lookupElement(JSContext *cx, HandleObject obj, uint32_t index,
MutableHandleObject objp, JSProperty **propp);
MutableHandleObject objp, MutableHandleShape propp);
static JSBool obj_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
MutableHandleObject objp, JSProperty **propp);
MutableHandleObject objp, MutableHandleShape 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

@ -4632,7 +4632,6 @@ HasSimpleContent(JSXML *xml);
static JSBool
HasFunctionProperty(JSContext *cx, JSObject *obj_, jsid funid_, JSBool *found)
{
JSProperty *prop;
JSXML *xml;
JS_ASSERT(obj_->getClass() == &XMLClass);
@ -4641,6 +4640,7 @@ HasFunctionProperty(JSContext *cx, JSObject *obj_, jsid funid_, JSBool *found)
Rooted<JSObject*> obj(cx, obj_);
RootedObject pobj(cx);
RootedShape prop(cx);
if (!baseops::LookupProperty(cx, obj, funid, &pobj, &prop))
return false;
if (!prop) {
@ -4743,8 +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, MutableHandleObject objp,
JSProperty **propp)
xml_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
MutableHandleObject objp, MutableHandleShape propp)
{
JSBool found;
JSXML *xml;
@ -4766,7 +4766,7 @@ xml_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, MutableHandleObj
}
if (!found) {
objp.set(NULL);
*propp = NULL;
propp.set(NULL);
} else {
Shape *shape =
js_AddNativeProperty(cx, obj, id, GetProperty, PutProperty,
@ -4776,14 +4776,14 @@ xml_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id, MutableHandleObj
return JS_FALSE;
objp.set(obj);
*propp = (JSProperty *) shape;
propp.set(shape);
}
return JS_TRUE;
}
static JSBool
xml_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape propp)
{
Rooted<jsid> id(cx, NameToId(name));
return xml_lookupGeneric(cx, obj, id, objp, propp);
@ -4791,12 +4791,12 @@ xml_lookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
static JSBool
xml_lookupElement(JSContext *cx, HandleObject obj, uint32_t index, MutableHandleObject objp,
JSProperty **propp)
MutableHandleShape propp)
{
JSXML *xml = reinterpret_cast<JSXML *>(obj->getPrivate());
if (!HasIndexedProperty(xml, index)) {
objp.set(NULL);
*propp = NULL;
propp.set(NULL);
return true;
}
@ -4811,13 +4811,13 @@ xml_lookupElement(JSContext *cx, HandleObject obj, uint32_t index, MutableHandle
return false;
objp.set(obj);
*propp = (JSProperty *) shape;
propp.set(shape);
return true;
}
static JSBool
xml_lookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape propp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return xml_lookupGeneric(cx, obj, id, objp, propp);
@ -7745,7 +7745,6 @@ js_FindXMLProperty(JSContext *cx, const Value &nameval, MutableHandleObject objp
JSObject *obj, *target, *proto;
JSXML *xml;
JSBool found;
JSProperty *prop;
JS_ASSERT(nameval.isObject());
nameobj = &nameval.toObject();
@ -7792,6 +7791,7 @@ js_FindXMLProperty(JSContext *cx, const Value &nameval, MutableHandleObject objp
}
} else if (!JSID_IS_VOID(funid)) {
RootedObject pobj(cx);
RootedShape prop(cx);
if (!target->lookupGeneric(cx, funid, &pobj, &prop))
return JS_FALSE;
if (prop) {

View File

@ -5071,13 +5071,12 @@ mjit::Compiler::testSingletonProperty(HandleObject obj, HandleId id)
}
RootedObject holder(cx);
JSProperty *prop = NULL;
if (!obj->lookupGeneric(cx, id, &holder, &prop))
RootedShape shape(cx);
if (!obj->lookupGeneric(cx, id, &holder, &shape))
return false;
if (!prop)
if (!shape)
return false;
Shape *shape = (Shape *) prop;
if (shape->hasDefaultGetter()) {
if (!shape->hasSlot())
return false;

View File

@ -2686,18 +2686,17 @@ mjit::Compiler::jsop_initprop()
}
RootedObject holder(cx);
JSProperty *prop = NULL;
RootedShape shape(cx);
Rooted<jsid> id(cx, NameToId(name));
#ifdef DEBUG
bool res =
#endif
LookupPropertyWithFlags(cx, baseobj, id, JSRESOLVE_QUALIFIED, &holder, &prop);
JS_ASSERT(res && prop && holder == baseobj);
LookupPropertyWithFlags(cx, baseobj, id, JSRESOLVE_QUALIFIED, &holder, &shape);
JS_ASSERT(res && shape && holder == baseobj);
RegisterID objReg = frame.copyDataIntoReg(obj);
/* Perform the store. */
Shape *shape = (Shape *) prop;
Address address = masm.objPropAddress(baseobj, objReg, shape->slot());
frame.storeTo(fe, address);
frame.freeReg(objReg);

View File

@ -454,19 +454,17 @@ class SetPropCompiler : public PICStubCompiler
return disable("ops set property hook");
RootedObject holder(cx);
JSProperty *prop = NULL;
RootedShape shape(cx);
/* lookupProperty can trigger recompilations. */
RecompilationMonitor monitor(cx);
if (!obj->lookupProperty(cx, name, &holder, &prop))
if (!obj->lookupProperty(cx, name, &holder, &shape))
return error();
if (monitor.recompiled())
return Lookup_Uncacheable;
/* If the property exists but is on a prototype, treat as addprop. */
if (prop && holder != obj) {
Shape *shape = (Shape *) prop;
if (shape && holder != obj) {
if (!holder->isNative())
return disable("non-native holder");
@ -479,10 +477,10 @@ class SetPropCompiler : public PICStubCompiler
if (!shape->hasSlot())
return disable("missing slot");
prop = NULL;
shape = NULL;
}
if (!prop) {
if (!shape) {
/* Adding a property to the object. */
if (obj->isDelegate())
return disable("delegate");
@ -523,7 +521,7 @@ class SetPropCompiler : public PICStubCompiler
* populate the slot to satisfy the method invariant (in case we
* hit an early return below).
*/
Shape *shape =
shape =
obj->putProperty(cx, name, getter, clasp->setProperty,
SHAPE_INVALID_SLOT, JSPROP_ENUMERATE, flags, 0);
if (!shape)
@ -575,7 +573,6 @@ class SetPropCompiler : public PICStubCompiler
return generateStub(initialShape, shape, true);
}
Shape *shape = (Shape *) prop;
if (!shape->writable())
return disable("readonly");
if (shape->hasDefaultSetter()) {
@ -661,14 +658,14 @@ struct GetPropHelper {
// 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.
RootedObject holder;
JSProperty *prop;
RootedShape prop;
// This field is set by |bind| and |lookup| only if they returned
// Lookup_Cacheable, otherwise it is NULL.
Shape *shape;
RootedShape shape;
GetPropHelper(JSContext *cx, JSObject *obj, PropertyName *name, IC &ic, VMFrame &f)
: cx(cx), obj(cx, obj), name(cx, name), ic(ic), f(f), holder(cx), prop(NULL), shape(NULL)
: cx(cx), obj(cx, obj), name(cx, name), ic(ic), f(f), holder(cx), prop(cx), shape(cx)
{ }
public:
@ -687,7 +684,7 @@ struct GetPropHelper {
return ic.disable(cx, "non-native");
if (!IsCacheableProtoChain(obj, holder))
return ic.disable(cx, "non-native holder");
shape = (Shape *)prop;
shape = prop;
return Lookup_Cacheable;
}
@ -708,7 +705,7 @@ struct GetPropHelper {
return ic.disable(f, "lookup failed");
if (!IsCacheableProtoChain(obj, holder))
return ic.disable(f, "non-native holder");
shape = (Shape *)prop;
shape = prop;
return Lookup_Cacheable;
}
@ -1675,7 +1672,7 @@ class ScopeNameCompiler : public PICStubCompiler
{
JSObject *obj = getprop.obj;
Rooted<JSObject*> holder(cx, getprop.holder);
const JSProperty *prop = getprop.prop;
RootedShape prop(cx, getprop.prop);
if (!prop) {
/* Kludge to allow (typeof foo == "undefined") tests. */
@ -1698,7 +1695,7 @@ class ScopeNameCompiler : public PICStubCompiler
return true;
}
Shape *shape = getprop.shape;
RootedShape shape(cx, getprop.shape);
Rooted<JSObject*> normalized(cx, obj);
if (obj->isWith() && !shape->hasDefaultGetter())
normalized = &obj->asWith().object();

View File

@ -193,7 +193,7 @@ stubs::ImplicitThis(VMFrame &f, PropertyName *name_)
RootedPropertyName name(f.cx, name_);
RootedObject obj(f.cx), obj2(f.cx);
JSProperty *prop;
RootedShape prop(f.cx);
if (!FindPropertyHelper(f.cx, name, false, scopeObj, &obj, &obj2, &prop))
THROW();
@ -338,16 +338,16 @@ stubs::DefFun(VMFrame &f, JSFunction *fun_)
/* ES5 10.5 (NB: with subsequent errata). */
PropertyName *name = fun->atom->asPropertyName();
JSProperty *prop = NULL;
RootedShape shape(cx);
RootedObject pobj(cx);
if (!parent->lookupProperty(cx, name, &pobj, &prop))
if (!parent->lookupProperty(cx, name, &pobj, &shape))
THROW();
Value rval = ObjectValue(*fun);
do {
/* Steps 5d, 5f. */
if (!prop || pobj != parent) {
if (!shape || pobj != parent) {
if (!parent->defineProperty(cx, name, rval,
JS_PropertyStub, JS_StrictPropertyStub, attrs))
{
@ -358,7 +358,6 @@ stubs::DefFun(VMFrame &f, JSFunction *fun_)
/* Step 5e. */
JS_ASSERT(parent->isNative());
Shape *shape = reinterpret_cast<Shape *>(prop);
if (parent->isGlobal()) {
if (shape->configurable()) {
if (!parent->defineProperty(cx, name, rval,
@ -1339,7 +1338,7 @@ stubs::DelName(VMFrame &f, PropertyName *name_)
RootedPropertyName name(f.cx, name_);
RootedObject obj(f.cx), obj2(f.cx);
JSProperty *prop;
RootedShape prop(f.cx);
if (!FindProperty(f.cx, name, scopeObj, &obj, &obj2, &prop))
THROW();
@ -1439,7 +1438,7 @@ stubs::In(VMFrame &f)
THROWV(JS_FALSE);
RootedObject obj2(cx);
JSProperty *prop;
RootedShape prop(cx);
if (!obj->lookupGeneric(cx, id, &obj2, &prop))
THROWV(JS_FALSE);

View File

@ -2689,19 +2689,18 @@ static JSBool
CopyProperty(JSContext *cx, HandleObject obj, HandleObject referent, HandleId id,
unsigned lookupFlags, MutableHandleObject objp)
{
JSProperty *prop;
RootedShape shape(cx);
PropertyDescriptor desc;
unsigned propFlags = 0;
RootedObject obj2(cx);
objp.set(NULL);
if (referent->isNative()) {
if (!LookupPropertyWithFlags(cx, referent, id, lookupFlags, &obj2, &prop))
if (!LookupPropertyWithFlags(cx, referent, id, lookupFlags, &obj2, &shape))
return false;
if (obj2 != referent)
return true;
const Shape *shape = (Shape *) prop;
if (shape->hasSlot()) {
desc.value = referent->nativeGetSlot(shape->slot());
} else {
@ -2724,7 +2723,7 @@ CopyProperty(JSContext *cx, HandleObject obj, HandleObject referent, HandleId id
if (!desc.obj)
return true;
} else {
if (!referent->lookupGeneric(cx, id, objp, &prop))
if (!referent->lookupGeneric(cx, id, objp, &shape))
return false;
if (objp != referent)
return true;

View File

@ -259,7 +259,7 @@ args_enumerate(JSContext *cx, HandleObject obj)
: INT_TO_JSID(i);
RootedObject pobj(cx);
JSProperty *prop;
RootedShape prop(cx);
if (!baseops::LookupProperty(cx, argsobj, id, &pobj, &prop))
return false;
}
@ -369,7 +369,7 @@ strictargs_enumerate(JSContext *cx, HandleObject obj)
* js_LookupProperty calls.
*/
RootedObject pobj(cx);
JSProperty *prop;
RootedShape prop(cx);
RootedId id(cx);
// length

View File

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

View File

@ -351,22 +351,22 @@ WithObject::create(JSContext *cx, HandleObject proto, HandleObject enclosing, ui
static JSBool
with_LookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape propp)
{
return obj->asWith().object().lookupGeneric(cx, id, objp, propp);
}
static JSBool
with_LookupProperty(JSContext *cx, HandleObject obj, HandlePropertyName name,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape 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, MutableHandleObject objp,
JSProperty **propp)
with_LookupElement(JSContext *cx, HandleObject obj, uint32_t index,
MutableHandleObject objp, MutableHandleShape propp)
{
RootedId id(cx);
if (!IndexToId(cx, index, id.address()))
@ -376,7 +376,7 @@ with_LookupElement(JSContext *cx, HandleObject obj, uint32_t index, MutableHandl
static JSBool
with_LookupSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid,
MutableHandleObject objp, JSProperty **propp)
MutableHandleObject objp, MutableHandleShape propp)
{
Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return with_LookupGeneric(cx, obj, id, objp, propp);