зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1002737 - Make AutoPropDescRooter into an AutoVectorRooter. (r=jorendorff)
This commit is contained in:
Родитель
8f1835b4f0
Коммит
4d5e51d5bd
|
@ -388,16 +388,11 @@ AutoGCRooter::trace(JSTracer *trc)
|
|||
return;
|
||||
}
|
||||
|
||||
case DESCRIPTORS: {
|
||||
PropDescArray &descriptors =
|
||||
static_cast<AutoPropDescArrayRooter *>(this)->descriptors;
|
||||
for (size_t i = 0, len = descriptors.length(); i < len; i++) {
|
||||
PropDesc &desc = descriptors[i];
|
||||
MarkValueRoot(trc, &desc.pd_, "PropDesc::pd_");
|
||||
MarkValueRoot(trc, &desc.value_, "PropDesc::value_");
|
||||
MarkValueRoot(trc, &desc.get_, "PropDesc::get_");
|
||||
MarkValueRoot(trc, &desc.set_, "PropDesc::set_");
|
||||
}
|
||||
case DESCVECTOR: {
|
||||
AutoPropDescVector::VectorImpl &descriptors =
|
||||
static_cast<AutoPropDescVector *>(this)->vector;
|
||||
for (size_t i = 0, len = descriptors.length(); i < len; i++)
|
||||
descriptors[i].trace(trc);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ class JS_PUBLIC_API(AutoGCRooter) {
|
|||
PARSER = -3, /* js::frontend::Parser */
|
||||
SHAPEVECTOR = -4, /* js::AutoShapeVector */
|
||||
IDARRAY = -6, /* js::AutoIdArray */
|
||||
DESCRIPTORS = -7, /* js::AutoPropDescArrayRooter */
|
||||
DESCVECTOR = -7, /* js::AutoPropDescVector */
|
||||
VALVECTOR = -10, /* js::AutoValueVector */
|
||||
IDVECTOR = -13, /* js::AutoIdVector */
|
||||
OBJVECTOR = -14, /* js::AutoObjectVector */
|
||||
|
|
|
@ -1090,7 +1090,7 @@ js::DefineOwnProperty(JSContext *cx, HandleObject obj, HandleId id,
|
|||
|
||||
bool
|
||||
js::ReadPropertyDescriptors(JSContext *cx, HandleObject props, bool checkAccessors,
|
||||
AutoIdVector *ids, AutoPropDescArrayRooter *descs)
|
||||
AutoIdVector *ids, AutoPropDescVector *descs)
|
||||
{
|
||||
if (!GetPropertyNames(cx, props, JSITER_OWNONLY, ids))
|
||||
return false;
|
||||
|
@ -1098,11 +1098,11 @@ js::ReadPropertyDescriptors(JSContext *cx, HandleObject props, bool checkAccesso
|
|||
RootedId id(cx);
|
||||
for (size_t i = 0, len = ids->length(); i < len; i++) {
|
||||
id = (*ids)[i];
|
||||
PropDesc* desc = descs->append();
|
||||
Rooted<PropDesc> desc(cx);
|
||||
RootedValue v(cx);
|
||||
if (!desc ||
|
||||
!JSObject::getGeneric(cx, props, props, id, &v) ||
|
||||
!desc->initialize(cx, v, checkAccessors))
|
||||
if (!JSObject::getGeneric(cx, props, props, id, &v) ||
|
||||
!desc.initialize(cx, v, checkAccessors) ||
|
||||
!descs->append(desc))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -1114,7 +1114,7 @@ bool
|
|||
js::DefineProperties(JSContext *cx, HandleObject obj, HandleObject props)
|
||||
{
|
||||
AutoIdVector ids(cx);
|
||||
AutoPropDescArrayRooter descs(cx);
|
||||
AutoPropDescVector descs(cx);
|
||||
if (!ReadPropertyDescriptors(cx, props, true, &ids, &descs))
|
||||
return false;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ struct ObjectsExtraSizes;
|
|||
|
||||
namespace js {
|
||||
|
||||
class AutoPropDescArrayRooter;
|
||||
class AutoPropDescVector;
|
||||
struct GCMarker;
|
||||
struct NativeIterator;
|
||||
class Nursery;
|
||||
|
@ -1401,7 +1401,7 @@ DefineProperties(JSContext *cx, HandleObject obj, HandleObject props);
|
|||
*/
|
||||
extern bool
|
||||
ReadPropertyDescriptors(JSContext *cx, HandleObject props, bool checkAccessors,
|
||||
AutoIdVector *ids, AutoPropDescArrayRooter *descs);
|
||||
AutoIdVector *ids, AutoPropDescVector *descs);
|
||||
|
||||
/* Read the name using a dynamic lookup on the scopeChain. */
|
||||
extern bool
|
||||
|
|
|
@ -772,32 +772,17 @@ IsInternalFunctionObject(JSObject *funobj)
|
|||
return fun->isLambda() && !funobj->getParent();
|
||||
}
|
||||
|
||||
class AutoPropDescArrayRooter : private AutoGCRooter
|
||||
class AutoPropDescVector : public AutoVectorRooter<PropDesc>
|
||||
{
|
||||
public:
|
||||
explicit AutoPropDescArrayRooter(JSContext *cx)
|
||||
: AutoGCRooter(cx, DESCRIPTORS), descriptors(cx)
|
||||
{ }
|
||||
|
||||
PropDesc *append() {
|
||||
if (!descriptors.append(PropDesc()))
|
||||
return nullptr;
|
||||
return &descriptors.back();
|
||||
explicit AutoPropDescVector(JSContext *cx
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoVectorRooter<PropDesc>(cx, DESCVECTOR)
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
|
||||
bool reserve(size_t n) {
|
||||
return descriptors.reserve(n);
|
||||
}
|
||||
|
||||
PropDesc& operator[](size_t i) {
|
||||
JS_ASSERT(i < descriptors.length());
|
||||
return descriptors[i];
|
||||
}
|
||||
|
||||
friend void AutoGCRooter::trace(JSTracer *trc);
|
||||
|
||||
private:
|
||||
PropDescArray descriptors;
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -5354,19 +5354,16 @@ DebuggerObject_defineProperties(JSContext *cx, unsigned argc, Value *vp)
|
|||
return false;
|
||||
|
||||
AutoIdVector ids(cx);
|
||||
AutoPropDescArrayRooter descs(cx);
|
||||
AutoPropDescVector descs(cx);
|
||||
if (!ReadPropertyDescriptors(cx, props, false, &ids, &descs))
|
||||
return false;
|
||||
size_t n = ids.length();
|
||||
|
||||
AutoPropDescArrayRooter unwrappedDescs(cx);
|
||||
AutoPropDescVector unwrappedDescs(cx);
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
if (!unwrappedDescs.append())
|
||||
if (!unwrappedDescs.append(PropDesc()))
|
||||
return false;
|
||||
Handle<PropDesc> wrapped = Handle<PropDesc>::fromMarkedLocation(&descs[i]);
|
||||
MutableHandle<PropDesc> unwrapped =
|
||||
MutableHandle<PropDesc>::fromMarkedLocation(&unwrappedDescs[i]);
|
||||
if (!dbg->unwrapPropDescInto(cx, obj, wrapped, unwrapped))
|
||||
if (!dbg->unwrapPropDescInto(cx, obj, descs[i], unwrappedDescs[i]))
|
||||
return false;
|
||||
if (!unwrappedDescs[i].checkGetter(cx) || !unwrappedDescs[i].checkSetter(cx))
|
||||
return false;
|
||||
|
@ -5374,17 +5371,18 @@ DebuggerObject_defineProperties(JSContext *cx, unsigned argc, Value *vp)
|
|||
|
||||
{
|
||||
AutoIdVector rewrappedIds(cx);
|
||||
AutoPropDescArrayRooter rewrappedDescs(cx);
|
||||
AutoPropDescVector rewrappedDescs(cx);
|
||||
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, obj);
|
||||
RootedId id(cx);
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
if (!rewrappedIds.append(JSID_VOID) || !rewrappedDescs.append())
|
||||
if (!rewrappedIds.append(JSID_VOID) || !rewrappedDescs.append(PropDesc()))
|
||||
return false;
|
||||
id = ids[i];
|
||||
if (!unwrappedDescs[i].wrapInto(cx, obj, id, rewrappedIds[i].address(), &rewrappedDescs[i]))
|
||||
if (!unwrappedDescs[i].get().wrapInto(cx, obj, ids[i], rewrappedIds[i].address(),
|
||||
rewrappedDescs[i].address()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ErrorCopier ec(ac, dbg->toJSObject());
|
||||
|
|
|
@ -64,7 +64,6 @@ struct PropDesc {
|
|||
}
|
||||
|
||||
public:
|
||||
friend void JS::AutoGCRooter::trace(JSTracer *trc);
|
||||
friend struct GCMethods<PropDesc>;
|
||||
|
||||
void trace(JSTracer *trc);
|
||||
|
|
Загрузка…
Ссылка в новой задаче