| 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 1710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1721 address + Assembler::kCallTargetAddressOffset; | 1721 address + Assembler::kCallTargetAddressOffset; |
| 1722 | 1722 |
| 1723 // If the instruction following the call is not a test eax, nothing | 1723 // If the instruction following the call is not a test eax, nothing |
| 1724 // was inlined. | 1724 // was inlined. |
| 1725 if (*test_instruction_address != Assembler::kTestEaxByte) return false; | 1725 if (*test_instruction_address != Assembler::kTestEaxByte) return false; |
| 1726 | 1726 |
| 1727 // Extract the encoded deltas from the test eax instruction. | 1727 // Extract the encoded deltas from the test eax instruction. |
| 1728 Address encoded_offsets_address = test_instruction_address + 1; | 1728 Address encoded_offsets_address = test_instruction_address + 1; |
| 1729 int encoded_offsets = *reinterpret_cast<int*>(encoded_offsets_address); | 1729 int encoded_offsets = *reinterpret_cast<int*>(encoded_offsets_address); |
| 1730 int delta_to_map_check = -(encoded_offsets & 0xFFFF); | 1730 int delta_to_map_check = -(encoded_offsets & 0xFFFF); |
| 1731 #ifndef BASELINE_GC |
| 1731 int delta_to_record_write = encoded_offsets >> 16; | 1732 int delta_to_record_write = encoded_offsets >> 16; |
| 1733 #endif |
| 1732 | 1734 |
| 1733 // Patch the map to check. The map address is the last 4 bytes of | 1735 // Patch the map to check. The map address is the last 4 bytes of |
| 1734 // the 7-byte operand-immediate compare instruction. | 1736 // the 7-byte operand-immediate compare instruction. |
| 1735 Address map_check_address = test_instruction_address + delta_to_map_check; | 1737 Address map_check_address = test_instruction_address + delta_to_map_check; |
| 1736 Address map_address = map_check_address + 3; | 1738 Address map_address = map_check_address + 3; |
| 1737 *(reinterpret_cast<Object**>(map_address)) = map; | 1739 *(reinterpret_cast<Object**>(map_address)) = map; |
| 1738 | 1740 |
| 1739 // Patch the offset in the store instruction. The offset is in the | 1741 // Patch the offset in the store instruction. The offset is in the |
| 1740 // last 4 bytes of a six byte register-to-memory move instruction. | 1742 // last 4 bytes of a six byte register-to-memory move instruction. |
| 1741 Address offset_address = | 1743 Address offset_address = |
| 1742 map_check_address + StoreIC::kOffsetToStoreInstruction + 2; | 1744 map_check_address + StoreIC::kOffsetToStoreInstruction + 2; |
| 1743 // The offset should have initial value (kMaxInt - 1), cleared value | 1745 // The offset should have initial value (kMaxInt - 1), cleared value |
| 1744 // (-1) or we should be clearing the inlined version. | 1746 // (-1) or we should be clearing the inlined version. |
| 1745 ASSERT(*reinterpret_cast<int*>(offset_address) == kMaxInt - 1 || | 1747 ASSERT(*reinterpret_cast<int*>(offset_address) == kMaxInt - 1 || |
| 1746 *reinterpret_cast<int*>(offset_address) == -1 || | 1748 *reinterpret_cast<int*>(offset_address) == -1 || |
| 1747 (offset == 0 && map == Heap::null_value())); | 1749 (offset == 0 && map == Heap::null_value())); |
| 1748 *reinterpret_cast<int*>(offset_address) = offset - kHeapObjectTag; | 1750 *reinterpret_cast<int*>(offset_address) = offset - kHeapObjectTag; |
| 1749 | 1751 |
| 1752 #ifndef BASELINE_GC |
| 1750 // Patch the offset in the write-barrier code. The offset is the | 1753 // Patch the offset in the write-barrier code. The offset is the |
| 1751 // last 4 bytes of a six byte lea instruction. | 1754 // last 4 bytes of a six byte lea instruction. |
| 1752 offset_address = map_check_address + delta_to_record_write + 2; | 1755 offset_address = map_check_address + delta_to_record_write + 2; |
| 1753 // The offset should have initial value (kMaxInt), cleared value | 1756 // The offset should have initial value (kMaxInt), cleared value |
| 1754 // (-1) or we should be clearing the inlined version. | 1757 // (-1) or we should be clearing the inlined version. |
| 1755 ASSERT(*reinterpret_cast<int*>(offset_address) == kMaxInt || | 1758 ASSERT(*reinterpret_cast<int*>(offset_address) == kMaxInt || |
| 1756 *reinterpret_cast<int*>(offset_address) == -1 || | 1759 *reinterpret_cast<int*>(offset_address) == -1 || |
| 1757 (offset == 0 && map == Heap::null_value())); | 1760 (offset == 0 && map == Heap::null_value())); |
| 1758 *reinterpret_cast<int*>(offset_address) = offset - kHeapObjectTag; | 1761 *reinterpret_cast<int*>(offset_address) = offset - kHeapObjectTag; |
| 1762 #endif |
| 1759 | 1763 |
| 1760 return true; | 1764 return true; |
| 1761 } | 1765 } |
| 1762 | 1766 |
| 1763 | 1767 |
| 1764 static bool PatchInlinedMapCheck(Address address, Object* map) { | 1768 static bool PatchInlinedMapCheck(Address address, Object* map) { |
| 1765 if (V8::UseCrankshaft()) return false; | 1769 if (V8::UseCrankshaft()) return false; |
| 1766 | 1770 |
| 1767 Address test_instruction_address = | 1771 Address test_instruction_address = |
| 1768 address + Assembler::kCallTargetAddressOffset; | 1772 address + Assembler::kCallTargetAddressOffset; |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2116 // short jump at this position. | 2120 // short jump at this position. |
| 2117 Address jmp_address = test_instruction_address - delta; | 2121 Address jmp_address = test_instruction_address - delta; |
| 2118 ASSERT(*jmp_address == Assembler::kJmpShortOpcode); | 2122 ASSERT(*jmp_address == Assembler::kJmpShortOpcode); |
| 2119 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | not_zero); | 2123 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | not_zero); |
| 2120 } | 2124 } |
| 2121 | 2125 |
| 2122 | 2126 |
| 2123 } } // namespace v8::internal | 2127 } } // namespace v8::internal |
| 2124 | 2128 |
| 2125 #endif // V8_TARGET_ARCH_IA32 | 2129 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |