From 55c576c93cbd97deef362136b67dcd3fac6430c8 Mon Sep 17 00:00:00 2001 From: Eric Faust Date: Sat, 10 Aug 2013 22:20:36 -0700 Subject: [PATCH] Bug 902264 - Part 2: Expose Array.length optimization to idempotent GetPropertyICs. (r=jandem) --- js/src/jit/IonCaches.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/js/src/jit/IonCaches.cpp b/js/src/jit/IonCaches.cpp index f4a21dc8f2f..2c76d2803c2 100644 --- a/js/src/jit/IonCaches.cpp +++ b/js/src/jit/IonCaches.cpp @@ -1111,18 +1111,20 @@ GetPropertyIC::canAttachNative(JSContext *cx, HandleObject obj, HandlePropertyNa } return CanAttachReadSlot; } - else if (allowGetters() && (IsCacheableGetPropCallNative(obj, holder, shape) || - IsCacheableGetPropCallPropertyOp(obj, holder, shape))) + + if (obj->is() && 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() && cx->names().length == name) - { - return CanAttachArrayLength; - } - return CanAttachCallGetter; }