Bug 1355058 part 1 - Try the TypedObject optimizations last as typed objects are disabled by default. r=h4writer
authorJan de Mooij <jdemooij@mozilla.com>
Sat, 15 Apr 2017 10:24:54 +0200
changeset 563287 fd4b315d43b9de9f9b4faa75867862978fd93ac9
parent 563286 3d8a235f178992885fa6c8381f6804f05d007793
child 563288 ad497a610771d177c0810e3a58c199205b6daeef
push id54258
push usercpeterson@mozilla.com
push dateSun, 16 Apr 2017 05:52:14 +0000
reviewersh4writer
bugs1355058
milestone55.0a1
Bug 1355058 part 1 - Try the TypedObject optimizations last as typed objects are disabled by default. r=h4writer
js/src/jit/IonBuilder.cpp
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -7635,21 +7635,16 @@ IonBuilder::jsop_getelem()
             return abort(AbortReason::Disable, "Type is not definitely lazy arguments.");
     }
 
     obj = maybeUnboxForPropertyAccess(obj);
     if (obj->type() == MIRType::Object)
         obj = convertUnboxedObjects(obj);
 
     if (!forceInlineCaches()) {
-        trackOptimizationAttempt(TrackedStrategy::GetElem_TypedObject);
-        MOZ_TRY(getElemTryTypedObject(&emitted, obj, index));
-        if (emitted)
-            return Ok();
-
         // Note: no trackOptimizationAttempt call is needed, getElemTryGetProp
         // will call it.
         MOZ_TRY(getElemTryGetProp(&emitted, obj, index));
         if (emitted)
             return Ok();
 
         trackOptimizationAttempt(TrackedStrategy::GetElem_Dense);
         MOZ_TRY(getElemTryDense(&emitted, obj, index));
@@ -7665,16 +7660,21 @@ IonBuilder::jsop_getelem()
         MOZ_TRY(getElemTryTypedArray(&emitted, obj, index));
         if (emitted)
             return Ok();
 
         trackOptimizationAttempt(TrackedStrategy::GetElem_String);
         MOZ_TRY(getElemTryString(&emitted, obj, index));
         if (emitted)
             return Ok();
+
+        trackOptimizationAttempt(TrackedStrategy::GetElem_TypedObject);
+        MOZ_TRY(getElemTryTypedObject(&emitted, obj, index));
+        if (emitted)
+            return Ok();
     }
 
     trackOptimizationAttempt(TrackedStrategy::GetElem_InlineCache);
     return getElemAddCache(obj, index);
 }
 
 AbortReasonOr<Ok>
 IonBuilder::getElemTryTypedObject(bool* emitted, MDefinition* obj, MDefinition* index)
@@ -8762,21 +8762,16 @@ IonBuilder::jsop_setelem()
     if (shouldAbortOnPreliminaryGroups(object)) {
         MInstruction* ins = MCallSetElement::New(alloc(), object, index, value, IsStrictSetPC(pc));
         current->add(ins);
         current->push(value);
         return resumeAfter(ins);
     }
 
     if (!forceInlineCaches()) {
-        trackOptimizationAttempt(TrackedStrategy::SetElem_TypedObject);
-        MOZ_TRY(setElemTryTypedObject(&emitted, object, index, value));
-        if (emitted)
-            return Ok();
-
         trackOptimizationAttempt(TrackedStrategy::SetElem_TypedStatic);
         MOZ_TRY(setElemTryTypedStatic(&emitted, object, index, value));
         if (emitted)
             return Ok();
 
         trackOptimizationAttempt(TrackedStrategy::SetElem_TypedArray);
         MOZ_TRY(setElemTryTypedArray(&emitted, object, index, value));
         if (emitted)
@@ -8788,16 +8783,21 @@ IonBuilder::jsop_setelem()
         MOZ_TRY(initOrSetElemTryDense(&emitted, object, index, value, writeHole));
         if (emitted)
             return Ok();
 
         trackOptimizationAttempt(TrackedStrategy::SetElem_Arguments);
         MOZ_TRY(setElemTryArguments(&emitted, object, index, value));
         if (emitted)
             return Ok();
+
+        trackOptimizationAttempt(TrackedStrategy::SetElem_TypedObject);
+        MOZ_TRY(setElemTryTypedObject(&emitted, object, index, value));
+        if (emitted)
+            return Ok();
     }
 
     if (script()->argumentsHasVarBinding() &&
         object->mightBeType(MIRType::MagicOptimizedArguments) &&
         info().analysisMode() != Analysis_ArgumentsUsage)
     {
         return abort(AbortReason::Disable, "Type is not definitely lazy arguments.");
     }
@@ -10218,22 +10218,16 @@ IonBuilder::jsop_getprop(PropertyName* n
             return Ok();
 
         // Try to hardcode known not-defined
         trackOptimizationAttempt(TrackedStrategy::GetProp_NotDefined);
         MOZ_TRY(getPropTryNotDefined(&emitted, obj, NameToId(name), types));
         if (emitted)
             return Ok();
 
-        // Try to emit loads from known binary data blocks
-        trackOptimizationAttempt(TrackedStrategy::GetProp_TypedObject);
-        MOZ_TRY(getPropTryTypedObject(&emitted, obj, name));
-        if (emitted)
-            return Ok();
-
         // Try to emit loads from definite slots.
         trackOptimizationAttempt(TrackedStrategy::GetProp_DefiniteSlot);
         MOZ_TRY(getPropTryDefiniteSlot(&emitted, obj, name, barrier, types));
         if (emitted)
             return Ok();
 
         // Try to emit loads from unboxed objects.
         trackOptimizationAttempt(TrackedStrategy::GetProp_Unboxed);
@@ -10253,16 +10247,22 @@ IonBuilder::jsop_getprop(PropertyName* n
         if (emitted)
             return Ok();
 
         // Try to emit loads from a module namespace.
         trackOptimizationAttempt(TrackedStrategy::GetProp_ModuleNamespace);
         MOZ_TRY(getPropTryModuleNamespace(&emitted, obj, name, barrier, types));
         if (emitted)
             return Ok();
+
+        // Try to emit loads from known binary data blocks
+        trackOptimizationAttempt(TrackedStrategy::GetProp_TypedObject);
+        MOZ_TRY(getPropTryTypedObject(&emitted, obj, name));
+        if (emitted)
+            return Ok();
     }
 
     // Emit a polymorphic cache.
     trackOptimizationAttempt(TrackedStrategy::GetProp_InlineCache);
     return getPropAddCache(obj, name, barrier, types);
 }
 
 AbortReasonOr<Ok>