Changeset 146396 in webkit


Ignore:
Timestamp:
Mar 20, 2013 3:07:23 PM (11 years ago)
Author:
zherczeg@webkit.org
Message:

ARMv7 replaceWithJump ASSERT failure after r135330.
https://bugs.webkit.org/show_bug.cgi?id=103146

Reviewed by Filip Pizlo.

On Linux, the 24 bit distance range of jumps sometimes does not
enough to cover all targets addresses. This patch supports jumps
outside of this range using a mov/movt/bx 10 byte long sequence.

  • assembler/ARMv7Assembler.h:

(ARMv7Assembler):
(JSC::ARMv7Assembler::revertJumpTo_movT3movtcmpT2):
(JSC::ARMv7Assembler::nopw):
(JSC::ARMv7Assembler::label):
(JSC::ARMv7Assembler::replaceWithJump):
(JSC::ARMv7Assembler::maxJumpReplacementSize):

  • assembler/MacroAssemblerARMv7.h:

(JSC::MacroAssemblerARMv7::revertJumpReplacementToBranchPtrWithPatch):

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r146392 r146396  
     12013-03-20  Zoltan Herczeg  <zherczeg@webkit.org>
     2
     3        ARMv7 replaceWithJump ASSERT failure after r135330.
     4        https://bugs.webkit.org/show_bug.cgi?id=103146
     5
     6        Reviewed by Filip Pizlo.
     7
     8        On Linux, the 24 bit distance range of jumps sometimes does not
     9        enough to cover all targets addresses. This patch supports jumps
     10        outside of this range using a mov/movt/bx 10 byte long sequence.
     11
     12        * assembler/ARMv7Assembler.h:
     13        (ARMv7Assembler):
     14        (JSC::ARMv7Assembler::revertJumpTo_movT3movtcmpT2):
     15        (JSC::ARMv7Assembler::nopw):
     16        (JSC::ARMv7Assembler::label):
     17        (JSC::ARMv7Assembler::replaceWithJump):
     18        (JSC::ARMv7Assembler::maxJumpReplacementSize):
     19        * assembler/MacroAssemblerARMv7.h:
     20        (JSC::MacroAssemblerARMv7::revertJumpReplacementToBranchPtrWithPatch):
     21
    1222013-03-20  Mark Hahnenberg  <mhahnenberg@apple.com>
    223
  • trunk/Source/JavaScriptCore/assembler/ARMv7Assembler.h

    r145505 r146396  
    12671267    }
    12681268   
     1269#if OS(LINUX)
     1270    static void revertJumpTo_movT3movtcmpT2(void* instructionStart, RegisterID left, RegisterID right, uintptr_t imm)
     1271    {
     1272        uint16_t* address = static_cast<uint16_t*>(instructionStart);
     1273        ARMThumbImmediate lo16 = ARMThumbImmediate::makeUInt16(static_cast<uint16_t>(imm));
     1274        ARMThumbImmediate hi16 = ARMThumbImmediate::makeUInt16(static_cast<uint16_t>(imm >> 16));
     1275        address[0] = twoWordOp5i6Imm4Reg4EncodedImmFirst(OP_MOV_imm_T3, lo16);
     1276        address[1] = twoWordOp5i6Imm4Reg4EncodedImmSecond(right, lo16);
     1277        address[2] = twoWordOp5i6Imm4Reg4EncodedImmFirst(OP_MOVT, hi16);
     1278        address[3] = twoWordOp5i6Imm4Reg4EncodedImmSecond(right, hi16);
     1279        address[4] = OP_CMP_reg_T2 | left;
     1280        cacheFlush(address, sizeof(uint16_t) * 5);
     1281    }
     1282#else
    12691283    static void revertJumpTo_movT3(void* instructionStart, RegisterID rd, ARMThumbImmediate imm)
    12701284    {
     
    12781292        cacheFlush(address, sizeof(uint16_t) * 2);
    12791293    }
     1294#endif
    12801295
    12811296    ALWAYS_INLINE void mov(RegisterID rd, ARMThumbImmediate imm)
     
    18831898        m_formatter.oneWordOp8Imm8(OP_NOP_T1, 0);
    18841899    }
    1885    
     1900
     1901    void nopw()
     1902    {
     1903        m_formatter.twoWordOp16Op16(OP_NOP_T2a, OP_NOP_T2b);
     1904    }
     1905
    18861906    AssemblerLabel labelIgnoringWatchpoints()
    18871907    {
     
    19031923        AssemblerLabel result = m_formatter.label();
    19041924        while (UNLIKELY(static_cast<int>(result.m_offset) < m_indexOfTailOfLastWatchpoint)) {
    1905             nop();
     1925            if (UNLIKELY(static_cast<int>(result.m_offset) + 4 <= m_indexOfTailOfLastWatchpoint))
     1926                nopw();
     1927            else
     1928                nop();
    19061929            result = m_formatter.label();
    19071930        }
     
    21612184        ASSERT(!(bitwise_cast<uintptr_t>(instructionStart) & 1));
    21622185        ASSERT(!(bitwise_cast<uintptr_t>(to) & 1));
     2186
     2187#if OS(LINUX)
     2188        if (canBeJumpT4(reinterpret_cast<uint16_t*>(instructionStart), to)) {
     2189            uint16_t* ptr = reinterpret_cast<uint16_t*>(instructionStart) + 2;
     2190            linkJumpT4(ptr, to);
     2191            cacheFlush(ptr - 2, sizeof(uint16_t) * 2);
     2192        } else {
     2193            uint16_t* ptr = reinterpret_cast<uint16_t*>(instructionStart) + 5;
     2194            linkBX(ptr, to);
     2195            cacheFlush(ptr - 5, sizeof(uint16_t) * 5);
     2196        }
     2197#else
    21632198        uint16_t* ptr = reinterpret_cast<uint16_t*>(instructionStart) + 2;
    2164        
    21652199        linkJumpT4(ptr, to);
    21662200        cacheFlush(ptr - 2, sizeof(uint16_t) * 2);
     2201#endif
    21672202    }
    21682203   
    21692204    static ptrdiff_t maxJumpReplacementSize()
    21702205    {
     2206#if OS(LINUX)
     2207        return 10;
     2208#else
    21712209        return 4;
     2210#endif
    21722211    }
    21732212   
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h

    r146195 r146396  
    17741774    }
    17751775   
    1776     static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID, void* initialValue)
    1777     {
     1776    static void revertJumpReplacementToBranchPtrWithPatch(CodeLocationLabel instructionStart, RegisterID rd, void* initialValue)
     1777    {
     1778#if OS(LINUX)
     1779        ARMv7Assembler::revertJumpTo_movT3movtcmpT2(instructionStart.dataLocation(), rd, dataTempRegister, reinterpret_cast<uintptr_t>(initialValue));
     1780#else
     1781        UNUSED_PARAM(rd);
    17781782        ARMv7Assembler::revertJumpTo_movT3(instructionStart.dataLocation(), dataTempRegister, ARMThumbImmediate::makeUInt16(reinterpret_cast<uintptr_t>(initialValue) & 0xffff));
     1783#endif
    17791784    }
    17801785   
Note: See TracChangeset for help on using the changeset viewer.