| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 // code object moves. | 180 // code object moves. |
| 181 return (1 << rmode_) & kApplyMask; | 181 return (1 << rmode_) & kApplyMask; |
| 182 } | 182 } |
| 183 | 183 |
| 184 | 184 |
| 185 bool RelocInfo::IsInConstantPool() { | 185 bool RelocInfo::IsInConstantPool() { |
| 186 return false; | 186 return false; |
| 187 } | 187 } |
| 188 | 188 |
| 189 | 189 |
| 190 // Patch the code at the current PC with a call to the target address. | |
| 191 // Additional guard int3 instructions can be added if required. | |
| 192 void RelocInfo::PatchCodeWithCall(Address target, int guard_bytes) { | |
| 193 // Call instruction takes up 5 bytes and int3 takes up one byte. | |
| 194 static const int kCallCodeSize = 5; | |
| 195 int code_size = kCallCodeSize + guard_bytes; | |
| 196 | |
| 197 // Create a code patcher. | |
| 198 CodePatcher patcher(pc_, code_size); | |
| 199 | |
| 200 // Add a label for checking the size of the code used for returning. | |
| 201 #ifdef DEBUG | |
| 202 Label check_codesize; | |
| 203 patcher.masm()->bind(&check_codesize); | |
| 204 #endif | |
| 205 | |
| 206 // Patch the code. | |
| 207 patcher.masm()->call(target, RelocInfo::NONE32); | |
| 208 | |
| 209 // Check that the size of the code generated is as expected. | |
| 210 DCHECK_EQ(kCallCodeSize, | |
| 211 patcher.masm()->SizeOfCodeGeneratedSince(&check_codesize)); | |
| 212 | |
| 213 // Add the requested number of int3 instructions after the call. | |
| 214 DCHECK_GE(guard_bytes, 0); | |
| 215 for (int i = 0; i < guard_bytes; i++) { | |
| 216 patcher.masm()->int3(); | |
| 217 } | |
| 218 } | |
| 219 | |
| 220 | |
| 221 // ----------------------------------------------------------------------------- | 190 // ----------------------------------------------------------------------------- |
| 222 // Implementation of Operand | 191 // Implementation of Operand |
| 223 | 192 |
| 224 Operand::Operand(Register base, int32_t disp, RelocInfo::Mode rmode) { | 193 Operand::Operand(Register base, int32_t disp, RelocInfo::Mode rmode) { |
| 225 // [base + disp/r] | 194 // [base + disp/r] |
| 226 if (disp == 0 && RelocInfo::IsNone(rmode) && !base.is(ebp)) { | 195 if (disp == 0 && RelocInfo::IsNone(rmode) && !base.is(ebp)) { |
| 227 // [base] | 196 // [base] |
| 228 set_modrm(0, base); | 197 set_modrm(0, base); |
| 229 if (base.is(esp)) set_sib(times_1, esp, base); | 198 if (base.is(esp)) set_sib(times_1, esp, base); |
| 230 } else if (is_int8(disp) && RelocInfo::IsNone(rmode)) { | 199 } else if (is_int8(disp) && RelocInfo::IsNone(rmode)) { |
| (...skipping 2739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2970 fflush(coverage_log); | 2939 fflush(coverage_log); |
| 2971 } | 2940 } |
| 2972 } | 2941 } |
| 2973 | 2942 |
| 2974 #endif | 2943 #endif |
| 2975 | 2944 |
| 2976 } // namespace internal | 2945 } // namespace internal |
| 2977 } // namespace v8 | 2946 } // namespace v8 |
| 2978 | 2947 |
| 2979 #endif // V8_TARGET_ARCH_IA32 | 2948 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |