OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1693 set_target(*rewritten); | 1693 set_target(*rewritten); |
1694 | 1694 |
1695 #ifdef DEBUG | 1695 #ifdef DEBUG |
1696 if (FLAG_trace_ic) { | 1696 if (FLAG_trace_ic) { |
1697 PrintF("[CompareIC (%s->%s)#%s]\n", | 1697 PrintF("[CompareIC (%s->%s)#%s]\n", |
1698 GetStateName(previous_state), | 1698 GetStateName(previous_state), |
1699 GetStateName(state), | 1699 GetStateName(state), |
1700 Token::Name(op_)); | 1700 Token::Name(op_)); |
1701 } | 1701 } |
1702 #endif | 1702 #endif |
| 1703 |
| 1704 // Activate inlined smi code. |
| 1705 if (previous_state == UNINITIALIZED) { |
| 1706 PatchInlinedSmiCode(address()); |
| 1707 } |
1703 } | 1708 } |
1704 | 1709 |
1705 | 1710 |
1706 void PatchInlinedSmiCode(Address address) { | 1711 void PatchInlinedSmiCode(Address address) { |
1707 // Currently there is no smi inlining in the ARM full code generator. | 1712 Address cmp_instruction_address = |
| 1713 address + Assembler::kCallTargetAddressOffset; |
| 1714 |
| 1715 // If the instruction following the call is not a cmp rx, #yyy, nothing |
| 1716 // was inlined. |
| 1717 Instr instr = Assembler::instr_at(cmp_instruction_address); |
| 1718 if (!Assembler::IsCmpImmediate(instr)) { |
| 1719 return; |
| 1720 } |
| 1721 |
| 1722 // The delta to the start of the map check instruction and the |
| 1723 // condition code uses at the patched jump. |
| 1724 int delta = Assembler::GetCmpImmediateRawImmediate(instr); |
| 1725 delta += |
| 1726 Assembler::GetCmpImmediateRegister(instr).code() * kOff12Mask; |
| 1727 // If the delta is 0 the instruction is cmp r0, #0 which also signals that |
| 1728 // nothing was inlined. |
| 1729 if (delta == 0) { |
| 1730 return; |
| 1731 } |
| 1732 |
| 1733 #ifdef DEBUG |
| 1734 if (FLAG_trace_ic) { |
| 1735 PrintF("[ patching ic at %p, cmp=%p, delta=%d\n", |
| 1736 address, cmp_instruction_address, delta); |
| 1737 } |
| 1738 #endif |
| 1739 |
| 1740 Address patch_address = |
| 1741 cmp_instruction_address - delta * Instruction::kInstrSize; |
| 1742 Instr instr_at_patch = Assembler::instr_at(patch_address); |
| 1743 Instr branch_instr = |
| 1744 Assembler::instr_at(patch_address + Instruction::kInstrSize); |
| 1745 ASSERT(Assembler::IsCmpRegister(instr_at_patch)); |
| 1746 ASSERT_EQ(Assembler::GetRn(instr_at_patch).code(), |
| 1747 Assembler::GetRm(instr_at_patch).code()); |
| 1748 ASSERT(Assembler::IsBranch(branch_instr)); |
| 1749 if (Assembler::GetCondition(branch_instr) == eq) { |
| 1750 // This is patching a "jump if not smi" site to be active. |
| 1751 // Changing |
| 1752 // cmp rx, rx |
| 1753 // b eq, <target> |
| 1754 // to |
| 1755 // tst rx, #kSmiTagMask |
| 1756 // b ne, <target> |
| 1757 CodePatcher patcher(patch_address, 2); |
| 1758 Register reg = Assembler::GetRn(instr_at_patch); |
| 1759 patcher.masm()->tst(reg, Operand(kSmiTagMask)); |
| 1760 patcher.EmitCondition(ne); |
| 1761 } else { |
| 1762 ASSERT(Assembler::GetCondition(branch_instr) == ne); |
| 1763 // This is patching a "jump if smi" site to be active. |
| 1764 // Changing |
| 1765 // cmp rx, rx |
| 1766 // b ne, <target> |
| 1767 // to |
| 1768 // tst rx, #kSmiTagMask |
| 1769 // b eq, <target> |
| 1770 CodePatcher patcher(patch_address, 2); |
| 1771 Register reg = Assembler::GetRn(instr_at_patch); |
| 1772 patcher.masm()->tst(reg, Operand(kSmiTagMask)); |
| 1773 patcher.EmitCondition(eq); |
| 1774 } |
1708 } | 1775 } |
1709 | 1776 |
1710 | 1777 |
1711 } } // namespace v8::internal | 1778 } } // namespace v8::internal |
1712 | 1779 |
1713 #endif // V8_TARGET_ARCH_ARM | 1780 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |