mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 849420 - Use MaybeRooted instead of Shape::AutoRooter, r=sfink.
This commit is contained in:
parent
ac4358ae6a
commit
b2adf364d1
@ -2340,8 +2340,7 @@ static inline bool
|
||||
ForEachLetDef(JSContext *cx, ParseContext<ParseHandler> *pc,
|
||||
HandleStaticBlockObject blockObj, Op op)
|
||||
{
|
||||
for (Shape::Range r = blockObj->lastProperty()->all(); !r.empty(); r.popFront()) {
|
||||
Shape::Range::AutoRooter rooter(cx, &r);
|
||||
for (Shape::Range<CanGC> r(cx, blockObj->lastProperty()); !r.empty(); r.popFront()) {
|
||||
Shape &shape = r.front();
|
||||
|
||||
/* Beware the destructuring dummy slots. */
|
||||
|
@ -538,12 +538,6 @@ AutoGCRooter::trace(JSTracer *trc)
|
||||
return;
|
||||
}
|
||||
|
||||
case SHAPERANGE: {
|
||||
Shape::Range::AutoRooter *rooter = static_cast<Shape::Range::AutoRooter *>(this);
|
||||
rooter->trace(trc);
|
||||
return;
|
||||
}
|
||||
|
||||
case STACKSHAPE: {
|
||||
StackShape::AutoRooter *rooter = static_cast<StackShape::AutoRooter *>(this);
|
||||
if (rooter->shape->base)
|
||||
@ -649,13 +643,6 @@ AutoGCRooter::traceAllWrappers(JSTracer *trc)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Shape::Range::AutoRooter::trace(JSTracer *trc)
|
||||
{
|
||||
if (r->cursor)
|
||||
MarkShapeRoot(trc, const_cast<Shape**>(&r->cursor), "Shape::Range::AutoRooter");
|
||||
}
|
||||
|
||||
void
|
||||
RegExpStatics::AutoRooter::trace(JSTracer *trc)
|
||||
{
|
||||
|
@ -4396,8 +4396,8 @@ JS_DeleteProperty(JSContext *cx, JSObject *objArg, const char *name)
|
||||
static RawShape
|
||||
LastConfigurableShape(JSObject *obj)
|
||||
{
|
||||
for (Shape::Range r(obj->lastProperty()->all()); !r.empty(); r.popFront()) {
|
||||
RawShape shape = &r.front();
|
||||
for (Shape::Range<NoGC> r(obj->lastProperty()); !r.empty(); r.popFront()) {
|
||||
Shape *shape = &r.front();
|
||||
if (shape->configurable())
|
||||
return shape;
|
||||
}
|
||||
@ -4425,8 +4425,8 @@ JS_ClearNonGlobalObject(JSContext *cx, JSObject *objArg)
|
||||
}
|
||||
|
||||
/* Set all remaining writable plain data properties to undefined. */
|
||||
for (Shape::Range r(obj->lastProperty()->all()); !r.empty(); r.popFront()) {
|
||||
RawShape shape = &r.front();
|
||||
for (Shape::Range<NoGC> r(obj->lastProperty()); !r.empty(); r.popFront()) {
|
||||
Shape *shape = &r.front();
|
||||
if (shape->isDataDescriptor() &&
|
||||
shape->writable() &&
|
||||
shape->hasDefaultSetter() &&
|
||||
|
@ -129,7 +129,6 @@ class JS_PUBLIC_API(AutoGCRooter) {
|
||||
STRINGVECTOR =-17, /* js::AutoStringVector */
|
||||
SCRIPTVECTOR =-18, /* js::AutoScriptVector */
|
||||
PROPDESC = -19, /* js::PropDesc::AutoRooter */
|
||||
SHAPERANGE = -20, /* js::Shape::Range::AutoRooter */
|
||||
STACKSHAPE = -21, /* js::StackShape::AutoRooter */
|
||||
STACKBASESHAPE=-22,/* js::StackBaseShape::AutoRooter */
|
||||
GETTERSETTER =-24, /* js::AutoRooterGetterSetter */
|
||||
|
@ -728,8 +728,7 @@ JS_GetPropertyDescArray(JSContext *cx, JSObject *obj_, JSPropertyDescArray *pda)
|
||||
return false;
|
||||
|
||||
{
|
||||
Shape::Range r(obj->lastProperty()->all());
|
||||
Shape::Range::AutoRooter rooter(cx, &r);
|
||||
Shape::Range<CanGC> r(cx, obj->lastProperty());
|
||||
RootedShape shape(cx);
|
||||
for (; !r.empty(); r.popFront()) {
|
||||
pd[i].id = JSVAL_NULL;
|
||||
|
@ -142,8 +142,7 @@ EnumerateNativeProperties(JSContext *cx, HandleObject pobj, unsigned flags, IdSe
|
||||
size_t initialLength = props->length();
|
||||
|
||||
/* Collect all unique properties from this object's scope. */
|
||||
Shape::Range r = pobj->lastProperty()->all();
|
||||
Shape::Range::AutoRooter root(cx, &r);
|
||||
Shape::Range<NoGC> r(pobj->lastProperty());
|
||||
for (; !r.empty(); r.popFront()) {
|
||||
Shape &shape = r.front();
|
||||
|
||||
|
@ -1080,7 +1080,7 @@ JSObject::sealOrFreeze(JSContext *cx, HandleObject obj, ImmutabilityType it)
|
||||
|
||||
/* Get an in order list of the shapes in this object. */
|
||||
AutoShapeVector shapes(cx);
|
||||
for (Shape::Range r = obj->lastProperty()->all(); !r.empty(); r.popFront()) {
|
||||
for (Shape::Range<NoGC> r(obj->lastProperty()); !r.empty(); r.popFront()) {
|
||||
if (!shapes.append(&r.front()))
|
||||
return false;
|
||||
}
|
||||
@ -1632,7 +1632,7 @@ JS_CopyPropertiesFrom(JSContext *cx, JSObject *targetArg, JSObject *objArg)
|
||||
return true;
|
||||
|
||||
AutoShapeVector shapes(cx);
|
||||
for (Shape::Range r(obj->lastProperty()); !r.empty(); r.popFront()) {
|
||||
for (Shape::Range<NoGC> r(obj->lastProperty()); !r.empty(); r.popFront()) {
|
||||
if (!shapes.append(&r.front()))
|
||||
return false;
|
||||
}
|
||||
@ -4943,7 +4943,7 @@ JSObject::dump()
|
||||
if (obj->isNative()) {
|
||||
fprintf(stderr, "properties:\n");
|
||||
Vector<RawShape, 8, SystemAllocPolicy> props;
|
||||
for (Shape::Range r = obj->lastProperty()->all(); !r.empty(); r.popFront())
|
||||
for (Shape::Range<NoGC> r(obj->lastProperty()); !r.empty(); r.popFront())
|
||||
props.append(&r.front());
|
||||
for (size_t i = props.length(); i-- != 0;)
|
||||
DumpProperty(obj, *props[i]);
|
||||
|
@ -475,8 +475,7 @@ ToDisassemblySource(JSContext *cx, jsval v, JSAutoByteString *bytes)
|
||||
if (!source)
|
||||
return false;
|
||||
|
||||
Shape::Range r = obj->lastProperty()->all();
|
||||
Shape::Range::AutoRooter root(cx, &r);
|
||||
Shape::Range<CanGC> r(cx, obj->lastProperty());
|
||||
|
||||
while (!r.empty()) {
|
||||
Rooted<Shape*> shape(cx, &r.front());
|
||||
@ -1429,7 +1428,7 @@ ExpressionDecompiler::findLetVar(jsbytecode *pc, unsigned depth)
|
||||
uint32_t blockDepth = block.stackDepth();
|
||||
uint32_t blockCount = block.slotCount();
|
||||
if (uint32_t(depth - blockDepth) < uint32_t(blockCount)) {
|
||||
for (Shape::Range r(block.lastProperty()); !r.empty(); r.popFront()) {
|
||||
for (Shape::Range<NoGC> r(block.lastProperty()); !r.empty(); r.popFront()) {
|
||||
const Shape &shape = r.front();
|
||||
if (shape.shortid() == int(depth - blockDepth))
|
||||
return JSID_TO_ATOM(shape.propid());
|
||||
|
@ -232,7 +232,7 @@ js::ObjectImpl::checkShapeConsistency()
|
||||
if (shape->hasTable()) {
|
||||
ShapeTable &table = shape->table();
|
||||
MOZ_ASSERT(shape->parent);
|
||||
for (Shape::Range r(shape); !r.empty(); r.popFront()) {
|
||||
for (Shape::Range<NoGC> r(shape); !r.empty(); r.popFront()) {
|
||||
Shape **spp = table.search(r.front().propid(), false);
|
||||
MOZ_ASSERT(SHAPE_FETCH(spp) == &r.front());
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ js::ScopeCoordinateToStaticScopeShape(JSContext *cx, JSScript *script, jsbytecod
|
||||
PropertyName *
|
||||
js::ScopeCoordinateName(JSContext *cx, JSScript *script, jsbytecode *pc)
|
||||
{
|
||||
Shape::Range r = ScopeCoordinateToStaticScopeShape(cx, script, pc)->all();
|
||||
Shape::Range<NoGC> r(ScopeCoordinateToStaticScopeShape(cx, script, pc));
|
||||
ScopeCoordinate sc(pc);
|
||||
while (r.front().slot() != sc.slot)
|
||||
r.popFront();
|
||||
@ -787,8 +787,8 @@ js::XDRStaticBlockObject(XDRState<mode> *xdr, HandleObject enclosingScope, Handl
|
||||
if (!shapes.growBy(count))
|
||||
return false;
|
||||
|
||||
for (Shape::Range r(obj->lastProperty()); !r.empty(); r.popFront()) {
|
||||
RawShape shape = &r.front();
|
||||
for (Shape::Range<NoGC> r(obj->lastProperty()); !r.empty(); r.popFront()) {
|
||||
Shape *shape = &r.front();
|
||||
shapes[shape->shortid()] = shape;
|
||||
}
|
||||
|
||||
@ -844,7 +844,7 @@ js::CloneStaticBlockObject(JSContext *cx, HandleObject enclosingScope, Handle<St
|
||||
AutoShapeVector shapes(cx);
|
||||
if (!shapes.growBy(srcBlock->slotCount()))
|
||||
return NULL;
|
||||
for (Shape::Range r = srcBlock->lastProperty()->all(); !r.empty(); r.popFront())
|
||||
for (Shape::Range<NoGC> r(srcBlock->lastProperty()); !r.empty(); r.popFront())
|
||||
shapes[r.front().shortid()] = &r.front();
|
||||
|
||||
for (Shape **p = shapes.begin(); p != shapes.end(); ++p) {
|
||||
|
@ -62,7 +62,7 @@ ShapeTable::init(JSRuntime *rt, RawShape lastProp)
|
||||
return false;
|
||||
|
||||
hashShift = HASH_BITS - sizeLog2;
|
||||
for (Shape::Range r = lastProp->all(); !r.empty(); r.popFront()) {
|
||||
for (Shape::Range<NoGC> r(lastProp); !r.empty(); r.popFront()) {
|
||||
Shape &shape = r.front();
|
||||
Shape **spp = search(shape.propid(), true);
|
||||
|
||||
|
@ -545,15 +545,21 @@ class Shape : public js::gc::Cell
|
||||
return parent;
|
||||
}
|
||||
|
||||
template <AllowGC allowGC>
|
||||
class Range {
|
||||
protected:
|
||||
friend class Shape;
|
||||
|
||||
/* |cursor| is rooted manually when necessary using Range::AutoRooter. */
|
||||
RawShape cursor;
|
||||
typename MaybeRooted<Shape*, allowGC>::RootType cursor;
|
||||
|
||||
public:
|
||||
Range(RawShape shape) : cursor(shape) { }
|
||||
Range(JSContext *cx, Shape *shape) : cursor(cx, shape) {
|
||||
JS_STATIC_ASSERT(allowGC == CanGC);
|
||||
}
|
||||
|
||||
Range(Shape *shape) : cursor(NULL, shape) {
|
||||
JS_STATIC_ASSERT(allowGC == NoGC);
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
return !cursor || cursor->isEmptyShape();
|
||||
@ -568,31 +574,8 @@ class Shape : public js::gc::Cell
|
||||
JS_ASSERT(!empty());
|
||||
cursor = cursor->parent;
|
||||
}
|
||||
|
||||
class AutoRooter : private AutoGCRooter
|
||||
{
|
||||
public:
|
||||
explicit AutoRooter(JSContext *cx, Range *r_
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx, SHAPERANGE), r(r_), skip(cx, r_)
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
friend void AutoGCRooter::trace(JSTracer *trc);
|
||||
void trace(JSTracer *trc);
|
||||
|
||||
private:
|
||||
Range *r;
|
||||
SkipRoot skip;
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
};
|
||||
|
||||
Range all() {
|
||||
return Range(this);
|
||||
}
|
||||
|
||||
Class *getObjectClass() const { return base()->clasp; }
|
||||
JSObject *getObjectParent() const { return base()->parent; }
|
||||
|
||||
@ -798,7 +781,7 @@ class Shape : public js::gc::Cell
|
||||
|
||||
RawShape shape = this;
|
||||
uint32_t count = 0;
|
||||
for (Shape::Range r = shape->all(); !r.empty(); r.popFront())
|
||||
for (Shape::Range<NoGC> r(shape); !r.empty(); r.popFront())
|
||||
++count;
|
||||
return count;
|
||||
}
|
||||
@ -807,7 +790,7 @@ class Shape : public js::gc::Cell
|
||||
JS_ASSERT(!hasTable());
|
||||
RawShape shape = this;
|
||||
uint32_t count = 0;
|
||||
for (Shape::Range r = shape->all(); !r.empty(); r.popFront()) {
|
||||
for (Shape::Range<NoGC> r(shape); !r.empty(); r.popFront()) {
|
||||
++count;
|
||||
if (count >= ShapeTable::MIN_ENTRIES)
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user