Remove JSObject::containsSlot, bug 710516. r=luke

This commit is contained in:
Brian Hackett 2011-12-21 06:31:11 -08:00
Родитель 26e0e2b46f
Коммит 0071452454
5 изменённых файлов: 19 добавлений и 40 удалений

Просмотреть файл

@ -1781,8 +1781,8 @@ LookupCompileTimeConstant(JSContext *cx, BytecodeEmitter *bce, JSAtom *atom, Val
* from our variable object here.
*/
if (!shape->writable() && !shape->configurable() &&
shape->hasDefaultGetter() && obj->containsSlot(shape->slot())) {
*constp = obj->getSlot(shape->slot());
shape->hasDefaultGetter() && shape->hasSlot()) {
*constp = obj->nativeGetSlot(shape->slot());
}
}

Просмотреть файл

@ -866,15 +866,6 @@ JS_GetPropertyDesc(JSContext *cx, JSObject *obj, JSScopeProperty *sprop,
}
pd->alias = JSVAL_VOID;
if (obj->containsSlot(shape->slot())) {
for (Shape::Range r = obj->lastProperty()->all(); !r.empty(); r.popFront()) {
const Shape &aprop = r.front();
if (&aprop != shape && aprop.slot() == shape->slot()) {
pd->alias = IdToJsval(aprop.propid());
break;
}
}
}
return JS_TRUE;
}

Просмотреть файл

@ -5034,7 +5034,7 @@ js_FindClassObject(JSContext *cx, JSObject *start, JSProtoKey protoKey,
Value v = UndefinedValue();
if (prop && pobj->isNative()) {
shape = (Shape *) prop;
if (pobj->containsSlot(shape->slot())) {
if (shape->hasSlot()) {
v = pobj->nativeGetSlot(shape->slot());
if (v.isPrimitive())
v.setUndefined();
@ -5291,7 +5291,7 @@ CallAddPropertyHook(JSContext *cx, Class *clasp, JSObject *obj, const Shape *sha
if (!CallJSPropertyOp(cx, clasp->addProperty, obj, shape->propid(), vp))
return false;
if (*vp != nominal) {
if (obj->containsSlot(shape->slot()))
if (shape->hasSlot())
obj->nativeSetSlotWithType(cx, shape, *vp);
}
}
@ -5421,7 +5421,7 @@ DefineNativeProperty(JSContext *cx, JSObject *obj, jsid id, const Value &value,
}
/* Store valueCopy before calling addProperty, in case the latter GC's. */
if (shape->hasSlot() && obj->containsSlot(shape->slot()))
if (shape->hasSlot())
obj->nativeSetSlot(shape->slot(), valueCopy);
/* XXXbe called with lock held */
@ -5856,7 +5856,6 @@ js_NativeSet(JSContext *cx, JSObject *obj, const Shape *shape, bool added, bool
if (shape->hasSlot()) {
uint32_t slot = shape->slot();
JS_ASSERT(obj->containsSlot(slot));
/* If shape has a stub setter, just store *vp. */
if (shape->hasDefaultSetter()) {
@ -6338,7 +6337,7 @@ js_SetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uintN defineHow,
* Note that we store before calling addProperty, to match the order
* in DefineNativeProperty.
*/
if (obj->containsSlot(shape->slot()))
if (shape->hasSlot())
obj->nativeSetSlot(shape->slot(), UndefinedValue());
/* XXXbe called with obj locked */
@ -6465,12 +6464,7 @@ js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool str
return true;
}
if (!CallJSPropertyOp(cx, obj->getClass()->delProperty, obj, shape->getUserId(), rval))
return false;
if (rval->isFalse())
return true;
if (shape->hasSlot() && obj->containsSlot(shape->slot())) {
if (shape->hasSlot()) {
const Value &v = obj->nativeGetSlot(shape->slot());
GCPoke(cx, v);
@ -6504,6 +6498,11 @@ js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool str
}
}
if (!CallJSPropertyOp(cx, obj->getClass()->delProperty, obj, shape->getUserId(), rval))
return false;
if (rval->isFalse())
return true;
return obj->removeProperty(cx, id) && js_SuppressDeletedProperty(cx, obj, id);
}
@ -6523,7 +6522,6 @@ HasDataProperty(JSContext *cx, JSObject *obj, jsid methodid, Value *vp)
{
if (const Shape *shape = obj->nativeLookup(cx, methodid)) {
if (shape->hasDefaultGetterOrIsMethod() && shape->hasSlot()) {
JS_ASSERT(obj->containsSlot(shape->slot()));
*vp = obj->nativeGetSlot(shape->slot());
return true;
}
@ -6967,10 +6965,8 @@ js_PrintObjectSlotName(JSTracer *trc, char *buf, size_t bufsize)
const Shape *shape;
if (obj->isNative()) {
shape = obj->lastProperty();
while (shape->previous() && shape->maybeSlot() != slot)
while (shape && (!shape->hasSlot() || shape->slot() != slot))
shape = shape->previous();
if (shape->maybeSlot() != slot)
shape = NULL;
} else {
shape = NULL;
}
@ -7027,8 +7023,8 @@ js_ClearNative(JSContext *cx, JSObject *obj)
if (shape->isDataDescriptor() &&
shape->writable() &&
shape->hasDefaultSetter() &&
obj->containsSlot(shape->maybeSlot())) {
obj->setSlot(shape->slot(), UndefinedValue());
shape->hasSlot()) {
obj->nativeSetSlot(shape->slot(), UndefinedValue());
}
}
return true;
@ -7295,7 +7291,7 @@ DumpProperty(JSObject *obj, const Shape &shape)
uint32_t slot = shape.hasSlot() ? shape.maybeSlot() : SHAPE_INVALID_SLOT;
fprintf(stderr, ": slot %d", slot);
if (obj->containsSlot(slot)) {
if (shape.hasSlot()) {
fprintf(stderr, " = ");
dumpValue(obj->getSlot(slot));
} else if (slot != SHAPE_INVALID_SLOT) {

Просмотреть файл

@ -711,8 +711,6 @@ struct JSObject : js::gc::Cell
inline uint32_t slotSpan() const;
inline bool containsSlot(uint32_t slot) const;
void rollbackProperties(JSContext *cx, uint32_t slotSpan);
#ifdef DEBUG

Просмотреть файл

@ -1142,17 +1142,11 @@ JSObject::slotSpan() const
return lastProperty()->slotSpan();
}
inline bool
JSObject::containsSlot(uint32_t slot) const
{
return slot < slotSpan();
}
inline js::HeapValue &
JSObject::nativeGetSlotRef(uintN slot)
{
JS_ASSERT(isNative());
JS_ASSERT(containsSlot(slot));
JS_ASSERT(slot < slotSpan());
return getSlotRef(slot);
}
@ -1160,7 +1154,7 @@ inline const js::Value &
JSObject::nativeGetSlot(uintN slot) const
{
JS_ASSERT(isNative());
JS_ASSERT(containsSlot(slot));
JS_ASSERT(slot < slotSpan());
return getSlot(slot);
}
@ -1184,7 +1178,7 @@ inline void
JSObject::nativeSetSlot(uintN slot, const js::Value &value)
{
JS_ASSERT(isNative());
JS_ASSERT(containsSlot(slot));
JS_ASSERT(slot < slotSpan());
return setSlot(slot, value);
}