Bug 960342 - Convert StackShape from AutoRooter to RootedGeneric, r=terrence

This commit is contained in:
Steve Fink 2014-01-22 11:52:44 -08:00
Родитель 193fe092cd
Коммит edd13ec3e9
7 изменённых файлов: 33 добавлений и 51 удалений

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

@ -600,11 +600,11 @@ AutoHashableValueRooter::trace(JSTracer *trc)
}
void
StackShape::AutoRooter::trace(JSTracer *trc)
StackShape::trace(JSTracer *trc)
{
if (shape->base)
MarkBaseShapeRoot(trc, (BaseShape**) &shape->base, "StackShape::AutoRooter base");
MarkIdRoot(trc, (jsid*) &shape->propid, "StackShape::AutoRooter id");
if (base)
MarkBaseShapeRoot(trc, (BaseShape**) &base, "StackShape base");
MarkIdRoot(trc, (jsid*) &propid, "StackShape id");
}
void

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

@ -1130,14 +1130,14 @@ JSObject::sealOrFreeze(JSContext *cx, HandleObject obj, ImmutabilityType it)
Reverse(shapes.begin(), shapes.end());
for (size_t i = 0; i < shapes.length(); i++) {
StackShape child(shapes[i]);
StackShape::AutoRooter rooter(cx, &child);
child.attrs |= getSealedOrFrozenAttributes(child.attrs, it);
StackShape unrootedChild(shapes[i]);
RootedGeneric<StackShape*> child(cx, &unrootedChild);
child->attrs |= getSealedOrFrozenAttributes(child->attrs, it);
if (!JSID_IS_EMPTY(child.propid) && it == FREEZE)
MarkTypePropertyNonWritable(cx, obj, child.propid);
if (!JSID_IS_EMPTY(child->propid) && it == FREEZE)
MarkTypePropertyNonWritable(cx, obj, child->propid);
last = cx->compartment()->propertyTree.getChild(cx, last, child);
last = cx->compartment()->propertyTree.getChild(cx, last, *child);
if (!last)
return false;
}

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

@ -126,7 +126,7 @@ Shape::removeChild(Shape *child)
}
Shape *
PropertyTree::getChild(ExclusiveContext *cx, Shape *parentArg, const StackShape &child)
PropertyTree::getChild(ExclusiveContext *cx, Shape *parentArg, StackShape &unrootedChild)
{
RootedShape parent(cx, parentArg);
JS_ASSERT(parent);
@ -144,11 +144,11 @@ PropertyTree::getChild(ExclusiveContext *cx, Shape *parentArg, const StackShape
KidsPointer *kidp = &parent->kids;
if (kidp->isShape()) {
Shape *kid = kidp->toShape();
if (kid->matches(child))
existingShape = kid;
if (kid->matches(unrootedChild))
existingShape = kid;
} else if (kidp->isHash()) {
if (KidsHash::Ptr p = kidp->toHash()->lookup(child))
existingShape = *p;
if (KidsHash::Ptr p = kidp->toHash()->lookup(unrootedChild))
existingShape = *p;
} else {
/* If kidp->isNull(), we always insert. */
}
@ -181,13 +181,13 @@ PropertyTree::getChild(ExclusiveContext *cx, Shape *parentArg, const StackShape
if (existingShape)
return existingShape;
StackShape::AutoRooter childRoot(cx, &child);
RootedGeneric<StackShape*> child(cx, &unrootedChild);
Shape *shape = newShape(cx);
if (!shape)
return nullptr;
new (shape) Shape(child, parent->numFixedSlots());
new (shape) Shape(*child, parent->numFixedSlots());
if (!insertChild(cx, parent, shape))
return nullptr;

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

@ -97,7 +97,7 @@ class PropertyTree
JSCompartment *compartment() { return compartment_; }
Shape *newShape(ExclusiveContext *cx);
Shape *getChild(ExclusiveContext *cx, Shape *parent, const StackShape &child);
Shape *getChild(ExclusiveContext *cx, Shape *parent, StackShape &child);
Shape *lookupChild(ThreadSafeContext *cx, Shape *parent, const StackShape &child);
};

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

@ -234,14 +234,6 @@ AutoRooterGetterSetter::AutoRooterGetterSetter(ThreadSafeContext *cx, uint8_t at
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
inline
StackShape::AutoRooter::AutoRooter(ThreadSafeContext *cx, const StackShape *shape_
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: CustomAutoRooter(cx), shape(shape_), skip(cx, shape_)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
} /* namespace js */
#endif /* vm_Shape_inl_h */

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

@ -363,15 +363,15 @@ JSObject::getChildPropertyOnDictionary(ThreadSafeContext *cx, JS::HandleObject o
if (obj->inDictionaryMode()) {
JS_ASSERT(parent == obj->lastProperty());
StackShape::AutoRooter childRoot(cx, &child);
RootedGeneric<StackShape*> childRoot(cx, &child);
shape = js_NewGCShape(cx);
if (!shape)
return nullptr;
if (child.hasSlot() && child.slot() >= obj->lastProperty()->base()->slotSpan()) {
if (!JSObject::setSlotSpan(cx, obj, child.slot() + 1))
if (childRoot->hasSlot() && childRoot->slot() >= obj->lastProperty()->base()->slotSpan()) {
if (!JSObject::setSlotSpan(cx, obj, childRoot->slot() + 1))
return nullptr;
}
shape->initDictionaryShape(child, obj->numFixedSlots(), &obj->shape_);
shape->initDictionaryShape(*childRoot, obj->numFixedSlots(), &obj->shape_);
}
return shape;
@ -379,13 +379,13 @@ JSObject::getChildPropertyOnDictionary(ThreadSafeContext *cx, JS::HandleObject o
/* static */ Shape *
JSObject::getChildProperty(ExclusiveContext *cx,
HandleObject obj, HandleShape parent, StackShape &child)
HandleObject obj, HandleShape parent, StackShape &unrootedChild)
{
StackShape::AutoRooter childRoot(cx, &child);
RootedShape shape(cx, getChildPropertyOnDictionary(cx, obj, parent, child));
RootedGeneric<StackShape*> child(cx, &unrootedChild);
RootedShape shape(cx, getChildPropertyOnDictionary(cx, obj, parent, *child));
if (!obj->inDictionaryMode()) {
shape = cx->compartment()->propertyTree.getChild(cx, parent, child);
shape = cx->compartment()->propertyTree.getChild(cx, parent, *child);
if (!shape)
return nullptr;
//JS_ASSERT(shape->parent == parent);
@ -399,15 +399,15 @@ JSObject::getChildProperty(ExclusiveContext *cx,
/* static */ Shape *
JSObject::lookupChildProperty(ThreadSafeContext *cx,
HandleObject obj, HandleShape parent, StackShape &child)
HandleObject obj, HandleShape parent, StackShape &unrootedChild)
{
StackShape::AutoRooter childRoot(cx, &child);
RootedGeneric<StackShape*> child(cx, &unrootedChild);
JS_ASSERT(cx->isThreadLocal(obj));
RootedShape shape(cx, getChildPropertyOnDictionary(cx, obj, parent, child));
RootedShape shape(cx, getChildPropertyOnDictionary(cx, obj, parent, *child));
if (!obj->inDictionaryMode()) {
shape = cx->compartment_->propertyTree.lookupChild(cx, parent, child);
shape = cx->compartment_->propertyTree.lookupChild(cx, parent, *child);
if (!shape)
return nullptr;
if (!JSObject::setLastProperty(cx, obj, shape))

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

@ -1546,19 +1546,9 @@ struct StackShape
return hash;
}
class AutoRooter : private JS::CustomAutoRooter
{
public:
inline AutoRooter(ThreadSafeContext *cx, const StackShape *shape_
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
private:
virtual void trace(JSTracer *trc);
const StackShape *shape;
SkipRoot skip;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
// For RootedGeneric<StackShape*>
static inline js::ThingRootKind rootKind() { return js::THING_ROOT_CUSTOM; }
void trace(JSTracer *trc);
};
} /* namespace js */