Skip to content

Commit

Permalink
Bug 1348905 part 2 - Clean up and fix HasTypePropertyId. r=h4writer
Browse files Browse the repository at this point in the history
  • Loading branch information
jandem committed Mar 21, 2017
1 parent bd96432 commit 8b15113
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
32 changes: 18 additions & 14 deletions js/src/vm/TypeInference-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ TypeMonitorCall(JSContext* cx, const js::CallArgs& args, bool constructing)
}
}

inline bool
TrackPropertyTypes(JSContext* cx, JSObject* obj, jsid id)
MOZ_ALWAYS_INLINE bool
TrackPropertyTypes(JSObject* obj, jsid id)
{
if (obj->hasLazyGroup() || obj->group()->unknownProperties())
return false;
Expand Down Expand Up @@ -404,22 +404,26 @@ PropertyHasBeenMarkedNonConstant(JSObject* obj, jsid id)
return types->nonConstantProperty();
}

inline bool
MOZ_ALWAYS_INLINE bool
HasTypePropertyId(JSObject* obj, jsid id, TypeSet::Type type)
{
if (obj->hasLazyGroup())
id = IdToTypeId(id);
if (!TrackPropertyTypes(obj, id))
return true;

if (obj->group()->unknownProperties())
if (HeapTypeSet* types = obj->group()->maybeGetProperty(id)) {
if (!types->hasType(type))
return false;
// Non-constant properties are only relevant for singleton objects.
if (obj->isSingleton() && !types->nonConstantProperty())
return false;
return true;

if (HeapTypeSet* types = obj->group()->maybeGetProperty(IdToTypeId(id)))
return types->hasType(type) && !types->nonConstantProperty();
}

return false;
}

inline bool
MOZ_ALWAYS_INLINE bool
HasTypePropertyId(JSObject* obj, jsid id, const Value& value)
{
return HasTypePropertyId(obj, id, TypeSet::GetValueType(value));
Expand All @@ -433,15 +437,15 @@ inline void
AddTypePropertyId(JSContext* cx, JSObject* obj, jsid id, TypeSet::Type type)
{
id = IdToTypeId(id);
if (TrackPropertyTypes(cx, obj, id))
if (TrackPropertyTypes(obj, id))
AddTypePropertyId(cx, obj->group(), obj, id, type);
}

inline void
AddTypePropertyId(JSContext* cx, JSObject* obj, jsid id, const Value& value)
{
id = IdToTypeId(id);
if (TrackPropertyTypes(cx, obj, id))
if (TrackPropertyTypes(obj, id))
AddTypePropertyId(cx, obj->group(), obj, id, value);
}

Expand All @@ -463,15 +467,15 @@ inline void
MarkTypePropertyNonData(JSContext* cx, JSObject* obj, jsid id)
{
id = IdToTypeId(id);
if (TrackPropertyTypes(cx, obj, id))
if (TrackPropertyTypes(obj, id))
obj->group()->markPropertyNonData(cx, obj, id);
}

inline void
MarkTypePropertyNonWritable(JSContext* cx, JSObject* obj, jsid id)
{
id = IdToTypeId(id);
if (TrackPropertyTypes(cx, obj, id))
if (TrackPropertyTypes(obj, id))
obj->group()->markPropertyNonWritable(cx, obj, id);
}

Expand Down Expand Up @@ -909,7 +913,7 @@ TypeSet::Type::maybeCompartment()
return nullptr;
}

inline bool
MOZ_ALWAYS_INLINE bool
TypeSet::hasType(Type type) const
{
if (unknown())
Expand Down
2 changes: 1 addition & 1 deletion js/src/vm/TypeInference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ js::EnsureTrackPropertyTypes(JSContext* cx, JSObject* obj, jsid id)
}
}

MOZ_ASSERT(obj->group()->unknownProperties() || TrackPropertyTypes(cx, obj, id));
MOZ_ASSERT(obj->group()->unknownProperties() || TrackPropertyTypes(obj, id));
}

bool
Expand Down
2 changes: 1 addition & 1 deletion js/src/vm/TypeInference.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ class TypeSet
void print(FILE* fp = stderr);

/* Whether this set contains a specific type. */
inline bool hasType(Type type) const;
MOZ_ALWAYS_INLINE bool hasType(Type type) const;

TypeFlags baseFlags() const { return flags & TYPE_FLAG_BASE_MASK; }
bool unknown() const { return !!(flags & TYPE_FLAG_UNKNOWN); }
Expand Down

0 comments on commit 8b15113

Please sign in to comment.