Bug 1359952 - Add ownProp flag to CanAttachDenseElementHole draft
authorTed Campbell <tcampbell@mozilla.com>
Thu, 27 Apr 2017 12:06:13 -0400
changeset 571929 2f0b5fb1b8172f75734a3040db5343a631fe3e54
parent 571928 43bbf70cfb3d1611e4459b1acfbd3e48169485c5
child 571930 c243d75634fbb5942685a9f3368f50e41eaee464
child 571971 71c705ec8eaa7feb8e77a5f79cf57e25f94870b2
push id56961
push userbmo:tcampbell@mozilla.com
push dateWed, 03 May 2017 14:31:20 +0000
bugs1359952
milestone55.0a1
Bug 1359952 - Add ownProp flag to CanAttachDenseElementHole MozReview-Commit-ID: EvpCisLDTk2
js/src/jit/CacheIR.cpp
--- 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();