diff --git a/js/src/gc/RootMarking.cpp b/js/src/gc/RootMarking.cpp index 50bc98644ce3..7b9cf0db28a0 100644 --- a/js/src/gc/RootMarking.cpp +++ b/js/src/gc/RootMarking.cpp @@ -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 diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index c52b69116e68..c14f37d0003f 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -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 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; } diff --git a/js/src/jspropertytree.cpp b/js/src/jspropertytree.cpp index a35457d20b49..6e4d162576f4 100644 --- a/js/src/jspropertytree.cpp +++ b/js/src/jspropertytree.cpp @@ -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 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; diff --git a/js/src/jspropertytree.h b/js/src/jspropertytree.h index 1015bf4228b8..362c45c6d02c 100644 --- a/js/src/jspropertytree.h +++ b/js/src/jspropertytree.h @@ -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); }; diff --git a/js/src/vm/Shape-inl.h b/js/src/vm/Shape-inl.h index 4617d3395b90..c5fb04615429 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 -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 */ diff --git a/js/src/vm/Shape.cpp b/js/src/vm/Shape.cpp index 531bf1ad0065..73b92fa9f542 100644 --- a/js/src/vm/Shape.cpp +++ b/js/src/vm/Shape.cpp @@ -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 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 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 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)) diff --git a/js/src/vm/Shape.h b/js/src/vm/Shape.h index 227b00f829b2..d1da317898c4 100644 --- a/js/src/vm/Shape.h +++ b/js/src/vm/Shape.h @@ -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 + static inline js::ThingRootKind rootKind() { return js::THING_ROOT_CUSTOM; } + void trace(JSTracer *trc); }; } /* namespace js */