OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 | 836 |
837 // We extract the destination register from the emitted nop instruction. | 837 // We extract the destination register from the emitted nop instruction. |
838 Register dst = Register::from_code( | 838 Register dst = Register::from_code( |
839 Instruction::RmValue(instr_at(pos + kInstrSize))); | 839 Instruction::RmValue(instr_at(pos + kInstrSize))); |
840 DCHECK(IsNop(instr_at(pos + kInstrSize), dst.code())); | 840 DCHECK(IsNop(instr_at(pos + kInstrSize), dst.code())); |
841 uint32_t target24 = target_pos + (Code::kHeaderSize - kHeapObjectTag); | 841 uint32_t target24 = target_pos + (Code::kHeaderSize - kHeapObjectTag); |
842 DCHECK(is_uint24(target24)); | 842 DCHECK(is_uint24(target24)); |
843 if (is_uint8(target24)) { | 843 if (is_uint8(target24)) { |
844 // If the target fits in a byte then only patch with a mov | 844 // If the target fits in a byte then only patch with a mov |
845 // instruction. | 845 // instruction. |
846 CodePatcher patcher(reinterpret_cast<byte*>(buffer_ + pos), | 846 CodePatcher patcher(isolate(), reinterpret_cast<byte*>(buffer_ + pos), 1, |
847 1, | |
848 CodePatcher::DONT_FLUSH); | 847 CodePatcher::DONT_FLUSH); |
849 patcher.masm()->mov(dst, Operand(target24)); | 848 patcher.masm()->mov(dst, Operand(target24)); |
850 } else { | 849 } else { |
851 uint16_t target16_0 = target24 & kImm16Mask; | 850 uint16_t target16_0 = target24 & kImm16Mask; |
852 uint16_t target16_1 = target24 >> 16; | 851 uint16_t target16_1 = target24 >> 16; |
853 if (CpuFeatures::IsSupported(ARMv7)) { | 852 if (CpuFeatures::IsSupported(ARMv7)) { |
854 // Patch with movw/movt. | 853 // Patch with movw/movt. |
855 if (target16_1 == 0) { | 854 if (target16_1 == 0) { |
856 CodePatcher patcher(reinterpret_cast<byte*>(buffer_ + pos), | 855 CodePatcher patcher(isolate(), reinterpret_cast<byte*>(buffer_ + pos), |
857 1, | 856 1, CodePatcher::DONT_FLUSH); |
858 CodePatcher::DONT_FLUSH); | |
859 patcher.masm()->movw(dst, target16_0); | 857 patcher.masm()->movw(dst, target16_0); |
860 } else { | 858 } else { |
861 CodePatcher patcher(reinterpret_cast<byte*>(buffer_ + pos), | 859 CodePatcher patcher(isolate(), reinterpret_cast<byte*>(buffer_ + pos), |
862 2, | 860 2, CodePatcher::DONT_FLUSH); |
863 CodePatcher::DONT_FLUSH); | |
864 patcher.masm()->movw(dst, target16_0); | 861 patcher.masm()->movw(dst, target16_0); |
865 patcher.masm()->movt(dst, target16_1); | 862 patcher.masm()->movt(dst, target16_1); |
866 } | 863 } |
867 } else { | 864 } else { |
868 // Patch with a sequence of mov/orr/orr instructions. | 865 // Patch with a sequence of mov/orr/orr instructions. |
869 uint8_t target8_0 = target16_0 & kImm8Mask; | 866 uint8_t target8_0 = target16_0 & kImm8Mask; |
870 uint8_t target8_1 = target16_0 >> 8; | 867 uint8_t target8_1 = target16_0 >> 8; |
871 uint8_t target8_2 = target16_1 & kImm8Mask; | 868 uint8_t target8_2 = target16_1 & kImm8Mask; |
872 if (target8_2 == 0) { | 869 if (target8_2 == 0) { |
873 CodePatcher patcher(reinterpret_cast<byte*>(buffer_ + pos), | 870 CodePatcher patcher(isolate(), reinterpret_cast<byte*>(buffer_ + pos), |
874 2, | 871 2, CodePatcher::DONT_FLUSH); |
875 CodePatcher::DONT_FLUSH); | |
876 patcher.masm()->mov(dst, Operand(target8_0)); | 872 patcher.masm()->mov(dst, Operand(target8_0)); |
877 patcher.masm()->orr(dst, dst, Operand(target8_1 << 8)); | 873 patcher.masm()->orr(dst, dst, Operand(target8_1 << 8)); |
878 } else { | 874 } else { |
879 CodePatcher patcher(reinterpret_cast<byte*>(buffer_ + pos), | 875 CodePatcher patcher(isolate(), reinterpret_cast<byte*>(buffer_ + pos), |
880 3, | 876 3, CodePatcher::DONT_FLUSH); |
881 CodePatcher::DONT_FLUSH); | |
882 patcher.masm()->mov(dst, Operand(target8_0)); | 877 patcher.masm()->mov(dst, Operand(target8_0)); |
883 patcher.masm()->orr(dst, dst, Operand(target8_1 << 8)); | 878 patcher.masm()->orr(dst, dst, Operand(target8_1 << 8)); |
884 patcher.masm()->orr(dst, dst, Operand(target8_2 << 16)); | 879 patcher.masm()->orr(dst, dst, Operand(target8_2 << 16)); |
885 } | 880 } |
886 } | 881 } |
887 } | 882 } |
888 return; | 883 return; |
889 } | 884 } |
890 int imm26 = target_pos - (pos + kPcLoadDelta); | 885 int imm26 = target_pos - (pos + kPcLoadDelta); |
891 DCHECK_EQ(5 * B25, instr & 7 * B25); // b, bl, or blx imm24 | 886 DCHECK_EQ(5 * B25, instr & 7 * B25); // b, bl, or blx imm24 |
(...skipping 3217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4109 DCHECK(is_uint12(offset)); | 4104 DCHECK(is_uint12(offset)); |
4110 instr_at_put(pc, SetLdrRegisterImmediateOffset(instr, offset)); | 4105 instr_at_put(pc, SetLdrRegisterImmediateOffset(instr, offset)); |
4111 } | 4106 } |
4112 } | 4107 } |
4113 | 4108 |
4114 | 4109 |
4115 } // namespace internal | 4110 } // namespace internal |
4116 } // namespace v8 | 4111 } // namespace v8 |
4117 | 4112 |
4118 #endif // V8_TARGET_ARCH_ARM | 4113 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |