Changeset 204009 in webkit


Ignore:
Timestamp:
Aug 1, 2016 10:02:27 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

[JSC][ARM64] Fix branchTest32/64 taking an immediate as mask
https://bugs.webkit.org/show_bug.cgi?id=160439

Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-08-01
Reviewed by Filip Pizlo.

Source/JavaScriptCore:

  • assembler/MacroAssemblerARM64.h:

(JSC::MacroAssemblerARM64::branchTest64):

  • b3/air/AirOpcode.opcodes:

Fix the ARM64 codegen to lower BitImm64 without using a scratch register.

Source/WTF:

  • wtf/MathExtras.h:

(getLSBSet):
This was not working at all for MacroAssembler.
Since TrustedImm32/64 are signed integers, the arithmetic shift would
never get rid of the top bit and we get an infinite loop.

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r203996 r204009  
     12016-08-01  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC][ARM64] Fix branchTest32/64 taking an immediate as mask
     4        https://bugs.webkit.org/show_bug.cgi?id=160439
     5
     6        Reviewed by Filip Pizlo.
     7
     8        * assembler/MacroAssemblerARM64.h:
     9        (JSC::MacroAssemblerARM64::branchTest64):
     10        * b3/air/AirOpcode.opcodes:
     11        Fix the ARM64 codegen to lower BitImm64 without using a scratch register.
     12
    1132016-07-22  Filip Pizlo  <fpizlo@apple.com>
    214
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM64.h

    r203851 r204009  
    25212521    Jump branchTest64(ResultCondition cond, RegisterID reg, TrustedImm64 mask)
    25222522    {
    2523         move(mask, getCachedDataTempRegisterIDAndInvalidate());
    2524         return branchTest64(cond, reg, dataTempRegister);
     2523        if (mask.m_value == -1) {
     2524            if ((cond == Zero) || (cond == NonZero))
     2525                return Jump(makeCompareAndBranch<64>(static_cast<ZeroCondition>(cond), reg));
     2526            m_assembler.tst<64>(reg, reg);
     2527        } else if (hasOneBitSet(mask.m_value) && ((cond == Zero) || (cond == NonZero)))
     2528            return Jump(makeTestBitAndBranch(reg, getLSBSet(mask.m_value), static_cast<ZeroCondition>(cond)));
     2529        else {
     2530            LogicalImmediate logicalImm = LogicalImmediate::create64(mask.m_value);
     2531
     2532            if (logicalImm.isValid()) {
     2533                m_assembler.tst<64>(reg, logicalImm);
     2534                return Jump(makeBranch(cond));
     2535            }
     2536
     2537            move(mask, getCachedDataTempRegisterIDAndInvalidate());
     2538            m_assembler.tst<64>(reg, dataTempRegister);
     2539        }
     2540        return Jump(makeBranch(cond));
    25252541    }
    25262542
  • trunk/Source/JavaScriptCore/b3/air/AirOpcode.opcodes

    r203996 r204009  
    681681BranchTest32 U:G:32, U:G:32, U:G:32 /branch
    682682    ResCond, Tmp, Tmp
    683     x86: ResCond, Tmp, BitImm
     683    ResCond, Tmp, BitImm
    684684    x86: ResCond, Addr, BitImm
    685685    x86: ResCond, Index, BitImm
     
    68968964: BranchTest64 U:G:32, U:G:64, U:G:64 /branch
    690690    ResCond, Tmp, Tmp
     691    arm64: ResCond, Tmp, BitImm64
    691692    x86: ResCond, Tmp, BitImm
    692693    x86: ResCond, Addr, BitImm
  • trunk/Source/WTF/ChangeLog

    r203911 r204009  
     12016-08-01  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [JSC][ARM64] Fix branchTest32/64 taking an immediate as mask
     4        https://bugs.webkit.org/show_bug.cgi?id=160439
     5
     6        Reviewed by Filip Pizlo.
     7
     8        * wtf/MathExtras.h:
     9        (getLSBSet):
     10        This was not working at all for MacroAssembler.
     11        Since TrustedImm32/64 are signed integers, the arithmetic shift would
     12        never get rid of the top bit and we get an infinite loop.
     13
    1142016-07-29  Mark Lam  <mark.lam@apple.com>
    215
  • trunk/Source/WTF/wtf/MathExtras.h

    r199133 r204009  
    216216template <typename T> inline unsigned getLSBSet(T value)
    217217{
     218    typedef typename std::make_unsigned<T>::type UnsignedT;
    218219    unsigned result = 0;
    219220
    220     while (value >>= 1)
     221    UnsignedT unsignedValue = static_cast<UnsignedT>(value);
     222    while (unsignedValue >>= 1)
    221223        ++result;
    222224
Note: See TracChangeset for help on using the changeset viewer.