From c1ddaedd56777c983530a8b73ed2534350cd277e Mon Sep 17 00:00:00 2001 From: Steve Fink Date: Wed, 22 Jan 2014 11:52:44 -0800 Subject: [PATCH] Bug 960342 - Convert StackBaseShape from AutoRooter to RootedGeneric, r=terrence --- js/src/vm/Shape-inl.h | 8 -------- js/src/vm/Shape.cpp | 38 +++++++++++++++++++------------------- js/src/vm/Shape.h | 20 +++++--------------- 3 files changed, 24 insertions(+), 42 deletions(-) diff --git a/js/src/vm/Shape-inl.h b/js/src/vm/Shape-inl.h index 1846ec819cf..4617d3395b9 100644 --- a/js/src/vm/Shape-inl.h +++ b/js/src/vm/Shape-inl.h @@ -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) diff --git a/js/src/vm/Shape.cpp b/js/src/vm/Shape.cpp index 41c465fc8c9..531bf1ad006 100644 --- a/js/src/vm/Shape.cpp +++ b/js/src/vm/Shape.cpp @@ -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 static inline UnownedBaseShape * GetOrLookupUnownedBaseShape(typename ExecutionModeTraits::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 root(cx, &base); BaseShape *nbase_ = js_NewGCBaseShape(cx); if (!nbase_) return nullptr; - new (nbase_) BaseShape(base); + new (nbase_) BaseShape(*root); UnownedBaseShape *nbase = static_cast(nbase_); - if (!p.add(cx, table, &base, nbase)) + if (!p.add(cx, table, root, nbase)) return nullptr; return nbase; diff --git a/js/src/vm/Shape.h b/js/src/vm/Shape.h index d81da1d0af3..227b00f829b 100644 --- a/js/src/vm/Shape.h +++ b/js/src/vm/Shape.h @@ -715,7 +715,7 @@ class BaseShape : public gc::BarrieredCell * 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 + static inline js::ThingRootKind rootKind() { return js::THING_ROOT_CUSTOM; } + void trace(JSTracer *trc); }; inline @@ -961,7 +951,7 @@ class Shape : public gc::BarrieredCell } /* 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); /*