Add absDouble to the MacroAssembler interface, and abstract the 'x & -x' trick away as it is an x86-specific optimization. [bug 655260] [r=bhackett]

This commit is contained in:
Jacob Bramley 2011-05-11 15:16:22 +01:00
parent d187d1fc87
commit f6cf2952eb
4 changed files with 23 additions and 4 deletions

View File

@ -190,6 +190,7 @@ namespace JSC {
FCPYD = 0x0eb00b40,
FADDD = 0x0e300b00,
FNEGD = 0x0eb10b40,
FABSD = 0x0eb00bc0,
FDIVD = 0x0e800b00,
FSUBD = 0x0e300b40,
FMULD = 0x0e200b00,
@ -548,6 +549,13 @@ namespace JSC {
m_buffer.putInt(static_cast<ARMWord>(cc) | FNEGD | DD(dd) | DM(dm));
}
void fabsd_r(int dd, int dm, Condition cc = AL)
{
js::JaegerSpew(js::JSpew_Insns,
IPFX "%-15s %s, %s, %s, %s\n", MAYBE_PAD, "fabsd", nameFpRegD(dd), nameFpRegD(dm));
m_buffer.putInt(static_cast<ARMWord>(cc) | FABSD | DD(dd) | DM(dm));
}
void fdivd_r(int dd, int dn, int dm, Condition cc = AL)
{
js::JaegerSpew(js::JSpew_Insns,

View File

@ -1037,6 +1037,11 @@ public:
m_assembler.fnegd_r(dest, src);
}
void absDouble(FPRegisterID src, FPRegisterID dest)
{
m_assembler.fabsd_r(dest, src);
}
void sqrtDouble(FPRegisterID src, FPRegisterID dest)
{
m_assembler.fsqrtd_r(dest, src);

View File

@ -639,6 +639,15 @@ public:
m_assembler.andpd_rr(src, dest);
}
void absDouble(FPRegisterID src, FPRegisterID dest)
{
ASSERT(isSSE2Present());
/* Compile abs(x) as x & -x. */
zeroDouble(dest);
subDouble(src, dest);
andDouble(src, dest);
}
void convertInt32ToDouble(RegisterID src, FPRegisterID dest)
{
ASSERT(isSSE2Present());

View File

@ -94,10 +94,7 @@ mjit::Compiler::compileMathAbsDouble(FrameEntry *arg)
MaybeJump notNumber = loadDouble(arg, &fpReg, &allocate);
JS_ASSERT(!notNumber.isSet());
/* Compile abs(x) as x & -x. */
masm.zeroDouble(fpResultReg);
masm.subDouble(fpReg, fpResultReg);
masm.andDouble(fpReg, fpResultReg);
masm.absDouble(fpReg, fpResultReg);
if (allocate)
frame.freeReg(fpReg);