Bug 1066652 - Clean up APIs for adding property types, r=jandem.

This commit is contained in:
Brian Hackett 2014-09-22 17:29:15 -07:00
parent 346ead7bd3
commit 585400ecfd
3 changed files with 16 additions and 35 deletions

View File

@ -2599,8 +2599,7 @@ TypeCompartment::setTypeToHomogenousArray(ExclusiveContext *cx,
return;
obj->setType(objType);
if (!objType->unknownProperties())
objType->addPropertyType(cx, JSID_VOID, elementType);
AddTypePropertyId(cx, objType, JSID_VOID, elementType);
key.proto = objProto;
(void) p.add(cx, *arrayTypeTable, key, objType);
@ -2727,7 +2726,7 @@ UpdateObjectTableEntryTypes(ExclusiveContext *cx, ObjectTableEntry &entry,
/* Include 'double' in the property types to avoid the update below later. */
entry.types[i] = Type::DoubleType();
}
entry.object->addPropertyType(cx, IdToTypeId(properties[i].id), ntype);
AddTypePropertyId(cx, entry.object, IdToTypeId(properties[i].id), ntype);
}
}
}
@ -2804,8 +2803,7 @@ TypeCompartment::fixObjectType(ExclusiveContext *cx, JSObject *obj)
for (size_t i = 0; i < properties.length(); i++) {
ids[i] = properties[i].id;
types[i] = GetValueTypeForTable(obj->getSlot(i));
if (!objType->unknownProperties())
objType->addPropertyType(cx, IdToTypeId(ids[i]), types[i]);
AddTypePropertyId(cx, objType, IdToTypeId(ids[i]), types[i]);
}
ObjectTableKey key;
@ -3050,11 +3048,14 @@ TypeObject::matchDefiniteProperties(HandleObject obj)
return true;
}
static inline void
InlineAddTypeProperty(ExclusiveContext *cx, TypeObject *obj, jsid id, Type type)
void
types::AddTypePropertyId(ExclusiveContext *cx, TypeObject *obj, jsid id, Type type)
{
JS_ASSERT(id == IdToTypeId(id));
if (obj->unknownProperties())
return;
AutoEnterAnalysis enter(cx);
HeapTypeSet *types = obj->getProperty(cx, id);
@ -3083,21 +3084,14 @@ InlineAddTypeProperty(ExclusiveContext *cx, TypeObject *obj, jsid id, Type type)
if (obj->newScript() && obj->newScript()->initializedType()) {
if (type.isObjectUnchecked() && types->unknownObject())
type = Type::AnyObjectType();
if (!obj->newScript()->initializedType()->unknownProperties())
obj->newScript()->initializedType()->addPropertyType(cx, id, type);
AddTypePropertyId(cx, obj->newScript()->initializedType(), id, type);
}
}
void
TypeObject::addPropertyType(ExclusiveContext *cx, jsid id, Type type)
types::AddTypePropertyId(ExclusiveContext *cx, TypeObject *obj, jsid id, const Value &value)
{
InlineAddTypeProperty(cx, this, id, type);
}
void
TypeObject::addPropertyType(ExclusiveContext *cx, jsid id, const Value &value)
{
InlineAddTypeProperty(cx, this, id, GetValueType(value));
AddTypePropertyId(cx, obj, id, GetValueType(value));
}
void

View File

@ -1194,8 +1194,6 @@ struct TypeObject : public gc::TenuredCell
bool addDefiniteProperties(ExclusiveContext *cx, Shape *shape);
bool matchDefiniteProperties(HandleObject obj);
void addPrototype(JSContext *cx, TypeObject *proto);
void addPropertyType(ExclusiveContext *cx, jsid id, Type type);
void addPropertyType(ExclusiveContext *cx, jsid id, const Value &value);
void markPropertyNonData(ExclusiveContext *cx, jsid id);
void markPropertyNonWritable(ExclusiveContext *cx, jsid id);
void markStateChange(ExclusiveContext *cx);

View File

@ -461,13 +461,16 @@ HasTypePropertyId(JSObject *obj, jsid id, const Value &value)
return HasTypePropertyId(obj, id, GetValueType(value));
}
void AddTypePropertyId(ExclusiveContext *cx, TypeObject *obj, jsid id, Type type);
void AddTypePropertyId(ExclusiveContext *cx, TypeObject *obj, jsid id, const Value &value);
/* Add a possible type for a property of obj. */
inline void
AddTypePropertyId(ExclusiveContext *cx, JSObject *obj, jsid id, Type type)
{
id = IdToTypeId(id);
if (TrackPropertyTypes(cx, obj, id))
obj->type()->addPropertyType(cx, id, type);
AddTypePropertyId(cx, obj->type(), id, type);
}
inline void
@ -475,21 +478,7 @@ AddTypePropertyId(ExclusiveContext *cx, JSObject *obj, jsid id, const Value &val
{
id = IdToTypeId(id);
if (TrackPropertyTypes(cx, obj, id))
obj->type()->addPropertyType(cx, id, value);
}
inline void
AddTypePropertyId(ExclusiveContext *cx, TypeObject *obj, jsid id, Type type)
{
if (!obj->unknownProperties())
obj->addPropertyType(cx, id, type);
}
inline void
AddTypePropertyId(ExclusiveContext *cx, TypeObject *obj, jsid id, const Value &value)
{
if (!obj->unknownProperties())
obj->addPropertyType(cx, id, value);
AddTypePropertyId(cx, obj->type(), id, value);
}
/* Set one or more dynamic flags on a type object. */