Changeset 218519 in webkit


Ignore:
Timestamp:
Jun 19, 2017 5:50:23 PM (7 years ago)
Author:
Caio Lima
Message:

[ARMv6][DFG] ARM MacroAssembler is always emitting cmn when immediate is 0
https://bugs.webkit.org/show_bug.cgi?id=172972

Reviewed by Mark Lam.

We are changing internalCompare32 implementation in ARM
MacroAssembler to emit "cmp" when the "right.value" is 0.
It is generating wrong comparison cases, since the
semantics of cmn is opposite of cmp[1]. One case that it's breaking is
"branch32(MacroAssembler::Above, gpr, TrustedImm32(0))", where ends
resulting in following assembly code:

`
cmn $r0, #0
bhi <address>
`

However, as cmn is similar to "adds", it will never take the branch
when $r0 > 0. In that case, the correct opcode is "cmp". With this
patch we will fix current broken tests that uses
"branch32(MacroAssembler::Above, gpr, TrustedImm32(0))",
such as ForwardVarargs, Spread and GetRestLength.

[1] - http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihiddid.html

  • assembler/MacroAssemblerARM.h:

(JSC::MacroAssemblerARM::internalCompare32):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r218512 r218519  
     12017-06-19  Caio Lima  <ticaiolima@gmail.com>
     2
     3        [ARMv6][DFG] ARM MacroAssembler is always emitting cmn when immediate is 0
     4        https://bugs.webkit.org/show_bug.cgi?id=172972
     5
     6        Reviewed by Mark Lam.
     7
     8        We are changing internalCompare32 implementation in ARM
     9        MacroAssembler to emit "cmp" when the "right.value" is 0.
     10        It is generating wrong comparison cases, since the
     11        semantics of cmn is opposite of cmp[1]. One case that it's breaking is
     12        "branch32(MacroAssembler::Above, gpr, TrustedImm32(0))", where ends
     13        resulting in following assembly code:
     14
     15        ```
     16        cmn $r0, #0
     17        bhi <address>
     18        ```
     19
     20        However, as cmn is similar to "adds", it will never take the branch
     21        when $r0 > 0. In that case, the correct opcode is "cmp". With this
     22        patch we will fix current broken tests that uses
     23        "branch32(MacroAssembler::Above, gpr, TrustedImm32(0))",
     24        such as ForwardVarargs, Spread and GetRestLength.
     25
     26        [1] - http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihiddid.html
     27
     28        * assembler/MacroAssemblerARM.h:
     29        (JSC::MacroAssemblerARM::internalCompare32):
     30
    1312017-06-19  Joseph Pecoraro  <pecoraro@apple.com>
    232
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM.h

    r217756 r218519  
    16011601    void internalCompare32(RegisterID left, TrustedImm32 right)
    16021602    {
    1603         ARMWord tmp = (static_cast<unsigned>(right.m_value) == 0x80000000) ? ARMAssembler::InvalidImmediate : m_assembler.getOp2(-right.m_value);
     1603        ARMWord tmp = (!right.value || static_cast<unsigned>(right.m_value) == 0x80000000) ? ARMAssembler::InvalidImmediate : m_assembler.getOp2(-right.m_value);
    16041604        if (tmp != ARMAssembler::InvalidImmediate)
    16051605            m_assembler.cmn(left, tmp);
     
    16101610    void internalCompare32(Address left, TrustedImm32 right)
    16111611    {
    1612         ARMWord tmp = (static_cast<unsigned>(right.m_value) == 0x80000000) ? ARMAssembler::InvalidImmediate : m_assembler.getOp2(-right.m_value);
     1612        ARMWord tmp = (!right.value || static_cast<unsigned>(right.m_value) == 0x80000000) ? ARMAssembler::InvalidImmediate : m_assembler.getOp2(-right.m_value);
    16131613        load32(left, ARMRegisters::S1);
    16141614        if (tmp != ARMAssembler::InvalidImmediate)
Note: See TracChangeset for help on using the changeset viewer.