зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1002737 - Convert PropDesc::pd_ to a JSObject *. (r=jorendorff)
This commit is contained in:
Родитель
1747cb6e6c
Коммит
42141896c8
|
@ -268,7 +268,7 @@ js::NewPropertyDescriptorObject(JSContext *cx, Handle<PropertyDescriptor> desc,
|
|||
d.initFromPropertyDescriptor(desc);
|
||||
if (!d.makeObject(cx))
|
||||
return false;
|
||||
vp.set(d.pd());
|
||||
vp.set(d.descriptorValue());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ void
|
|||
PropDesc::initFromPropertyDescriptor(Handle<PropertyDescriptor> desc)
|
||||
{
|
||||
isUndefined_ = false;
|
||||
pd_.setUndefined();
|
||||
descObj_ = nullptr;
|
||||
attrs = uint8_t(desc.attributes());
|
||||
JS_ASSERT_IF(attrs & JSPROP_READONLY, !(attrs & (JSPROP_GETTER | JSPROP_SETTER)));
|
||||
if (desc.hasGetterOrSetterObject()) {
|
||||
|
@ -333,7 +333,7 @@ PropDesc::makeObject(JSContext *cx)
|
|||
return false;
|
||||
}
|
||||
|
||||
pd_.setObject(*obj);
|
||||
descObj_ = obj;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -443,7 +443,7 @@ PropDesc::initialize(JSContext *cx, const Value &origval, bool checkAccessors)
|
|||
RootedObject desc(cx, &v.toObject());
|
||||
|
||||
/* Make a copy of the descriptor. We might need it later. */
|
||||
pd_ = v;
|
||||
descObj_ = desc;
|
||||
|
||||
isUndefined_ = false;
|
||||
|
||||
|
@ -1048,7 +1048,7 @@ js::DefineProperty(JSContext *cx, HandleObject obj, HandleId id, const PropDesc
|
|||
* TrapDefineOwnProperty directly
|
||||
*/
|
||||
if (obj->is<ProxyObject>()) {
|
||||
RootedValue pd(cx, desc.pd());
|
||||
RootedValue pd(cx, desc.descriptorValue());
|
||||
return Proxy::defineProperty(cx, obj, id, pd);
|
||||
}
|
||||
return Reject(cx, obj, JSMSG_OBJECT_NOT_EXTENSIBLE, throwError, rval);
|
||||
|
@ -1135,7 +1135,7 @@ js::DefineProperties(JSContext *cx, HandleObject obj, HandleObject props)
|
|||
*/
|
||||
if (obj->is<ProxyObject>()) {
|
||||
for (size_t i = 0, len = ids.length(); i < len; i++) {
|
||||
RootedValue pd(cx, descs[i].pd());
|
||||
RootedValue pd(cx, descs[i].descriptorValue());
|
||||
if (!Proxy::defineProperty(cx, obj, ids[i], pd))
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -644,7 +644,7 @@ namespace js {
|
|||
|
||||
PropDesc::PropDesc(const Value &getter, const Value &setter,
|
||||
Enumerability enumerable, Configurability configurable)
|
||||
: pd_(UndefinedValue()),
|
||||
: descObj_(nullptr),
|
||||
value_(UndefinedValue()),
|
||||
get_(getter), set_(setter),
|
||||
attrs(JSPROP_GETTER | JSPROP_SETTER | JSPROP_SHARED |
|
||||
|
|
|
@ -1111,7 +1111,7 @@ FromGenericPropertyDescriptor(JSContext *cx, MutableHandle<PropDesc> desc, Mutab
|
|||
// steps 3-9
|
||||
if (!desc.makeObject(cx))
|
||||
return false;
|
||||
rval.set(desc.pd());
|
||||
rval.set(desc.descriptorValue());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -5334,7 +5334,7 @@ DebuggerObject_defineProperty(JSContext *cx, unsigned argc, Value *vp)
|
|||
Rooted<PropDesc> desc(cx);
|
||||
if (!desc.initialize(cx, args[1], false))
|
||||
return false;
|
||||
desc.clearPd();
|
||||
desc.clearDescriptorObject();
|
||||
|
||||
if (!dbg->unwrapPropDescInto(cx, obj, desc, &desc))
|
||||
return false;
|
||||
|
|
|
@ -25,7 +25,7 @@ PropDesc::PropDesc()
|
|||
void
|
||||
PropDesc::setUndefined()
|
||||
{
|
||||
pd_ = UndefinedValue();
|
||||
descObj_ = nullptr;
|
||||
value_ = UndefinedValue();
|
||||
get_ = UndefinedValue();
|
||||
set_ = UndefinedValue();
|
||||
|
@ -333,7 +333,8 @@ js::ObjectImpl::markChildren(JSTracer *trc)
|
|||
void
|
||||
PropDesc::trace(JSTracer *trc)
|
||||
{
|
||||
gc::MarkValueRoot(trc, &pd_, "PropDesc pd");
|
||||
if (descObj_)
|
||||
gc::MarkObjectRoot(trc, &descObj_, "PropDesc descriptor object");
|
||||
gc::MarkValueRoot(trc, &value_, "PropDesc value");
|
||||
gc::MarkValueRoot(trc, &get_, "PropDesc get");
|
||||
gc::MarkValueRoot(trc, &set_, "PropDesc set");
|
||||
|
|
|
@ -34,7 +34,7 @@ struct PropDesc {
|
|||
* Original object from which this descriptor derives, passed through for
|
||||
* the benefit of proxies.
|
||||
*/
|
||||
Value pd_;
|
||||
JSObject *descObj_;
|
||||
|
||||
Value value_, get_, set_;
|
||||
|
||||
|
@ -53,7 +53,7 @@ struct PropDesc {
|
|||
bool isUndefined_ : 1;
|
||||
|
||||
explicit PropDesc(const Value &v)
|
||||
: pd_(UndefinedValue()),
|
||||
: descObj_(nullptr),
|
||||
value_(v),
|
||||
get_(UndefinedValue()), set_(UndefinedValue()),
|
||||
attrs(0),
|
||||
|
@ -80,7 +80,7 @@ struct PropDesc {
|
|||
|
||||
PropDesc(const Value &v, Writability writable,
|
||||
Enumerability enumerable, Configurability configurable)
|
||||
: pd_(UndefinedValue()),
|
||||
: descObj_(nullptr),
|
||||
value_(v),
|
||||
get_(UndefinedValue()), set_(UndefinedValue()),
|
||||
attrs((writable ? 0 : JSPROP_READONLY) |
|
||||
|
@ -138,8 +138,11 @@ struct PropDesc {
|
|||
bool hasEnumerable() const { MOZ_ASSERT(!isUndefined()); return hasEnumerable_; }
|
||||
bool hasConfigurable() const { MOZ_ASSERT(!isUndefined()); return hasConfigurable_; }
|
||||
|
||||
Value pd() const { MOZ_ASSERT(!isUndefined()); return pd_; }
|
||||
void clearPd() { pd_ = UndefinedValue(); }
|
||||
Value descriptorValue() const {
|
||||
MOZ_ASSERT(!isUndefined());
|
||||
return descObj_ ? ObjectValue(*descObj_) : UndefinedValue();
|
||||
}
|
||||
void clearDescriptorObject() { descObj_ = nullptr; }
|
||||
|
||||
uint8_t attributes() const { MOZ_ASSERT(!isUndefined()); return attrs; }
|
||||
|
||||
|
@ -261,7 +264,7 @@ class PropDescOperations
|
|||
bool hasEnumerable() const { return desc()->hasEnumerable(); }
|
||||
bool hasConfigurable() const { return desc()->hasConfigurable(); }
|
||||
|
||||
Value pd() const { return desc()->pd(); }
|
||||
Value descriptorValue() const { return desc()->descriptorValue(); }
|
||||
|
||||
uint8_t attributes() const { return desc()->attributes(); }
|
||||
|
||||
|
@ -321,7 +324,7 @@ class MutablePropDescOperations : public PropDescOperations<Outer>
|
|||
}
|
||||
|
||||
void setUndefined() { desc()->setUndefined(); }
|
||||
void clearPd() { desc()->clearPd(); }
|
||||
void clearDescriptorObject() { desc()->clearDescriptorObject(); }
|
||||
};
|
||||
|
||||
} /* namespace JS */
|
||||
|
@ -333,8 +336,7 @@ struct GCMethods<PropDesc> {
|
|||
static PropDesc initial() { return PropDesc(); }
|
||||
static ThingRootKind kind() { return THING_ROOT_PROP_DESC; }
|
||||
static bool poisoned(const PropDesc &desc) {
|
||||
return (desc.pd_.isGCThing() &&
|
||||
JS::IsPoisonedPtr(desc.pd_.toGCThing())) ||
|
||||
return JS::IsPoisonedPtr(desc.descObj_) ||
|
||||
(desc.value_.isGCThing() &&
|
||||
JS::IsPoisonedPtr(desc.value_.toGCThing())) ||
|
||||
(desc.get_.isGCThing() &&
|
||||
|
|
Загрузка…
Ссылка в новой задаче