From 0d9bf57aa840ce0381496ebca931b16b938ac644 Mon Sep 17 00:00:00 2001 From: Hannes Verschore Date: Sun, 25 May 2014 22:44:24 +0200 Subject: [PATCH] Bug 995166 - IonMonkey: Add type policy to MFilterTypeSet, r=jandem --- js/src/jit/MIR.h | 6 +++++- js/src/jit/TypePolicy.cpp | 31 +++++++++++++++++++++++++++++++ js/src/jit/TypePolicy.h | 6 ++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/js/src/jit/MIR.h b/js/src/jit/MIR.h index f1e0d42c0ca..6601a3e1abf 100644 --- a/js/src/jit/MIR.h +++ b/js/src/jit/MIR.h @@ -9393,7 +9393,8 @@ class MGuardThreadExclusive }; class MFilterTypeSet - : public MUnaryInstruction + : public MUnaryInstruction, + public FilterTypeSetPolicy { MFilterTypeSet(MDefinition *def, types::TemporaryTypeSet *types) : MUnaryInstruction(def) @@ -9411,6 +9412,9 @@ class MFilterTypeSet return new(alloc) MFilterTypeSet(def, types); } + TypePolicy *typePolicy() { + return this; + } bool congruentTo(const MDefinition *def) const { return false; } diff --git a/js/src/jit/TypePolicy.cpp b/js/src/jit/TypePolicy.cpp index 459bd54c0ca..92c050064ef 100644 --- a/js/src/jit/TypePolicy.cpp +++ b/js/src/jit/TypePolicy.cpp @@ -824,3 +824,34 @@ ClampPolicy::adjustInputs(TempAllocator &alloc, MInstruction *ins) 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; +} diff --git a/js/src/jit/TypePolicy.h b/js/src/jit/TypePolicy.h index 17dea10e389..1635c1b3aa1 100644 --- a/js/src/jit/TypePolicy.h +++ b/js/src/jit/TypePolicy.h @@ -327,6 +327,12 @@ class ClampPolicy : public BoxInputsPolicy bool adjustInputs(TempAllocator &alloc, MInstruction *ins); }; +class FilterTypeSetPolicy : public BoxInputsPolicy +{ + public: + bool adjustInputs(TempAllocator &alloc, MInstruction *ins); +}; + static inline bool CoercesToDouble(MIRType type) {