Changeset 65993 in webkit for trunk/JavaScriptCore/assembler


Ignore:
Timestamp:
Aug 25, 2010, 12:52:16 AM (15 years ago)
Author:
[email protected]
Message:

Enable truncated floating point feature on ARM
https://bugs.webkit.org/show_bug.cgi?id=44233

Reviewed by Gavin Barraclough.

Enable truncated floating point feature with the help of VCVTR.S32.F64
instruction. If VCVTR.S32.F64 can't fit the result into a 32-bit
integer/register, it saturates at INT_MAX or INT_MIN. Testing this
looks quicker than testing FPSCR for exception.

Inspired by Jacob Bramley's patch from JaegerMonkey

  • assembler/ARMAssembler.h:

(JSC::ARMAssembler::):
(JSC::ARMAssembler::cmn_r):
(JSC::ARMAssembler::vcvtr_s32_f64_r):

  • assembler/MacroAssemblerARM.h:

(JSC::MacroAssemblerARM::supportsFloatingPointTruncate):
(JSC::MacroAssemblerARM::branchTruncateDoubleToInt32):

Location:
trunk/JavaScriptCore/assembler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/assembler/ARMAssembler.h

    r65303 r65993  
    162162            VCVT_F64_S32 = 0x0eb80bc0,
    163163            VCVT_S32_F64 = 0x0ebd0b40,
     164            VCVTR_S32_F64 = 0x0ebd0bc0,
    164165            VMRS_APSR = 0x0ef1fa10,
    165166#if WTF_ARM_ARCH_AT_LEAST(5)
     
    372373        }
    373374
     375        void cmn_r(int rn, ARMWord op2, Condition cc = AL)
     376        {
     377            emitInst(static_cast<ARMWord>(cc) | CMN | SET_CC, 0, rn, op2);
     378        }
     379
    374380        void orr_r(int rd, int rn, ARMWord op2, Condition cc = AL)
    375381        {
     
    577583            ASSERT(!(sd & 0x1)); // sd must be divisible by 2
    578584            emitDoublePrecisionInst(static_cast<ARMWord>(cc) | VCVT_S32_F64, (sd >> 1), 0, dm);
     585        }
     586
     587        void vcvtr_s32_f64_r(int sd, int dm, Condition cc = AL)
     588        {
     589            ASSERT(!(sd & 0x1)); // sd must be divisible by 2
     590            emitDoublePrecisionInst(static_cast<ARMWord>(cc) | VCVTR_S32_F64, (sd >> 1), 0, dm);
    579591        }
    580592
  • trunk/JavaScriptCore/assembler/MacroAssemblerARM.h

    r65303 r65993  
    770770    bool supportsFloatingPointTruncate() const
    771771    {
    772         return false;
     772        return s_isVFPPresent;
    773773    }
    774774
     
    879879    // If the result is not representable as a 32 bit value, branch.
    880880    // May also branch for some values that are representable in 32 bits
    881     // (specifically, in this case, INT_MIN).
     881    // (specifically, in this case, INT_MIN and INT_MAX).
    882882    Jump branchTruncateDoubleToInt32(FPRegisterID src, RegisterID dest)
    883883    {
    884         UNUSED_PARAM(src);
    885         UNUSED_PARAM(dest);
    886         ASSERT_NOT_REACHED();
    887         return jump();
     884        m_assembler.vcvtr_s32_f64_r(ARMRegisters::SD0 << 1, src);
     885        // If VCVTR.S32.F64 can't fit the result into a 32-bit
     886        // integer, it saturates at INT_MAX or INT_MIN. Testing this is
     887        // probably quicker than testing FPSCR for exception.
     888        m_assembler.vmov_arm_r(dest, ARMRegisters::SD0 << 1);
     889        m_assembler.sub_r(ARMRegisters::S0, dest, ARMAssembler::getOp2(0x80000000));
     890        m_assembler.cmn_r(ARMRegisters::S0, ARMAssembler::getOp2(1), ARMCondition(NotEqual));
     891        return Jump(m_assembler.jmp(ARMCondition(Equal)));
    888892    }
    889893
Note: See TracChangeset for help on using the changeset viewer.