Skip to content

Commit

Permalink
Fastpath for hasOwnProperty == true.
Browse files Browse the repository at this point in the history
  • Loading branch information
dilijev committed Aug 16, 2016
1 parent ade59a0 commit fd50619
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions lib/Runtime/Language/JavascriptOperators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1075,10 +1075,9 @@ namespace Js

BOOL JavascriptOperators::HasOwnProperty(Var instance, PropertyId propertyId, ScriptContext *requestContext)
{
BOOL result;
if (TaggedNumber::Is(instance))
{
result = false;
return FALSE;
}
else
{
Expand All @@ -1091,10 +1090,30 @@ namespace Js
}
else
{
return object && object->HasOwnProperty(propertyId);
#ifdef DEBUG
// In debug builds, calculate expectedAnswer up-front so that
// we can Assert the fastpath gets the right result.
BOOL expectedAnswer = object && object->HasOwnProperty(propertyId);
#endif

PropertyString *propString = requestContext->GetPropertyString(propertyId);
const PropertyCache *propCache = propString->GetPropertyCache();

if (object->GetType() == propCache->type)
{
// The type cached for the property was the same as the type of this object
// (i.e. obj in obj.hasOwnProperty), so we know the answer is "true".
Assert(expectedAnswer == TRUE); // sanity check on the fastpath result
return TRUE;
}

#ifndef DEBUG
// In release builds, wait until here to calculate the result.
BOOL expectedAnswer = object && object->HasOwnProperty(propertyId);
#endif
return expectedAnswer;
}
}
return result;
}

BOOL JavascriptOperators::GetOwnAccessors(Var instance, PropertyId propertyId, Var* getter, Var* setter, ScriptContext * requestContext)
Expand Down

0 comments on commit fd50619

Please sign in to comment.