⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 179888 in webkit


Ignore:
Timestamp:
Feb 10, 2015, 3:24:24 PM (12 years ago)
Author:
bshafiei@apple.com
Message:

Merged r176083. rdar://problem/19670901

Location:
branches/safari-600.1.4.15-branch/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-600.1.4.15-branch/Source/JavaScriptCore/ChangeLog

    r179685 r179888  
     12015-02-10  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Merge r176083.
     4
     5    2014-11-13  Benjamin Poulain  <benjamin@webkit.org>
     6
     7            ARMv7(s) Assembler: LDRH with immediate offset is loading from the wrong offset
     8            https://bugs.webkit.org/show_bug.cgi?id=136914
     9
     10            Reviewed by Michael Saboff.
     11
     12            TLDR: the immediate offset of half-word load was divided by 2.
     13
     14            Story time: So I started getting those weird reports of :nth-child() behaving bizarrely
     15            on ARMv7 and ARMv7s. To make things worse, the behavior changes depending on style updates.
     16
     17            I started looking the disassembly on the tests cases...
     18
     19            The first thing I noticed was that the computation of An+B looked wrong. For example,
     20            in the case of n+6, the instruction should have been:
     21                subs r1, r1, #6
     22            but was
     23                subs r1, r1, #2
     24
     25            After spending a lot of time trying to find the error in the assembler, I discovered
     26            the problem was not real, but just a bug in the disassembler.
     27            This is the first fix: ARMv7DOpcodeAddSubtractImmediate3's immediate3() was truncating
     28            the value to 2 bits instead of 3 bits.
     29
     30            The disassembler being fixed, I still have no lead on the weird bug. Some disassembly later,
     31            I realize the LDRH instruction is not decoded at all. The reason is that both LDRH and STRH
     32            were under the umbrella ARMv7DOpcodeLoadStoreRegisterImmediateHalfWord but the pattern
     33            only matched SRTH.
     34
     35            I fix that next, ARMv7DOpcodeLoadStoreRegisterImmediateHalfWord is split into
     36            ARMv7DOpcodeStoreRegisterImmediateHalfWord and ARMv7DOpcodeLoadRegisterImmediateHalfWord,
     37            each with their own pattern and their instruction group.
     38
     39            Now that I can see the LDRHs correctly, there is something fishy about them, their offset
     40            is way too small for the data I load.
     41
     42            This time, looking at the binary, the generated code is indeed incorrect. It turns out that
     43            the ARMv7 assembler shifted the offset of half-word load as if they were byte load: divided by 4.
     44            As a result, all the load of half-words with more than zero offset were loading
     45            values with a smaller offset than what they should have.
     46
     47            That being fixed, I dump the assembly: still wrong. I am ready to throw my keyboard through
     48            my screen at that point.
     49
     50            Looking at the disassembler, there is yet again a bug. The computation of the scale() adjustment
     51            of the offset was incorrect for anything but word loads.
     52            I replaced it by a switch-case to make it explicit.
     53
     54            STRH is likely incorrect too. I'll fix that in a follow up, I want to survey all the 16 bits cases
     55            that are not directly used by the CSS JIT.
     56
     57            * assembler/ARMv7Assembler.h:
     58            (JSC::ARMv7Assembler::ldrh):
     59            Fix the immediate scaling. Add an assertion to make sure the alignment of the input is correct.
     60
     61            * disassembler/ARMv7/ARMv7DOpcode.cpp:
     62            (JSC::ARMv7Disassembler::ARMv7DOpcodeLoadStoreRegisterImmediate::scale):
     63            Fix the scaling code. Just hardcode instruction-to-scale table.
     64
     65            * disassembler/ARMv7/ARMv7DOpcode.h:
     66            (JSC::ARMv7Disassembler::ARMv7DOpcodeAddSubtractImmediate3::immediate3):
     67            The mask for a 3 bits immediate is not 3 :)
     68
     69            (JSC::ARMv7Disassembler::ARMv7DOpcodeLoadStoreRegisterImmediate::scale): Deleted.
     70
    1712015-02-05  Lucas Forschler  <lforschler@apple.com>
    272
  • branches/safari-600.1.4.15-branch/Source/JavaScriptCore/assembler/ARMv7Assembler.h

    r171123 r179888  
    11951195        ASSERT(rn != ARMRegisters::pc); // LDR (literal)
    11961196        ASSERT(imm.isUInt12());
     1197        ASSERT(!(imm.isUInt12() & 1));
    11971198
    11981199        if (!((rt | rn) & 8) && imm.isUInt6())
    1199             m_formatter.oneWordOp5Imm5Reg3Reg3(OP_LDRH_imm_T1, imm.getUInt6() >> 2, rn, rt);
     1200            m_formatter.oneWordOp5Imm5Reg3Reg3(OP_LDRH_imm_T1, imm.getUInt6() >> 1, rn, rt);
    12001201        else
    12011202            m_formatter.twoWordOp12Reg4Reg4Imm12(OP_LDRH_imm_T2, rn, rt, imm.getUInt12());
  • branches/safari-600.1.4.15-branch/Source/JavaScriptCore/disassembler/ARMv7/ARMv7DOpcode.cpp

    r170843 r179888  
    9292    OPCODE_GROUP_ENTRY(0xe, ARMv7DOpcodeLoadStoreRegisterImmediateWordAndByte),
    9393    OPCODE_GROUP_ENTRY(0xf, ARMv7DOpcodeLoadStoreRegisterImmediateWordAndByte),
    94     OPCODE_GROUP_ENTRY(0x10, ARMv7DOpcodeLoadStoreRegisterImmediateHalfWord),
    95     OPCODE_GROUP_ENTRY(0x11, ARMv7DOpcodeLoadStoreRegisterImmediateHalfWord),
     94    OPCODE_GROUP_ENTRY(0x10, ARMv7DOpcodeStoreRegisterImmediateHalfWord),
     95    OPCODE_GROUP_ENTRY(0x11, ARMv7DOpcodeLoadRegisterImmediateHalfWord),
    9696    OPCODE_GROUP_ENTRY(0x12, ARMv7DOpcodeLoadStoreRegisterSPRelative),
    9797    OPCODE_GROUP_ENTRY(0x13, ARMv7DOpcodeLoadStoreRegisterSPRelative),
     
    513513
    514514    return m_formatBuffer;
     515}
     516
     517unsigned ARMv7DOpcodeLoadStoreRegisterImmediate::scale()
     518{
     519    switch (op()) {
     520    case 0:
     521    case 1:
     522        return 2;
     523    case 2:
     524    case 3:
     525        return 0;
     526    case 4:
     527    case 5:
     528        return 1;
     529    default:
     530        break;
     531    }
     532    ASSERT_NOT_REACHED();
     533    return 0;
    515534}
    516535
  • branches/safari-600.1.4.15-branch/Source/JavaScriptCore/disassembler/ARMv7/ARMv7DOpcode.h

    r170839 r179888  
    276276
    277277    unsigned op() { return (m_opcode >> 9) & 0x1; }
    278     unsigned immediate3() { return (m_opcode >> 6) & 0x3; }
     278    unsigned immediate3() { return (m_opcode >> 6) & 0x7; }
    279279    unsigned rn() { return (m_opcode >> 3) & 0x7; }
    280280};
     
    442442    unsigned rn() { return (m_opcode >> 3) & 0x7; }
    443443    unsigned rt() { return m_opcode & 0x7; }
    444     unsigned scale() { return 2 - (op() >> 1); }
     444    unsigned scale();
    445445};
    446446
     
    453453};
    454454
    455 class ARMv7DOpcodeLoadStoreRegisterImmediateHalfWord : public ARMv7DOpcodeLoadStoreRegisterImmediate {
     455class ARMv7DOpcodeStoreRegisterImmediateHalfWord : public ARMv7DOpcodeLoadStoreRegisterImmediate {
    456456public:
    457457    static const uint16_t s_mask = 0xf800;
    458458    static const uint16_t s_pattern = 0x8000;
     459
     460    DEFINE_STATIC_FORMAT16(ARMv7DOpcodeLoadStoreRegisterImmediate, thisObj);
     461};
     462
     463class ARMv7DOpcodeLoadRegisterImmediateHalfWord : public ARMv7DOpcodeLoadStoreRegisterImmediate {
     464public:
     465    static const uint16_t s_mask = 0xf800;
     466    static const uint16_t s_pattern = 0x8800;
    459467
    460468    DEFINE_STATIC_FORMAT16(ARMv7DOpcodeLoadStoreRegisterImmediate, thisObj);
Note: See TracChangeset for help on using the changeset viewer.