Changeset 39284 in webkit for trunk/JavaScriptCore/jit/JIT.cpp
- Timestamp:
- Dec 13, 2008, 3:58:58 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/jit/JIT.cpp
r39268 r39284 41 41 #endif 42 42 43 #define __ m_assembler. 44 43 45 using namespace std; 44 46 … … 237 239 #endif 238 240 239 m_labels[m_bytecodeIndex] = __label();241 m_labels[m_bytecodeIndex] = label(); 240 242 OpcodeID opcodeID = m_interpreter->getOpcodeID(currentInstruction->u.opcode); 241 243 … … 278 280 emitCTICall(Interpreter::cti_op_end); 279 281 emitGetVirtualRegister(currentInstruction[1].u.operand, X86::eax); 280 __ pushl_m(RegisterFile::ReturnPC * static_cast<int>(sizeof(Register)), X86::edi);282 __ pushl_m(RegisterFile::ReturnPC * static_cast<int>(sizeof(Register)), callFrameRegister); 281 283 __ ret(); 282 284 NEXT_OPCODE(op_end); … … 514 516 515 517 // Restore our caller's "r". 516 emitGetFromCallFrameHeader(RegisterFile::CallerFrame, X86::edi);518 emitGetFromCallFrameHeader(RegisterFile::CallerFrame, callFrameRegister); 517 519 518 520 // Return. … … 768 770 int retAddrDst = currentInstruction[1].u.operand; 769 771 int target = currentInstruction[2].u.operand; 770 __ movl_i32m(0, sizeof(Register) * retAddrDst, X86::edi); 771 JmpDst addrPosition = __ label(); 772 addJump(__ jmp(), target + 2); 773 JmpDst sretTarget = __ label(); 774 m_jsrSites.append(JSRInfo(addrPosition, sretTarget)); 772 DataLabelPtr storeLocation = storePtrWithRepatch(Address(callFrameRegister, sizeof(Register) * retAddrDst)); 773 addJump(jump(), target + 2); 774 m_jsrSites.append(JSRInfo(storeLocation, label())); 775 775 NEXT_OPCODE(op_jsr); 776 776 } 777 777 case op_sret: { 778 __ jmp_m(sizeof(Register) * currentInstruction[1].u.operand, X86::edi);778 jump(Address(callFrameRegister, sizeof(Register) * currentInstruction[1].u.operand)); 779 779 NEXT_OPCODE(op_sret); 780 780 } … … 793 793 emitFastArithImmToInt(X86::eax); 794 794 emitFastArithImmToInt(X86::ecx); 795 __ shll_CLr(X86::eax);795 lshift32(X86::ecx, X86::eax); 796 796 emitFastArithIntToImmOrSlowCase(X86::eax); 797 797 emitPutVirtualRegister(currentInstruction[1].u.operand); … … 833 833 emitJumpSlowCaseIfNotImmNum(X86::ecx); 834 834 emitFastArithImmToInt(X86::ecx); 835 __ sarl_CLr(X86::eax);835 rshift32(X86::ecx, X86::eax); 836 836 } 837 837 emitFastArithPotentiallyReTagImmediate(X86::eax); … … 867 867 emitFastArithDeTagImmediate(X86::eax); 868 868 addSlowCase(emitFastArithDeTagImmediateJumpIfZero(X86::ecx)); 869 __ cdq(); 870 __ idivl_r(X86::ecx); 869 mod32(X86::ecx, X86::eax, X86::edx); 871 870 emitFastArithReTagImmediate(X86::edx); 872 871 move(X86::edx, X86::eax); … … 1006 1005 } 1007 1006 case op_catch: { 1008 emitGetCTIParam(CTI_ARGS_callFrame, X86::edi); // edi := r1007 emitGetCTIParam(CTI_ARGS_callFrame, callFrameRegister); 1009 1008 emitPutVirtualRegister(currentInstruction[1].u.operand); 1010 1009 NEXT_OPCODE(op_catch); … … 1200 1199 case op_profile_will_call: { 1201 1200 emitGetCTIParam(CTI_ARGS_profilerReference, X86::eax); 1202 __ cmpl_i32m(0, X86::eax); 1203 JmpSrc noProfiler = __ je(); 1201 Jump noProfiler = jzPtr(Address(X86::eax)); 1204 1202 emitPutJITStubArgFromVirtualRegister(currentInstruction[1].u.operand, 1, X86::eax); 1205 1203 emitCTICall(Interpreter::cti_op_profile_will_call); 1206 __ link(noProfiler, __ label());1204 noProfiler.link(this); 1207 1205 1208 1206 NEXT_OPCODE(op_profile_will_call); … … 1210 1208 case op_profile_did_call: { 1211 1209 emitGetCTIParam(CTI_ARGS_profilerReference, X86::eax); 1212 __ cmpl_i32m(0, X86::eax); 1213 JmpSrc noProfiler = __ je(); 1210 Jump noProfiler = jzPtr(Address(X86::eax)); 1214 1211 emitPutJITStubArgFromVirtualRegister(currentInstruction[1].u.operand, 1, X86::eax); 1215 1212 emitCTICall(Interpreter::cti_op_profile_did_call); 1216 __ link(noProfiler, __ label());1213 noProfiler.link(this); 1217 1214 1218 1215 NEXT_OPCODE(op_profile_did_call); … … 1247 1244 unsigned jmpTableCount = m_jmpTable.size(); 1248 1245 for (unsigned i = 0; i < jmpTableCount; ++i) 1249 __ link(m_jmpTable[i].from, m_labels[m_jmpTable[i].to]);1246 m_jmpTable[i].from.linkTo(m_labels[m_jmpTable[i].toBytecodeIndex], this); 1250 1247 m_jmpTable.clear(); 1251 1248 } … … 1738 1735 1739 1736 emitGetCTIParam(CTI_ARGS_registerFile, X86::eax); 1740 __ leal_mr(m_codeBlock->m_numCalleeRegisters * sizeof(Register), X86::edi, X86::edx); 1737 addPtr(Imm32(m_codeBlock->m_numCalleeRegisters * sizeof(Register)), callFrameRegister, X86::edx); 1738 1741 1739 slowRegisterFileCheck = jg32(X86::edx, Address(X86::eax, FIELD_OFFSET(RegisterFile, m_end))); 1742 afterRegisterFileCheck = MacroAssembler::Label(this);1740 afterRegisterFileCheck = label(); 1743 1741 } 1744 1742 … … 1760 1758 ASSERT(m_jmpTable.isEmpty()); 1761 1759 1762 RefPtr<ExecutablePool> allocator = m_globalData->poolForSize(__ size()); 1763 m_codeBlock->setExecutablePool(allocator.get()); 1764 void* code = __ executableCopy(allocator.get()); 1760 RefPtr<ExecutablePool> allocator = m_globalData->poolForSize(m_assembler.size()); 1761 void* code = m_assembler.executableCopy(allocator.get()); 1762 JITCodeRef codeRef(code, allocator); 1763 1764 RepatchBuffer repatchBuffer(code); 1765 1765 1766 1766 // Translate vPC offsets into addresses in JIT generated code, for switch tables. … … 1773 1773 ASSERT(record.jumpTable.simpleJumpTable->branchOffsets.size() == record.jumpTable.simpleJumpTable->ctiOffsets.size()); 1774 1774 1775 record.jumpTable.simpleJumpTable->ctiDefault = __ getRelocatedAddress(code,m_labels[bytecodeIndex + 3 + record.defaultOffset]);1775 record.jumpTable.simpleJumpTable->ctiDefault = repatchBuffer.addressOf(m_labels[bytecodeIndex + 3 + record.defaultOffset]); 1776 1776 1777 1777 for (unsigned j = 0; j < record.jumpTable.simpleJumpTable->branchOffsets.size(); ++j) { 1778 1778 unsigned offset = record.jumpTable.simpleJumpTable->branchOffsets[j]; 1779 record.jumpTable.simpleJumpTable->ctiOffsets[j] = offset ? __ getRelocatedAddress(code,m_labels[bytecodeIndex + 3 + offset]) : record.jumpTable.simpleJumpTable->ctiDefault;1779 record.jumpTable.simpleJumpTable->ctiOffsets[j] = offset ? repatchBuffer.addressOf(m_labels[bytecodeIndex + 3 + offset]) : record.jumpTable.simpleJumpTable->ctiDefault; 1780 1780 } 1781 1781 } else { 1782 1782 ASSERT(record.type == SwitchRecord::String); 1783 1783 1784 record.jumpTable.stringJumpTable->ctiDefault = __ getRelocatedAddress(code,m_labels[bytecodeIndex + 3 + record.defaultOffset]);1784 record.jumpTable.stringJumpTable->ctiDefault = repatchBuffer.addressOf(m_labels[bytecodeIndex + 3 + record.defaultOffset]); 1785 1785 1786 1786 StringJumpTable::StringOffsetTable::iterator end = record.jumpTable.stringJumpTable->offsetTable.end(); 1787 1787 for (StringJumpTable::StringOffsetTable::iterator it = record.jumpTable.stringJumpTable->offsetTable.begin(); it != end; ++it) { 1788 1788 unsigned offset = it->second.branchOffset; 1789 it->second.ctiOffset = offset ? __ getRelocatedAddress(code,m_labels[bytecodeIndex + 3 + offset]) : record.jumpTable.stringJumpTable->ctiDefault;1789 it->second.ctiOffset = offset ? repatchBuffer.addressOf(m_labels[bytecodeIndex + 3 + offset]) : record.jumpTable.stringJumpTable->ctiDefault; 1790 1790 } 1791 1791 } … … 1794 1794 for (size_t i = 0; i < m_codeBlock->numberOfExceptionHandlers(); ++i) { 1795 1795 HandlerInfo& handler = m_codeBlock->exceptionHandler(i); 1796 handler.nativeCode = __ getRelocatedAddress(code,m_labels[handler.target]);1796 handler.nativeCode = repatchBuffer.addressOf(m_labels[handler.target]); 1797 1797 } 1798 1798 … … 1800 1800 for (Vector<CallRecord>::iterator iter = m_calls.begin(); iter != m_calls.end(); ++iter) { 1801 1801 if (iter->to) 1802 X86Assembler::link(code,iter->from, iter->to);1803 m_codeBlock->pcVector().append(PC( __ getRelocatedAddress(code,iter->from), iter->bytecodeIndex));1802 repatchBuffer.link(iter->from, iter->to); 1803 m_codeBlock->pcVector().append(PC(repatchBuffer.addressOf(iter->from), iter->bytecodeIndex)); 1804 1804 } 1805 1805 1806 1806 // Link absolute addresses for jsr 1807 1807 for (Vector<JSRInfo>::iterator iter = m_jsrSites.begin(); iter != m_jsrSites.end(); ++iter) 1808 X86Assembler::linkAbsoluteAddress(code, iter->addrPosition, iter->target);1808 repatchBuffer.setPtr(iter->storeLocation, repatchBuffer.addressOf(iter->target)); 1809 1809 1810 1810 for (unsigned i = 0; i < m_codeBlock->numberOfStructureStubInfos(); ++i) { … … 1821 1821 } 1822 1822 1823 m_codeBlock->setJITCode(code );1823 m_codeBlock->setJITCode(codeRef); 1824 1824 } 1825 1825 … … 1829 1829 1830 1830 // Check eax is an array 1831 JmpSrc array_failureCases1 = emitJumpIfNotJSCell(X86::eax);1831 X86Assembler::JmpSrc array_failureCases1 = emitJumpIfNotJSCell(X86::eax); 1832 1832 __ cmpl_i32m(reinterpret_cast<unsigned>(m_interpreter->m_jsArrayVptr), X86::eax); 1833 JmpSrc array_failureCases2 = __ jne();1833 X86Assembler::JmpSrc array_failureCases2 = __ jne(); 1834 1834 1835 1835 // Checks out okay! - get the length from the storage … … 1838 1838 1839 1839 __ cmpl_i32r(JSImmediate::maxImmediateInt, X86::eax); 1840 JmpSrc array_failureCases3 = __ ja();1840 X86Assembler::JmpSrc array_failureCases3 = __ ja(); 1841 1841 1842 1842 __ addl_rr(X86::eax, X86::eax); … … 1847 1847 // (2) The second function provides fast property access for string length 1848 1848 1849 JmpDst stringLengthBegin = __ align(16);1849 X86Assembler::JmpDst stringLengthBegin = __ align(16); 1850 1850 1851 1851 // Check eax is a string 1852 JmpSrc string_failureCases1 = emitJumpIfNotJSCell(X86::eax);1852 X86Assembler::JmpSrc string_failureCases1 = emitJumpIfNotJSCell(X86::eax); 1853 1853 __ cmpl_i32m(reinterpret_cast<unsigned>(m_interpreter->m_jsStringVptr), X86::eax); 1854 JmpSrc string_failureCases2 = __ jne();1854 X86Assembler::JmpSrc string_failureCases2 = __ jne(); 1855 1855 1856 1856 // Checks out okay! - get the length from the Ustring. … … 1859 1859 1860 1860 __ cmpl_i32r(JSImmediate::maxImmediateInt, X86::eax); 1861 JmpSrc string_failureCases3 = __ ja();1861 X86Assembler::JmpSrc string_failureCases3 = __ ja(); 1862 1862 1863 1863 __ addl_rr(X86::eax, X86::eax); … … 1868 1868 // (3) Trampolines for the slow cases of op_call / op_call_eval / op_construct. 1869 1869 1870 JmpDst virtualCallPreLinkBegin = __ align(16);1870 X86Assembler::JmpDst virtualCallPreLinkBegin = __ align(16); 1871 1871 1872 1872 // Load the callee CodeBlock* into eax … … 1874 1874 __ movl_mr(FIELD_OFFSET(FunctionBodyNode, m_code), X86::eax, X86::eax); 1875 1875 __ testl_rr(X86::eax, X86::eax); 1876 JmpSrc hasCodeBlock1 = __ jne();1876 X86Assembler::JmpSrc hasCodeBlock1 = __ jne(); 1877 1877 __ popl_r(X86::ebx); 1878 emitPutCTIParam( X86::edi, CTI_ARGS_callFrame);1879 JmpSrc callJSFunction1 = __ call();1878 emitPutCTIParam(callFrameRegister, CTI_ARGS_callFrame); 1879 X86Assembler::JmpSrc callJSFunction1 = __ call(); 1880 1880 emitGetJITStubArg(1, X86::ecx); 1881 1881 emitGetJITStubArg(3, X86::edx); … … 1885 1885 // Check argCount matches callee arity. 1886 1886 __ cmpl_rm(X86::edx, FIELD_OFFSET(CodeBlock, m_numParameters), X86::eax); 1887 JmpSrc arityCheckOkay1 = __ je();1887 X86Assembler::JmpSrc arityCheckOkay1 = __ je(); 1888 1888 __ popl_r(X86::ebx); 1889 1889 emitPutJITStubArg(X86::ebx, 2); 1890 1890 emitPutJITStubArg(X86::eax, 4); 1891 emitPutCTIParam( X86::edi, CTI_ARGS_callFrame);1892 JmpSrc callArityCheck1 = __ call();1893 __ movl_rr(X86::edx, X86::edi);1891 emitPutCTIParam(callFrameRegister, CTI_ARGS_callFrame); 1892 X86Assembler::JmpSrc callArityCheck1 = __ call(); 1893 __ movl_rr(X86::edx, callFrameRegister); 1894 1894 emitGetJITStubArg(1, X86::ecx); 1895 1895 emitGetJITStubArg(3, X86::edx); … … 1901 1901 __ popl_r(X86::ebx); 1902 1902 emitPutJITStubArg(X86::ebx, 2); 1903 emitPutCTIParam( X86::edi, CTI_ARGS_callFrame);1904 JmpSrc callDontLazyLinkCall = __ call();1903 emitPutCTIParam(callFrameRegister, CTI_ARGS_callFrame); 1904 X86Assembler::JmpSrc callDontLazyLinkCall = __ call(); 1905 1905 __ pushl_r(X86::ebx); 1906 1906 1907 1907 __ jmp_r(X86::eax); 1908 1908 1909 JmpDst virtualCallLinkBegin = __ align(16);1909 X86Assembler::JmpDst virtualCallLinkBegin = __ align(16); 1910 1910 1911 1911 // Load the callee CodeBlock* into eax … … 1913 1913 __ movl_mr(FIELD_OFFSET(FunctionBodyNode, m_code), X86::eax, X86::eax); 1914 1914 __ testl_rr(X86::eax, X86::eax); 1915 JmpSrc hasCodeBlock2 = __ jne();1915 X86Assembler::JmpSrc hasCodeBlock2 = __ jne(); 1916 1916 __ popl_r(X86::ebx); 1917 emitPutCTIParam( X86::edi, CTI_ARGS_callFrame);1918 JmpSrc callJSFunction2 = __ call();1917 emitPutCTIParam(callFrameRegister, CTI_ARGS_callFrame); 1918 X86Assembler::JmpSrc callJSFunction2 = __ call(); 1919 1919 emitGetJITStubArg(1, X86::ecx); 1920 1920 emitGetJITStubArg(3, X86::edx); … … 1924 1924 // Check argCount matches callee arity. 1925 1925 __ cmpl_rm(X86::edx, FIELD_OFFSET(CodeBlock, m_numParameters), X86::eax); 1926 JmpSrc arityCheckOkay2 = __ je();1926 X86Assembler::JmpSrc arityCheckOkay2 = __ je(); 1927 1927 __ popl_r(X86::ebx); 1928 1928 emitPutJITStubArg(X86::ebx, 2); 1929 1929 emitPutJITStubArg(X86::eax, 4); 1930 emitPutCTIParam( X86::edi, CTI_ARGS_callFrame);1931 JmpSrc callArityCheck2 = __ call();1932 __ movl_rr(X86::edx, X86::edi);1930 emitPutCTIParam(callFrameRegister, CTI_ARGS_callFrame); 1931 X86Assembler::JmpSrc callArityCheck2 = __ call(); 1932 __ movl_rr(X86::edx, callFrameRegister); 1933 1933 emitGetJITStubArg(1, X86::ecx); 1934 1934 emitGetJITStubArg(3, X86::edx); … … 1940 1940 __ popl_r(X86::ebx); 1941 1941 emitPutJITStubArg(X86::ebx, 2); 1942 emitPutCTIParam( X86::edi, CTI_ARGS_callFrame);1943 JmpSrc callLazyLinkCall = __ call();1942 emitPutCTIParam(callFrameRegister, CTI_ARGS_callFrame); 1943 X86Assembler::JmpSrc callLazyLinkCall = __ call(); 1944 1944 __ pushl_r(X86::ebx); 1945 1945 1946 1946 __ jmp_r(X86::eax); 1947 1947 1948 JmpDst virtualCallBegin = __ align(16);1948 X86Assembler::JmpDst virtualCallBegin = __ align(16); 1949 1949 1950 1950 // Load the callee CodeBlock* into eax … … 1952 1952 __ movl_mr(FIELD_OFFSET(FunctionBodyNode, m_code), X86::eax, X86::eax); 1953 1953 __ testl_rr(X86::eax, X86::eax); 1954 JmpSrc hasCodeBlock3 = __ jne();1954 X86Assembler::JmpSrc hasCodeBlock3 = __ jne(); 1955 1955 __ popl_r(X86::ebx); 1956 emitPutCTIParam( X86::edi, CTI_ARGS_callFrame);1957 JmpSrc callJSFunction3 = __ call();1956 emitPutCTIParam(callFrameRegister, CTI_ARGS_callFrame); 1957 X86Assembler::JmpSrc callJSFunction3 = __ call(); 1958 1958 emitGetJITStubArg(1, X86::ecx); 1959 1959 emitGetJITStubArg(3, X86::edx); … … 1963 1963 // Check argCount matches callee arity. 1964 1964 __ cmpl_rm(X86::edx, FIELD_OFFSET(CodeBlock, m_numParameters), X86::eax); 1965 JmpSrc arityCheckOkay3 = __ je();1965 X86Assembler::JmpSrc arityCheckOkay3 = __ je(); 1966 1966 __ popl_r(X86::ebx); 1967 1967 emitPutJITStubArg(X86::ebx, 2); 1968 1968 emitPutJITStubArg(X86::eax, 4); 1969 emitPutCTIParam( X86::edi, CTI_ARGS_callFrame);1970 JmpSrc callArityCheck3 = __ call();1971 __ movl_rr(X86::edx, X86::edi);1969 emitPutCTIParam(callFrameRegister, CTI_ARGS_callFrame); 1970 X86Assembler::JmpSrc callArityCheck3 = __ call(); 1971 __ movl_rr(X86::edx, callFrameRegister); 1972 1972 emitGetJITStubArg(1, X86::ecx); 1973 1973 emitGetJITStubArg(3, X86::edx);
Note:
See TracChangeset
for help on using the changeset viewer.