Changeset 85432 in webkit
- Timestamp:
- May 1, 2011 3:20:59 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r85429 r85432 1 2011-05-01 Gavin Barraclough <barraclough@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 https://bugs.webkit.org/show_bug.cgi?id=59896 6 Remove JmpSrc/JmpDst types. 7 8 The JmpSrc/JmpDst classes predate the MacroAssembler interface. Having these 9 object be per-assembler in unhelpful, causes unnecessary code duplication, 10 and prevents the AssemblerBuffer from providing a richer type for labels. 11 The limited semantic meaning that they did convey is undermined by the manner 12 in which their meanings have been overloaded (use of JmpSrc for Call, JmpDst 13 for data labels). 14 15 Jumps on ARMv7 have had additional information added to the object via the 16 ARMv7 JmpSrc. This data should probably be in the instruction stream. This 17 patch does not fix the problem, and moves the data (ifdefed) to 18 AbstractMacroAssembler::Jump (which is effectively where it was before!). 19 This at least closes the hole such that no further data may be added to JmpSrc, 20 but this is unfortunate, and should be cleaned up. 21 22 * assembler/ARMAssembler.h: 23 (JSC::ARMAssembler::blx): 24 (JSC::ARMAssembler::label): 25 (JSC::ARMAssembler::align): 26 (JSC::ARMAssembler::loadBranchTarget): 27 (JSC::ARMAssembler::jmp): 28 (JSC::ARMAssembler::linkPointer): 29 (JSC::ARMAssembler::linkJump): 30 (JSC::ARMAssembler::linkCall): 31 (JSC::ARMAssembler::getRelocatedAddress): 32 (JSC::ARMAssembler::getDifferenceBetweenLabels): 33 (JSC::ARMAssembler::getCallReturnOffset): 34 * assembler/ARMv7Assembler.h: 35 (JSC::ARMv7Assembler::b): 36 (JSC::ARMv7Assembler::blx): 37 (JSC::ARMv7Assembler::bx): 38 (JSC::ARMv7Assembler::label): 39 (JSC::ARMv7Assembler::align): 40 (JSC::ARMv7Assembler::getRelocatedAddress): 41 (JSC::ARMv7Assembler::getDifferenceBetweenLabels): 42 (JSC::ARMv7Assembler::getCallReturnOffset): 43 (JSC::ARMv7Assembler::linkJump): 44 (JSC::ARMv7Assembler::linkCall): 45 (JSC::ARMv7Assembler::linkPointer): 46 * assembler/AbstractMacroAssembler.h: 47 (JSC::AbstractMacroAssembler::Label::isSet): 48 (JSC::AbstractMacroAssembler::Call::Call): 49 (JSC::AbstractMacroAssembler::Jump::Jump): 50 (JSC::AbstractMacroAssembler::Jump::link): 51 (JSC::AbstractMacroAssembler::Jump::linkTo): 52 (JSC::AbstractMacroAssembler::linkPointer): 53 (JSC::AbstractMacroAssembler::getLinkerAddress): 54 * assembler/AssemblerBuffer.h: 55 (JSC::AssemblerLabel::AssemblerLabel): 56 (JSC::AssemblerLabel::isSet): 57 * assembler/LinkBuffer.h: 58 (JSC::LinkBuffer::patch): 59 * assembler/MIPSAssembler.h: 60 (JSC::MIPSAssembler::label): 61 (JSC::MIPSAssembler::align): 62 (JSC::MIPSAssembler::getRelocatedAddress): 63 (JSC::MIPSAssembler::getDifferenceBetweenLabels): 64 (JSC::MIPSAssembler::getCallReturnOffset): 65 (JSC::MIPSAssembler::linkJump): 66 (JSC::MIPSAssembler::linkCall): 67 (JSC::MIPSAssembler::linkPointer): 68 * assembler/MacroAssemblerARMv7.h: 69 (JSC::MacroAssemblerARMv7::branchDouble): 70 (JSC::MacroAssemblerARMv7::branchDoubleZeroOrNaN): 71 (JSC::MacroAssemblerARMv7::jump): 72 (JSC::MacroAssemblerARMv7::nearCall): 73 (JSC::MacroAssemblerARMv7::call): 74 (JSC::MacroAssemblerARMv7::ret): 75 (JSC::MacroAssemblerARMv7::tailRecursiveCall): 76 (JSC::MacroAssemblerARMv7::makeBranch): 77 * assembler/MacroAssemblerMIPS.h: 78 (JSC::MacroAssemblerMIPS::nearCall): 79 (JSC::MacroAssemblerMIPS::call): 80 (JSC::MacroAssemblerMIPS::tailRecursiveCall): 81 (JSC::MacroAssemblerMIPS::branchTrue): 82 (JSC::MacroAssemblerMIPS::branchFalse): 83 (JSC::MacroAssemblerMIPS::branchEqual): 84 (JSC::MacroAssemblerMIPS::branchNotEqual): 85 * assembler/SH4Assembler.h: 86 (JSC::SH4Assembler::call): 87 (JSC::SH4Assembler::jmp): 88 (JSC::SH4Assembler::jne): 89 (JSC::SH4Assembler::je): 90 (JSC::SH4Assembler::label): 91 (JSC::SH4Assembler::align): 92 (JSC::SH4Assembler::linkJump): 93 (JSC::SH4Assembler::linkCall): 94 (JSC::SH4Assembler::linkPointer): 95 (JSC::SH4Assembler::getCallReturnOffset): 96 (JSC::SH4Assembler::getRelocatedAddress): 97 (JSC::SH4Assembler::getDifferenceBetweenLabels): 98 (JSC::SH4Assembler::patchPointer): 99 * assembler/X86Assembler.h: 100 (JSC::X86Assembler::call): 101 (JSC::X86Assembler::jmp): 102 (JSC::X86Assembler::jmp_r): 103 (JSC::X86Assembler::jne): 104 (JSC::X86Assembler::jnz): 105 (JSC::X86Assembler::je): 106 (JSC::X86Assembler::jz): 107 (JSC::X86Assembler::jl): 108 (JSC::X86Assembler::jb): 109 (JSC::X86Assembler::jle): 110 (JSC::X86Assembler::jbe): 111 (JSC::X86Assembler::jge): 112 (JSC::X86Assembler::jg): 113 (JSC::X86Assembler::ja): 114 (JSC::X86Assembler::jae): 115 (JSC::X86Assembler::jo): 116 (JSC::X86Assembler::jp): 117 (JSC::X86Assembler::js): 118 (JSC::X86Assembler::jCC): 119 (JSC::X86Assembler::label): 120 (JSC::X86Assembler::labelFor): 121 (JSC::X86Assembler::align): 122 (JSC::X86Assembler::linkJump): 123 (JSC::X86Assembler::linkCall): 124 (JSC::X86Assembler::linkPointer): 125 (JSC::X86Assembler::getCallReturnOffset): 126 (JSC::X86Assembler::getRelocatedAddress): 127 (JSC::X86Assembler::getDifferenceBetweenLabels): 128 (JSC::X86Assembler::rewindToLabel): 129 (JSC::X86Assembler::X86InstructionFormatter::immediateRel32): 130 (JSC::X86Assembler::X86InstructionFormatter::rewindToLabel): 131 * jit/JIT.cpp: 132 (JSC::JIT::privateCompileMainPass): 133 * jit/JIT.h: 134 * jit/JITInlineMethods.h: 135 (JSC::JIT::atJumpTarget): 136 (JSC::JIT::emitGetVirtualRegister): 137 * jit/JITOpcodes.cpp: 138 (JSC::JIT::emit_op_jmp): 139 (JSC::JIT::emit_op_jfalse): 140 (JSC::JIT::emit_op_jeq_null): 141 (JSC::JIT::emit_op_jneq_null): 142 (JSC::JIT::emit_op_jneq_ptr): 143 (JSC::JIT::emit_op_jsr): 144 (JSC::JIT::emit_op_jtrue): 145 (JSC::JIT::emit_op_jmp_scopes): 146 1 147 2011-05-01 Chao-ying Fu <fu@mips.com> 2 148 -
trunk/Source/JavaScriptCore/assembler/ARMAssembler.h
r85403 r85432 214 214 static const int DefaultPrefetching = 2; 215 215 216 class JmpSrc {217 friend class ARMAssembler;218 public:219 JmpSrc()220 : m_offset(-1)221 {222 }223 224 private:225 JmpSrc(int offset)226 : m_offset(offset)227 {228 }229 230 int m_offset;231 };232 233 class JmpDst {234 friend class ARMAssembler;235 public:236 JmpDst()237 : m_offset(-1)238 , m_used(false)239 {240 }241 242 bool isUsed() const { return m_used; }243 bool isSet() const { return (m_offset != -1); }244 void used() { m_used = true; }245 private:246 JmpDst(int offset)247 : m_offset(offset)248 , m_used(false)249 {250 ASSERT(m_offset == offset);251 }252 253 signed int m_offset : 31;254 int m_used : 1;255 };256 257 216 // Instruction formating 258 217 … … 623 582 } 624 583 625 JmpSrcblx(int rm, Condition cc = AL)584 AssemblerLabel blx(int rm, Condition cc = AL) 626 585 { 627 586 #if WTF_ARM_ARCH_AT_LEAST(5) … … 633 592 bx(rm, cc); 634 593 #endif 635 return JmpSrc(m_buffer.label());594 return AssemblerLabel(m_buffer.label()); 636 595 } 637 596 … … 695 654 } 696 655 697 JmpDstlabel()656 AssemblerLabel label() 698 657 { 699 658 m_buffer.ensureSpaceForAnyOneInstruction(); 700 return JmpDst(m_buffer.label());701 } 702 703 JmpDstalign(int alignment)659 return AssemblerLabel(m_buffer.label()); 660 } 661 662 AssemblerLabel align(int alignment) 704 663 { 705 664 while (!m_buffer.isAligned(alignment)) … … 709 668 } 710 669 711 JmpSrcloadBranchTarget(int rd, Condition cc = AL, int useConstantPool = 0)670 AssemblerLabel loadBranchTarget(int rd, Condition cc = AL, int useConstantPool = 0) 712 671 { 713 672 ensureSpace(sizeof(ARMWord), sizeof(ARMWord)); 714 673 m_jumps.append(m_buffer.label() | (useConstantPool & 0x1)); 715 674 ldr_un_imm(rd, InvalidBranchTarget, cc); 716 return JmpSrc(m_buffer.label());717 } 718 719 JmpSrcjmp(Condition cc = AL, int useConstantPool = 0)675 return AssemblerLabel(m_buffer.label()); 676 } 677 678 AssemblerLabel jmp(Condition cc = AL, int useConstantPool = 0) 720 679 { 721 680 return loadBranchTarget(ARMRegisters::pc, cc, useConstantPool); … … 777 736 // Patch pointers 778 737 779 static void linkPointer(void* code, JmpDstfrom, void* to)738 static void linkPointer(void* code, AssemblerLabel from, void* to) 780 739 { 781 740 patchPointerInternal(reinterpret_cast<intptr_t>(code) + from.m_offset, to); … … 798 757 } 799 758 800 void linkJump( JmpSrc from, JmpDstto)759 void linkJump(AssemblerLabel from, AssemblerLabel to) 801 760 { 802 761 ARMWord* insn = reinterpret_cast<ARMWord*>(getAbsoluteJumpAddress(m_buffer.data(), from.m_offset)); … … 805 764 } 806 765 807 static void linkJump(void* code, JmpSrcfrom, void* to)766 static void linkJump(void* code, AssemblerLabel from, void* to) 808 767 { 809 768 patchPointerInternal(getAbsoluteJumpAddress(code, from.m_offset), to); … … 815 774 } 816 775 817 static void linkCall(void* code, JmpSrcfrom, void* to)776 static void linkCall(void* code, AssemblerLabel from, void* to) 818 777 { 819 778 patchPointerInternal(getAbsoluteJumpAddress(code, from.m_offset), to); … … 827 786 // Address operations 828 787 829 static void* getRelocatedAddress(void* code, JmpSrc jump) 830 { 831 return reinterpret_cast<void*>(reinterpret_cast<char*>(code) + jump.m_offset); 832 } 833 834 static void* getRelocatedAddress(void* code, JmpDst label) 788 static void* getRelocatedAddress(void* code, AssemblerLabel label) 835 789 { 836 790 return reinterpret_cast<void*>(reinterpret_cast<char*>(code) + label.m_offset); … … 839 793 // Address differences 840 794 841 static int getDifferenceBetweenLabels(JmpDst from, JmpSrc to) 842 { 843 return to.m_offset - from.m_offset; 844 } 845 846 static int getDifferenceBetweenLabels(JmpDst from, JmpDst to) 847 { 848 return to.m_offset - from.m_offset; 849 } 850 851 static unsigned getCallReturnOffset(JmpSrc call) 795 static int getDifferenceBetweenLabels(AssemblerLabel a, AssemblerLabel b) 796 { 797 return b.m_offset - a.m_offset; 798 } 799 800 static unsigned getCallReturnOffset(AssemblerLabel call) 852 801 { 853 802 return call.m_offset; -
trunk/Source/JavaScriptCore/assembler/ARMv7Assembler.h
r85403 r85432 472 472 JumpLinkType m_linkType : 4; 473 473 Condition m_condition : 16; 474 };475 476 class JmpSrc {477 friend class ARMv7Assembler;478 friend class ARMInstructionFormatter;479 friend class LinkBuffer;480 public:481 JmpSrc()482 : m_offset(-1)483 {484 }485 486 private:487 JmpSrc(int offset, JumpType type)488 : m_offset(offset)489 , m_condition(ConditionInvalid)490 , m_type(type)491 {492 ASSERT(m_type == JumpFixed || m_type == JumpNoCondition || m_type == JumpNoConditionFixedSize);493 }494 495 JmpSrc(int offset, JumpType type, Condition condition)496 : m_offset(offset)497 , m_condition(condition)498 , m_type(type)499 {500 ASSERT(m_type == JumpFixed || m_type == JumpCondition || m_type == JumpConditionFixedSize);501 }502 503 int m_offset;504 Condition m_condition : 16;505 JumpType m_type : 16;506 507 };508 509 class JmpDst {510 friend class ARMv7Assembler;511 friend class ARMInstructionFormatter;512 friend class LinkBuffer;513 public:514 JmpDst()515 : m_offset(-1)516 , m_used(false)517 {518 }519 520 bool isUsed() const { return m_used; }521 bool isSet() const { return (m_offset != -1); }522 void used() { m_used = true; }523 private:524 JmpDst(int offset)525 : m_offset(offset)526 , m_used(false)527 {528 ASSERT(m_offset == offset);529 }530 531 signed int m_offset : 31;532 int m_used : 1;533 474 }; 534 475 … … 883 824 884 825 // Only allowed in IT (if then) block if last instruction. 885 JmpSrc b(JumpType type)826 AssemblerLabel b() 886 827 { 887 828 m_formatter.twoWordOp16Op16(OP_B_T4a, OP_B_T4b); 888 return JmpSrc(m_formatter.label(), type);829 return AssemblerLabel(m_formatter.label()); 889 830 } 890 831 891 832 // Only allowed in IT (if then) block if last instruction. 892 JmpSrc blx(RegisterID rm, JumpType type)833 AssemblerLabel blx(RegisterID rm) 893 834 { 894 835 ASSERT(rm != ARMRegisters::pc); 895 836 m_formatter.oneWordOp8RegReg143(OP_BLX, rm, (RegisterID)8); 896 return JmpSrc(m_formatter.label(), type);837 return AssemblerLabel(m_formatter.label()); 897 838 } 898 839 899 840 // Only allowed in IT (if then) block if last instruction. 900 JmpSrc bx(RegisterID rm, JumpType type, Condition condition)841 AssemblerLabel bx(RegisterID rm) 901 842 { 902 843 m_formatter.oneWordOp8RegReg143(OP_BX, rm, (RegisterID)0); 903 return JmpSrc(m_formatter.label(), type, condition); 904 } 905 906 JmpSrc bx(RegisterID rm, JumpType type) 907 { 908 m_formatter.oneWordOp8RegReg143(OP_BX, rm, (RegisterID)0); 909 return JmpSrc(m_formatter.label(), type); 844 return AssemblerLabel(m_formatter.label()); 910 845 } 911 846 … … 1592 1527 } 1593 1528 1594 JmpDstlabel()1595 { 1596 return JmpDst(m_formatter.label());1597 } 1598 1599 JmpDstalign(int alignment)1529 AssemblerLabel label() 1530 { 1531 return AssemblerLabel(m_formatter.label()); 1532 } 1533 1534 AssemblerLabel align(int alignment) 1600 1535 { 1601 1536 while (!m_formatter.isAligned(alignment)) … … 1605 1540 } 1606 1541 1607 static void* getRelocatedAddress(void* code, JmpSrc jump) 1608 { 1609 ASSERT(jump.m_offset != -1); 1610 1611 return reinterpret_cast<void*>(reinterpret_cast<ptrdiff_t>(code) + jump.m_offset); 1612 } 1613 1614 static void* getRelocatedAddress(void* code, JmpDst destination) 1615 { 1616 ASSERT(destination.m_offset != -1); 1617 1618 return reinterpret_cast<void*>(reinterpret_cast<ptrdiff_t>(code) + destination.m_offset); 1619 } 1620 1621 static int getDifferenceBetweenLabels(JmpDst src, JmpDst dst) 1622 { 1623 return dst.m_offset - src.m_offset; 1624 } 1625 1626 static int getDifferenceBetweenLabels(JmpDst src, JmpSrc dst) 1627 { 1628 return dst.m_offset - src.m_offset; 1629 } 1630 1631 static int getDifferenceBetweenLabels(JmpSrc src, JmpDst dst) 1632 { 1633 return dst.m_offset - src.m_offset; 1542 static void* getRelocatedAddress(void* code, AssemblerLabel label) 1543 { 1544 ASSERT(label.isSet()); 1545 return reinterpret_cast<void*>(reinterpret_cast<ptrdiff_t>(code) + label.m_offset); 1546 } 1547 1548 static int getDifferenceBetweenLabels(AssemblerLabel a, AssemblerLabel b) 1549 { 1550 return b.m_offset - a.m_offset; 1634 1551 } 1635 1552 … … 1765 1682 size_t codeSize() const { return m_formatter.codeSize(); } 1766 1683 1767 static unsigned getCallReturnOffset( JmpSrccall)1768 { 1769 ASSERT(call. m_offset >= 0);1684 static unsigned getCallReturnOffset(AssemblerLabel call) 1685 { 1686 ASSERT(call.isSet()); 1770 1687 return call.m_offset; 1771 1688 } … … 1779 1696 // pool the 'repatch' and 'relink' methods should be used. 1780 1697 1781 void linkJump( JmpSrc from, JmpDst to)1782 { 1783 ASSERT(to. m_offset != -1);1784 ASSERT(from. m_offset != -1);1785 m_jumpsToLink.append(LinkRecord(from.m_offset, to.m_offset, from.m_type, from.m_condition));1786 } 1787 1788 static void linkJump(void* code, JmpSrcfrom, void* to)1789 { 1790 ASSERT(from. m_offset != -1);1698 void linkJump(AssemblerLabel from, AssemblerLabel to, JumpType type, Condition condition) 1699 { 1700 ASSERT(to.isSet()); 1701 ASSERT(from.isSet()); 1702 m_jumpsToLink.append(LinkRecord(from.m_offset, to.m_offset, type, condition)); 1703 } 1704 1705 static void linkJump(void* code, AssemblerLabel from, void* to) 1706 { 1707 ASSERT(from.isSet()); 1791 1708 1792 1709 uint16_t* location = reinterpret_cast<uint16_t*>(reinterpret_cast<intptr_t>(code) + from.m_offset); … … 1794 1711 } 1795 1712 1796 // bah, this mathod should really be static, since it is used by the LinkBuffer. 1797 // return a bool saying whether the link was successful? 1798 static void linkCall(void* code, JmpSrc from, void* to) 1713 static void linkCall(void* code, AssemblerLabel from, void* to) 1799 1714 { 1800 1715 ASSERT(!(reinterpret_cast<intptr_t>(code) & 1)); 1801 ASSERT(from. m_offset != -1);1716 ASSERT(from.isSet()); 1802 1717 ASSERT(reinterpret_cast<intptr_t>(to) & 1); 1803 1718 … … 1805 1720 } 1806 1721 1807 static void linkPointer(void* code, JmpDstwhere, void* value)1722 static void linkPointer(void* code, AssemblerLabel where, void* value) 1808 1723 { 1809 1724 setPointer(reinterpret_cast<char*>(code) + where.m_offset, value); -
trunk/Source/JavaScriptCore/assembler/AbstractMacroAssembler.h
r85403 r85432 50 50 51 51 typedef typename AssemblerType::RegisterID RegisterID; 52 typedef typename AssemblerType::JmpSrc JmpSrc;53 typedef typename AssemblerType::JmpDst JmpDst;54 55 52 56 53 // Section 1: MacroAssembler operand types … … 261 258 } 262 259 263 bool isUsed() const { return m_label.isUsed(); }264 260 bool isSet() const { return m_label.isSet(); } 265 void used() { m_label.used(); }266 261 private: 267 JmpDstm_label;262 AssemblerLabel m_label; 268 263 }; 269 264 … … 289 284 290 285 private: 291 JmpDstm_label;286 AssemblerLabel m_label; 292 287 }; 293 288 … … 311 306 312 307 private: 313 JmpDstm_label;308 AssemblerLabel m_label; 314 309 }; 315 310 … … 337 332 } 338 333 339 Call( JmpSrcjmp, Flags flags)334 Call(AssemblerLabel jmp, Flags flags) 340 335 : m_jmp(jmp) 341 336 , m_flags(flags) … … 353 348 } 354 349 355 JmpSrcm_jmp;350 AssemblerLabel m_jmp; 356 351 private: 357 352 Flags m_flags; … … 374 369 } 375 370 376 Jump(JmpSrc jmp) 371 #if CPU(ARMv7) 372 // Fixme: this information should be stored in the instruction stream, not in the Jump object. 373 Jump(AssemblerLabel jmp, ARMv7Assembler::JumpType type, ARMv7Assembler::Condition condition = ARMv7Assembler::ConditionInvalid) 377 374 : m_jmp(jmp) 378 { 379 } 380 375 , m_type(type) 376 , m_condition(condition) 377 { 378 } 379 #else 380 Jump(AssemblerLabel jmp) 381 : m_jmp(jmp) 382 { 383 } 384 #endif 385 381 386 void link(AbstractMacroAssembler<AssemblerType>* masm) const 382 387 { 388 #if CPU(ARMv7) 389 masm->m_assembler.linkJump(m_jmp, masm->m_assembler.label(), m_type, m_condition); 390 #else 383 391 masm->m_assembler.linkJump(m_jmp, masm->m_assembler.label()); 392 #endif 384 393 } 385 394 386 395 void linkTo(Label label, AbstractMacroAssembler<AssemblerType>* masm) const 387 396 { 397 #if CPU(ARMv7) 398 masm->m_assembler.linkJump(m_jmp, label.m_label, m_jmp.m_type, m_jmp.m_condition); 399 #else 388 400 masm->m_assembler.linkJump(m_jmp, label.m_label); 401 #endif 389 402 } 390 403 … … 392 405 393 406 private: 394 JmpSrc m_jmp; 407 AssemblerLabel m_jmp; 408 #if CPU(ARMv7) 409 ARMv7Assembler::JumpType m_type; 410 ARMv7Assembler::Condition m_condition; 411 #endif 395 412 }; 396 413 … … 523 540 } 524 541 525 static void linkPointer(void* code, typename AssemblerType::JmpDstlabel, void* value)542 static void linkPointer(void* code, AssemblerLabel label, void* value) 526 543 { 527 544 AssemblerType::linkPointer(code, label, value); 528 545 } 529 546 530 static void* getLinkerAddress(void* code, typename AssemblerType::JmpSrclabel)547 static void* getLinkerAddress(void* code, AssemblerLabel label) 531 548 { 532 549 return AssemblerType::getRelocatedAddress(code, label); 533 550 } 534 551 535 static void* getLinkerAddress(void* code, typename AssemblerType::JmpDst label)536 {537 return AssemblerType::getRelocatedAddress(code, label);538 }539 540 552 static unsigned getLinkerCallReturnOffset(Call call) 541 553 { -
trunk/Source/JavaScriptCore/assembler/AssemblerBuffer.h
r85403 r85432 38 38 namespace JSC { 39 39 40 struct AssemblerLabel { 41 AssemblerLabel(uint32_t offset = std::numeric_limits<uint32_t>::max()) 42 : m_offset(offset) 43 { 44 } 45 46 bool isSet() const { return (m_offset != std::numeric_limits<uint32_t>::max()); } 47 48 uint32_t m_offset; 49 }; 50 40 51 class AssemblerBuffer { 41 52 static const int inlineCapacity = 128 - sizeof(char*) - 2 * sizeof(int); -
trunk/Source/JavaScriptCore/assembler/LinkBuffer.h
r85403 r85432 61 61 typedef MacroAssembler::DataLabel32 DataLabel32; 62 62 typedef MacroAssembler::DataLabelPtr DataLabelPtr; 63 typedef MacroAssembler::JmpDst JmpDst;64 63 #if ENABLE(BRANCH_COMPACTION) 65 64 typedef MacroAssembler::LinkRecord LinkRecord; … … 120 119 void patch(DataLabelPtr label, void* value) 121 120 { 122 JmpDsttarget = applyOffset(label.m_label);121 AssemblerLabel target = applyOffset(label.m_label); 123 122 MacroAssembler::linkPointer(code(), target, value); 124 123 } … … 126 125 void patch(DataLabelPtr label, CodeLocationLabel value) 127 126 { 128 JmpDsttarget = applyOffset(label.m_label);127 AssemblerLabel target = applyOffset(label.m_label); 129 128 MacroAssembler::linkPointer(code(), target, value.executableAddress()); 130 129 } -
trunk/Source/JavaScriptCore/assembler/MIPSAssembler.h
r85429 r85432 167 167 }; 168 168 169 class JmpSrc {170 friend class MIPSAssembler;171 public:172 JmpSrc()173 : m_offset(-1)174 {175 }176 177 private:178 JmpSrc(int offset)179 : m_offset(offset)180 {181 }182 183 int m_offset;184 };185 186 class JmpDst {187 friend class MIPSAssembler;188 public:189 JmpDst()190 : m_offset(-1)191 , m_used(false)192 {193 }194 195 bool isUsed() const { return m_used; }196 bool isSet() const { return (m_offset != -1); }197 void used() { m_used = true; }198 private:199 JmpDst(int offset)200 : m_offset(offset)201 , m_used(false)202 {203 ASSERT(m_offset == offset);204 }205 206 int m_offset : 31;207 int m_used : 1;208 };209 210 169 void emitInst(MIPSWord op) 211 170 { … … 503 462 } 504 463 505 JmpSrc newJmpSrc()506 {507 return JmpSrc(m_buffer.label());508 }509 510 464 void appendJump() 511 465 { … … 662 616 // General helpers 663 617 664 JmpDstlabel()665 { 666 return JmpDst(m_buffer.label());667 } 668 669 JmpDstalign(int alignment)618 AssemblerLabel label() 619 { 620 return AssemblerLabel(m_buffer.label()); 621 } 622 623 AssemblerLabel align(int alignment) 670 624 { 671 625 while (!m_buffer.isAligned(alignment)) … … 675 629 } 676 630 677 static void* getRelocatedAddress(void* code, JmpSrc jump) 678 { 679 ASSERT(jump.m_offset != -1); 680 void* b = reinterpret_cast<void*>((reinterpret_cast<intptr_t>(code)) + jump.m_offset); 681 return b; 682 } 683 684 static void* getRelocatedAddress(void* code, JmpDst label) 685 { 686 void* b = reinterpret_cast<void*>((reinterpret_cast<intptr_t>(code)) + label.m_offset); 687 return b; 688 } 689 690 static int getDifferenceBetweenLabels(JmpDst from, JmpDst to) 691 { 692 return to.m_offset - from.m_offset; 693 } 694 695 static int getDifferenceBetweenLabels(JmpDst from, JmpSrc to) 696 { 697 return to.m_offset - from.m_offset; 698 } 699 700 static int getDifferenceBetweenLabels(JmpSrc from, JmpDst to) 701 { 702 return to.m_offset - from.m_offset; 631 static void* getRelocatedAddress(void* code, AssemblerLabel label) 632 { 633 return reinterpret_cast<void*>(reinterpret_cast<char*>(code) + label.m_offset); 634 } 635 636 static int getDifferenceBetweenLabels(AssemblerLabel a, AssemblerLabel b) 637 { 638 return b.m_offset - a.m_offset; 703 639 } 704 640 … … 724 660 #endif 725 661 726 static unsigned getCallReturnOffset( JmpSrccall)662 static unsigned getCallReturnOffset(AssemblerLabel call) 727 663 { 728 664 // The return address is after a call and a delay slot instruction … … 738 674 // pool the 'repatch' and 'relink' methods should be used. 739 675 740 void linkJump( JmpSrc from, JmpDstto)741 { 742 ASSERT(to. m_offset != -1);743 ASSERT(from. m_offset != -1);676 void linkJump(AssemblerLabel from, AssemblerLabel to) 677 { 678 ASSERT(to.isSet()); 679 ASSERT(from.isSet()); 744 680 MIPSWord* insn = reinterpret_cast<MIPSWord*>(reinterpret_cast<intptr_t>(m_buffer.data()) + from.m_offset); 745 681 MIPSWord* toPos = reinterpret_cast<MIPSWord*>(reinterpret_cast<intptr_t>(m_buffer.data()) + to.m_offset); … … 750 686 } 751 687 752 static void linkJump(void* code, JmpSrcfrom, void* to)753 { 754 ASSERT(from. m_offset != -1);688 static void linkJump(void* code, AssemblerLabel from, void* to) 689 { 690 ASSERT(from.isSet()); 755 691 MIPSWord* insn = reinterpret_cast<MIPSWord*>(reinterpret_cast<intptr_t>(code) + from.m_offset); 756 692 … … 760 696 } 761 697 762 static void linkCall(void* code, JmpSrcfrom, void* to)698 static void linkCall(void* code, AssemblerLabel from, void* to) 763 699 { 764 700 MIPSWord* insn = reinterpret_cast<MIPSWord*>(reinterpret_cast<intptr_t>(code) + from.m_offset); … … 766 702 } 767 703 768 static void linkPointer(void* code, JmpDstfrom, void* to)704 static void linkPointer(void* code, AssemblerLabel from, void* to) 769 705 { 770 706 MIPSWord* insn = reinterpret_cast<MIPSWord*>(reinterpret_cast<intptr_t>(code) + from.m_offset); -
trunk/Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h
r84399 r85432 674 674 unordered.link(this); 675 675 // We get here if either unordered or equal. 676 Jump result = makeJump();676 Jump result = jump(); 677 677 notEqual.link(this); 678 678 return result; … … 722 722 unordered.link(this); 723 723 // We get here if either unordered or equal. 724 Jump result = makeJump();724 Jump result = jump(); 725 725 notEqual.link(this); 726 726 return result; … … 996 996 } 997 997 998 Jump jump()999 {1000 return Jump(makeJump());1001 }1002 1003 998 void jump(RegisterID target) 1004 999 { 1005 m_assembler.bx(target , ARMv7Assembler::JumpFixed);1000 m_assembler.bx(target); 1006 1001 } 1007 1002 … … 1010 1005 { 1011 1006 load32(address, dataTempRegister); 1012 m_assembler.bx(dataTempRegister , ARMv7Assembler::JumpFixed);1007 m_assembler.bx(dataTempRegister); 1013 1008 } 1014 1009 … … 1112 1107 { 1113 1108 moveFixedWidthEncoding(TrustedImm32(0), dataTempRegister); 1114 return Call(m_assembler.blx(dataTempRegister , ARMv7Assembler::JumpFixed), Call::LinkableNear);1109 return Call(m_assembler.blx(dataTempRegister), Call::LinkableNear); 1115 1110 } 1116 1111 … … 1118 1113 { 1119 1114 moveFixedWidthEncoding(TrustedImm32(0), dataTempRegister); 1120 return Call(m_assembler.blx(dataTempRegister , ARMv7Assembler::JumpFixed), Call::Linkable);1115 return Call(m_assembler.blx(dataTempRegister), Call::Linkable); 1121 1116 } 1122 1117 1123 1118 Call call(RegisterID target) 1124 1119 { 1125 return Call(m_assembler.blx(target , ARMv7Assembler::JumpFixed), Call::None);1120 return Call(m_assembler.blx(target), Call::None); 1126 1121 } 1127 1122 … … 1129 1124 { 1130 1125 load32(address, dataTempRegister); 1131 return Call(m_assembler.blx(dataTempRegister , ARMv7Assembler::JumpFixed), Call::None);1126 return Call(m_assembler.blx(dataTempRegister), Call::None); 1132 1127 } 1133 1128 1134 1129 void ret() 1135 1130 { 1136 m_assembler.bx(linkRegister , ARMv7Assembler::JumpFixed);1131 m_assembler.bx(linkRegister); 1137 1132 } 1138 1133 … … 1219 1214 // Like a normal call, but don't link. 1220 1215 moveFixedWidthEncoding(TrustedImm32(0), dataTempRegister); 1221 return Call(m_assembler.bx(dataTempRegister , ARMv7Assembler::JumpFixed), Call::Linkable);1216 return Call(m_assembler.bx(dataTempRegister), Call::Linkable); 1222 1217 } 1223 1218 … … 1240 1235 } 1241 1236 1242 ARMv7Assembler::JmpSrc makeJump()1237 Jump jump() 1243 1238 { 1244 1239 moveFixedWidthEncoding(TrustedImm32(0), dataTempRegister); 1245 return m_assembler.bx(dataTempRegister, inUninterruptedSequence() ? ARMv7Assembler::JumpNoConditionFixedSize : ARMv7Assembler::JumpNoCondition);1246 } 1247 1248 ARMv7Assembler::JmpSrcmakeBranch(ARMv7Assembler::Condition cond)1240 return Jump(m_assembler.bx(dataTempRegister), inUninterruptedSequence() ? ARMv7Assembler::JumpNoConditionFixedSize : ARMv7Assembler::JumpNoCondition); 1241 } 1242 1243 Jump makeBranch(ARMv7Assembler::Condition cond) 1249 1244 { 1250 1245 m_assembler.it(cond, true, true); 1251 1246 moveFixedWidthEncoding(TrustedImm32(0), dataTempRegister); 1252 return m_assembler.bx(dataTempRegister, inUninterruptedSequence() ? ARMv7Assembler::JumpConditionFixedSize : ARMv7Assembler::JumpCondition, cond);1253 } 1254 ARMv7Assembler::JmpSrcmakeBranch(RelationalCondition cond) { return makeBranch(armV7Condition(cond)); }1255 ARMv7Assembler::JmpSrcmakeBranch(ResultCondition cond) { return makeBranch(armV7Condition(cond)); }1256 ARMv7Assembler::JmpSrcmakeBranch(DoubleCondition cond) { return makeBranch(armV7Condition(cond)); }1247 return Jump(m_assembler.bx(dataTempRegister), inUninterruptedSequence() ? ARMv7Assembler::JumpConditionFixedSize : ARMv7Assembler::JumpCondition, cond); 1248 } 1249 Jump makeBranch(RelationalCondition cond) { return makeBranch(armV7Condition(cond)); } 1250 Jump makeBranch(ResultCondition cond) { return makeBranch(armV7Condition(cond)); } 1251 Jump makeBranch(DoubleCondition cond) { return makeBranch(armV7Condition(cond)); } 1257 1252 1258 1253 ArmAddress setupArmAddress(BaseIndex address) -
trunk/Source/JavaScriptCore/assembler/MacroAssemblerMIPS.h
r85429 r85432 1291 1291 m_assembler.jal(); 1292 1292 m_assembler.nop(); 1293 return Call(m_assembler. newJmpSrc(), Call::LinkableNear);1293 return Call(m_assembler.label(), Call::LinkableNear); 1294 1294 } 1295 1295 … … 1300 1300 m_assembler.jalr(MIPSRegisters::t9); 1301 1301 m_assembler.nop(); 1302 return Call(m_assembler. newJmpSrc(), Call::Linkable);1302 return Call(m_assembler.label(), Call::Linkable); 1303 1303 } 1304 1304 … … 1307 1307 m_assembler.jalr(target); 1308 1308 m_assembler.nop(); 1309 return Call(m_assembler. newJmpSrc(), Call::None);1309 return Call(m_assembler.label(), Call::None); 1310 1310 } 1311 1311 … … 1317 1317 m_assembler.nop(); 1318 1318 m_fixedWidth = false; 1319 return Call(m_assembler. newJmpSrc(), Call::None);1319 return Call(m_assembler.label(), Call::None); 1320 1320 } 1321 1321 … … 1462 1462 m_assembler.nop(); 1463 1463 m_fixedWidth = false; 1464 return Call(m_assembler. newJmpSrc(), Call::Linkable);1464 return Call(m_assembler.label(), Call::Linkable); 1465 1465 } 1466 1466 … … 1626 1626 m_assembler.nop(); 1627 1627 insertRelaxationWords(); 1628 return Jump(m_assembler. newJmpSrc());1628 return Jump(m_assembler.label()); 1629 1629 } 1630 1630 … … 1635 1635 m_assembler.nop(); 1636 1636 insertRelaxationWords(); 1637 return Jump(m_assembler. newJmpSrc());1637 return Jump(m_assembler.label()); 1638 1638 } 1639 1639 … … 1644 1644 m_assembler.nop(); 1645 1645 insertRelaxationWords(); 1646 return Jump(m_assembler. newJmpSrc());1646 return Jump(m_assembler.label()); 1647 1647 } 1648 1648 … … 1653 1653 m_assembler.nop(); 1654 1654 insertRelaxationWords(); 1655 return Jump(m_assembler. newJmpSrc());1655 return Jump(m_assembler.label()); 1656 1656 } 1657 1657 -
trunk/Source/JavaScriptCore/assembler/SH4Assembler.h
r85403 r85432 352 352 // Opaque label types 353 353 public: 354 class JmpSrc {355 friend class SH4Assembler;356 public:357 JmpSrc()358 : m_offset(-1)359 {360 }361 362 private:363 JmpSrc(int offset)364 : m_offset(offset)365 {366 }367 368 int m_offset;369 };370 371 class JmpDst {372 friend class SH4Assembler;373 public:374 JmpDst()375 : m_offset(-1)376 , m_used(false)377 {378 }379 380 bool isUsed() const { return m_used; }381 bool isSet() const { return (m_offset != -1); }382 void used() { m_used = true; }383 384 private:385 JmpDst(int offset)386 : m_offset(offset)387 , m_used(false)388 {389 ASSERT(m_offset == offset);390 }391 392 int m_offset : 31;393 int m_used : 1;394 };395 396 354 bool isImmediate(int constant) 397 355 { … … 1185 1143 // Flow control 1186 1144 1187 JmpSrccall()1145 AssemblerLabel call() 1188 1146 { 1189 1147 RegisterID scr = claimScratch(); … … 1193 1151 nop(); 1194 1152 releaseScratch(scr); 1195 return JmpSrc(m_buffer.label());1196 } 1197 1198 JmpSrccall(RegisterID dst)1153 return AssemblerLabel(m_buffer.label()); 1154 } 1155 1156 AssemblerLabel call(RegisterID dst) 1199 1157 { 1200 1158 m_buffer.ensureSpace(maxInstructionSize + 2); 1201 1159 branch(JSR_OPCODE, dst); 1202 1160 nop(); 1203 return JmpSrc(m_buffer.label());1204 } 1205 1206 JmpSrcjmp()1161 return AssemblerLabel(m_buffer.label()); 1162 } 1163 1164 AssemblerLabel jmp() 1207 1165 { 1208 1166 RegisterID scr = claimScratch(); … … 1213 1171 nop(); 1214 1172 releaseScratch(scr); 1215 return JmpSrc(m_size);1216 } 1217 1218 JmpSrcjmp(RegisterID dst)1173 return AssemblerLabel(m_size); 1174 } 1175 1176 AssemblerLabel jmp(RegisterID dst) 1219 1177 { 1220 1178 jmpReg(dst); 1221 return JmpSrc(m_buffer.label());1179 return AssemblerLabel(m_buffer.label()); 1222 1180 } 1223 1181 … … 1229 1187 } 1230 1188 1231 JmpSrcjne()1189 AssemblerLabel jne() 1232 1190 { 1233 1191 int m_size = m_buffer.label(); 1234 1192 branch(BF_OPCODE, 0); 1235 return JmpSrc(m_size);1236 } 1237 1238 JmpSrcje()1193 return AssemblerLabel(m_size); 1194 } 1195 1196 AssemblerLabel je() 1239 1197 { 1240 1198 int m_size = m_buffer.label(); 1241 1199 branch(BT_OPCODE, 0); 1242 return JmpSrc(m_size);1200 return AssemblerLabel(m_size); 1243 1201 } 1244 1202 … … 1249 1207 } 1250 1208 1251 JmpDstlabel()1209 AssemblerLabel label() 1252 1210 { 1253 1211 m_buffer.ensureSpaceForAnyOneInstruction(); 1254 return JmpDst(m_buffer.label());1212 return AssemblerLabel(m_buffer.label()); 1255 1213 } 1256 1214 … … 1260 1218 } 1261 1219 1262 JmpDstalign(int alignment)1220 AssemblerLabel align(int alignment) 1263 1221 { 1264 1222 m_buffer.ensureSpace(maxInstructionSize + 2); … … 1281 1239 } 1282 1240 1283 static void linkJump(void* code, JmpSrcfrom, void* to)1284 { 1285 ASSERT(from. m_offset != -1);1241 static void linkJump(void* code, AssemblerLabel from, void* to) 1242 { 1243 ASSERT(from.isSet()); 1286 1244 1287 1245 uint16_t* instructionPtr = getInstructionPtr(code, from.m_offset); … … 1323 1281 } 1324 1282 1325 static void linkCall(void* code, JmpSrcfrom, void* to)1283 static void linkCall(void* code, AssemblerLabel from, void* to) 1326 1284 { 1327 1285 uint16_t* instructionPtr = getInstructionPtr(code, from.m_offset); … … 1330 1288 } 1331 1289 1332 static void linkPointer(void* code, JmpDstwhere, void* value)1290 static void linkPointer(void* code, AssemblerLabel where, void* value) 1333 1291 { 1334 1292 uint16_t* instructionPtr = getInstructionPtr(code, where.m_offset); … … 1336 1294 } 1337 1295 1338 static unsigned getCallReturnOffset( JmpSrccall)1339 { 1340 ASSERT(call. m_offset >= 0);1296 static unsigned getCallReturnOffset(AssemblerLabel call) 1297 { 1298 ASSERT(call.isSet()); 1341 1299 return call.m_offset; 1342 1300 } … … 1433 1391 // Linking & patching 1434 1392 1435 void linkJump( JmpSrc from, JmpDstto)1436 { 1437 ASSERT(to. m_offset != -1);1438 ASSERT(from. m_offset != -1);1393 void linkJump(AssemblerLabel from, AssemblerLabel to) 1394 { 1395 ASSERT(to.isSet()); 1396 ASSERT(from.isSet()); 1439 1397 1440 1398 uint16_t* instructionPtr = getInstructionPtr(data(), from.m_offset); … … 1487 1445 } 1488 1446 1489 static void* getRelocatedAddress(void* code, JmpSrc jump) 1490 { 1491 return reinterpret_cast<void*>(reinterpret_cast<uint32_t>(code) + jump.m_offset); 1492 } 1493 1494 static void* getRelocatedAddress(void* code, JmpDst destination) 1495 { 1496 ASSERT(destination.m_offset != -1); 1497 return reinterpret_cast<void*>(reinterpret_cast<uint32_t>(code) + destination.m_offset); 1498 } 1499 1500 static int getDifferenceBetweenLabels(JmpDst src, JmpDst dst) 1501 { 1502 return dst.m_offset - src.m_offset; 1503 } 1504 1505 static int getDifferenceBetweenLabels(JmpDst src, JmpSrc dst) 1506 { 1507 return dst.m_offset - src.m_offset; 1508 } 1509 1510 static int getDifferenceBetweenLabels(JmpSrc src, JmpDst dst) 1511 { 1512 return dst.m_offset - src.m_offset; 1513 } 1514 1515 static void patchPointer(void* code, JmpDst where, void* value) 1447 static void* getRelocatedAddress(void* code, AssemblerLabel label) 1448 { 1449 return reinterpret_cast<void*>(reinterpret_cast<char*>(code) + label.m_offset); 1450 } 1451 1452 static int getDifferenceBetweenLabels(AssemblerLabel a, AssemblerLabel b) 1453 { 1454 return b.m_offset - a.m_offset; 1455 } 1456 1457 static void patchPointer(void* code, AssemblerLabel where, void* value) 1516 1458 { 1517 1459 patchPointer(reinterpret_cast<uint32_t*>(code) + where.m_offset, value); -
trunk/Source/JavaScriptCore/assembler/X86Assembler.h
r85403 r85432 221 221 public: 222 222 223 class JmpSrc {224 friend class X86Assembler;225 friend class X86InstructionFormatter;226 public:227 JmpSrc()228 : m_offset(-1)229 {230 }231 232 bool isSet() const { return (m_offset != -1); }233 234 private:235 JmpSrc(int offset)236 : m_offset(offset)237 {238 }239 240 int m_offset;241 };242 243 class JmpDst {244 friend class X86Assembler;245 friend class X86InstructionFormatter;246 public:247 JmpDst()248 : m_offset(-1)249 , m_used(false)250 {251 }252 253 bool isUsed() const { return m_used; }254 bool isSet() const { return (m_offset != -1); }255 void used() { m_used = true; }256 private:257 JmpDst(int offset)258 : m_offset(offset)259 , m_used(false)260 {261 ASSERT(m_offset == offset);262 }263 264 int m_offset : 31;265 bool m_used : 1;266 };267 268 223 X86Assembler() 269 224 { … … 1214 1169 // Flow control: 1215 1170 1216 JmpSrccall()1171 AssemblerLabel call() 1217 1172 { 1218 1173 m_formatter.oneByteOp(OP_CALL_rel32); … … 1220 1175 } 1221 1176 1222 JmpSrccall(RegisterID dst)1177 AssemblerLabel call(RegisterID dst) 1223 1178 { 1224 1179 m_formatter.oneByteOp(OP_GROUP5_Ev, GROUP5_OP_CALLN, dst); 1225 return JmpSrc(m_formatter.label());1180 return AssemblerLabel(m_formatter.label()); 1226 1181 } 1227 1182 … … 1231 1186 } 1232 1187 1233 JmpSrcjmp()1188 AssemblerLabel jmp() 1234 1189 { 1235 1190 m_formatter.oneByteOp(OP_JMP_rel32); … … 1237 1192 } 1238 1193 1239 // Return a JmpSrcso we have a label to the jump, so we can use this1194 // Return a AssemblerLabel so we have a label to the jump, so we can use this 1240 1195 // To make a tail recursive call on x86-64. The MacroAssembler 1241 1196 // really shouldn't wrap this as a Jump, since it can't be linked. :-/ 1242 JmpSrcjmp_r(RegisterID dst)1197 AssemblerLabel jmp_r(RegisterID dst) 1243 1198 { 1244 1199 m_formatter.oneByteOp(OP_GROUP5_Ev, GROUP5_OP_JMPN, dst); 1245 return JmpSrc(m_formatter.label());1200 return AssemblerLabel(m_formatter.label()); 1246 1201 } 1247 1202 … … 1251 1206 } 1252 1207 1253 JmpSrcjne()1208 AssemblerLabel jne() 1254 1209 { 1255 1210 m_formatter.twoByteOp(jccRel32(ConditionNE)); … … 1257 1212 } 1258 1213 1259 JmpSrcjnz()1214 AssemblerLabel jnz() 1260 1215 { 1261 1216 return jne(); 1262 1217 } 1263 1218 1264 JmpSrcje()1219 AssemblerLabel je() 1265 1220 { 1266 1221 m_formatter.twoByteOp(jccRel32(ConditionE)); … … 1268 1223 } 1269 1224 1270 JmpSrcjz()1225 AssemblerLabel jz() 1271 1226 { 1272 1227 return je(); 1273 1228 } 1274 1229 1275 JmpSrcjl()1230 AssemblerLabel jl() 1276 1231 { 1277 1232 m_formatter.twoByteOp(jccRel32(ConditionL)); … … 1279 1234 } 1280 1235 1281 JmpSrcjb()1236 AssemblerLabel jb() 1282 1237 { 1283 1238 m_formatter.twoByteOp(jccRel32(ConditionB)); … … 1285 1240 } 1286 1241 1287 JmpSrcjle()1242 AssemblerLabel jle() 1288 1243 { 1289 1244 m_formatter.twoByteOp(jccRel32(ConditionLE)); … … 1291 1246 } 1292 1247 1293 JmpSrcjbe()1248 AssemblerLabel jbe() 1294 1249 { 1295 1250 m_formatter.twoByteOp(jccRel32(ConditionBE)); … … 1297 1252 } 1298 1253 1299 JmpSrcjge()1254 AssemblerLabel jge() 1300 1255 { 1301 1256 m_formatter.twoByteOp(jccRel32(ConditionGE)); … … 1303 1258 } 1304 1259 1305 JmpSrcjg()1260 AssemblerLabel jg() 1306 1261 { 1307 1262 m_formatter.twoByteOp(jccRel32(ConditionG)); … … 1309 1264 } 1310 1265 1311 JmpSrcja()1266 AssemblerLabel ja() 1312 1267 { 1313 1268 m_formatter.twoByteOp(jccRel32(ConditionA)); … … 1315 1270 } 1316 1271 1317 JmpSrcjae()1272 AssemblerLabel jae() 1318 1273 { 1319 1274 m_formatter.twoByteOp(jccRel32(ConditionAE)); … … 1321 1276 } 1322 1277 1323 JmpSrcjo()1278 AssemblerLabel jo() 1324 1279 { 1325 1280 m_formatter.twoByteOp(jccRel32(ConditionO)); … … 1327 1282 } 1328 1283 1329 JmpSrcjp()1284 AssemblerLabel jp() 1330 1285 { 1331 1286 m_formatter.twoByteOp(jccRel32(ConditionP)); … … 1333 1288 } 1334 1289 1335 JmpSrcjs()1290 AssemblerLabel js() 1336 1291 { 1337 1292 m_formatter.twoByteOp(jccRel32(ConditionS)); … … 1339 1294 } 1340 1295 1341 JmpSrcjCC(Condition cond)1296 AssemblerLabel jCC(Condition cond) 1342 1297 { 1343 1298 m_formatter.twoByteOp(jccRel32(cond)); … … 1522 1477 } 1523 1478 1524 JmpDstlabel()1525 { 1526 return JmpDst(m_formatter.label());1527 } 1528 1529 static JmpDst labelFor(JmpSrcjump, intptr_t offset = 0)1530 { 1531 return JmpDst(jump.m_offset + offset);1532 } 1533 1534 JmpDstalign(int alignment)1479 AssemblerLabel label() 1480 { 1481 return AssemblerLabel(m_formatter.label()); 1482 } 1483 1484 static AssemblerLabel labelFor(AssemblerLabel jump, intptr_t offset = 0) 1485 { 1486 return AssemblerLabel(jump.m_offset + offset); 1487 } 1488 1489 AssemblerLabel align(int alignment) 1535 1490 { 1536 1491 while (!m_formatter.isAligned(alignment)) … … 1548 1503 // pool the 'repatch' and 'relink' methods should be used. 1549 1504 1550 void linkJump( JmpSrc from, JmpDstto)1551 { 1552 ASSERT(from. m_offset != -1);1553 ASSERT(to. m_offset != -1);1505 void linkJump(AssemblerLabel from, AssemblerLabel to) 1506 { 1507 ASSERT(from.isSet()); 1508 ASSERT(to.isSet()); 1554 1509 1555 1510 char* code = reinterpret_cast<char*>(m_formatter.data()); … … 1558 1513 } 1559 1514 1560 static void linkJump(void* code, JmpSrcfrom, void* to)1561 { 1562 ASSERT(from. m_offset != -1);1515 static void linkJump(void* code, AssemblerLabel from, void* to) 1516 { 1517 ASSERT(from.isSet()); 1563 1518 1564 1519 setRel32(reinterpret_cast<char*>(code) + from.m_offset, to); 1565 1520 } 1566 1521 1567 static void linkCall(void* code, JmpSrcfrom, void* to)1568 { 1569 ASSERT(from. m_offset != -1);1522 static void linkCall(void* code, AssemblerLabel from, void* to) 1523 { 1524 ASSERT(from.isSet()); 1570 1525 1571 1526 setRel32(reinterpret_cast<char*>(code) + from.m_offset, to); 1572 1527 } 1573 1528 1574 static void linkPointer(void* code, JmpDstwhere, void* value)1575 { 1576 ASSERT(where. m_offset != -1);1529 static void linkPointer(void* code, AssemblerLabel where, void* value) 1530 { 1531 ASSERT(where.isSet()); 1577 1532 1578 1533 setPointer(reinterpret_cast<char*>(code) + where.m_offset, value); … … 1599 1554 } 1600 1555 1601 static unsigned getCallReturnOffset( JmpSrccall)1602 { 1603 ASSERT(call. m_offset >= 0);1556 static unsigned getCallReturnOffset(AssemblerLabel call) 1557 { 1558 ASSERT(call.isSet()); 1604 1559 return call.m_offset; 1605 1560 } 1606 1561 1607 static void* getRelocatedAddress(void* code, JmpSrc jump) 1608 { 1609 ASSERT(jump.m_offset != -1); 1610 1611 return reinterpret_cast<void*>(reinterpret_cast<ptrdiff_t>(code) + jump.m_offset); 1612 } 1613 1614 static void* getRelocatedAddress(void* code, JmpDst destination) 1615 { 1616 ASSERT(destination.m_offset != -1); 1617 1618 return reinterpret_cast<void*>(reinterpret_cast<ptrdiff_t>(code) + destination.m_offset); 1619 } 1620 1621 static int getDifferenceBetweenLabels(JmpDst src, JmpDst dst) 1622 { 1623 return dst.m_offset - src.m_offset; 1624 } 1625 1626 static int getDifferenceBetweenLabels(JmpDst src, JmpSrc dst) 1627 { 1628 return dst.m_offset - src.m_offset; 1629 } 1630 1631 static int getDifferenceBetweenLabels(JmpSrc src, JmpDst dst) 1632 { 1633 return dst.m_offset - src.m_offset; 1562 static void* getRelocatedAddress(void* code, AssemblerLabel label) 1563 { 1564 ASSERT(label.isSet()); 1565 return reinterpret_cast<void*>(reinterpret_cast<ptrdiff_t>(code) + label.m_offset); 1566 } 1567 1568 static int getDifferenceBetweenLabels(AssemblerLabel a, AssemblerLabel b) 1569 { 1570 return b.m_offset - a.m_offset; 1634 1571 } 1635 1572 … … 1639 1576 } 1640 1577 1641 void rewindToLabel( JmpDstrewindTo) { m_formatter.rewindToLabel(rewindTo); }1578 void rewindToLabel(AssemblerLabel rewindTo) { m_formatter.rewindToLabel(rewindTo); } 1642 1579 1643 1580 #ifndef NDEBUG … … 1931 1868 } 1932 1869 1933 JmpSrcimmediateRel32()1870 AssemblerLabel immediateRel32() 1934 1871 { 1935 1872 m_buffer.putIntUnchecked(0); 1936 return JmpSrc(label());1873 return AssemblerLabel(label()); 1937 1874 } 1938 1875 … … 1949 1886 } 1950 1887 1951 void rewindToLabel( JmpDstrewindTo) { m_buffer.rewindToOffset(rewindTo.m_offset); }1888 void rewindToLabel(AssemblerLabel rewindTo) { m_buffer.rewindToOffset(rewindTo.m_offset); } 1952 1889 1953 1890 #ifndef NDEBUG -
trunk/Source/JavaScriptCore/jit/JIT.cpp
r85403 r85432 184 184 185 185 #if USE(JSVALUE64) 186 if ( m_labels[m_bytecodeOffset].isUsed())186 if (atJumpTarget()) 187 187 killLastResultRegister(); 188 188 #endif -
trunk/Source/JavaScriptCore/jit/JIT.h
r85372 r85432 908 908 bool isOperandConstantImmediateChar(unsigned src); 909 909 910 bool atJumpTarget(); 911 910 912 Jump getSlowCase(Vector<SlowCaseEntry>::iterator& iter) 911 913 { … … 985 987 #else 986 988 int m_lastResultBytecodeRegister; 989 #endif 987 990 unsigned m_jumpTargetsPosition; 988 #endif989 991 990 992 #ifndef NDEBUG -
trunk/Source/JavaScriptCore/jit/JITInlineMethods.h
r84445 r85432 110 110 } 111 111 112 ALWAYS_INLINE bool JIT::atJumpTarget() 113 { 114 while (m_jumpTargetsPosition < m_codeBlock->numberOfJumpTargets() && m_codeBlock->jumpTarget(m_jumpTargetsPosition) <= m_bytecodeOffset) { 115 if (m_codeBlock->jumpTarget(m_jumpTargetsPosition) == m_bytecodeOffset) 116 return true; 117 ++m_jumpTargetsPosition; 118 } 119 return false; 120 } 121 112 122 #if defined(ASSEMBLER_HAS_CONSTANT_POOL) && ASSEMBLER_HAS_CONSTANT_POOL 113 123 … … 652 662 } 653 663 654 if (src == m_lastResultBytecodeRegister && m_codeBlock->isTemporaryRegisterIndex(src)) { 655 bool atJumpTarget = false; 656 while (m_jumpTargetsPosition < m_codeBlock->numberOfJumpTargets() && m_codeBlock->jumpTarget(m_jumpTargetsPosition) <= m_bytecodeOffset) { 657 if (m_codeBlock->jumpTarget(m_jumpTargetsPosition) == m_bytecodeOffset) 658 atJumpTarget = true; 659 ++m_jumpTargetsPosition; 660 } 661 662 if (!atJumpTarget) { 663 // The argument we want is already stored in eax 664 if (dst != cachedResultRegister) 665 move(cachedResultRegister, dst); 666 killLastResultRegister(); 667 return; 668 } 664 if (src == m_lastResultBytecodeRegister && m_codeBlock->isTemporaryRegisterIndex(src) && !atJumpTarget()) { 665 // The argument we want is already stored in eax 666 if (dst != cachedResultRegister) 667 move(cachedResultRegister, dst); 668 killLastResultRegister(); 669 return; 669 670 } 670 671 -
trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp
r85403 r85432 42 42 #if USE(JSVALUE64) 43 43 44 #define RECORD_JUMP_TARGET(targetOffset) \45 do { m_labels[m_bytecodeOffset + (targetOffset)].used(); } while (false)46 47 44 void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executablePool, JSGlobalData* globalData, TrampolineStructure *trampolines) 48 45 { … … 341 338 unsigned target = currentInstruction[1].u.operand; 342 339 addJump(jump(), target); 343 RECORD_JUMP_TARGET(target);344 340 } 345 341 … … 719 715 720 716 isNonZero.link(this); 721 RECORD_JUMP_TARGET(target);722 717 } 723 718 … … 741 736 742 737 wasNotImmediate.link(this); 743 RECORD_JUMP_TARGET(target);744 738 }; 745 739 void JIT::emit_op_jneq_null(Instruction* currentInstruction) … … 762 756 763 757 wasNotImmediate.link(this); 764 RECORD_JUMP_TARGET(target);765 758 } 766 759 … … 773 766 emitGetVirtualRegister(src, regT0); 774 767 addJump(branchPtr(NotEqual, regT0, TrustedImmPtr(JSValue::encode(JSValue(ptr)))), target); 775 776 RECORD_JUMP_TARGET(target);777 768 } 778 769 … … 785 776 m_jsrSites.append(JSRInfo(storeLocation, label())); 786 777 killLastResultRegister(); 787 RECORD_JUMP_TARGET(target);788 778 } 789 779 … … 839 829 840 830 isZero.link(this); 841 RECORD_JUMP_TARGET(target);842 831 } 843 832 … … 1077 1066 stubCall.call(); 1078 1067 addJump(jump(), currentInstruction[2].u.operand); 1079 RECORD_JUMP_TARGET(currentInstruction[2].u.operand);1080 1068 } 1081 1069
Note: See TracChangeset
for help on using the changeset viewer.