Bug 1255316 - IonMonkey: Enable folding of MLoadUnboxedObjectOrNull with the stored value, r=jandem
authorHannes Verschore <hv1989@gmail.com>
Mon, 14 Mar 2016 07:08:50 -0400
changeset 288559 1b7481e9a32de585e6d563c7290088319e090fc6
parent 288558 e1f5afcd210c857cb96fd7eeb578be3655737854
child 288560 9814ff02695354505c46acc4fa86745336136966
push id30084
push userkwierso@gmail.com
push dateTue, 15 Mar 2016 00:39:07 +0000
treeherdermozilla-central@422077f61bcb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1255316
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1255316 - IonMonkey: Enable folding of MLoadUnboxedObjectOrNull with the stored value, r=jandem
js/src/jit/MIR.cpp
js/src/jit/MIR.h
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -4719,16 +4719,39 @@ MLoadElement::foldsTo(TempAllocator& all
         return this;
 
     if (store->index() != index())
         return this;
 
     return foldsToStoredValue(alloc, store->value());
 }
 
+MDefinition*
+MLoadUnboxedObjectOrNull::foldsTo(TempAllocator& alloc)
+{
+    if (!dependency() || !dependency()->isStoreUnboxedObjectOrNull())
+        return this;
+
+    MStoreUnboxedObjectOrNull* store = dependency()->toStoreUnboxedObjectOrNull();
+    if (!store->block()->dominates(block()))
+        return this;
+
+    if (store->elements() != elements())
+        return this;
+
+    if (store->index() != index())
+        return this;
+
+    if (store->value()->type() == MIRType_ObjectOrNull)
+        return this;
+
+    MOZ_ASSERT(offsetAdjustment() == store->offsetAdjustment());
+    return foldsToStoredValue(alloc, store->value());
+}
+
 // Gets the MDefinition* representing the source/target object's storage.
 // Usually this is just an MElements*, but sometimes there are layers
 // of indirection or inlining, which are handled elsewhere.
 static inline const MElements*
 MaybeUnwrapElements(const MDefinition* elementsOrObj)
 {
     // Sometimes there is a level of indirection for conversion.
     if (elementsOrObj->isConvertElementsToDoubles())
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -9293,16 +9293,17 @@ class MLoadUnboxedObjectOrNull
             return false;
         if (offsetAdjustment() != other->offsetAdjustment())
             return false;
         return congruentIfOperandsEqual(other);
     }
     AliasSet getAliasSet() const override {
         return AliasSet::Load(AliasSet::UnboxedElement);
     }
+    MDefinition* foldsTo(TempAllocator& alloc) override;
     bool mightAlias(const MDefinition* store) const override;
 
     ALLOW_CLONE(MLoadUnboxedObjectOrNull)
 };
 
 class MLoadUnboxedString
   : public MBinaryInstruction,
     public SingleObjectPolicy::Data