Bug 673125: Provide stack-allocated vectors of JSObject pointers. r=luke.

This commit is contained in:
Jim Blandy 2011-08-23 14:45:21 -05:00
parent fab58c0d9c
commit 3abd972834
2 changed files with 21 additions and 1 deletions

View File

@ -1482,7 +1482,8 @@ class AutoGCRooter {
STRING = -14, /* js::AutoStringRooter */
IDVECTOR = -15, /* js::AutoIdVector */
BINDINGS = -16, /* js::Bindings */
SHAPEVECTOR = -17 /* js::AutoShapeVector */
SHAPEVECTOR = -17, /* js::AutoShapeVector */
OBJVECTOR = -18 /* js::AutoObjectVector */
};
private:
@ -2487,6 +2488,19 @@ class AutoValueVector : public AutoVectorRooter<Value>
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
};
class AutoObjectVector : public AutoVectorRooter<JSObject *>
{
public:
explicit AutoObjectVector(JSContext *cx
JS_GUARD_OBJECT_NOTIFIER_PARAM)
: AutoVectorRooter<JSObject *>(cx, OBJVECTOR)
{
JS_GUARD_OBJECT_NOTIFIER_INIT;
}
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
};
class AutoIdVector : public AutoVectorRooter<jsid>
{
public:

View File

@ -1784,6 +1784,12 @@ AutoGCRooter::trace(JSTracer *trc)
static_cast<js::AutoBindingsRooter *>(this)->bindings.trace(trc);
return;
}
case OBJVECTOR: {
AutoObjectVector::VectorImpl &vector = static_cast<AutoObjectVector *>(this)->vector;
MarkObjectRange(trc, vector.length(), vector.begin(), "js::AutoObjectVector.vector");
return;
}
}
JS_ASSERT(tag >= 0);