| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 Memory::uint32_at(patch_site + 9) = 0xD2FF4900u; // 0x00, call r10 | 171 Memory::uint32_at(patch_site + 9) = 0xD2FF4900u; // 0x00, call r10 |
| 172 Memory::Address_at(patch_site + 2) = target; | 172 Memory::Address_at(patch_site + 2) = target; |
| 173 | 173 |
| 174 // Add the requested number of int3 instructions after the call. | 174 // Add the requested number of int3 instructions after the call. |
| 175 for (int i = 0; i < guard_bytes; i++) { | 175 for (int i = 0; i < guard_bytes; i++) { |
| 176 *(patch_site + 13 + i) = 0xCC; // int3 | 176 *(patch_site + 13 + i) = 0xCC; // int3 |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 | 179 |
| 180 | 180 |
| 181 void RelocInfo::PatchCode(byte* instructions, int instruction_count) { |
| 182 // Patch the code at the current address with the supplied instructions. |
| 183 for (int i = 0; i < instruction_count; i++) { |
| 184 *(pc_ + i) = *(instructions + i); |
| 185 } |
| 186 } |
| 187 |
| 181 // ----------------------------------------------------------------------------- | 188 // ----------------------------------------------------------------------------- |
| 182 // Implementation of Operand | 189 // Implementation of Operand |
| 183 | 190 |
| 184 Operand::Operand(Register base, int32_t disp): rex_(0) { | 191 Operand::Operand(Register base, int32_t disp): rex_(0) { |
| 185 len_ = 1; | 192 len_ = 1; |
| 186 if (base.is(rsp) || base.is(r12)) { | 193 if (base.is(rsp) || base.is(r12)) { |
| 187 // SIB byte is needed to encode (rsp + offset) or (r12 + offset). | 194 // SIB byte is needed to encode (rsp + offset) or (r12 + offset). |
| 188 set_sib(times_1, rsp, base); | 195 set_sib(times_1, rsp, base); |
| 189 } | 196 } |
| 190 | 197 |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 last_pc_ = pc_; | 1071 last_pc_ = pc_; |
| 1065 // Opcode FF/4 r64 | 1072 // Opcode FF/4 r64 |
| 1066 if (target.high_bit()) { | 1073 if (target.high_bit()) { |
| 1067 emit_rex_64(target); | 1074 emit_rex_64(target); |
| 1068 } | 1075 } |
| 1069 emit(0xFF); | 1076 emit(0xFF); |
| 1070 emit_modrm(0x4, target); | 1077 emit_modrm(0x4, target); |
| 1071 } | 1078 } |
| 1072 | 1079 |
| 1073 | 1080 |
| 1081 void Assembler::jmp(const Operand& src) { |
| 1082 EnsureSpace ensure_space(this); |
| 1083 last_pc_ = pc_; |
| 1084 // Opcode FF/4 m64 |
| 1085 emit_optional_rex_32(src); |
| 1086 emit(0xFF); |
| 1087 emit_operand(0x4, src); |
| 1088 } |
| 1089 |
| 1090 |
| 1074 void Assembler::lea(Register dst, const Operand& src) { | 1091 void Assembler::lea(Register dst, const Operand& src) { |
| 1075 EnsureSpace ensure_space(this); | 1092 EnsureSpace ensure_space(this); |
| 1076 last_pc_ = pc_; | 1093 last_pc_ = pc_; |
| 1077 emit_rex_64(dst, src); | 1094 emit_rex_64(dst, src); |
| 1078 emit(0x8D); | 1095 emit(0x8D); |
| 1079 emit_operand(dst, src); | 1096 emit_operand(dst, src); |
| 1080 } | 1097 } |
| 1081 | 1098 |
| 1082 | 1099 |
| 1083 void Assembler::load_rax(void* value, RelocInfo::Mode mode) { | 1100 void Assembler::load_rax(void* value, RelocInfo::Mode mode) { |
| (...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2331 RecordRelocInfo(RelocInfo::POSITION, current_position_); | 2348 RecordRelocInfo(RelocInfo::POSITION, current_position_); |
| 2332 written_position_ = current_position_; | 2349 written_position_ = current_position_; |
| 2333 } | 2350 } |
| 2334 } | 2351 } |
| 2335 | 2352 |
| 2336 | 2353 |
| 2337 const int RelocInfo::kApplyMask = 1 << RelocInfo::INTERNAL_REFERENCE; | 2354 const int RelocInfo::kApplyMask = 1 << RelocInfo::INTERNAL_REFERENCE; |
| 2338 | 2355 |
| 2339 | 2356 |
| 2340 } } // namespace v8::internal | 2357 } } // namespace v8::internal |
| OLD | NEW |