Bug 1118344 - IonMonkey: Inline SIMD.int32x4.add calls. r=bbouvier

This commit is contained in:
Nicolas B. Pierron 2015-01-26 12:22:56 +01:00
parent c43d9d2822
commit 911efad68f
4 changed files with 52 additions and 4 deletions

View File

@ -788,7 +788,11 @@ class IonBuilder
bool elementAccessIsTypedObjectArrayOfScalarType(MDefinition* obj, MDefinition* id,
ScalarTypeDescr::Type *arrayType);
InliningStatus inlineConstructTypedObject(CallInfo &callInfo, TypeDescr *target);
// SIMD intrinsics and natives.
InliningStatus inlineConstructSimdObject(CallInfo &callInfo, SimdTypeDescr *target);
InliningStatus inlineSimdInt32x4BinaryArith(CallInfo &callInfo, JSNative native,
MSimdBinaryArith::Operation op);
// Utility intrinsics.
InliningStatus inlineIsCallable(CallInfo &callInfo);

View File

@ -7,6 +7,7 @@
#include "jsmath.h"
#include "builtin/AtomicsObject.h"
#include "builtin/SIMD.h"
#include "builtin/TestingFunctions.h"
#include "builtin/TypedObject.h"
#include "jit/BaselineInspector.h"
@ -246,6 +247,10 @@ IonBuilder::inlineNativeCall(CallInfo &callInfo, JSFunction *target)
if (native == js::CallOrConstructBoundFunction)
return inlineBoundFunction(callInfo, target);
// Simd functions
if (native == js::simd_int32x4_add)
return inlineSimdInt32x4BinaryArith(callInfo, native, MSimdBinaryArith::Add);
return InliningStatus_NotInlined;
}
@ -2612,5 +2617,37 @@ IonBuilder::inlineConstructSimdObject(CallInfo &callInfo, SimdTypeDescr *descr)
return InliningStatus_Inlined;
}
IonBuilder::InliningStatus
IonBuilder::inlineSimdInt32x4BinaryArith(CallInfo &callInfo, JSNative native,
MSimdBinaryArith::Operation op)
{
if (callInfo.argc() != 2)
return InliningStatus_NotInlined;
JSObject *templateObject = inspector->getTemplateObjectForNative(pc, native);
if (!templateObject)
return InliningStatus_NotInlined;
InlineTypedObject *inlineTypedObject = &templateObject->as<InlineTypedObject>();
MOZ_ASSERT(inlineTypedObject->typeDescr().as<SimdTypeDescr>().type() == js::Int32x4::type);
// If the type of any of the arguments is neither a SIMD type, an Object
// type, or a Value, then the applyTypes phase will add a fallible box &
// unbox sequence. This does not matter much as the binary arithmetic
// instruction is supposed to produce a TypeError once it is called.
MSimdBinaryArith *ins = MSimdBinaryArith::New(alloc(), callInfo.getArg(0), callInfo.getArg(1),
op, MIRType_Int32x4);
MSimdBox *obj = MSimdBox::New(alloc(), constraints(), ins, inlineTypedObject,
inlineTypedObject->type()->initialHeap(constraints()));
current->add(ins);
current->add(obj);
current->push(obj);
callInfo.setImplicitlyUsedUnchecked();
return InliningStatus_Inlined;
}
} // namespace jit
} // namespace js

View File

@ -1922,7 +1922,7 @@ class MSimdBinaryComp
class MSimdBinaryArith
: public MBinaryInstruction,
public NoTypePolicy::Data
public MixPolicy<SimdSameAsReturnedTypePolicy<0>, SimdSameAsReturnedTypePolicy<1> >::Data
{
public:
enum Operation {
@ -1958,8 +1958,6 @@ class MSimdBinaryArith
{
MOZ_ASSERT_IF(type == MIRType_Int32x4, op == Add || op == Sub || op == Mul);
MOZ_ASSERT(IsSimdType(type));
MOZ_ASSERT(left->type() == right->type());
MOZ_ASSERT(left->type() == type);
setResultType(type);
setMovable();
if (op == Add || op == Mul || op == Min || op == Max)
@ -1968,10 +1966,18 @@ class MSimdBinaryArith
public:
INSTRUCTION_HEADER(SimdBinaryArith)
static MSimdBinaryArith *New(TempAllocator &alloc, MDefinition *left, MDefinition *right,
Operation op, MIRType t)
{
return new(alloc) MSimdBinaryArith(left, right, op, t);
}
static MSimdBinaryArith *NewAsmJS(TempAllocator &alloc, MDefinition *left, MDefinition *right,
Operation op, MIRType t)
{
return new(alloc) MSimdBinaryArith(left, right, op, t);
MOZ_ASSERT(left->type() == right->type());
MOZ_ASSERT(left->type() == t);
return New(alloc, left, right, op, t);
}
AliasSet getAliasSet() const MOZ_OVERRIDE {

View File

@ -1065,6 +1065,7 @@ FilterTypeSetPolicy::adjustInputs(TempAllocator &alloc, MInstruction *ins)
_(MixPolicy<ObjectPolicy<0>, StringPolicy<1> >) \
_(MixPolicy<ObjectPolicy<0>, ConvertToStringPolicy<2> >) \
_(MixPolicy<ObjectPolicy<1>, ConvertToStringPolicy<0> >) \
_(MixPolicy<SimdSameAsReturnedTypePolicy<0>, SimdSameAsReturnedTypePolicy<1> >) \
_(MixPolicy<StringPolicy<0>, IntPolicy<1> >) \
_(MixPolicy<StringPolicy<0>, StringPolicy<1> >) \
_(NoFloatPolicy<0>) \