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):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.