Bug 1155788 - Make the Ion inner-window optimizations work again. r=efaust, a=sledru
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 17 Apr 2015 22:05:03 -0400
changeset 258540 e4192150f53a
parent 258539 9117f9af554e
child 258541 704989f295eb
push id4691
push userryanvm@gmail.com
push date2015-04-20 17:16 +0000
treeherdermozilla-beta@72f1b4086067 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersefaust, sledru
bugs1155788
milestone38.0
Bug 1155788 - Make the Ion inner-window optimizations work again. r=efaust, a=sledru
js/public/TrackedOptimizationInfo.h
js/src/jit/IonBuilder.cpp
--- a/js/public/TrackedOptimizationInfo.h
+++ b/js/public/TrackedOptimizationInfo.h
@@ -13,16 +13,18 @@ namespace JS {
     _(GetProp_ArgumentsLength,                          \
       "getprop arguments.length")                       \
     _(GetProp_ArgumentsCallee,                          \
       "getprop arguments.callee")                       \
     _(GetProp_InferredConstant,                         \
       "getprop inferred constant")                      \
     _(GetProp_Constant,                                 \
       "getprop constant")                               \
+    _(GetProp_StaticName,                               \
+      "getprop static name")                            \
     _(GetProp_TypedObject,                              \
       "getprop TypedObject")                            \
     _(GetProp_DefiniteSlot,                             \
       "getprop definite slot")                          \
     _(GetProp_Unboxed,                                  \
       "getprop unboxed object")                         \
     _(GetProp_CommonGetter,                             \
       "getprop common getter")                          \
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -9760,16 +9760,24 @@ IonBuilder::jsop_getprop(PropertyName* n
             if (!getPropTryConstant(&emitted, obj, name, types) || emitted)
                 return emitted;
         }
 
         current->push(call);
         return resumeAfter(call) && pushTypeBarrier(call, types, BarrierKind::TypeSet);
     }
 
+    // Try to optimize accesses on outer window proxies, for example window.foo.
+    // This needs to come before the various strategies getPropTryInnerize tries
+    // internally, since some of those strategies will "succeed" in silly ways
+    // even for an outer object.
+    trackOptimizationAttempt(TrackedStrategy::GetProp_Innerize);
+    if (!getPropTryInnerize(&emitted, obj, name, types) || emitted)
+        return emitted;
+
     // Try to hardcode known constants.
     trackOptimizationAttempt(TrackedStrategy::GetProp_Constant);
     if (!getPropTryConstant(&emitted, obj, name, types) || emitted)
         return emitted;
 
     // Try to emit loads from known binary data blocks
     trackOptimizationAttempt(TrackedStrategy::GetProp_TypedObject);
     if (!getPropTryTypedObject(&emitted, obj, name) || emitted)
@@ -9790,21 +9798,16 @@ IonBuilder::jsop_getprop(PropertyName* n
     if (!getPropTryCommonGetter(&emitted, obj, name, types) || emitted)
         return emitted;
 
     // Try to emit a monomorphic/polymorphic access based on baseline caches.
     trackOptimizationAttempt(TrackedStrategy::GetProp_InlineAccess);
     if (!getPropTryInlineAccess(&emitted, obj, name, barrier, types) || emitted)
         return emitted;
 
-    // Try to optimize accesses on outer window proxies, for example window.foo.
-    trackOptimizationAttempt(TrackedStrategy::GetProp_Innerize);
-    if (!getPropTryInnerize(&emitted, obj, name, types) || emitted)
-        return emitted;
-
     // Try to emit a polymorphic cache.
     trackOptimizationAttempt(TrackedStrategy::GetProp_InlineCache);
     if (!getPropTryCache(&emitted, obj, name, barrier, types) || emitted)
         return emitted;
 
     // Emit a call.
     MCallGetProperty* call = MCallGetProperty::New(alloc(), obj, name, *pc == JSOP_CALLPROP);
     current->add(call);
@@ -10661,29 +10664,38 @@ IonBuilder::getPropTryInnerize(bool* emi
     MDefinition* inner = tryInnerizeWindow(obj);
     if (inner == obj)
         return true;
 
     // Note: the Baseline ICs don't know about this optimization, so it's
     // possible the global property's HeapTypeSet has not been initialized
     // yet. In this case we'll fall back to getPropTryCache for now.
 
+    // Note that it's important that we do this _before_ we'd try to
+    // do the optimizations below on obj normally, since some of those
+    // optimizations have fallback paths that are slower than the path
+    // we'd produce here.
+
+    trackOptimizationAttempt(TrackedStrategy::GetProp_Constant);
     if (!getPropTryConstant(emitted, inner, name, types) || *emitted)
         return *emitted;
 
+    trackOptimizationAttempt(TrackedStrategy::GetProp_StaticName);
     if (!getStaticName(&script()->global(), name, emitted) || *emitted)
         return *emitted;
 
+    trackOptimizationAttempt(TrackedStrategy::GetProp_CommonGetter);
     if (!getPropTryCommonGetter(emitted, inner, name, types) || *emitted)
         return *emitted;
 
     // Passing the inner object to GetProperty IC is safe, see the
     // needsOuterizedThisObject check in IsCacheableGetPropCallNative.
     BarrierKind barrier = PropertyReadNeedsTypeBarrier(analysisContext, constraints(),
                                                        inner, name, types);
+    trackOptimizationAttempt(TrackedStrategy::GetProp_InlineCache);
     if (!getPropTryCache(emitted, inner, name, barrier, types) || *emitted)
         return *emitted;
 
     MOZ_ASSERT(*emitted == false);
     return true;
 }
 
 bool