OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1681 if (FLAG_trace_ic) { | 1681 if (FLAG_trace_ic) { |
1682 PrintF("[CompareIC (%s->%s)#%s]\n", | 1682 PrintF("[CompareIC (%s->%s)#%s]\n", |
1683 GetStateName(previous_state), | 1683 GetStateName(previous_state), |
1684 GetStateName(state), | 1684 GetStateName(state), |
1685 Token::Name(op_)); | 1685 Token::Name(op_)); |
1686 } | 1686 } |
1687 #endif | 1687 #endif |
1688 | 1688 |
1689 // Activate inlined smi code. | 1689 // Activate inlined smi code. |
1690 if (previous_state == UNINITIALIZED) { | 1690 if (previous_state == UNINITIALIZED) { |
1691 PatchInlinedSmiCode(address()); | 1691 PatchInlinedSmiCode(address(), ENABLE_INLINED_SMI_CHECK); |
1692 } | 1692 } |
1693 } | 1693 } |
1694 | 1694 |
1695 | 1695 |
1696 void PatchInlinedSmiCode(Address address) { | 1696 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check) { |
1697 Address andi_instruction_address = | 1697 Address andi_instruction_address = |
1698 address + Assembler::kCallTargetAddressOffset; | 1698 address + Assembler::kCallTargetAddressOffset; |
1699 | 1699 |
1700 // If the instruction following the call is not a andi at, rx, #yyy, nothing | 1700 // If the instruction following the call is not a andi at, rx, #yyy, nothing |
1701 // was inlined. | 1701 // was inlined. |
1702 Instr instr = Assembler::instr_at(andi_instruction_address); | 1702 Instr instr = Assembler::instr_at(andi_instruction_address); |
1703 if (!(Assembler::IsAndImmediate(instr) && | 1703 if (!(Assembler::IsAndImmediate(instr) && |
1704 Assembler::GetRt(instr) == (uint32_t)zero_reg.code())) { | 1704 Assembler::GetRt(instr) == (uint32_t)zero_reg.code())) { |
1705 return; | 1705 return; |
1706 } | 1706 } |
(...skipping 13 matching lines...) Expand all Loading... |
1720 PrintF("[ patching ic at %p, andi=%p, delta=%d\n", | 1720 PrintF("[ patching ic at %p, andi=%p, delta=%d\n", |
1721 address, andi_instruction_address, delta); | 1721 address, andi_instruction_address, delta); |
1722 } | 1722 } |
1723 #endif | 1723 #endif |
1724 | 1724 |
1725 Address patch_address = | 1725 Address patch_address = |
1726 andi_instruction_address - delta * Instruction::kInstrSize; | 1726 andi_instruction_address - delta * Instruction::kInstrSize; |
1727 Instr instr_at_patch = Assembler::instr_at(patch_address); | 1727 Instr instr_at_patch = Assembler::instr_at(patch_address); |
1728 Instr branch_instr = | 1728 Instr branch_instr = |
1729 Assembler::instr_at(patch_address + Instruction::kInstrSize); | 1729 Assembler::instr_at(patch_address + Instruction::kInstrSize); |
1730 ASSERT(Assembler::IsAndImmediate(instr_at_patch)); | 1730 // This is patching a conditional "jump if not smi/jump if smi" site. |
1731 ASSERT_EQ(0, Assembler::GetImmediate16(instr_at_patch)); | 1731 // Enabling by changing from |
| 1732 // andi at, rx, 0 |
| 1733 // Branch <target>, eq, at, Operand(zero_reg) |
| 1734 // to: |
| 1735 // andi at, rx, #kSmiTagMask |
| 1736 // Branch <target>, ne, at, Operand(zero_reg) |
| 1737 // and vice-versa to be disabled again. |
| 1738 CodePatcher patcher(patch_address, 2); |
| 1739 Register reg = Register::from_code(Assembler::GetRs(instr_at_patch)); |
| 1740 if (check == ENABLE_INLINED_SMI_CHECK) { |
| 1741 ASSERT(Assembler::IsAndImmediate(instr_at_patch)); |
| 1742 ASSERT_EQ(0, Assembler::GetImmediate16(instr_at_patch)); |
| 1743 patcher.masm()->andi(at, reg, kSmiTagMask); |
| 1744 } else { |
| 1745 ASSERT(check == DISABLE_INLINED_SMI_CHECK); |
| 1746 ASSERT(Assembler::IsAndImmediate(instr_at_patch)); |
| 1747 patcher.masm()->andi(at, reg, 0); |
| 1748 } |
1732 ASSERT(Assembler::IsBranch(branch_instr)); | 1749 ASSERT(Assembler::IsBranch(branch_instr)); |
1733 if (Assembler::IsBeq(branch_instr)) { | 1750 if (Assembler::IsBeq(branch_instr)) { |
1734 // This is patching a "jump if not smi" site to be active. | |
1735 // Changing: | |
1736 // andi at, rx, 0 | |
1737 // Branch <target>, eq, at, Operand(zero_reg) | |
1738 // to: | |
1739 // andi at, rx, #kSmiTagMask | |
1740 // Branch <target>, ne, at, Operand(zero_reg) | |
1741 CodePatcher patcher(patch_address, 2); | |
1742 Register reg = Register::from_code(Assembler::GetRs(instr_at_patch)); | |
1743 patcher.masm()->andi(at, reg, kSmiTagMask); | |
1744 patcher.ChangeBranchCondition(ne); | 1751 patcher.ChangeBranchCondition(ne); |
1745 } else { | 1752 } else { |
1746 ASSERT(Assembler::IsBne(branch_instr)); | 1753 ASSERT(Assembler::IsBne(branch_instr)); |
1747 // This is patching a "jump if smi" site to be active. | |
1748 // Changing: | |
1749 // andi at, rx, 0 | |
1750 // Branch <target>, ne, at, Operand(zero_reg) | |
1751 // to: | |
1752 // andi at, rx, #kSmiTagMask | |
1753 // Branch <target>, eq, at, Operand(zero_reg) | |
1754 CodePatcher patcher(patch_address, 2); | |
1755 Register reg = Register::from_code(Assembler::GetRs(instr_at_patch)); | |
1756 patcher.masm()->andi(at, reg, kSmiTagMask); | |
1757 patcher.ChangeBranchCondition(eq); | 1754 patcher.ChangeBranchCondition(eq); |
1758 } | 1755 } |
1759 } | 1756 } |
1760 | 1757 |
1761 | 1758 |
1762 } } // namespace v8::internal | 1759 } } // namespace v8::internal |
1763 | 1760 |
1764 #endif // V8_TARGET_ARCH_MIPS | 1761 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |