Bug 995166 - IonMonkey: Add type policy to MFilterTypeSet, r=jandem a=sylvestre
authorHannes Verschore <hv1989@gmail.com>
Mon, 26 May 2014 16:04:04 +0200
changeset 199314 d15fa8e918b104ac0fa9a01ba3d64b1a02f1233d
parent 199313 3e33cb9495dbe62eeaba293939e2f3305ac534ef
child 199315 80b59b6b4da519668e39390a9cb74ed8bada9282
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem, sylvestre
bugs995166
milestone31.0a2
Bug 995166 - IonMonkey: Add type policy to MFilterTypeSet, r=jandem a=sylvestre
js/src/jit/MIR.h
js/src/jit/TypePolicy.cpp
js/src/jit/TypePolicy.h
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -9041,33 +9041,37 @@ class MGuardThreadExclusive
         return AliasSet::None();
     }
     bool possiblyCalls() const {
         return true;
     }
 };
 
 class MFilterTypeSet
-  : public MUnaryInstruction
+  : public MUnaryInstruction,
+    public FilterTypeSetPolicy
 {
     MFilterTypeSet(MDefinition *def, types::TemporaryTypeSet *types)
       : MUnaryInstruction(def)
     {
         JS_ASSERT(!types->unknown());
         setResultType(types->getKnownMIRType());
         setResultTypeSet(types);
     }
 
   public:
     INSTRUCTION_HEADER(FilterTypeSet)
 
     static MFilterTypeSet *New(TempAllocator &alloc, MDefinition *def, types::TemporaryTypeSet *types) {
         return new(alloc) MFilterTypeSet(def, types);
     }
 
+    TypePolicy *typePolicy() {
+        return this;
+    }
     bool congruentTo(const MDefinition *def) const {
         return false;
     }
     AliasSet getAliasSet() const {
         return AliasSet::None();
     }
     virtual bool neverHoist() const {
         return resultTypeSet()->empty();
--- a/js/src/jit/TypePolicy.cpp
+++ b/js/src/jit/TypePolicy.cpp
@@ -820,8 +820,39 @@ ClampPolicy::adjustInputs(TempAllocator 
         break;
       default:
           ins->replaceOperand(0, boxAt(alloc, ins, in));
         break;
     }
 
     return true;
 }
+
+bool
+FilterTypeSetPolicy::adjustInputs(TempAllocator &alloc, MInstruction *ins)
+{
+    MOZ_ASSERT(ins->numOperands() == 1);
+
+    // Do nothing if already same type.
+    if (ins->type() == ins->getOperand(0)->type())
+        return true;
+
+    // Box input if ouput type is MIRType_Value
+    if (ins->type() == MIRType_Value) {
+        ins->replaceOperand(0, boxAt(alloc, ins, ins->getOperand(0)));
+        return true;
+    }
+
+    // For simplicity just mark output type as MIRType_Value if input type
+    // is MIRType_Value. It should be possible to unbox, but we need to
+    // add extra code for Undefined/Null.
+    if (ins->getOperand(0)->type() == MIRType_Value) {
+        ins->setResultType(MIRType_Value);
+        return true;
+    }
+
+    // In all other cases we will definitely bail, since types don't
+    // correspond. Just box and mark output as MIRType_Value.
+    ins->replaceOperand(0, boxAt(alloc, ins, ins->getOperand(0)));
+    ins->setResultType(MIRType_Value);
+
+    return true;
+}
--- a/js/src/jit/TypePolicy.h
+++ b/js/src/jit/TypePolicy.h
@@ -322,16 +322,22 @@ class StoreTypedArrayElementStaticPolicy
 
 // Accepts integers and doubles. Everything else is boxed.
 class ClampPolicy : public BoxInputsPolicy
 {
   public:
     bool adjustInputs(TempAllocator &alloc, MInstruction *ins);
 };
 
+class FilterTypeSetPolicy : public BoxInputsPolicy
+{
+  public:
+    bool adjustInputs(TempAllocator &alloc, MInstruction *ins);
+};
+
 static inline bool
 CoercesToDouble(MIRType type)
 {
     if (type == MIRType_Undefined || IsFloatingPointType(type))
         return true;
     return false;
 }