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; 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 inline
StackShape::AutoRooter::AutoRooter(ThreadSafeContext *cx, const StackShape *shape_ StackShape::AutoRooter::AutoRooter(ThreadSafeContext *cx, const StackShape *shape_
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL) MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)

View File

@ -306,7 +306,7 @@ ShapeTable::grow(ThreadSafeContext *cx)
} }
/* static */ Shape * /* static */ Shape *
Shape::replaceLastProperty(ExclusiveContext *cx, const StackBaseShape &base, Shape::replaceLastProperty(ExclusiveContext *cx, StackBaseShape &base,
TaggedProto proto, HandleShape shape) TaggedProto proto, HandleShape shape)
{ {
JS_ASSERT(!shape->inDictionary()); JS_ASSERT(!shape->inDictionary());
@ -546,7 +546,7 @@ ShouldConvertToDictionary(JSObject *obj)
template <ExecutionMode mode> template <ExecutionMode mode>
static inline UnownedBaseShape * static inline UnownedBaseShape *
GetOrLookupUnownedBaseShape(typename ExecutionModeTraits<mode>::ExclusiveContextType cx, GetOrLookupUnownedBaseShape(typename ExecutionModeTraits<mode>::ExclusiveContextType cx,
const StackBaseShape &base) StackBaseShape &base)
{ {
if (mode == ParallelExecution) if (mode == ParallelExecution)
return BaseShape::lookupUnowned(cx, base); return BaseShape::lookupUnowned(cx, base);
@ -1439,28 +1439,28 @@ StackBaseShape::match(UnownedBaseShape *key, const StackBaseShape *lookup)
} }
void void
StackBaseShape::AutoRooter::trace(JSTracer *trc) StackBaseShape::trace(JSTracer *trc)
{ {
if (base->parent) { if (parent) {
gc::MarkObjectRoot(trc, (JSObject**)&base->parent, gc::MarkObjectRoot(trc, (JSObject**)&parent,
"StackBaseShape::AutoRooter parent"); "StackBaseShape parent");
} }
if (base->metadata) { if (metadata) {
gc::MarkObjectRoot(trc, (JSObject**)&base->metadata, gc::MarkObjectRoot(trc, (JSObject**)&metadata,
"StackBaseShape::AutoRooter metadata"); "StackBaseShape metadata");
} }
if ((base->flags & BaseShape::HAS_GETTER_OBJECT) && base->rawGetter) { if ((flags & BaseShape::HAS_GETTER_OBJECT) && rawGetter) {
gc::MarkObjectRoot(trc, (JSObject**)&base->rawGetter, gc::MarkObjectRoot(trc, (JSObject**)&rawGetter,
"StackBaseShape::AutoRooter getter"); "StackBaseShape getter");
} }
if ((base->flags & BaseShape::HAS_SETTER_OBJECT) && base->rawSetter) { if ((flags & BaseShape::HAS_SETTER_OBJECT) && rawSetter) {
gc::MarkObjectRoot(trc, (JSObject**)&base->rawSetter, gc::MarkObjectRoot(trc, (JSObject**)&rawSetter,
"StackBaseShape::AutoRooter setter"); "StackBaseShape setter");
} }
} }
/* static */ UnownedBaseShape* /* static */ UnownedBaseShape*
BaseShape::getUnowned(ExclusiveContext *cx, const StackBaseShape &base) BaseShape::getUnowned(ExclusiveContext *cx, StackBaseShape &base)
{ {
BaseShapeSet &table = cx->compartment()->baseShapes; BaseShapeSet &table = cx->compartment()->baseShapes;
@ -1471,17 +1471,17 @@ BaseShape::getUnowned(ExclusiveContext *cx, const StackBaseShape &base)
if (p) if (p)
return *p; return *p;
StackBaseShape::AutoRooter root(cx, &base); RootedGeneric<StackBaseShape*> root(cx, &base);
BaseShape *nbase_ = js_NewGCBaseShape<CanGC>(cx); BaseShape *nbase_ = js_NewGCBaseShape<CanGC>(cx);
if (!nbase_) if (!nbase_)
return nullptr; return nullptr;
new (nbase_) BaseShape(base); new (nbase_) BaseShape(*root);
UnownedBaseShape *nbase = static_cast<UnownedBaseShape *>(nbase_); UnownedBaseShape *nbase = static_cast<UnownedBaseShape *>(nbase_);
if (!p.add(cx, table, &base, nbase)) if (!p.add(cx, table, root, nbase))
return nullptr; return nullptr;
return nbase; 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 * Lookup base shapes from the compartment's baseShapes table, adding if
* not already found. * 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 * 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 HashNumber hash(const StackBaseShape *lookup);
static inline bool match(UnownedBaseShape *key, const StackBaseShape *lookup); static inline bool match(UnownedBaseShape *key, const StackBaseShape *lookup);
class AutoRooter : private JS::CustomAutoRooter // For RootedGeneric<StackBaseShape*>
{ static inline js::ThingRootKind rootKind() { return js::THING_ROOT_CUSTOM; }
public: void trace(JSTracer *trc);
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
};
}; };
inline 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. */ /* 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); TaggedProto proto, HandleShape shape);
/* /*