Bug 1700052 part 14 - Rename DataProperty to Property in a few places. r=jonco

Because these methods are now also used for accessor properties.

Differential Revision: https://phabricator.services.mozilla.com/D110261
This commit is contained in:
Jan de Mooij 2021-04-07 07:16:09 +00:00
Родитель 889dd0226f
Коммит bb9065ded4
7 изменённых файлов: 54 добавлений и 56 удалений

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

@ -3878,7 +3878,7 @@ Shape* StringObject::assignInitialShape(JSContext* cx,
Handle<StringObject*> obj) {
MOZ_ASSERT(obj->empty());
return NativeObject::addDataProperty(cx, obj, cx->names().length, LENGTH_SLOT,
return NativeObject::addProperty(cx, obj, cx->names().length, LENGTH_SLOT,
JSPROP_PERMANENT | JSPROP_READONLY);
}

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

@ -429,15 +429,15 @@ Shape* js::ErrorObject::assignInitialShape(JSContext* cx,
Handle<ErrorObject*> obj) {
MOZ_ASSERT(obj->empty());
if (!NativeObject::addDataProperty(cx, obj, cx->names().fileName,
FILENAME_SLOT, 0)) {
if (!NativeObject::addProperty(cx, obj, cx->names().fileName, FILENAME_SLOT,
0)) {
return nullptr;
}
if (!NativeObject::addDataProperty(cx, obj, cx->names().lineNumber,
if (!NativeObject::addProperty(cx, obj, cx->names().lineNumber,
LINENUMBER_SLOT, 0)) {
return nullptr;
}
return NativeObject::addDataProperty(cx, obj, cx->names().columnNumber,
return NativeObject::addProperty(cx, obj, cx->names().columnNumber,
COLUMNNUMBER_SLOT, 0);
}
@ -462,7 +462,7 @@ bool js::ErrorObject::init(JSContext* cx, Handle<ErrorObject*> obj,
// |new Error("")| -- but not in others -- |new Error(undefined)|,
// |new Error()|.
if (message) {
Shape* messageShape = NativeObject::addDataProperty(
Shape* messageShape = NativeObject::addProperty(
cx, obj, cx->names().message, MESSAGE_SLOT, 0);
if (!messageShape) {
return false;

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

@ -1144,12 +1144,12 @@ void NativeObject::freeSlot(JSContext* cx, uint32_t slot) {
}
/* static */
Shape* NativeObject::addDataProperty(JSContext* cx, HandleNativeObject obj,
Shape* NativeObject::addProperty(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);
return addProperty(cx, obj, id, slot, attrs);
}
template <AllowGC allowGC>
@ -1307,7 +1307,7 @@ static bool ChangeProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
}
}
Shape* shape = NativeObject::putDataProperty(cx, obj, id, attrs);
Shape* shape = NativeObject::putProperty(cx, obj, id, attrs);
if (!shape) {
return false;
}
@ -1371,15 +1371,15 @@ static MOZ_ALWAYS_INLINE bool AddOrChangeProperty(
if (!gs) {
return false;
}
Shape* shape = NativeObject::addDataProperty(
cx, obj, id, SHAPE_INVALID_SLOT, desc.attributes());
Shape* shape = NativeObject::addProperty(cx, obj, id, SHAPE_INVALID_SLOT,
desc.attributes());
if (!shape) {
return false;
}
obj->initSlot(shape->slot(), PrivateGCThingValue(gs));
} else {
Shape* shape = NativeObject::addDataProperty(
cx, obj, id, SHAPE_INVALID_SLOT, desc.attributes());
Shape* shape = NativeObject::addProperty(cx, obj, id, SHAPE_INVALID_SLOT,
desc.attributes());
if (!shape) {
return false;
}
@ -1392,8 +1392,7 @@ static MOZ_ALWAYS_INLINE bool AddOrChangeProperty(
return false;
}
} else {
Shape* shape =
NativeObject::putDataProperty(cx, obj, id, desc.attributes());
Shape* shape = NativeObject::putProperty(cx, obj, id, desc.attributes());
if (!shape) {
return false;
}

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

@ -940,7 +940,7 @@ class NativeObject : public JSObject {
void freeSlot(JSContext* cx, uint32_t slot);
private:
static MOZ_ALWAYS_INLINE Shape* getChildDataProperty(
static MOZ_ALWAYS_INLINE Shape* getChildProperty(
JSContext* cx, HandleNativeObject obj, HandleShape parent,
MutableHandle<StackShape> child);
static MOZ_ALWAYS_INLINE Shape* getChildCustomDataProperty(
@ -956,7 +956,7 @@ class NativeObject : public JSObject {
public:
/* Add a property whose id is not yet in this scope. */
static MOZ_ALWAYS_INLINE Shape* addDataProperty(JSContext* cx,
static MOZ_ALWAYS_INLINE Shape* addProperty(JSContext* cx,
HandleNativeObject obj,
HandleId id, uint32_t slot,
unsigned attrs);
@ -968,13 +968,13 @@ class NativeObject : public JSObject {
HandleId id);
/* Add a data property whose id is not yet in this scope. */
static Shape* addDataProperty(JSContext* cx, HandleNativeObject obj,
static Shape* addProperty(JSContext* cx, HandleNativeObject obj,
HandlePropertyName name, uint32_t slot,
unsigned attrs);
/* Add or overwrite a property for id in this scope. */
static Shape* putDataProperty(JSContext* cx, HandleNativeObject obj,
HandleId id, unsigned attrs);
static Shape* putProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
unsigned attrs);
static Shape* changeCustomDataPropAttributes(JSContext* cx,
HandleNativeObject obj,
@ -986,15 +986,11 @@ class NativeObject : public JSObject {
protected:
/*
* Internal helper that adds a shape not yet mapped by this object.
*
* Notes:
* 1. getter and setter must be normalized based on flags (see jsscope.cpp).
* 2. Checks for non-extensibility must be done by callers.
* Note: checks for non-extensibility must be done by callers.
*/
static Shape* addDataPropertyInternal(JSContext* cx, HandleNativeObject obj,
HandleId id, uint32_t slot,
unsigned attrs, ShapeTable* table,
ShapeTable::Entry* entry,
static Shape* addPropertyInternal(JSContext* cx, HandleNativeObject obj,
HandleId id, uint32_t slot, unsigned attrs,
ShapeTable* table, ShapeTable::Entry* entry,
const AutoKeepShapeCaches& keep);
[[nodiscard]] static bool fillInAfterSwap(JSContext* cx,

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

@ -265,7 +265,7 @@ Shape* RegExpObject::assignInitialShape(JSContext* cx,
static_assert(LAST_INDEX_SLOT == 0);
/* The lastIndex property alone is writable but non-configurable. */
return NativeObject::addDataProperty(cx, self, cx->names().lastIndex,
return NativeObject::addProperty(cx, self, cx->names().lastIndex,
LAST_INDEX_SLOT, JSPROP_PERMANENT);
}

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

@ -347,7 +347,7 @@ MOZ_ALWAYS_INLINE Shape* Shape::searchNoHashify(Shape* start, jsid id) {
return foundShape;
}
/* static */ MOZ_ALWAYS_INLINE Shape* NativeObject::addDataProperty(
/* static */ MOZ_ALWAYS_INLINE Shape* NativeObject::addProperty(
JSContext* cx, HandleNativeObject obj, HandleId id, uint32_t slot,
unsigned attrs) {
MOZ_ASSERT(!JSID_IS_VOID(id));
@ -365,7 +365,7 @@ MOZ_ALWAYS_INLINE Shape* Shape::searchNoHashify(Shape* start, jsid id) {
entry = &table->search<MaybeAdding::Adding>(id, keep);
}
return addDataPropertyInternal(cx, obj, id, slot, attrs, table, entry, keep);
return addPropertyInternal(cx, obj, id, slot, attrs, table, entry, keep);
}
MOZ_ALWAYS_INLINE ObjectFlags GetObjectFlagsForNewProperty(Shape* last, jsid id,

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

@ -355,7 +355,7 @@ Shape* Shape::replaceLastProperty(JSContext* cx, ObjectFlags objectFlags,
* which must be lastProperty() if inDictionaryMode(), else parent must be
* one of lastProperty() or lastProperty()->parent.
*/
/* static */ MOZ_ALWAYS_INLINE Shape* NativeObject::getChildDataProperty(
/* static */ MOZ_ALWAYS_INLINE Shape* NativeObject::getChildProperty(
JSContext* cx, HandleNativeObject obj, HandleShape parent,
MutableHandle<StackShape> child) {
MOZ_ASSERT(!child.isCustomDataProperty());
@ -657,13 +657,14 @@ Shape* NativeObject::addCustomDataProperty(JSContext* cx,
}
/* static */
Shape* NativeObject::addDataPropertyInternal(JSContext* cx,
HandleNativeObject obj,
Shape* NativeObject::addPropertyInternal(JSContext* cx, HandleNativeObject obj,
HandleId id, uint32_t slot,
unsigned attrs, ShapeTable* table,
ShapeTable::Entry* entry,
const AutoKeepShapeCaches& keep) {
AutoCheckShapeConsistency check(obj);
MOZ_ASSERT(!(attrs & JSPROP_CUSTOM_DATA_PROP),
"Use addCustomDataProperty for custom data properties");
// The slot, if any, must be a reserved slot.
MOZ_ASSERT(slot == SHAPE_INVALID_SLOT ||
@ -682,7 +683,7 @@ Shape* NativeObject::addDataPropertyInternal(JSContext* cx,
Rooted<StackShape> child(
cx, StackShape(last->base(), objectFlags, id, slot, attrs));
shape = getChildDataProperty(cx, obj, last, &child);
shape = getChildProperty(cx, obj, last, &child);
if (!shape) {
return nullptr;
}
@ -910,12 +911,14 @@ bool NativeObject::maybeToDictionaryModeForPut(JSContext* cx,
}
/* static */
Shape* NativeObject::putDataProperty(JSContext* cx, HandleNativeObject obj,
Shape* NativeObject::putProperty(JSContext* cx, HandleNativeObject obj,
HandleId id, unsigned attrs) {
MOZ_ASSERT(!JSID_IS_VOID(id));
AutoCheckShapeConsistency check(obj);
AssertValidArrayIndex(obj, id);
MOZ_ASSERT(!(attrs & JSPROP_CUSTOM_DATA_PROP),
"Use changeCustomDataPropAttributes for custom data properties");
// Search for id in order to claim its entry if table has been allocated.
AutoKeepShapeCaches keep(cx);
@ -933,8 +936,8 @@ Shape* NativeObject::putDataProperty(JSContext* cx, HandleNativeObject obj,
obj->isExtensible() ||
(JSID_IS_INT(id) && obj->containsDenseElement(JSID_TO_INT(id))),
"Can't add new property to non-extensible object");
return addDataPropertyInternal(cx, obj, id, SHAPE_INVALID_SLOT, attrs,
table, entry, keep);
return addPropertyInternal(cx, obj, id, SHAPE_INVALID_SLOT, attrs, table,
entry, keep);
}
// Property exists: search must have returned a valid entry.
@ -1010,7 +1013,7 @@ Shape* NativeObject::putDataProperty(JSContext* cx, HandleNativeObject obj,
Rooted<StackShape> child(cx, StackShape(obj->lastProperty()->base(),
objectFlags, id, slot, attrs));
RootedShape parent(cx, shape->parent);
shape = getChildDataProperty(cx, obj, parent, &child);
shape = getChildProperty(cx, obj, parent, &child);
if (!shape) {
return nullptr;
}