Bug 1134638: 13. Inline splat in Ion; r=nbp

This commit is contained in:
Benjamin Bouvier 2015-02-26 12:34:34 +01:00
parent 3a04a2fbc8
commit 3f85d61183
8 changed files with 47 additions and 9 deletions

View File

@ -2792,7 +2792,7 @@ class FunctionCompiler
return nullptr;
MOZ_ASSERT(IsSimdType(type));
MSimdSplatX4 *ins = MSimdSplatX4::New(alloc(), type, v);
MSimdSplatX4 *ins = MSimdSplatX4::NewAsmJS(alloc(), v, type);
curBlock_->add(ins);
return ins;
}

View File

@ -0,0 +1,13 @@
load(libdir + 'simd.js');
setJitCompilerOption("ion.warmup.trigger", 50);
function f() {
for (var i = 0; i < 150; i++) {
assertEqX4(SIMD.int32x4.splat(42), [42, 42, 42, 42]);
assertEqX4(SIMD.float32x4.splat(42), [42, 42, 42, 42]);
}
}
f();

View File

@ -9235,7 +9235,8 @@ GetTemplateObjectForNative(JSContext *cx, HandleScript script, jsbytecode *pc,
COMP_COMMONX4_SIMD_OP(ADD_FLOAT32X4_SIMD_OP_NAME_)
WITH_COMMONX4_SIMD_OP(ADD_INT32X4_SIMD_OP_NAME_)
|| native == js::simd_int32x4_not || native == js::simd_int32x4_neg
|| native == js::simd_int32x4_fromFloat32x4 || native == js::simd_int32x4_fromFloat32x4Bits)
|| native == js::simd_int32x4_fromFloat32x4 || native == js::simd_int32x4_fromFloat32x4Bits
|| native == js::simd_int32x4_splat)
{
Rooted<SimdTypeDescr *> descr(cx, &cx->global()->int32x4TypeDescr().as<SimdTypeDescr>());
res.set(cx->compartment()->jitCompartment()->getSimdTemplateObjectFor(cx, descr));
@ -9249,7 +9250,8 @@ GetTemplateObjectForNative(JSContext *cx, HandleScript script, jsbytecode *pc,
|| native == js::simd_float32x4_abs || native == js::simd_float32x4_sqrt
|| native == js::simd_float32x4_reciprocal || native == js::simd_float32x4_reciprocalSqrt
|| native == js::simd_float32x4_not || native == js::simd_float32x4_neg
|| native == js::simd_float32x4_fromInt32x4 || native == js::simd_float32x4_fromInt32x4Bits)
|| native == js::simd_float32x4_fromInt32x4 || native == js::simd_float32x4_fromInt32x4Bits
|| native == js::simd_float32x4_splat)
{
Rooted<SimdTypeDescr *> descr(cx, &cx->global()->float32x4TypeDescr().as<SimdTypeDescr>());
res.set(cx->compartment()->jitCompartment()->getSimdTemplateObjectFor(cx, descr));

View File

@ -824,6 +824,7 @@ class IonBuilder
MSimdUnaryArith::Operation op, SimdTypeDescr::Type type);
InliningStatus inlineSimdWith(CallInfo &callInfo, JSNative native, SimdLane lane,
SimdTypeDescr::Type type);
InliningStatus inlineSimdSplat(CallInfo &callInfo, JSNative native, SimdTypeDescr::Type type);
InliningStatus inlineSimdConvert(CallInfo &callInfo, JSNative native, bool isCast,
SimdTypeDescr::Type from, SimdTypeDescr::Type to);

View File

@ -329,6 +329,11 @@ IonBuilder::inlineNativeCall(CallInfo &callInfo, JSFunction *target)
if (native == js::simd_int32x4_fromFloat32x4Bits)
return inlineSimdConvert(callInfo, native, IsCast(true), SimdTypeDescr::TYPE_FLOAT32, SimdTypeDescr::TYPE_INT32);
if (native == js::simd_int32x4_splat)
return inlineSimdSplat(callInfo, native, SimdTypeDescr::TYPE_INT32);
if (native == js::simd_float32x4_splat)
return inlineSimdSplat(callInfo, native, SimdTypeDescr::TYPE_FLOAT32);
return InliningStatus_NotInlined;
}
@ -3012,6 +3017,19 @@ IonBuilder::inlineUnarySimd(CallInfo &callInfo, JSNative native, MSimdUnaryArith
return boxSimd(callInfo, ins, templateObj);
}
IonBuilder::InliningStatus
IonBuilder::inlineSimdSplat(CallInfo &callInfo, JSNative native, SimdTypeDescr::Type type)
{
InlineTypedObject *templateObj = nullptr;
if (!checkInlineSimd(callInfo, native, type, 1, &templateObj))
return InliningStatus_NotInlined;
// See comment in inlineBinarySimd
MIRType mirType = SimdTypeDescrToMIRType(type);
MSimdSplatX4 *ins = MSimdSplatX4::New(alloc(), callInfo.getArg(0), mirType);
return boxSimd(callInfo, ins, templateObj);
}
IonBuilder::InliningStatus
IonBuilder::inlineSimdWith(CallInfo &callInfo, JSNative native, SimdLane lane,
SimdTypeDescr::Type type)

View File

@ -886,7 +886,7 @@ MSimdValueX4::foldsTo(TempAllocator &alloc)
}
MOZ_ASSERT(allSame);
return MSimdSplatX4::New(alloc, type(), getOperand(0));
return MSimdSplatX4::New(alloc, getOperand(0), type());
}
MDefinition*

View File

@ -1434,16 +1434,13 @@ class MSimdValueX4
// Generic constructor of SIMD valuesX4.
class MSimdSplatX4
: public MUnaryInstruction,
public NoTypePolicy::Data
public SimdScalarPolicy<0>::Data
{
protected:
MSimdSplatX4(MIRType type, MDefinition *v)
: MUnaryInstruction(v)
{
MOZ_ASSERT(IsSimdType(type));
mozilla::DebugOnly<MIRType> scalarType = SimdTypeToScalarType(type);
MOZ_ASSERT(scalarType == v->type());
setMovable();
setResultType(type);
}
@ -1451,7 +1448,13 @@ class MSimdSplatX4
public:
INSTRUCTION_HEADER(SimdSplatX4)
static MSimdSplatX4 *New(TempAllocator &alloc, MIRType type, MDefinition *v)
static MSimdSplatX4 *NewAsmJS(TempAllocator &alloc, MDefinition *v, MIRType type)
{
MOZ_ASSERT(SimdTypeToScalarType(type) == v->type());
return new(alloc) MSimdSplatX4(type, v);
}
static MSimdSplatX4 *New(TempAllocator &alloc, MDefinition *v, MIRType type)
{
return new(alloc) MSimdSplatX4(type, v);
}

View File

@ -1124,6 +1124,7 @@ FilterTypeSetPolicy::adjustInputs(TempAllocator &alloc, MInstruction *ins)
_(ObjectPolicy<3>) \
_(SimdPolicy<0>) \
_(SimdSameAsReturnedTypePolicy<0>) \
_(SimdScalarPolicy<0>) \
_(StringPolicy<0>)