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

This commit is contained in:
Steve Fink 2014-01-22 11:52:44 -08:00
parent c5a9558249
commit c1ddaedd56
3 changed files with 24 additions and 42 deletions

View File

@ -234,14 +234,6 @@ AutoRooterGetterSetter::AutoRooterGetterSetter(ThreadSafeContext *cx, uint8_t at
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
inline
StackBaseShape::AutoRooter::AutoRooter(ThreadSafeContext *cx, const StackBaseShape *base_
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: CustomAutoRooter(cx), base(base_), skip(cx, base_)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
inline
StackShape::AutoRooter::AutoRooter(ThreadSafeContext *cx, const StackShape *shape_
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)

View File

@ -306,7 +306,7 @@ ShapeTable::grow(ThreadSafeContext *cx)
}
/* static */ Shape *
Shape::replaceLastProperty(ExclusiveContext *cx, const StackBaseShape &base,
Shape::replaceLastProperty(ExclusiveContext *cx, StackBaseShape &base,
TaggedProto proto, HandleShape shape)
{
JS_ASSERT(!shape->inDictionary());
@ -546,7 +546,7 @@ ShouldConvertToDictionary(JSObject *obj)
template <ExecutionMode mode>
static inline UnownedBaseShape *
GetOrLookupUnownedBaseShape(typename ExecutionModeTraits<mode>::ExclusiveContextType cx,
const StackBaseShape &base)
StackBaseShape &base)
{
if (mode == ParallelExecution)
return BaseShape::lookupUnowned(cx, base);
@ -1439,28 +1439,28 @@ StackBaseShape::match(UnownedBaseShape *key, const StackBaseShape *lookup)
}
void
StackBaseShape::AutoRooter::trace(JSTracer *trc)
StackBaseShape::trace(JSTracer *trc)
{
if (base->parent) {
gc::MarkObjectRoot(trc, (JSObject**)&base->parent,
"StackBaseShape::AutoRooter parent");
if (parent) {
gc::MarkObjectRoot(trc, (JSObject**)&parent,
"StackBaseShape parent");
}
if (base->metadata) {
gc::MarkObjectRoot(trc, (JSObject**)&base->metadata,
"StackBaseShape::AutoRooter metadata");
if (metadata) {
gc::MarkObjectRoot(trc, (JSObject**)&metadata,
"StackBaseShape metadata");
}
if ((base->flags & BaseShape::HAS_GETTER_OBJECT) && base->rawGetter) {
gc::MarkObjectRoot(trc, (JSObject**)&base->rawGetter,
"StackBaseShape::AutoRooter getter");
if ((flags & BaseShape::HAS_GETTER_OBJECT) && rawGetter) {
gc::MarkObjectRoot(trc, (JSObject**)&rawGetter,
"StackBaseShape getter");
}
if ((base->flags & BaseShape::HAS_SETTER_OBJECT) && base->rawSetter) {
gc::MarkObjectRoot(trc, (JSObject**)&base->rawSetter,
"StackBaseShape::AutoRooter setter");
if ((flags & BaseShape::HAS_SETTER_OBJECT) && rawSetter) {
gc::MarkObjectRoot(trc, (JSObject**)&rawSetter,
"StackBaseShape setter");
}
}
/* static */ UnownedBaseShape*
BaseShape::getUnowned(ExclusiveContext *cx, const StackBaseShape &base)
BaseShape::getUnowned(ExclusiveContext *cx, StackBaseShape &base)
{
BaseShapeSet &table = cx->compartment()->baseShapes;
@ -1471,17 +1471,17 @@ BaseShape::getUnowned(ExclusiveContext *cx, const StackBaseShape &base)
if (p)
return *p;
StackBaseShape::AutoRooter root(cx, &base);
RootedGeneric<StackBaseShape*> root(cx, &base);
BaseShape *nbase_ = js_NewGCBaseShape<CanGC>(cx);
if (!nbase_)
return nullptr;
new (nbase_) BaseShape(base);
new (nbase_) BaseShape(*root);
UnownedBaseShape *nbase = static_cast<UnownedBaseShape *>(nbase_);
if (!p.add(cx, table, &base, nbase))
if (!p.add(cx, table, root, nbase))
return nullptr;
return nbase;

View File

@ -715,7 +715,7 @@ class BaseShape : public gc::BarrieredCell<BaseShape>
* Lookup base shapes from the compartment's baseShapes table, adding if
* not already found.
*/
static UnownedBaseShape* getUnowned(ExclusiveContext *cx, const StackBaseShape &base);
static UnownedBaseShape* getUnowned(ExclusiveContext *cx, StackBaseShape &base);
/*
* Lookup base shapes from the compartment's baseShapes table, returning
@ -847,19 +847,9 @@ struct StackBaseShape
static inline HashNumber hash(const StackBaseShape *lookup);
static inline bool match(UnownedBaseShape *key, const StackBaseShape *lookup);
class AutoRooter : private JS::CustomAutoRooter
{
public:
inline AutoRooter(ThreadSafeContext *cx, const StackBaseShape *base_
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
private:
virtual void trace(JSTracer *trc);
const StackBaseShape *base;
SkipRoot skip;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
// For RootedGeneric<StackBaseShape*>
static inline js::ThingRootKind rootKind() { return js::THING_ROOT_CUSTOM; }
void trace(JSTracer *trc);
};
inline
@ -961,7 +951,7 @@ class Shape : public gc::BarrieredCell<Shape>
}
/* Replace the base shape of the last shape in a non-dictionary lineage with base. */
static Shape *replaceLastProperty(ExclusiveContext *cx, const StackBaseShape &base,
static Shape *replaceLastProperty(ExclusiveContext *cx, StackBaseShape &base,
TaggedProto proto, HandleShape shape);
/*