Bug 1153592 part 2 - Remove JSPROP_SHARED; ensure accessor props don't have slots. r=evilpie

This commit is contained in:
Jan de Mooij 2017-09-26 12:26:50 +02:00
Родитель c6ddca339e
Коммит dbca189324
24 изменённых файлов: 56 добавлений и 74 удалений

Просмотреть файл

@ -2732,8 +2732,7 @@ class AttrDefiner(PropertyDefiner):
def flags(attr):
unforgeable = " | JSPROP_PERMANENT" if self.unforgeable else ""
enumerable = " | %s" % EnumerabilityFlags(attr)
return ("JSPROP_SHARED" + enumerable + unforgeable)
return EnumerabilityFlags(attr) + unforgeable
def getter(attr):
if self.static:

Просмотреть файл

@ -1660,7 +1660,7 @@ Console::PopulateConsoleNotificationInTheTargetScope(JSContext* aCx,
if (NS_WARN_IF(!JS_DefineProperty(aCx, eventObj, "stacktrace",
JS_DATA_TO_FUNC_PTR(JSNative, funObj.get()),
nullptr,
JSPROP_ENUMERATE | JSPROP_SHARED |
JSPROP_ENUMERATE |
JSPROP_GETTER | JSPROP_SETTER))) {
return false;
}

Просмотреть файл

@ -45,7 +45,7 @@ public:
const char16_t* GetName() const { return mName; }
unsigned AccessorAttributes() const {
return JSPROP_SHARED | JSPROP_GETTER | JSPROP_SETTER |
return JSPROP_GETTER | JSPROP_SETTER |
(mJSAttributes & (JSPROP_ENUMERATE | JSPROP_PERMANENT));
}

Просмотреть файл

@ -213,7 +213,7 @@ nsXBLProtoImplProperty::CompileMember(AutoJSAPI& jsapi, const nsString& aClassSt
mGetter.SetJSFunction(getterObject);
if (mGetter.GetJSFunction() && NS_SUCCEEDED(rv)) {
mJSAttributes |= JSPROP_GETTER | JSPROP_SHARED;
mJSAttributes |= JSPROP_GETTER;
}
if (NS_FAILED(rv)) {
mGetter.SetJSFunction(nullptr);
@ -259,7 +259,7 @@ nsXBLProtoImplProperty::CompileMember(AutoJSAPI& jsapi, const nsString& aClassSt
mSetter.SetJSFunction(setterObject);
if (mSetter.GetJSFunction() && NS_SUCCEEDED(rv)) {
mJSAttributes |= JSPROP_SETTER | JSPROP_SHARED;
mJSAttributes |= JSPROP_SETTER;
}
if (NS_FAILED(rv)) {
mSetter.SetJSFunction(nullptr);
@ -308,7 +308,7 @@ nsXBLProtoImplProperty::Read(nsIObjectInputStream* aStream,
nsresult rv = XBL_DeserializeFunction(aStream, &getterObject);
NS_ENSURE_SUCCESS(rv, rv);
mJSAttributes |= JSPROP_GETTER | JSPROP_SHARED;
mJSAttributes |= JSPROP_GETTER;
}
mGetter.SetJSFunction(getterObject);
@ -318,7 +318,7 @@ nsXBLProtoImplProperty::Read(nsIObjectInputStream* aStream,
nsresult rv = XBL_DeserializeFunction(aStream, &setterObject);
NS_ENSURE_SUCCESS(rv, rv);
mJSAttributes |= JSPROP_SETTER | JSPROP_SHARED;
mJSAttributes |= JSPROP_SETTER;
}
mSetter.SetJSFunction(setterObject);

Просмотреть файл

@ -6120,7 +6120,7 @@ StructType::DefineInternal(JSContext* cx, JSObject* typeObj_, JSObject* fieldsOb
nameChars.twoByteChars(), name->length(),
JS_DATA_TO_FUNC_PTR(JSNative, getterObj.get()),
JS_DATA_TO_FUNC_PTR(JSNative, setterObj.get()),
JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_GETTER | JSPROP_SETTER))
JSPROP_ENUMERATE | JSPROP_PERMANENT | JSPROP_GETTER | JSPROP_SETTER))
{
return false;
}

Просмотреть файл

@ -36,12 +36,12 @@ BEGIN_TEST(testDefineGetterSetterNonEnumerable)
CHECK(JS_DefineProperty(cx, vObject, PROPERTY_NAME,
JS_DATA_TO_FUNC_PTR(JSNative, (JSObject*) funGetObj),
JS_DATA_TO_FUNC_PTR(JSNative, (JSObject*) funSetObj),
JSPROP_GETTER | JSPROP_SETTER | JSPROP_SHARED | JSPROP_ENUMERATE));
JSPROP_GETTER | JSPROP_SETTER | JSPROP_ENUMERATE));
CHECK(JS_DefineProperty(cx, vObject, PROPERTY_NAME,
JS_DATA_TO_FUNC_PTR(JSNative, (JSObject*) funGetObj),
JS_DATA_TO_FUNC_PTR(JSNative, (JSObject*) funSetObj),
JSPROP_GETTER | JSPROP_SETTER | JSPROP_SHARED | JSPROP_PERMANENT));
JSPROP_GETTER | JSPROP_SETTER | JSPROP_PERMANENT));
JS::Rooted<JS::PropertyDescriptor> desc(cx);
CHECK(JS_GetOwnPropertyDescriptor(cx, vObject, PROPERTY_NAME, &desc));

Просмотреть файл

@ -17,7 +17,7 @@ BEGIN_TEST(testDefineProperty_bug564344)
JS::RootedObject obj(cx, x.toObjectOrNull());
for (int i = 0; i < 2; i++)
CHECK(JS_DefineProperty(cx, obj, "q", JS::UndefinedHandleValue, JSPROP_SHARED));
CHECK(JS_DefineProperty(cx, obj, "q", JS::UndefinedHandleValue, 0));
return true;
}
END_TEST(testDefineProperty_bug564344)

Просмотреть файл

@ -47,7 +47,7 @@ BEGIN_TEST(testDefinePropertyIgnoredAttributes)
// aren't passing it.
CHECK(JS_DefineProperty(cx, obj, "foo",
Getter, nullptr,
JSPROP_IGNORE_ENUMERATE | JSPROP_IGNORE_PERMANENT | JSPROP_SHARED));
JSPROP_IGNORE_ENUMERATE | JSPROP_IGNORE_PERMANENT));
CHECK(JS_GetOwnPropertyDescriptor(cx, obj, "foo", &desc));
@ -57,7 +57,7 @@ BEGIN_TEST(testDefinePropertyIgnoredAttributes)
// Install another configurable property, so we can futz with it.
CHECK(JS_DefineProperty(cx, obj, "bar",
Getter, nullptr,
JSPROP_IGNORE_ENUMERATE | JSPROP_SHARED));
JSPROP_IGNORE_ENUMERATE));
CHECK(JS_GetOwnPropertyDescriptor(cx, obj, "bar", &desc));
CHECK(CheckDescriptor(desc, AccessorDescriptor, false, true, true));
@ -65,7 +65,7 @@ BEGIN_TEST(testDefinePropertyIgnoredAttributes)
// unchanged.
CHECK(JS_DefineProperty(cx, obj, "bar",
Getter, nullptr,
JSPROP_IGNORE_PERMANENT | JSPROP_ENUMERATE | JSPROP_SHARED));
JSPROP_IGNORE_PERMANENT | JSPROP_ENUMERATE));
CHECK(JS_GetOwnPropertyDescriptor(cx, obj, "bar", &desc));
CHECK(CheckDescriptor(desc, AccessorDescriptor, true, true, true));

Просмотреть файл

@ -16,7 +16,7 @@ BEGIN_TEST(testSetProperty_NativeGetterStubSetter)
CHECK(JS_DefineProperty(cx, obj, "prop",
JS_PROPERTYOP_GETTER(NativeGet), nullptr,
JSPROP_SHARED | JSPROP_PROPOP_ACCESSORS));
JSPROP_PROPOP_ACCESSORS));
EXEC("'use strict'; \n"
"var error, passed = false; \n"

Просмотреть файл

@ -875,11 +875,6 @@ static const uint8_t JSPROP_GETTER = 0x10;
/* property holds setter function */
static const uint8_t JSPROP_SETTER = 0x20;
/* don't allocate a value slot for this property; don't copy the property on set
of the same-named property in an object that delegates to a prototype
containing this property */
static const uint8_t JSPROP_SHARED = 0x40;
/* internal JS engine use only */
static const uint8_t JSPROP_INTERNAL_USE_BIT = 0x80;
@ -2278,23 +2273,23 @@ inline int CheckIsSetterOp(JSSetterOp op);
*/
#define JS_PSG(name, getter, flags) \
JS_PS_ACCESSOR_SPEC(name, JSNATIVE_WRAPPER(getter), JSNATIVE_WRAPPER(nullptr), flags, \
JSPROP_SHARED)
0)
#define JS_PSGS(name, getter, setter, flags) \
JS_PS_ACCESSOR_SPEC(name, JSNATIVE_WRAPPER(getter), JSNATIVE_WRAPPER(setter), flags, \
JSPROP_SHARED)
0)
#define JS_SYM_GET(symbol, getter, flags) \
JS_PS_ACCESSOR_SPEC(reinterpret_cast<const char*>(uint32_t(::JS::SymbolCode::symbol) + 1), \
JSNATIVE_WRAPPER(getter), JSNATIVE_WRAPPER(nullptr), flags, JSPROP_SHARED)
JSNATIVE_WRAPPER(getter), JSNATIVE_WRAPPER(nullptr), flags, 0)
#define JS_SELF_HOSTED_GET(name, getterName, flags) \
JS_PS_ACCESSOR_SPEC(name, SELFHOSTED_WRAPPER(getterName), JSNATIVE_WRAPPER(nullptr), flags, \
JSPROP_SHARED | JSPROP_GETTER)
JSPROP_GETTER)
#define JS_SELF_HOSTED_GETSET(name, getterName, setterName, flags) \
JS_PS_ACCESSOR_SPEC(name, SELFHOSTED_WRAPPER(getterName), SELFHOSTED_WRAPPER(setterName), \
flags, JSPROP_SHARED | JSPROP_GETTER | JSPROP_SETTER)
flags, JSPROP_GETTER | JSPROP_SETTER)
#define JS_SELF_HOSTED_SYM_GET(symbol, getterName, flags) \
JS_PS_ACCESSOR_SPEC(reinterpret_cast<const char*>(uint32_t(::JS::SymbolCode::symbol) + 1), \
SELFHOSTED_WRAPPER(getterName), JSNATIVE_WRAPPER(nullptr), flags, \
JSPROP_SHARED | JSPROP_GETTER)
JSPROP_GETTER)
#define JS_STRING_PS(name, string, flags) \
JS_PS_VALUE_SPEC(name, STRINGVALUE_WRAPPER(string), flags)
#define JS_STRING_SYM_PS(symbol, string, flags) \
@ -2864,7 +2859,6 @@ class WrappedPtrOperations<JS::PropertyDescriptor, Wrapper>
}
bool hasGetterOrSetter() const { return desc().getter || desc().setter; }
bool isShared() const { return has(JSPROP_SHARED); }
JS::HandleObject object() const {
return JS::HandleObject::fromMarkedLocation(&desc().obj);
@ -2881,14 +2875,12 @@ class WrappedPtrOperations<JS::PropertyDescriptor, Wrapper>
JSPROP_IGNORE_VALUE |
JSPROP_GETTER |
JSPROP_SETTER |
JSPROP_SHARED |
JSPROP_REDEFINE_NONCONFIGURABLE |
JSPROP_RESOLVING |
SHADOWABLE)) == 0);
MOZ_ASSERT(!hasAll(JSPROP_IGNORE_ENUMERATE | JSPROP_ENUMERATE));
MOZ_ASSERT(!hasAll(JSPROP_IGNORE_PERMANENT | JSPROP_PERMANENT));
if (isAccessorDescriptor()) {
MOZ_ASSERT(has(JSPROP_SHARED));
MOZ_ASSERT(!has(JSPROP_READONLY));
MOZ_ASSERT(!has(JSPROP_IGNORE_READONLY));
MOZ_ASSERT(!has(JSPROP_IGNORE_VALUE));
@ -2917,7 +2909,6 @@ class WrappedPtrOperations<JS::PropertyDescriptor, Wrapper>
JSPROP_READONLY |
JSPROP_GETTER |
JSPROP_SETTER |
JSPROP_SHARED |
JSPROP_REDEFINE_NONCONFIGURABLE |
JSPROP_RESOLVING |
SHADOWABLE)) == 0);
@ -3018,12 +3009,12 @@ class MutableWrappedPtrOperations<JS::PropertyDescriptor, Wrapper>
void setGetterObject(JSObject* obj) {
desc().getter = reinterpret_cast<JSGetterOp>(obj);
desc().attrs &= ~(JSPROP_IGNORE_VALUE | JSPROP_IGNORE_READONLY | JSPROP_READONLY);
desc().attrs |= JSPROP_GETTER | JSPROP_SHARED;
desc().attrs |= JSPROP_GETTER;
}
void setSetterObject(JSObject* obj) {
desc().setter = reinterpret_cast<JSSetterOp>(obj);
desc().attrs &= ~(JSPROP_IGNORE_VALUE | JSPROP_IGNORE_READONLY | JSPROP_READONLY);
desc().attrs |= JSPROP_SETTER | JSPROP_SHARED;
desc().attrs |= JSPROP_SETTER;
}
JS::MutableHandleObject getterObject() {

Просмотреть файл

@ -1047,7 +1047,7 @@ AddLengthProperty(JSContext* cx, HandleArrayObject obj)
return NativeObject::addProperty(cx, obj, lengthId, array_length_getter, array_length_setter,
SHAPE_INVALID_SLOT,
JSPROP_PERMANENT | JSPROP_SHARED | JSPROP_SHADOWABLE,
JSPROP_PERMANENT | JSPROP_SHADOWABLE,
0, /* allowDictionary = */ false);
}

Просмотреть файл

@ -8657,7 +8657,7 @@ NewMemoryInfoObject(JSContext* cx)
#endif
if (!JS_DefineProperty(cx, obj, pair.name,
getter, nullptr,
JSPROP_ENUMERATE | JSPROP_SHARED))
JSPROP_ENUMERATE))
{
return nullptr;
}
@ -8692,7 +8692,7 @@ NewMemoryInfoObject(JSContext* cx)
#endif
if (!JS_DefineProperty(cx, zoneObj, pair.name,
getter, nullptr,
JSPROP_ENUMERATE | JSPROP_SHARED))
JSPROP_ENUMERATE))
{
return nullptr;
}

Просмотреть файл

@ -361,7 +361,7 @@ js::ToPropertyDescriptor(JSContext* cx, HandleValue descval, bool checkAccessors
js_getter_str);
return false;
}
attrs |= JSPROP_GETTER | JSPROP_SHARED;
attrs |= JSPROP_GETTER;
}
// step 9
@ -379,7 +379,7 @@ js::ToPropertyDescriptor(JSContext* cx, HandleValue descval, bool checkAccessors
js_setter_str);
return false;
}
attrs |= JSPROP_SETTER | JSPROP_SHARED;
attrs |= JSPROP_SETTER;
}
// step 10
@ -395,7 +395,6 @@ js::ToPropertyDescriptor(JSContext* cx, HandleValue descval, bool checkAccessors
desc.setAttributes(attrs);
MOZ_ASSERT_IF(attrs & JSPROP_READONLY, !(attrs & (JSPROP_GETTER | JSPROP_SETTER)));
MOZ_ASSERT_IF(attrs & (JSPROP_GETTER | JSPROP_SETTER), attrs & JSPROP_SHARED);
return true;
}
@ -425,7 +424,7 @@ js::CompletePropertyDescriptor(MutableHandle<PropertyDescriptor> desc)
desc.setGetterObject(nullptr);
if (!desc.hasSetterObject())
desc.setSetterObject(nullptr);
desc.attributesRef() |= JSPROP_GETTER | JSPROP_SETTER | JSPROP_SHARED;
desc.attributesRef() |= JSPROP_GETTER | JSPROP_SETTER;
}
if (!desc.hasConfigurable())
desc.attributesRef() |= JSPROP_PERMANENT;
@ -3526,7 +3525,6 @@ DumpProperty(const NativeObject* obj, Shape& shape, js::GenericPrinter& out)
if (attrs & JSPROP_ENUMERATE) out.put("enumerate ");
if (attrs & JSPROP_READONLY) out.put("readonly ");
if (attrs & JSPROP_PERMANENT) out.put("permanent ");
if (attrs & JSPROP_SHARED) out.put("shared ");
if (shape.hasGetterValue())
out.printf("getterValue=%p ", (void*) shape.getterObject());

Просмотреть файл

@ -7273,7 +7273,7 @@ static const JSJitInfo doFoo_methodinfo = {
static const JSPropertySpec dom_props[] = {
{"x",
JSPROP_SHARED | JSPROP_ENUMERATE,
JSPROP_ENUMERATE,
{ {
{ { dom_genericGetter, &dom_x_getterinfo } },
{ { dom_genericSetter, &dom_x_setterinfo } }

Просмотреть файл

@ -576,7 +576,7 @@ MappedArgumentsObject::obj_resolve(JSContext* cx, HandleObject obj, HandleId id,
return true;
}
unsigned attrs = JSPROP_SHARED | JSPROP_SHADOWABLE | JSPROP_RESOLVING;
unsigned attrs = JSPROP_SHADOWABLE | JSPROP_RESOLVING;
if (JSID_IS_INT(id)) {
uint32_t arg = uint32_t(JSID_TO_INT(id));
if (arg >= argsobj->initialLength() || argsobj->isElementDeleted(arg))
@ -776,7 +776,7 @@ UnmappedArgumentsObject::obj_resolve(JSContext* cx, HandleObject obj, HandleId i
return true;
}
unsigned attrs = JSPROP_SHARED | JSPROP_SHADOWABLE;
unsigned attrs = JSPROP_SHADOWABLE;
GetterOp getter = UnmappedArgGetter;
SetterOp setter = UnmappedArgSetter;
@ -793,7 +793,7 @@ UnmappedArgumentsObject::obj_resolve(JSContext* cx, HandleObject obj, HandleId i
if (!JSID_IS_ATOM(id, cx->names().callee))
return true;
attrs = JSPROP_PERMANENT | JSPROP_GETTER | JSPROP_SETTER | JSPROP_SHARED;
attrs = JSPROP_PERMANENT | JSPROP_GETTER | JSPROP_SETTER;
getter = CastAsGetterOp(argsobj->global().getThrowTypeError());
setter = CastAsSetterOp(argsobj->global().getThrowTypeError());
}

Просмотреть файл

@ -8484,7 +8484,7 @@ DebuggerArguments::create(JSContext* cx, HandleObject proto, HandleDebuggerFrame
if (!getobj ||
!NativeDefineAccessorProperty(cx, obj, id,
JS_DATA_TO_FUNC_PTR(GetterOp, getobj.get()), nullptr,
JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_GETTER))
JSPROP_ENUMERATE | JSPROP_GETTER))
{
return nullptr;
}

Просмотреть файл

@ -4805,10 +4805,10 @@ js::InitGetterSetterOperation(JSContext* cx, jsbytecode* pc, HandleObject obj, H
MOZ_ASSERT(val->isCallable());
GetterOp getter;
SetterOp setter;
unsigned attrs = JSPROP_SHARED;
JSOp op = JSOp(*pc);
unsigned attrs = 0;
if (!IsHiddenInitOp(op))
attrs |= JSPROP_ENUMERATE;

Просмотреть файл

@ -2064,8 +2064,6 @@ js::NativeGetOwnPropertyDescriptor(JSContext* cx, HandleNativeObject obj, Handle
desc.setAttributes(GetPropertyAttributes(obj, prop));
if (desc.isAccessorDescriptor()) {
MOZ_ASSERT(desc.isShared());
// The result of GetOwnPropertyDescriptor() must be either undefined or
// a complete property descriptor (per ES6 draft rev 32 (2015 Feb 2)
// 6.1.7.3, Invariants of the Essential Internal Methods).
@ -2095,7 +2093,6 @@ js::NativeGetOwnPropertyDescriptor(JSContext* cx, HandleNativeObject obj, Handle
// desc.getter/setter, and mask away the SHARED bit.
desc.setGetter(nullptr);
desc.setSetter(nullptr);
desc.attributesRef() &= ~JSPROP_SHARED;
if (prop.isDenseOrTypedArrayElement()) {
desc.value().set(obj->getDenseOrTypedArrayElement(JSID_TO_INT(id)));

Просмотреть файл

@ -624,14 +624,14 @@ intrinsic_DefineProperty(JSContext* cx, unsigned argc, Value* vp)
if (getter.isObject())
desc.setGetterObject(&getter.toObject());
if (!getter.isNull())
attrs |= JSPROP_GETTER | JSPROP_SHARED;
attrs |= JSPROP_GETTER;
Value setter = args[4];
MOZ_ASSERT(setter.isObject() || setter.isNullOrUndefined());
if (setter.isObject())
desc.setSetterObject(&setter.toObject());
if (!setter.isNull())
attrs |= JSPROP_SETTER | JSPROP_SHARED;
attrs |= JSPROP_SETTER;
// By convention, these bits are not used on accessor descriptors.
attrs &= ~(JSPROP_IGNORE_READONLY | JSPROP_IGNORE_VALUE);

Просмотреть файл

@ -681,7 +681,7 @@ AssertCanChangeAttrs(Shape* shape, unsigned attrs)
/* Reject attempts to remove a slot from the permanent data property. */
MOZ_ASSERT_IF(shape->isDataDescriptor() && shape->hasSlot(),
!(attrs & (JSPROP_GETTER | JSPROP_SETTER | JSPROP_SHARED)));
!(attrs & (JSPROP_GETTER | JSPROP_SETTER)));
#endif
}
@ -745,7 +745,8 @@ NativeObject::putProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
*/
bool hadSlot = shape->hasSlot();
uint32_t oldSlot = shape->maybeSlot();
if (!(attrs & JSPROP_SHARED) && slot == SHAPE_INVALID_SLOT && hadSlot)
bool needSlot = !getter && !setter;
if (needSlot && slot == SHAPE_INVALID_SLOT && hadSlot)
slot = oldSlot;
Rooted<UnownedBaseShape*> nbase(cx);
@ -777,7 +778,7 @@ NativeObject::putProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
shape = entry->shape();
}
MOZ_ASSERT_IF(shape->hasSlot() && !(attrs & JSPROP_SHARED), shape->slot() == slot);
MOZ_ASSERT_IF(shape->hasSlot() && needSlot, shape->slot() == slot);
if (obj->inDictionaryMode()) {
/*
@ -799,7 +800,7 @@ NativeObject::putProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
* FIXME bug 593129 -- slot allocation and NativeObject *this must move
* out of here!
*/
if (slot == SHAPE_INVALID_SLOT && !(attrs & JSPROP_SHARED)) {
if (slot == SHAPE_INVALID_SLOT && needSlot) {
if (!allocDictionarySlot(cx, obj, &slot))
return nullptr;
}
@ -809,8 +810,6 @@ NativeObject::putProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
else
shape->base_ = nbase;
MOZ_ASSERT_IF(attrs & (JSPROP_GETTER | JSPROP_SETTER), attrs & JSPROP_SHARED);
shape->setSlot(slot);
shape->attrs = uint8_t(attrs);
shape->flags = flags | Shape::IN_DICTIONARY | (accessorShape ? Shape::ACCESSOR_SHAPE : 0);
@ -874,11 +873,12 @@ NativeObject::changeProperty(JSContext* cx, HandleNativeObject obj, HandleShape
unsigned attrs, GetterOp getter, SetterOp setter)
{
MOZ_ASSERT(obj->containsPure(shape));
MOZ_ASSERT_IF(attrs & (JSPROP_GETTER | JSPROP_SETTER), attrs & JSPROP_SHARED);
/* Allow only shared (slotless) => unshared (slotful) transition. */
MOZ_ASSERT(!((attrs ^ shape->attrs) & JSPROP_SHARED) ||
!(attrs & JSPROP_SHARED));
#ifdef DEBUG
bool needSlot = !getter && !setter;
MOZ_ASSERT_IF(shape->hasSlot() != needSlot, needSlot);
#endif
MarkTypePropertyNonData(cx, obj, shape->propid());
@ -1800,7 +1800,6 @@ Shape::dump(js::GenericPrinter& out) const
DUMP_ATTR(PERMANENT, permanent);
DUMP_ATTR(GETTER, getter);
DUMP_ATTR(SETTER, setter);
DUMP_ATTR(SHARED, shared);
#undef DUMP_ATTR
out.putChar(')');
}

Просмотреть файл

@ -1013,7 +1013,7 @@ class Shape : public gc::TenuredCell
BaseShape* base() const { return base_.get(); }
bool hasSlot() const {
return (attrs & JSPROP_SHARED) == 0;
return !isEmptyShape() && !getter() && !setter();
}
uint32_t slot() const { MOZ_ASSERT(hasSlot() && !hasMissingSlot()); return maybeSlot(); }
uint32_t maybeSlot() const {
@ -1450,7 +1450,6 @@ struct StackShape
MOZ_ASSERT(base);
MOZ_ASSERT(!JSID_IS_VOID(propid));
MOZ_ASSERT(slot <= SHAPE_INVALID_SLOT);
MOZ_ASSERT_IF(attrs & (JSPROP_GETTER | JSPROP_SETTER), attrs & JSPROP_SHARED);
}
explicit StackShape(Shape* shape)
@ -1473,7 +1472,10 @@ struct StackShape
this->rawSetter = rawSetter;
}
bool hasSlot() const { return (attrs & JSPROP_SHARED) == 0; }
bool hasSlot() const {
MOZ_ASSERT(!JSID_IS_EMPTY(propid));
return !rawGetter && !rawSetter;
}
bool hasMissingSlot() const { return maybeSlot() == SHAPE_INVALID_SLOT; }
uint32_t slot() const { MOZ_ASSERT(hasSlot() && !hasMissingSlot()); return slot_; }
@ -1546,7 +1548,6 @@ Shape::Shape(const StackShape& other, uint32_t nfixed)
MOZ_ASSERT_IF(!isEmptyShape(), AtomIsMarked(zone(), propid()));
MOZ_ASSERT_IF(attrs & (JSPROP_GETTER | JSPROP_SETTER), attrs & JSPROP_SHARED);
kids.setNull();
}
@ -1567,7 +1568,7 @@ Shape::Shape(UnownedBaseShape* base, uint32_t nfixed)
: base_(base),
propid_(JSID_EMPTY),
slotInfo(SHAPE_INVALID_SLOT | (nfixed << FIXED_SLOTS_SHIFT)),
attrs(JSPROP_SHARED),
attrs(0),
flags(0),
parent(nullptr)
{

Просмотреть файл

@ -1370,7 +1370,7 @@ XRE_XPCShellMain(int argc, char** argv, char** envp,
JS_DefineProperty(cx, glob, "__LOCATION__",
GetLocationProperty, nullptr,
JSPROP_SHARED);
0);
{
// We are almost certainly going to run script here, so we need an

Просмотреть файл

@ -350,7 +350,7 @@ DefinePropertyIfFound(XPCCallContext& ccx,
if (!funobj)
return false;
propFlags |= JSPROP_GETTER | JSPROP_SHARED;
propFlags |= JSPROP_GETTER;
propFlags &= ~JSPROP_ENUMERATE;
AutoResolveName arn(ccx, id);
@ -434,7 +434,7 @@ DefinePropertyIfFound(XPCCallContext& ccx,
MOZ_ASSERT(member->IsAttribute(), "way broken!");
propFlags |= JSPROP_GETTER | JSPROP_SHARED;
propFlags |= JSPROP_GETTER;
propFlags &= ~JSPROP_READONLY;
JSObject* funobj = funval.toObjectOrNull();
JSNative getter = JS_DATA_TO_FUNC_PTR(JSNative, funobj);

Просмотреть файл

@ -1543,9 +1543,6 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext* cx, HandleObject wr
if (member->IsWritableAttribute())
attrs |= JSPROP_SETTER;
// Make the property shared on the holder so no slot is allocated
// for it. This avoids keeping garbage alive through that slot.
attrs |= JSPROP_SHARED;
desc.setAttributes(attrs);
} else {
// This is a method. Clone a function for it.
@ -1651,7 +1648,7 @@ XrayTraits::resolveOwnProperty(JSContext* cx, HandleObject wrapper, HandleObject
if (!JS_AlreadyHasOwnPropertyById(cx, holder, id, &found))
return false;
if (!found && !JS_DefinePropertyById(cx, holder, id, wrappedJSObject_getter, nullptr,
JSPROP_ENUMERATE | JSPROP_SHARED)) {
JSPROP_ENUMERATE)) {
return false;
}
if (!JS_GetOwnPropertyDescriptorById(cx, holder, id, desc))