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 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1654 // The offset is in the last 4 bytes of a six byte | 1654 // The offset is in the last 4 bytes of a six byte |
1655 // memory-to-register move instruction, so we add 2 to get the | 1655 // memory-to-register move instruction, so we add 2 to get the |
1656 // offset to the last 4 bytes. | 1656 // offset to the last 4 bytes. |
1657 Address offset_address = | 1657 Address offset_address = |
1658 test_instruction_address + delta + kOffsetToLoadInstruction + 2; | 1658 test_instruction_address + delta + kOffsetToLoadInstruction + 2; |
1659 *reinterpret_cast<int*>(offset_address) = offset - kHeapObjectTag; | 1659 *reinterpret_cast<int*>(offset_address) = offset - kHeapObjectTag; |
1660 return true; | 1660 return true; |
1661 } | 1661 } |
1662 | 1662 |
1663 | 1663 |
| 1664 // One byte opcode for mov ecx,0xXXXXXXXX. |
| 1665 static const byte kMovEcxByte = 0xB9; |
| 1666 |
| 1667 bool LoadIC::PatchInlinedContextualLoad(Address address, |
| 1668 Object* map, |
| 1669 Object* cell) { |
| 1670 // The address of the instruction following the call. |
| 1671 Address mov_instruction_address = |
| 1672 address + Assembler::kCallTargetAddressOffset; |
| 1673 // If the instruction following the call is not a cmp eax, nothing |
| 1674 // was inlined. |
| 1675 if (*mov_instruction_address != kMovEcxByte) return false; |
| 1676 |
| 1677 Address delta_address = mov_instruction_address + 1; |
| 1678 // The delta to the start of the map check instruction. |
| 1679 int delta = *reinterpret_cast<int*>(delta_address); |
| 1680 |
| 1681 // The map address is the last 4 bytes of the 7-byte |
| 1682 // operand-immediate compare instruction, so we add 3 to get the |
| 1683 // offset to the last 4 bytes. |
| 1684 Address map_address = mov_instruction_address + delta + 3; |
| 1685 *(reinterpret_cast<Object**>(map_address)) = map; |
| 1686 |
| 1687 // The cell is in the last 4 bytes of a five byte mov reg, imm32 |
| 1688 // instruction, so we add 1 to get the offset to the last 4 bytes. |
| 1689 Address offset_address = |
| 1690 mov_instruction_address + delta + kOffsetToLoadInstruction + 1; |
| 1691 *reinterpret_cast<Object**>(offset_address) = cell; |
| 1692 return true; |
| 1693 } |
| 1694 |
| 1695 |
1664 bool StoreIC::PatchInlinedStore(Address address, Object* map, int offset) { | 1696 bool StoreIC::PatchInlinedStore(Address address, Object* map, int offset) { |
1665 // The address of the instruction following the call. | 1697 // The address of the instruction following the call. |
1666 Address test_instruction_address = | 1698 Address test_instruction_address = |
1667 address + Assembler::kCallTargetAddressOffset; | 1699 address + Assembler::kCallTargetAddressOffset; |
1668 | 1700 |
1669 // If the instruction following the call is not a test eax, nothing | 1701 // If the instruction following the call is not a test eax, nothing |
1670 // was inlined. | 1702 // was inlined. |
1671 if (*test_instruction_address != kTestEaxByte) return false; | 1703 if (*test_instruction_address != kTestEaxByte) return false; |
1672 | 1704 |
1673 // Extract the encoded deltas from the test eax instruction. | 1705 // Extract the encoded deltas from the test eax instruction. |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1948 ExternalReference ref = ExternalReference(IC_Utility(kKeyedStoreIC_Miss)); | 1980 ExternalReference ref = ExternalReference(IC_Utility(kKeyedStoreIC_Miss)); |
1949 __ TailCallExternalReference(ref, 3, 1); | 1981 __ TailCallExternalReference(ref, 3, 1); |
1950 } | 1982 } |
1951 | 1983 |
1952 #undef __ | 1984 #undef __ |
1953 | 1985 |
1954 | 1986 |
1955 } } // namespace v8::internal | 1987 } } // namespace v8::internal |
1956 | 1988 |
1957 #endif // V8_TARGET_ARCH_IA32 | 1989 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |