Changeset 179888 in webkit
- Timestamp:
- Feb 10, 2015, 3:24:24 PM (12 years ago)
- Location:
- branches/safari-600.1.4.15-branch/Source/JavaScriptCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
assembler/ARMv7Assembler.h (modified) (1 diff)
-
disassembler/ARMv7/ARMv7DOpcode.cpp (modified) (2 diffs)
-
disassembler/ARMv7/ARMv7DOpcode.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-600.1.4.15-branch/Source/JavaScriptCore/ChangeLog
r179685 r179888 1 2015-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 1 71 2015-02-05 Lucas Forschler <lforschler@apple.com> 2 72 -
branches/safari-600.1.4.15-branch/Source/JavaScriptCore/assembler/ARMv7Assembler.h
r171123 r179888 1195 1195 ASSERT(rn != ARMRegisters::pc); // LDR (literal) 1196 1196 ASSERT(imm.isUInt12()); 1197 ASSERT(!(imm.isUInt12() & 1)); 1197 1198 1198 1199 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); 1200 1201 else 1201 1202 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 92 92 OPCODE_GROUP_ENTRY(0xe, ARMv7DOpcodeLoadStoreRegisterImmediateWordAndByte), 93 93 OPCODE_GROUP_ENTRY(0xf, ARMv7DOpcodeLoadStoreRegisterImmediateWordAndByte), 94 OPCODE_GROUP_ENTRY(0x10, ARMv7DOpcode LoadStoreRegisterImmediateHalfWord),95 OPCODE_GROUP_ENTRY(0x11, ARMv7DOpcodeLoad StoreRegisterImmediateHalfWord),94 OPCODE_GROUP_ENTRY(0x10, ARMv7DOpcodeStoreRegisterImmediateHalfWord), 95 OPCODE_GROUP_ENTRY(0x11, ARMv7DOpcodeLoadRegisterImmediateHalfWord), 96 96 OPCODE_GROUP_ENTRY(0x12, ARMv7DOpcodeLoadStoreRegisterSPRelative), 97 97 OPCODE_GROUP_ENTRY(0x13, ARMv7DOpcodeLoadStoreRegisterSPRelative), … … 513 513 514 514 return m_formatBuffer; 515 } 516 517 unsigned 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; 515 534 } 516 535 -
branches/safari-600.1.4.15-branch/Source/JavaScriptCore/disassembler/ARMv7/ARMv7DOpcode.h
r170839 r179888 276 276 277 277 unsigned op() { return (m_opcode >> 9) & 0x1; } 278 unsigned immediate3() { return (m_opcode >> 6) & 0x 3; }278 unsigned immediate3() { return (m_opcode >> 6) & 0x7; } 279 279 unsigned rn() { return (m_opcode >> 3) & 0x7; } 280 280 }; … … 442 442 unsigned rn() { return (m_opcode >> 3) & 0x7; } 443 443 unsigned rt() { return m_opcode & 0x7; } 444 unsigned scale() { return 2 - (op() >> 1); }444 unsigned scale(); 445 445 }; 446 446 … … 453 453 }; 454 454 455 class ARMv7DOpcode LoadStoreRegisterImmediateHalfWord : public ARMv7DOpcodeLoadStoreRegisterImmediate {455 class ARMv7DOpcodeStoreRegisterImmediateHalfWord : public ARMv7DOpcodeLoadStoreRegisterImmediate { 456 456 public: 457 457 static const uint16_t s_mask = 0xf800; 458 458 static const uint16_t s_pattern = 0x8000; 459 460 DEFINE_STATIC_FORMAT16(ARMv7DOpcodeLoadStoreRegisterImmediate, thisObj); 461 }; 462 463 class ARMv7DOpcodeLoadRegisterImmediateHalfWord : public ARMv7DOpcodeLoadStoreRegisterImmediate { 464 public: 465 static const uint16_t s_mask = 0xf800; 466 static const uint16_t s_pattern = 0x8800; 459 467 460 468 DEFINE_STATIC_FORMAT16(ARMv7DOpcodeLoadStoreRegisterImmediate, thisObj);
Note:
See TracChangeset
for help on using the changeset viewer.