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 1711 matching lines...) Loading... |
1722 return less_equal; | 1722 return less_equal; |
1723 case Token::GTE: | 1723 case Token::GTE: |
1724 return greater_equal; | 1724 return greater_equal; |
1725 default: | 1725 default: |
1726 UNREACHABLE(); | 1726 UNREACHABLE(); |
1727 return no_condition; | 1727 return no_condition; |
1728 } | 1728 } |
1729 } | 1729 } |
1730 | 1730 |
1731 | 1731 |
1732 static bool HasInlinedSmiCode(Address address) { | 1732 bool CompareIC::HasInlinedSmiCode(Address address) { |
1733 // The address of the instruction following the call. | 1733 // The address of the instruction following the call. |
1734 Address test_instruction_address = | 1734 Address test_instruction_address = |
1735 address + Assembler::kCallTargetAddressOffset; | 1735 address + Assembler::kCallTargetAddressOffset; |
1736 | 1736 |
1737 // If the instruction following the call is not a test al, nothing | 1737 // If the instruction following the call is not a test al, nothing |
1738 // was inlined. | 1738 // was inlined. |
1739 return *test_instruction_address == Assembler::kTestAlByte; | 1739 return *test_instruction_address == Assembler::kTestAlByte; |
1740 } | 1740 } |
1741 | 1741 |
1742 | 1742 |
1743 void CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) { | |
1744 HandleScope scope; | |
1745 Handle<Code> rewritten; | |
1746 State previous_state = GetState(); | |
1747 | |
1748 State state = TargetState(previous_state, HasInlinedSmiCode(address()), x, y); | |
1749 if (state == GENERIC) { | |
1750 CompareStub stub(GetCondition(), strict(), NO_COMPARE_FLAGS); | |
1751 rewritten = stub.GetCode(); | |
1752 } else { | |
1753 ICCompareStub stub(op_, state); | |
1754 if (state == KNOWN_OBJECTS) { | |
1755 stub.set_known_map(Handle<Map>(Handle<JSObject>::cast(x)->map())); | |
1756 } | |
1757 rewritten = stub.GetCode(); | |
1758 } | |
1759 set_target(*rewritten); | |
1760 | |
1761 #ifdef DEBUG | |
1762 if (FLAG_trace_ic) { | |
1763 PrintF("[CompareIC (%s->%s)#%s]\n", | |
1764 GetStateName(previous_state), | |
1765 GetStateName(state), | |
1766 Token::Name(op_)); | |
1767 } | |
1768 #endif | |
1769 | |
1770 // Activate inlined smi code. | |
1771 if (previous_state == UNINITIALIZED) { | |
1772 PatchInlinedSmiCode(address(), ENABLE_INLINED_SMI_CHECK); | |
1773 } | |
1774 } | |
1775 | |
1776 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check) { | 1743 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check) { |
1777 // The address of the instruction following the call. | 1744 // The address of the instruction following the call. |
1778 Address test_instruction_address = | 1745 Address test_instruction_address = |
1779 address + Assembler::kCallTargetAddressOffset; | 1746 address + Assembler::kCallTargetAddressOffset; |
1780 | 1747 |
1781 // If the instruction following the call is not a test al, nothing | 1748 // If the instruction following the call is not a test al, nothing |
1782 // was inlined. | 1749 // was inlined. |
1783 if (*test_instruction_address != Assembler::kTestAlByte) { | 1750 if (*test_instruction_address != Assembler::kTestAlByte) { |
1784 ASSERT(*test_instruction_address == Assembler::kNopByte); | 1751 ASSERT(*test_instruction_address == Assembler::kNopByte); |
1785 return; | 1752 return; |
(...skipping 20 matching lines...) Loading... |
1806 Condition cc = (check == ENABLE_INLINED_SMI_CHECK) | 1773 Condition cc = (check == ENABLE_INLINED_SMI_CHECK) |
1807 ? (*jmp_address == Assembler::kJncShortOpcode ? not_zero : zero) | 1774 ? (*jmp_address == Assembler::kJncShortOpcode ? not_zero : zero) |
1808 : (*jmp_address == Assembler::kJnzShortOpcode ? not_carry : carry); | 1775 : (*jmp_address == Assembler::kJnzShortOpcode ? not_carry : carry); |
1809 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); | 1776 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); |
1810 } | 1777 } |
1811 | 1778 |
1812 | 1779 |
1813 } } // namespace v8::internal | 1780 } } // namespace v8::internal |
1814 | 1781 |
1815 #endif // V8_TARGET_ARCH_X64 | 1782 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |