Bug 1146363: Inline SIMD.int32x4.bool; r=sunfish

--HG--
extra : rebase_source : dd1a610b148f362f6e35f6c3a90f68b6e4c31420
extra : amend_source : 7cf7bb3b747f86d49bcc4787d15e220e323daee7
This commit is contained in:
Benjamin Bouvier 2015-03-23 15:45:05 +01:00
Родитель 31c4421faf
Коммит 730757f275
7 изменённых файлов: 61 добавлений и 11 удалений

Просмотреть файл

@ -252,6 +252,8 @@
_(storeXY) \
_(storeXYZ) \
_(check)
#define ION_ONLY_INT32X4_SIMD_OP(_) \
_(bool)
#define FOREACH_COMMONX4_SIMD_OP(_) \
ION_COMMONX4_SIMD_OP(_) \
COMP_COMMONX4_TO_INT32X4_SIMD_OP(_)

Просмотреть файл

@ -0,0 +1,15 @@
load(libdir + 'simd.js');
setJitCompilerOption("ion.warmup.trigger", 50);
const T = -1, F = 0;
function f() {
for (var i = 0; i < 150; i++) {
assertEqX4(SIMD.int32x4.bool(i + 1, true, 'hey', null), [T, T, T, F]);
assertEqX4(SIMD.int32x4.bool(undefined, '', {}, objectEmulatingUndefined()), [F, F, T, F]);
assertEqX4(SIMD.int32x4.bool(null, NaN, false, Infinity), [F, F, F, T]);
}
}
f();

Просмотреть файл

@ -9461,7 +9461,8 @@ GetTemplateObjectForNative(JSContext* cx, HandleScript script, jsbytecode* pc,
ION_COMMONX4_SIMD_OP(ADD_INT32X4_SIMD_OP_NAME_)
COMP_COMMONX4_TO_INT32X4_SIMD_OP(ADD_INT32X4_SIMD_OP_NAME_)
COMP_COMMONX4_TO_INT32X4_SIMD_OP(ADD_FLOAT32X4_SIMD_OP_NAME_)
CONVERSION_INT32X4_SIMD_OP(ADD_INT32X4_SIMD_OP_NAME_))
CONVERSION_INT32X4_SIMD_OP(ADD_INT32X4_SIMD_OP_NAME_)
ION_ONLY_INT32X4_SIMD_OP(ADD_INT32X4_SIMD_OP_NAME_))
{
Rooted<SimdTypeDescr*> descr(cx, &cx->global()->int32x4TypeDescr().as<SimdTypeDescr>());
res.set(cx->compartment()->jitCompartment()->getSimdTemplateObjectFor(cx, descr));

Просмотреть файл

@ -9608,10 +9608,9 @@ IonBuilder::jsop_not()
{
MDefinition* value = current->pop();
MNot* ins = MNot::New(alloc(), value);
MNot* ins = MNot::New(alloc(), value, constraints());
current->add(ins);
current->push(ins);
ins->cacheOperandMightEmulateUndefined(constraints());
return true;
}

Просмотреть файл

@ -848,6 +848,8 @@ class IonBuilder
InliningStatus inlineSimdStore(CallInfo& callInfo, JSNative native, SimdTypeDescr::Type type,
unsigned numElems);
InliningStatus inlineSimdBool(CallInfo& callInfo, JSNative native, SimdTypeDescr::Type type);
// Utility intrinsics.
InliningStatus inlineIsCallable(CallInfo& callInfo);
InliningStatus inlineIsObject(CallInfo& callInfo);

Просмотреть файл

@ -2203,11 +2203,9 @@ IonBuilder::inlineHasClass(CallInfo& callInfo,
}
// Convert to bool with the '!!' idiom
MNot* resultInverted = MNot::New(alloc(), last);
resultInverted->cacheOperandMightEmulateUndefined(constraints());
MNot* resultInverted = MNot::New(alloc(), last, constraints());
current->add(resultInverted);
MNot* result = MNot::New(alloc(), resultInverted);
result->cacheOperandMightEmulateUndefined(constraints());
MNot* result = MNot::New(alloc(), resultInverted, constraints());
current->add(result);
current->push(result);
}
@ -3368,5 +3366,33 @@ IonBuilder::inlineSimdStore(CallInfo& callInfo, JSNative native, SimdTypeDescr::
return InliningStatus_Inlined;
}
IonBuilder::InliningStatus
IonBuilder::inlineSimdBool(CallInfo& callInfo, JSNative native, SimdTypeDescr::Type type)
{
InlineTypedObject* templateObj = nullptr;
if (!checkInlineSimd(callInfo, native, type, 4, &templateObj))
return InliningStatus_NotInlined;
MOZ_ASSERT(type == SimdTypeDescr::Int32x4, "at the moment, only int32x4.bool is inlined");
MInstruction* operands[4];
for (unsigned i = 0; i < 4; i++) {
operands[i] = MNot::New(alloc(), callInfo.getArg(i), constraints());
current->add(operands[i]);
}
// Inline int32x4.bool(x, y, z, w) as int32x4(!x - 1, !y - 1, !z - 1, !w - 1);
MSimdValueX4* vector = MSimdValueX4::New(alloc(), MIRType_Int32x4, operands[0], operands[1],
operands[2], operands[3]);
current->add(vector);
MSimdConstant* one = MSimdConstant::New(alloc(), SimdConstant::SplatX4(1), MIRType_Int32x4);
current->add(one);
MSimdBinaryArith* result = MSimdBinaryArith::New(alloc(), vector, one, MSimdBinaryArith::Op_sub,
MIRType_Int32x4);
return boxSimd(callInfo, result, templateObj);
}
} // namespace jit
} // namespace js

Просмотреть файл

@ -8035,18 +8035,24 @@ class MNot
bool operandMightEmulateUndefined_;
bool operandIsNeverNaN_;
explicit MNot(MDefinition* input)
explicit MNot(MDefinition* input, CompilerConstraintList* constraints = nullptr)
: MUnaryInstruction(input),
operandMightEmulateUndefined_(true),
operandIsNeverNaN_(false)
{
setResultType(MIRType_Boolean);
setMovable();
if (constraints)
cacheOperandMightEmulateUndefined(constraints);
}
void cacheOperandMightEmulateUndefined(CompilerConstraintList *constraints);
public:
static MNot* New(TempAllocator& alloc, MDefinition* elements) {
return new(alloc) MNot(elements);
static MNot* New(TempAllocator& alloc, MDefinition* elements,
CompilerConstraintList* constraints = nullptr)
{
return new(alloc) MNot(elements, constraints);
}
static MNot* NewAsmJS(TempAllocator& alloc, MDefinition* elements) {
MNot* ins = new(alloc) MNot(elements);
@ -8056,7 +8062,6 @@ class MNot
INSTRUCTION_HEADER(Not)
void cacheOperandMightEmulateUndefined(CompilerConstraintList* constraints);
MDefinition* foldsTo(TempAllocator& alloc) override;
void markOperandCantEmulateUndefined() {