Bug 902264 - Part 2: Expose Array.length optimization to idempotent GetPropertyICs. (r=jandem)
authorEric Faust <efaustbmo@gmail.com>
Sat, 10 Aug 2013 22:20:36 -0700
changeset 142194 87a5139e77eb5a299e10e660b606d683c9f4594c
parent 142193 093496cb699782e0673938345411e63099d3309b
child 142195 c81045074b71d32319d42f5591203e7a785d88a9
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersjandem
bugs902264
milestone26.0a1
Bug 902264 - Part 2: Expose Array.length optimization to idempotent GetPropertyICs. (r=jandem)
js/src/jit/IonCaches.cpp
--- a/js/src/jit/IonCaches.cpp
+++ b/js/src/jit/IonCaches.cpp
@@ -1106,28 +1106,30 @@ GetPropertyIC::canAttachNative(JSContext
             holder &&
             holder->hasSingletonType() &&
             holder->getSlot(shape->slot()).isUndefined())
         {
             return CanAttachNone;
         }
         return CanAttachReadSlot;
     }
-    else if (allowGetters() && (IsCacheableGetPropCallNative(obj, holder, shape) ||
-             IsCacheableGetPropCallPropertyOp(obj, holder, shape)))
+
+    if (obj->is<ArrayObject>() && cx->names().length == name) {
+        // The array length property is non-configurable, which means both that
+        // checking the class of the object and the name of the property is enough
+        // and that we don't need to worry about monitoring, since we know the
+        // return type statically.
+        return CanAttachArrayLength;
+    }
+
+    if (allowGetters() && (IsCacheableGetPropCallNative(obj, holder, shape) ||
+               IsCacheableGetPropCallPropertyOp(obj, holder, shape)))
     {
         // Don't enable getter call if cache is idempotent, since
         // they can be effectful. This is handled by allowGetters()
-
-        // Optimize Array.length if possible
-        if (obj->is<ArrayObject>() && cx->names().length == name)
-        {
-            return CanAttachArrayLength;
-        }
-
         return CanAttachCallGetter;
     }
 
     // Return true only if one strategy is viable.
     return CanAttachNone;
 }
 
 bool