OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1700 set_target(*rewritten); | 1700 set_target(*rewritten); |
1701 | 1701 |
1702 #ifdef DEBUG | 1702 #ifdef DEBUG |
1703 if (FLAG_trace_ic) { | 1703 if (FLAG_trace_ic) { |
1704 PrintF("[CompareIC (%s->%s)#%s]\n", | 1704 PrintF("[CompareIC (%s->%s)#%s]\n", |
1705 GetStateName(previous_state), | 1705 GetStateName(previous_state), |
1706 GetStateName(state), | 1706 GetStateName(state), |
1707 Token::Name(op_)); | 1707 Token::Name(op_)); |
1708 } | 1708 } |
1709 #endif | 1709 #endif |
| 1710 |
| 1711 // Activate inlined smi code. |
| 1712 if (previous_state == UNINITIALIZED) { |
| 1713 PatchInlinedSmiCode(address()); |
| 1714 } |
1710 } | 1715 } |
1711 | 1716 |
1712 void PatchInlinedSmiCode(Address address) { | 1717 void PatchInlinedSmiCode(Address address) { |
1713 // Disabled, then patched inline smi code is not implemented on X64. | 1718 // The address of the instruction following the call. |
1714 // So we do nothing in this case. | 1719 Address test_instruction_address = |
| 1720 address + Assembler::kCallTargetAddressOffset; |
| 1721 |
| 1722 // If the instruction following the call is not a test al, nothing |
| 1723 // was inlined. |
| 1724 if (*test_instruction_address != Assembler::kTestAlByte) { |
| 1725 ASSERT(*test_instruction_address == Assembler::kNopByte); |
| 1726 return; |
| 1727 } |
| 1728 |
| 1729 Address delta_address = test_instruction_address + 1; |
| 1730 // The delta to the start of the map check instruction and the |
| 1731 // condition code uses at the patched jump. |
| 1732 int8_t delta = *reinterpret_cast<int8_t*>(delta_address); |
| 1733 if (FLAG_trace_ic) { |
| 1734 PrintF("[ patching ic at %p, test=%p, delta=%d\n", |
| 1735 address, test_instruction_address, delta); |
| 1736 } |
| 1737 |
| 1738 // Patch with a short conditional jump. There must be a |
| 1739 // short jump-if-carry/not-carry at this position. |
| 1740 Address jmp_address = test_instruction_address - delta; |
| 1741 ASSERT(*jmp_address == Assembler::kJncShortOpcode || |
| 1742 *jmp_address == Assembler::kJcShortOpcode); |
| 1743 Condition cc = *jmp_address == Assembler::kJncShortOpcode |
| 1744 ? not_zero |
| 1745 : zero; |
| 1746 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); |
1715 } | 1747 } |
1716 | 1748 |
1717 | 1749 |
1718 } } // namespace v8::internal | 1750 } } // namespace v8::internal |
1719 | 1751 |
1720 #endif // V8_TARGET_ARCH_X64 | 1752 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |