mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1134638: 2. Inline some float32x4 binary arithmetic and bitwise operations; r=nbp
This commit is contained in:
parent
7d96b194ea
commit
61e3c42cf8
17
js/src/jit-test/tests/SIMD/float32x4-binary-arith.js
Normal file
17
js/src/jit-test/tests/SIMD/float32x4-binary-arith.js
Normal file
@ -0,0 +1,17 @@
|
||||
setJitCompilerOption("ion.warmup.trigger", 50);
|
||||
|
||||
function f() {
|
||||
var f1 = SIMD.float32x4(1, 2, 3, 4);
|
||||
var f2 = SIMD.float32x4(4, 3, 2, 1);
|
||||
var r = SIMD.float32x4(0, 0, 0, 0);
|
||||
for (var i = 0; i < 150; i++) {
|
||||
r = SIMD.float32x4.div(f1, f2);
|
||||
r = SIMD.float32x4.max(f1, r);
|
||||
r = SIMD.float32x4.min(r, f2);
|
||||
r = SIMD.float32x4.maxNum(f1, r);
|
||||
r = SIMD.float32x4.minNum(r, f2);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
f();
|
15
js/src/jit-test/tests/SIMD/float32x4-binary-bitwise.js
Normal file
15
js/src/jit-test/tests/SIMD/float32x4-binary-bitwise.js
Normal file
@ -0,0 +1,15 @@
|
||||
setJitCompilerOption("ion.warmup.trigger", 50);
|
||||
|
||||
function f() {
|
||||
var f1 = SIMD.float32x4(1, 2, 3, 4);
|
||||
var f2 = SIMD.float32x4(4, 3, 2, 1);
|
||||
var r = SIMD.float32x4(0, 0, 0, 0);
|
||||
for (var i = 0; i < 150; i++) {
|
||||
r = SIMD.float32x4.and(f1, f2);
|
||||
r = SIMD.float32x4.or(f1, r);
|
||||
r = SIMD.float32x4.xor(r, f2);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
f();
|
@ -9167,6 +9167,16 @@ GetTemplateObjectForNative(JSContext *cx, HandleScript script, jsbytecode *pc,
|
||||
return !!res;
|
||||
}
|
||||
#undef ADD_INT32X4_SIMD_OP_NAME_
|
||||
#define ADD_FLOAT32X4_SIMD_OP_NAME_(OP) || native == js::simd_float32x4_##OP
|
||||
if (false
|
||||
ARITH_FLOAT32X4_SIMD_OP(ADD_FLOAT32X4_SIMD_OP_NAME_)
|
||||
BITWISE_COMMONX4_SIMD_OP(ADD_FLOAT32X4_SIMD_OP_NAME_))
|
||||
{
|
||||
Rooted<SimdTypeDescr *> descr(cx, &cx->global()->float32x4TypeDescr().as<SimdTypeDescr>());
|
||||
res.set(cx->compartment()->jitCompartment()->getSimdTemplateObjectFor(cx, descr));
|
||||
return !!res;
|
||||
}
|
||||
#undef ADD_FLOAT32X4_SIMD_OP_NAME_
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -805,10 +805,10 @@ class IonBuilder
|
||||
|
||||
// SIMD intrinsics and natives.
|
||||
InliningStatus inlineConstructSimdObject(CallInfo &callInfo, SimdTypeDescr *target);
|
||||
InliningStatus inlineSimdInt32x4BinaryArith(CallInfo &callInfo, JSNative native,
|
||||
MSimdBinaryArith::Operation op);
|
||||
InliningStatus inlineSimdInt32x4BinaryBitwise(CallInfo &callInfo, JSNative native,
|
||||
MSimdBinaryBitwise::Operation op);
|
||||
InliningStatus inlineSimdBinaryArith(CallInfo &callInfo, JSNative native,
|
||||
MSimdBinaryArith::Operation op, SimdTypeDescr::Type type);
|
||||
InliningStatus inlineSimdBinaryBitwise(CallInfo &callInfo, JSNative native,
|
||||
MSimdBinaryBitwise::Operation op, SimdTypeDescr::Type type);
|
||||
|
||||
// Utility intrinsics.
|
||||
InliningStatus inlineIsCallable(CallInfo &callInfo);
|
||||
|
@ -257,17 +257,25 @@ IonBuilder::inlineNativeCall(CallInfo &callInfo, JSFunction *target)
|
||||
return inlineBoundFunction(callInfo, target);
|
||||
|
||||
// Simd functions
|
||||
#define INLINE_INT32X4_SIMD_ARITH_(OP) \
|
||||
if (native == js::simd_int32x4_##OP) \
|
||||
return inlineSimdInt32x4BinaryArith(callInfo, native, MSimdBinaryArith::Op_##OP);
|
||||
#define INLINE_INT32X4_SIMD_ARITH_(OP) \
|
||||
if (native == js::simd_int32x4_##OP) \
|
||||
return inlineSimdBinaryArith(callInfo, native, MSimdBinaryArith::Op_##OP, SimdTypeDescr::TYPE_INT32);
|
||||
ARITH_COMMONX4_SIMD_OP(INLINE_INT32X4_SIMD_ARITH_)
|
||||
#undef INLINE_INT32X4_SIMD_ARITH_
|
||||
|
||||
#define INLINE_INT32X4_SIMD_BITWISE_(OP) \
|
||||
if (native == js::simd_int32x4_##OP) \
|
||||
return inlineSimdInt32x4BinaryBitwise(callInfo, native, MSimdBinaryBitwise::OP##_);
|
||||
BITWISE_COMMONX4_SIMD_OP(INLINE_INT32X4_SIMD_BITWISE_)
|
||||
#undef INLINE_INT32X4_SIMD_BITWISE_
|
||||
#define INLINE_FLOAT32X4_SIMD_ARITH_(OP) \
|
||||
if (native == js::simd_float32x4_##OP) \
|
||||
return inlineSimdBinaryArith(callInfo, native, MSimdBinaryArith::Op_##OP, SimdTypeDescr::TYPE_FLOAT32);
|
||||
ARITH_FLOAT32X4_SIMD_OP(INLINE_FLOAT32X4_SIMD_ARITH_)
|
||||
#undef INLINE_FLOAT32X4_SIMD_ARITH_
|
||||
|
||||
#define INLINE_SIMD_BITWISE_(OP) \
|
||||
if (native == js::simd_int32x4_##OP) \
|
||||
return inlineSimdBinaryBitwise(callInfo, native, MSimdBinaryBitwise::OP##_, SimdTypeDescr::TYPE_INT32); \
|
||||
if (native == js::simd_float32x4_##OP) \
|
||||
return inlineSimdBinaryBitwise(callInfo, native, MSimdBinaryBitwise::OP##_, SimdTypeDescr::TYPE_FLOAT32);
|
||||
BITWISE_COMMONX4_SIMD_OP(INLINE_SIMD_BITWISE_)
|
||||
#undef INLINE_SIMD_BITWISE_
|
||||
|
||||
return InliningStatus_NotInlined;
|
||||
}
|
||||
@ -2860,9 +2868,20 @@ IonBuilder::inlineConstructSimdObject(CallInfo &callInfo, SimdTypeDescr *descr)
|
||||
return InliningStatus_Inlined;
|
||||
}
|
||||
|
||||
static MIRType
|
||||
SimdTypeDescrToMIRType(SimdTypeDescr::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case SimdTypeDescr::TYPE_FLOAT32: return MIRType_Float32x4;
|
||||
case SimdTypeDescr::TYPE_INT32: return MIRType_Int32x4;
|
||||
case SimdTypeDescr::TYPE_FLOAT64: break;
|
||||
}
|
||||
MOZ_CRASH("unexpected SimdTypeDescr");
|
||||
}
|
||||
|
||||
IonBuilder::InliningStatus
|
||||
IonBuilder::inlineSimdInt32x4BinaryArith(CallInfo &callInfo, JSNative native,
|
||||
MSimdBinaryArith::Operation op)
|
||||
IonBuilder::inlineSimdBinaryArith(CallInfo &callInfo, JSNative native,
|
||||
MSimdBinaryArith::Operation op, SimdTypeDescr::Type type)
|
||||
{
|
||||
if (callInfo.argc() != 2)
|
||||
return InliningStatus_NotInlined;
|
||||
@ -2872,14 +2891,14 @@ IonBuilder::inlineSimdInt32x4BinaryArith(CallInfo &callInfo, JSNative native,
|
||||
return InliningStatus_NotInlined;
|
||||
|
||||
InlineTypedObject *inlineTypedObject = &templateObject->as<InlineTypedObject>();
|
||||
MOZ_ASSERT(inlineTypedObject->typeDescr().as<SimdTypeDescr>().type() == js::Int32x4::type);
|
||||
MOZ_ASSERT(inlineTypedObject->typeDescr().as<SimdTypeDescr>().type() == 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);
|
||||
op, SimdTypeDescrToMIRType(type));
|
||||
|
||||
MSimdBox *obj = MSimdBox::New(alloc(), constraints(), ins, inlineTypedObject,
|
||||
inlineTypedObject->group()->initialHeap(constraints()));
|
||||
@ -2893,8 +2912,8 @@ IonBuilder::inlineSimdInt32x4BinaryArith(CallInfo &callInfo, JSNative native,
|
||||
}
|
||||
|
||||
IonBuilder::InliningStatus
|
||||
IonBuilder::inlineSimdInt32x4BinaryBitwise(CallInfo &callInfo, JSNative native,
|
||||
MSimdBinaryBitwise::Operation op)
|
||||
IonBuilder::inlineSimdBinaryBitwise(CallInfo &callInfo, JSNative native,
|
||||
MSimdBinaryBitwise::Operation op, SimdTypeDescr::Type type)
|
||||
{
|
||||
if (callInfo.argc() != 2)
|
||||
return InliningStatus_NotInlined;
|
||||
@ -2904,14 +2923,14 @@ IonBuilder::inlineSimdInt32x4BinaryBitwise(CallInfo &callInfo, JSNative native,
|
||||
return InliningStatus_NotInlined;
|
||||
|
||||
InlineTypedObject *inlineTypedObject = &templateObject->as<InlineTypedObject>();
|
||||
MOZ_ASSERT(inlineTypedObject->typeDescr().as<SimdTypeDescr>().type() == js::Int32x4::type);
|
||||
MOZ_ASSERT(inlineTypedObject->typeDescr().as<SimdTypeDescr>().type() == 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 bitwise
|
||||
// instruction is supposed to produce a TypeError once it is called.
|
||||
MSimdBinaryBitwise *ins = MSimdBinaryBitwise::New(alloc(), callInfo.getArg(0), callInfo.getArg(1),
|
||||
op, MIRType_Int32x4);
|
||||
op, SimdTypeDescrToMIRType(type));
|
||||
|
||||
MSimdBox *obj = MSimdBox::New(alloc(), constraints(), ins, inlineTypedObject,
|
||||
inlineTypedObject->group()->initialHeap(constraints()));
|
||||
|
Loading…
Reference in New Issue
Block a user