Changeset 49409 in webkit for trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
- Timestamp:
- Oct 9, 2009, 5:30:49 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r48662 r49409 609 609 PassRefPtr<Label> BytecodeGenerator::emitJump(Label* target) 610 610 { 611 size_t begin = instructions().size(); 611 612 emitOpcode(target->isForward() ? op_jmp : op_loop); 612 instructions().append(target-> offsetFrom(instructions().size()));613 instructions().append(target->bind(begin, instructions().size())); 613 614 return target; 614 615 } … … 625 626 if (cond->index() == dstIndex && cond->isTemporary() && !cond->refCount()) { 626 627 rewindBinaryOp(); 628 629 size_t begin = instructions().size(); 627 630 emitOpcode(op_loop_if_less); 628 631 instructions().append(src1Index); 629 632 instructions().append(src2Index); 630 instructions().append(target-> offsetFrom(instructions().size()));633 instructions().append(target->bind(begin, instructions().size())); 631 634 return target; 632 635 } … … 640 643 if (cond->index() == dstIndex && cond->isTemporary() && !cond->refCount()) { 641 644 rewindBinaryOp(); 645 646 size_t begin = instructions().size(); 642 647 emitOpcode(op_loop_if_lesseq); 643 648 instructions().append(src1Index); 644 649 instructions().append(src2Index); 645 instructions().append(target-> offsetFrom(instructions().size()));650 instructions().append(target->bind(begin, instructions().size())); 646 651 return target; 647 652 } … … 654 659 if (cond->index() == dstIndex && cond->isTemporary() && !cond->refCount()) { 655 660 rewindUnaryOp(); 661 662 size_t begin = instructions().size(); 656 663 emitOpcode(op_jeq_null); 657 664 instructions().append(srcIndex); 658 instructions().append(target-> offsetFrom(instructions().size()));665 instructions().append(target->bind(begin, instructions().size())); 659 666 return target; 660 667 } … … 667 674 if (cond->index() == dstIndex && cond->isTemporary() && !cond->refCount()) { 668 675 rewindUnaryOp(); 676 677 size_t begin = instructions().size(); 669 678 emitOpcode(op_jneq_null); 670 679 instructions().append(srcIndex); 671 instructions().append(target-> offsetFrom(instructions().size()));680 instructions().append(target->bind(begin, instructions().size())); 672 681 return target; 673 682 } 674 683 } 684 685 size_t begin = instructions().size(); 675 686 676 687 emitOpcode(target->isForward() ? op_jtrue : op_loop_if_true); 677 688 instructions().append(cond->index()); 678 instructions().append(target-> offsetFrom(instructions().size()));689 instructions().append(target->bind(begin, instructions().size())); 679 690 return target; 680 691 } … … 693 704 if (cond->index() == dstIndex && cond->isTemporary() && !cond->refCount()) { 694 705 rewindBinaryOp(); 706 707 size_t begin = instructions().size(); 695 708 emitOpcode(op_jnless); 696 709 instructions().append(src1Index); 697 710 instructions().append(src2Index); 698 instructions().append(target-> offsetFrom(instructions().size()));711 instructions().append(target->bind(begin, instructions().size())); 699 712 return target; 700 713 } … … 708 721 if (cond->index() == dstIndex && cond->isTemporary() && !cond->refCount()) { 709 722 rewindBinaryOp(); 723 724 size_t begin = instructions().size(); 710 725 emitOpcode(op_jnlesseq); 711 726 instructions().append(src1Index); 712 727 instructions().append(src2Index); 713 instructions().append(target-> offsetFrom(instructions().size()));728 instructions().append(target->bind(begin, instructions().size())); 714 729 return target; 715 730 } … … 722 737 if (cond->index() == dstIndex && cond->isTemporary() && !cond->refCount()) { 723 738 rewindUnaryOp(); 739 740 size_t begin = instructions().size(); 724 741 emitOpcode(op_jtrue); 725 742 instructions().append(srcIndex); 726 instructions().append(target-> offsetFrom(instructions().size()));743 instructions().append(target->bind(begin, instructions().size())); 727 744 return target; 728 745 } … … 735 752 if (cond->index() == dstIndex && cond->isTemporary() && !cond->refCount()) { 736 753 rewindUnaryOp(); 754 755 size_t begin = instructions().size(); 737 756 emitOpcode(op_jneq_null); 738 757 instructions().append(srcIndex); 739 instructions().append(target-> offsetFrom(instructions().size()));758 instructions().append(target->bind(begin, instructions().size())); 740 759 return target; 741 760 } … … 748 767 if (cond->index() == dstIndex && cond->isTemporary() && !cond->refCount()) { 749 768 rewindUnaryOp(); 769 770 size_t begin = instructions().size(); 750 771 emitOpcode(op_jeq_null); 751 772 instructions().append(srcIndex); 752 instructions().append(target-> offsetFrom(instructions().size()));773 instructions().append(target->bind(begin, instructions().size())); 753 774 return target; 754 775 } 755 776 } 756 777 778 size_t begin = instructions().size(); 757 779 emitOpcode(op_jfalse); 758 780 instructions().append(cond->index()); 759 instructions().append(target-> offsetFrom(instructions().size()));781 instructions().append(target->bind(begin, instructions().size())); 760 782 return target; 761 783 } … … 763 785 PassRefPtr<Label> BytecodeGenerator::emitJumpIfNotFunctionCall(RegisterID* cond, Label* target) 764 786 { 787 size_t begin = instructions().size(); 788 765 789 emitOpcode(op_jneq_ptr); 766 790 instructions().append(cond->index()); 767 791 instructions().append(m_scopeChain->globalObject()->d()->callFunction); 768 instructions().append(target-> offsetFrom(instructions().size()));792 instructions().append(target->bind(begin, instructions().size())); 769 793 return target; 770 794 } … … 772 796 PassRefPtr<Label> BytecodeGenerator::emitJumpIfNotFunctionApply(RegisterID* cond, Label* target) 773 797 { 798 size_t begin = instructions().size(); 799 774 800 emitOpcode(op_jneq_ptr); 775 801 instructions().append(cond->index()); 776 802 instructions().append(m_scopeChain->globalObject()->d()->applyFunction); 777 instructions().append(target-> offsetFrom(instructions().size()));803 instructions().append(target->bind(begin, instructions().size())); 778 804 return target; 779 805 } … … 1719 1745 1720 1746 if (nNormalScopes) { 1747 size_t begin = instructions().size(); 1748 1721 1749 // We need to remove a number of dynamic scopes to get to the next 1722 1750 // finally block … … 1727 1755 // left to emit, so make the jmp_scopes jump directly to the target label 1728 1756 if (topScope == bottomScope) { 1729 instructions().append(target-> offsetFrom(instructions().size()));1757 instructions().append(target->bind(begin, instructions().size())); 1730 1758 return target; 1731 1759 } … … 1734 1762 // to the next instruction 1735 1763 RefPtr<Label> nextInsn = newLabel(); 1736 instructions().append(nextInsn-> offsetFrom(instructions().size()));1764 instructions().append(nextInsn->bind(begin, instructions().size())); 1737 1765 emitLabel(nextInsn.get()); 1738 1766 } … … 1759 1787 return emitComplexJumpScopes(target, &m_scopeContextStack.last(), &m_scopeContextStack.last() - scopeDelta); 1760 1788 1789 size_t begin = instructions().size(); 1790 1761 1791 emitOpcode(op_jmp_scopes); 1762 1792 instructions().append(scopeDelta); 1763 instructions().append(target-> offsetFrom(instructions().size()));1793 instructions().append(target->bind(begin, instructions().size())); 1764 1794 return target; 1765 1795 } … … 1767 1797 RegisterID* BytecodeGenerator::emitNextPropertyName(RegisterID* dst, RegisterID* iter, Label* target) 1768 1798 { 1799 size_t begin = instructions().size(); 1800 1769 1801 emitOpcode(op_next_pname); 1770 1802 instructions().append(dst->index()); 1771 1803 instructions().append(iter->index()); 1772 instructions().append(target-> offsetFrom(instructions().size()));1804 instructions().append(target->bind(begin, instructions().size())); 1773 1805 return dst; 1774 1806 } … … 1777 1809 { 1778 1810 #if ENABLE(JIT) 1779 HandlerInfo info = { start-> offsetFrom(0), end->offsetFrom(0), instructions().size(), m_dynamicScopeDepth + m_baseScopeDepth, CodeLocationLabel() };1811 HandlerInfo info = { start->bind(0, 0), end->bind(0, 0), instructions().size(), m_dynamicScopeDepth + m_baseScopeDepth, CodeLocationLabel() }; 1780 1812 #else 1781 HandlerInfo info = { start-> offsetFrom(0), end->offsetFrom(0), instructions().size(), m_dynamicScopeDepth + m_baseScopeDepth };1813 HandlerInfo info = { start->bind(0, 0), end->bind(0, 0), instructions().size(), m_dynamicScopeDepth + m_baseScopeDepth }; 1782 1814 #endif 1783 1815 … … 1799 1831 PassRefPtr<Label> BytecodeGenerator::emitJumpSubroutine(RegisterID* retAddrDst, Label* finally) 1800 1832 { 1833 size_t begin = instructions().size(); 1834 1801 1835 emitOpcode(op_jsr); 1802 1836 instructions().append(retAddrDst->index()); 1803 instructions().append(finally-> offsetFrom(instructions().size()));1837 instructions().append(finally->bind(begin, instructions().size())); 1804 1838 emitLabel(newLabel().get()); // Record the fact that the next instruction is implicitly labeled, because op_sret will return to it. 1805 1839 return finally; … … 1871 1905 // the labels should not be "forward" references 1872 1906 ASSERT(!labels[i]->isForward()); 1873 jumpTable.add(keyForImmediateSwitch(nodes[i], min, max), labels[i]-> offsetFrom(switchAddress));1907 jumpTable.add(keyForImmediateSwitch(nodes[i], min, max), labels[i]->bind(switchAddress, switchAddress + 3)); 1874 1908 } 1875 1909 } … … 1897 1931 // the labels should not be "forward" references 1898 1932 ASSERT(!labels[i]->isForward()); 1899 jumpTable.add(keyForCharacterSwitch(nodes[i], min, max), labels[i]-> offsetFrom(switchAddress));1933 jumpTable.add(keyForCharacterSwitch(nodes[i], min, max), labels[i]->bind(switchAddress, switchAddress + 3)); 1900 1934 } 1901 1935 } … … 1911 1945 UString::Rep* clause = static_cast<StringNode*>(nodes[i])->value().ustring().rep(); 1912 1946 OffsetLocation location; 1913 location.branchOffset = labels[i]-> offsetFrom(switchAddress);1947 location.branchOffset = labels[i]->bind(switchAddress, switchAddress + 3); 1914 1948 jumpTable.offsetTable.add(clause, location); 1915 1949 } … … 1922 1956 if (switchInfo.switchType == SwitchInfo::SwitchImmediate) { 1923 1957 instructions()[switchInfo.bytecodeOffset + 1] = m_codeBlock->numberOfImmediateSwitchJumpTables(); 1924 instructions()[switchInfo.bytecodeOffset + 2] = defaultLabel-> offsetFrom(switchInfo.bytecodeOffset + 3);1958 instructions()[switchInfo.bytecodeOffset + 2] = defaultLabel->bind(switchInfo.bytecodeOffset, switchInfo.bytecodeOffset + 3); 1925 1959 1926 1960 SimpleJumpTable& jumpTable = m_codeBlock->addImmediateSwitchJumpTable(); 1927 prepareJumpTableForImmediateSwitch(jumpTable, switchInfo.bytecodeOffset + 3, clauseCount, labels, nodes, min, max);1961 prepareJumpTableForImmediateSwitch(jumpTable, switchInfo.bytecodeOffset, clauseCount, labels, nodes, min, max); 1928 1962 } else if (switchInfo.switchType == SwitchInfo::SwitchCharacter) { 1929 1963 instructions()[switchInfo.bytecodeOffset + 1] = m_codeBlock->numberOfCharacterSwitchJumpTables(); 1930 instructions()[switchInfo.bytecodeOffset + 2] = defaultLabel-> offsetFrom(switchInfo.bytecodeOffset + 3);1964 instructions()[switchInfo.bytecodeOffset + 2] = defaultLabel->bind(switchInfo.bytecodeOffset, switchInfo.bytecodeOffset + 3); 1931 1965 1932 1966 SimpleJumpTable& jumpTable = m_codeBlock->addCharacterSwitchJumpTable(); 1933 prepareJumpTableForCharacterSwitch(jumpTable, switchInfo.bytecodeOffset + 3, clauseCount, labels, nodes, min, max);1967 prepareJumpTableForCharacterSwitch(jumpTable, switchInfo.bytecodeOffset, clauseCount, labels, nodes, min, max); 1934 1968 } else { 1935 1969 ASSERT(switchInfo.switchType == SwitchInfo::SwitchString); 1936 1970 instructions()[switchInfo.bytecodeOffset + 1] = m_codeBlock->numberOfStringSwitchJumpTables(); 1937 instructions()[switchInfo.bytecodeOffset + 2] = defaultLabel-> offsetFrom(switchInfo.bytecodeOffset + 3);1971 instructions()[switchInfo.bytecodeOffset + 2] = defaultLabel->bind(switchInfo.bytecodeOffset, switchInfo.bytecodeOffset + 3); 1938 1972 1939 1973 StringJumpTable& jumpTable = m_codeBlock->addStringSwitchJumpTable(); 1940 prepareJumpTableForStringSwitch(jumpTable, switchInfo.bytecodeOffset + 3, clauseCount, labels, nodes);1974 prepareJumpTableForStringSwitch(jumpTable, switchInfo.bytecodeOffset, clauseCount, labels, nodes); 1941 1975 } 1942 1976 }
Note:
See TracChangeset
for help on using the changeset viewer.