Skip to content

Commit

Permalink
Bug 1394831 part 7 - Remove flags and allowDictionary arguments from …
Browse files Browse the repository at this point in the history
…addDataProperty. r=bhackett
  • Loading branch information
jandem committed Nov 1, 2017
1 parent 5b98977 commit 310ec33
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 32 deletions.
15 changes: 3 additions & 12 deletions js/src/vm/NativeObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 <AllowGC allowGC>
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 3 additions & 6 deletions js/src/vm/NativeObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -854,17 +854,15 @@ 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,
bool allowDictionary = true);
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);

Expand Down Expand Up @@ -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*
Expand Down
4 changes: 2 additions & 2 deletions js/src/vm/Shape-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -407,7 +407,7 @@ NativeObject::addDataProperty(JSContext* cx, HandleNativeObject obj, HandleId id
entry = &table->search<MaybeAdding::Adding>(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*
Expand Down
15 changes: 4 additions & 11 deletions js/src/vm/Shape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/*
Expand All @@ -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);
Expand Down Expand Up @@ -595,7 +589,7 @@ NativeObject::addDataPropertyInternal(JSContext* cx,
if (!nbase)
return nullptr;

Rooted<StackShape> child(cx, StackShape(nbase, id, slot, attrs, flags));
Rooted<StackShape> child(cx, StackShape(nbase, id, slot, attrs, 0));
shape = getChildProperty(cx, obj, last, &child);
if (!shape)
return nullptr;
Expand Down Expand Up @@ -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. */
Expand Down
4 changes: 3 additions & 1 deletion js/src/vm/UnboxedObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 310ec33

Please sign in to comment.