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 void
StackShape::AutoRooter::trace(JSTracer *trc) StackShape::trace(JSTracer *trc)
{ {
if (shape->base) if (base)
MarkBaseShapeRoot(trc, (BaseShape**) &shape->base, "StackShape::AutoRooter base"); MarkBaseShapeRoot(trc, (BaseShape**) &base, "StackShape base");
MarkIdRoot(trc, (jsid*) &shape->propid, "StackShape::AutoRooter id"); MarkIdRoot(trc, (jsid*) &propid, "StackShape id");
} }
void void

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

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

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

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

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

@ -97,7 +97,7 @@ class PropertyTree
JSCompartment *compartment() { return compartment_; } JSCompartment *compartment() { return compartment_; }
Shape *newShape(ExclusiveContext *cx); 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); 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; 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 */ } /* namespace js */
#endif /* vm_Shape_inl_h */ #endif /* vm_Shape_inl_h */

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

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

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

@ -1546,19 +1546,9 @@ struct StackShape
return hash; return hash;
} }
class AutoRooter : private JS::CustomAutoRooter // For RootedGeneric<StackShape*>
{ static inline js::ThingRootKind rootKind() { return js::THING_ROOT_CUSTOM; }
public: void trace(JSTracer *trc);
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
};
}; };
} /* namespace js */ } /* namespace js */