Bug 1359952 - Add ownProp flag to CanAttachDenseElementHole
MozReview-Commit-ID: EvpCisLDTk2
--- a/js/src/jit/CacheIR.cpp
+++ b/js/src/jit/CacheIR.cpp
@@ -1403,30 +1403,34 @@ GetPropIRGenerator::tryAttachDenseElemen
writer.loadDenseElementResult(objId, indexId);
writer.typeMonitorResult();
trackAttached("DenseElement");
return true;
}
static bool
-CanAttachDenseElementHole(JSObject* obj)
+CanAttachDenseElementHole(JSObject* obj, bool ownProp)
{
// Make sure the objects on the prototype don't have any indexed properties
// or that such properties can't appear without a shape change.
// Otherwise returning undefined for holes would obviously be incorrect,
// because we would have to lookup a property on the prototype instead.
do {
// The first two checks are also relevant to the receiver object.
if (obj->isIndexed())
return false;
if (ClassCanHaveExtraProperties(obj->getClass()))
return false;
+ // Don't need to check prototype for OwnProperty checks
+ if (ownProp)
+ return true;
+
JSObject* proto = obj->staticPrototype();
if (!proto)
break;
if (!proto->isNative())
return false;
// Make sure objects on the prototype don't have dense elements.
@@ -1444,17 +1448,17 @@ GetPropIRGenerator::tryAttachDenseElemen
uint32_t index, Int32OperandId indexId)
{
if (!obj->isNative())
return false;
if (obj->as<NativeObject>().containsDenseElement(index))
return false;
- if (!CanAttachDenseElementHole(obj))
+ if (!CanAttachDenseElementHole(obj, false))
return false;
// Guard on the shape, to prevent non-dense elements from appearing.
writer.guardShape(objId, obj->as<NativeObject>().lastProperty());
GeneratePrototypeHoleGuards(writer, obj, objId);
writer.loadDenseElementHoleResult(objId, indexId);
writer.typeMonitorResult();
@@ -2080,17 +2084,17 @@ InIRGenerator::tryAttachDenseInHole(uint
HandleObject obj, ObjOperandId objId)
{
if (!obj->isNative())
return false;
if (obj->as<NativeObject>().containsDenseElement(index))
return false;
- if (!CanAttachDenseElementHole(obj))
+ if (!CanAttachDenseElementHole(obj, false))
return false;
// Guard on the shape, to prevent non-dense elements from appearing.
writer.guardShape(objId, obj->as<NativeObject>().lastProperty());
GeneratePrototypeHoleGuards(writer, obj, objId);
writer.loadDenseElementHoleExistsResult(objId, indexId);
writer.returnFromIC();