diff --git a/js/src/vm/NativeObject.cpp b/js/src/vm/NativeObject.cpp index bbf50eaab7445..ba53d0566288d 100644 --- a/js/src/vm/NativeObject.cpp +++ b/js/src/vm/NativeObject.cpp @@ -498,7 +498,7 @@ NativeObject::sparsifyDenseElement(JSContext* cx, HandleNativeObject obj, uint32 // extensibility check if we're, for example, sparsifying frozen objects.. if (!addDataPropertyInternal(cx, obj, id, slot, obj->getElementsHeader()->elementAttributes(), - 0, entry, true, keep)) { + entry, keep)) { obj->setDenseElementUnchecked(index, value); return false; } @@ -1151,22 +1151,13 @@ NativeObject::freeSlot(JSContext* cx, uint32_t slot) setSlot(slot, UndefinedValue()); } -/* static */ Shape* -NativeObject::addDataProperty(JSContext* cx, HandleNativeObject obj, - jsid idArg, uint32_t slot, unsigned attrs) -{ - MOZ_ASSERT(!(attrs & (JSPROP_GETTER | JSPROP_SETTER))); - RootedId id(cx, idArg); - return addDataProperty(cx, obj, id, slot, attrs, 0); -} - /* static */ Shape* NativeObject::addDataProperty(JSContext* cx, HandleNativeObject obj, HandlePropertyName name, uint32_t slot, unsigned attrs) { MOZ_ASSERT(!(attrs & (JSPROP_GETTER | JSPROP_SETTER))); RootedId id(cx, NameToId(name)); - return addDataProperty(cx, obj, id, slot, attrs, 0); + return addDataProperty(cx, obj, id, slot, attrs); } template @@ -1432,7 +1423,7 @@ AddOrChangeProperty(JSContext* cx, HandleNativeObject obj, HandleId id, if (AddOrChange == IsAddOrChange::Add) { if (Shape::isDataProperty(desc.attributes(), desc.getter(), desc.setter())) { shape = NativeObject::addDataProperty(cx, obj, id, SHAPE_INVALID_SLOT, - desc.attributes(), 0); + desc.attributes()); } else { shape = NativeObject::addAccessorProperty(cx, obj, id, desc.getter(), desc.setter(), desc.attributes(), 0); diff --git a/js/src/vm/NativeObject.h b/js/src/vm/NativeObject.h index 3fd671abb9b10..f8ce2cec3c342 100644 --- a/js/src/vm/NativeObject.h +++ b/js/src/vm/NativeObject.h @@ -854,8 +854,8 @@ class NativeObject : public ShapedObject public: /* Add a property whose id is not yet in this scope. */ static MOZ_ALWAYS_INLINE Shape* addDataProperty(JSContext* cx, HandleNativeObject obj, HandleId id, - uint32_t slot, unsigned attrs, unsigned flags, - bool allowDictionary = true); + uint32_t slot, unsigned attrs); + static MOZ_ALWAYS_INLINE Shape* addAccessorProperty(JSContext* cx, HandleNativeObject obj, HandleId id, JSGetterOp getter, JSSetterOp setter, unsigned attrs, unsigned flags, @@ -863,8 +863,6 @@ class NativeObject : public ShapedObject static Shape* addEnumerableDataProperty(JSContext* cx, HandleNativeObject obj, HandleId id); /* Add a data property whose id is not yet in this scope. */ - static Shape* addDataProperty(JSContext* cx, HandleNativeObject obj, - jsid id_, uint32_t slot, unsigned attrs); static Shape* addDataProperty(JSContext* cx, HandleNativeObject obj, HandlePropertyName name, uint32_t slot, unsigned attrs); @@ -897,8 +895,7 @@ class NativeObject : public ShapedObject */ static Shape* addDataPropertyInternal(JSContext* cx, HandleNativeObject obj, HandleId id, - uint32_t slot, unsigned attrs, unsigned flags, - ShapeTable::Entry* entry, bool allowDictionary, + uint32_t slot, unsigned attrs, ShapeTable::Entry* entry, const AutoKeepShapeTables& keep); static Shape* diff --git a/js/src/vm/Shape-inl.h b/js/src/vm/Shape-inl.h index d94364867bd96..b533a4ca372b0 100644 --- a/js/src/vm/Shape-inl.h +++ b/js/src/vm/Shape-inl.h @@ -392,7 +392,7 @@ Shape::searchNoHashify(Shape* start, jsid id) /* static */ MOZ_ALWAYS_INLINE Shape* NativeObject::addDataProperty(JSContext* cx, HandleNativeObject obj, HandleId id, - uint32_t slot, unsigned attrs, unsigned flags, bool allowDictionary) + uint32_t slot, unsigned attrs) { MOZ_ASSERT(!JSID_IS_VOID(id)); MOZ_ASSERT(obj->uninlinedNonProxyIsExtensible()); @@ -407,7 +407,7 @@ NativeObject::addDataProperty(JSContext* cx, HandleNativeObject obj, HandleId id entry = &table->search(id, keep); } - return addDataPropertyInternal(cx, obj, id, slot, attrs, flags, entry, allowDictionary, keep); + return addDataPropertyInternal(cx, obj, id, slot, attrs, entry, keep); } /* static */ MOZ_ALWAYS_INLINE Shape* diff --git a/js/src/vm/Shape.cpp b/js/src/vm/Shape.cpp index 8d24a61d6a48f..0249f7c3d6cb2 100644 --- a/js/src/vm/Shape.cpp +++ b/js/src/vm/Shape.cpp @@ -547,11 +547,8 @@ NativeObject::addAccessorPropertyInternal(JSContext* cx, NativeObject::addDataPropertyInternal(JSContext* cx, HandleNativeObject obj, HandleId id, uint32_t slot, unsigned attrs, - unsigned flags, ShapeTable::Entry* entry, - bool allowDictionary, const AutoKeepShapeTables& keep) + ShapeTable::Entry* entry, const AutoKeepShapeTables& keep) { - MOZ_ASSERT_IF(!allowDictionary, !obj->inDictionaryMode()); - AutoCheckShapeConsistency check(obj); /* @@ -564,10 +561,7 @@ NativeObject::addDataPropertyInternal(JSContext* cx, (slot == SHAPE_INVALID_SLOT) || obj->lastProperty()->hasMissingSlot() || (slot == obj->lastProperty()->maybeSlot() + 1); - MOZ_ASSERT_IF(!allowDictionary, stableSlot); - if (allowDictionary && - (!stableSlot || ShouldConvertToDictionary(obj))) - { + if (!stableSlot || ShouldConvertToDictionary(obj)) { if (!toDictionaryMode(cx, obj)) return nullptr; table = obj->lastProperty()->maybeTable(keep); @@ -595,7 +589,7 @@ NativeObject::addDataPropertyInternal(JSContext* cx, if (!nbase) return nullptr; - Rooted child(cx, StackShape(nbase, id, slot, attrs, flags)); + Rooted child(cx, StackShape(nbase, id, slot, attrs, 0)); shape = getChildProperty(cx, obj, last, &child); if (!shape) return nullptr; @@ -817,8 +811,7 @@ NativeObject::putDataProperty(JSContext* cx, HandleNativeObject obj, HandleId id */ MOZ_ASSERT(obj->nonProxyIsExtensible()); - return addDataPropertyInternal(cx, obj, id, SHAPE_INVALID_SLOT, attrs, 0, entry, true, - keep); + return addDataPropertyInternal(cx, obj, id, SHAPE_INVALID_SLOT, attrs, entry, keep); } /* Property exists: search must have returned a valid entry. */ diff --git a/js/src/vm/UnboxedObject.cpp b/js/src/vm/UnboxedObject.cpp index d8422158301bc..2ed3144bd9a8d 100644 --- a/js/src/vm/UnboxedObject.cpp +++ b/js/src/vm/UnboxedObject.cpp @@ -394,9 +394,11 @@ MakeReplacementTemplateObject(JSContext* cx, HandleObjectGroup group, const Unbo if (!obj) return nullptr; + RootedId id(cx); for (size_t i = 0; i < layout.properties().length(); i++) { const UnboxedLayout::Property& property = layout.properties()[i]; - if (!NativeObject::addDataProperty(cx, obj, NameToId(property.name), i, JSPROP_ENUMERATE)) + id = NameToId(property.name); + if (!NativeObject::addDataProperty(cx, obj, id, i, JSPROP_ENUMERATE)) return nullptr; MOZ_ASSERT(obj->slotSpan() == i + 1); MOZ_ASSERT(!obj->inDictionaryMode());