| 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 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1728 if (FLAG_trace_ic) { | 1728 if (FLAG_trace_ic) { |
| 1729 PrintF("[CompareIC (%s->%s)#%s]\n", | 1729 PrintF("[CompareIC (%s->%s)#%s]\n", |
| 1730 GetStateName(previous_state), | 1730 GetStateName(previous_state), |
| 1731 GetStateName(state), | 1731 GetStateName(state), |
| 1732 Token::Name(op_)); | 1732 Token::Name(op_)); |
| 1733 } | 1733 } |
| 1734 #endif | 1734 #endif |
| 1735 | 1735 |
| 1736 // Activate inlined smi code. | 1736 // Activate inlined smi code. |
| 1737 if (previous_state == UNINITIALIZED) { | 1737 if (previous_state == UNINITIALIZED) { |
| 1738 PatchInlinedSmiCode(address()); | 1738 PatchInlinedSmiCode(address(), ENABLE_INLINED_SMI_CHECK); |
| 1739 } | 1739 } |
| 1740 } | 1740 } |
| 1741 | 1741 |
| 1742 | 1742 |
| 1743 void PatchInlinedSmiCode(Address address) { | 1743 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check) { |
| 1744 // The address of the instruction following the call. | 1744 // The address of the instruction following the call. |
| 1745 Address test_instruction_address = | 1745 Address test_instruction_address = |
| 1746 address + Assembler::kCallTargetAddressOffset; | 1746 address + Assembler::kCallTargetAddressOffset; |
| 1747 | 1747 |
| 1748 // 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 |
| 1749 // was inlined. | 1749 // was inlined. |
| 1750 if (*test_instruction_address != Assembler::kTestAlByte) { | 1750 if (*test_instruction_address != Assembler::kTestAlByte) { |
| 1751 ASSERT(*test_instruction_address == Assembler::kNopByte); | 1751 ASSERT(*test_instruction_address == Assembler::kNopByte); |
| 1752 return; | 1752 return; |
| 1753 } | 1753 } |
| 1754 | 1754 |
| 1755 Address delta_address = test_instruction_address + 1; | 1755 Address delta_address = test_instruction_address + 1; |
| 1756 // The delta to the start of the map check instruction and the | 1756 // The delta to the start of the map check instruction and the |
| 1757 // condition code uses at the patched jump. | 1757 // condition code uses at the patched jump. |
| 1758 int8_t delta = *reinterpret_cast<int8_t*>(delta_address); | 1758 int8_t delta = *reinterpret_cast<int8_t*>(delta_address); |
| 1759 if (FLAG_trace_ic) { | 1759 if (FLAG_trace_ic) { |
| 1760 PrintF("[ patching ic at %p, test=%p, delta=%d\n", | 1760 PrintF("[ patching ic at %p, test=%p, delta=%d\n", |
| 1761 address, test_instruction_address, delta); | 1761 address, test_instruction_address, delta); |
| 1762 } | 1762 } |
| 1763 | 1763 |
| 1764 // Patch with a short conditional jump. There must be a | 1764 // Patch with a short conditional jump. Enabling means switching from a short |
| 1765 // short jump-if-carry/not-carry at this position. | 1765 // jump-if-carry/not-carry to jump-if-zero/not-zero, whereas disabling is the |
| 1766 // reverse operation of that. |
| 1766 Address jmp_address = test_instruction_address - delta; | 1767 Address jmp_address = test_instruction_address - delta; |
| 1767 ASSERT(*jmp_address == Assembler::kJncShortOpcode || | 1768 ASSERT((check == ENABLE_INLINED_SMI_CHECK) |
| 1768 *jmp_address == Assembler::kJcShortOpcode); | 1769 ? (*jmp_address == Assembler::kJncShortOpcode || |
| 1769 Condition cc = *jmp_address == Assembler::kJncShortOpcode | 1770 *jmp_address == Assembler::kJcShortOpcode) |
| 1770 ? not_zero | 1771 : (*jmp_address == Assembler::kJnzShortOpcode || |
| 1771 : zero; | 1772 *jmp_address == Assembler::kJzShortOpcode)); |
| 1773 Condition cc = (check == ENABLE_INLINED_SMI_CHECK) |
| 1774 ? (*jmp_address == Assembler::kJncShortOpcode ? not_zero : zero) |
| 1775 : (*jmp_address == Assembler::kJnzShortOpcode ? not_carry : carry); |
| 1772 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); | 1776 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); |
| 1773 } | 1777 } |
| 1774 | 1778 |
| 1775 | 1779 |
| 1776 } } // namespace v8::internal | 1780 } } // namespace v8::internal |
| 1777 | 1781 |
| 1778 #endif // V8_TARGET_ARCH_IA32 | 1782 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |