| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // code object moves. | 95 // code object moves. |
| 96 return (1 << rmode_) & kApplyMask; | 96 return (1 << rmode_) & kApplyMask; |
| 97 } | 97 } |
| 98 | 98 |
| 99 | 99 |
| 100 bool RelocInfo::IsInConstantPool() { | 100 bool RelocInfo::IsInConstantPool() { |
| 101 return false; | 101 return false; |
| 102 } | 102 } |
| 103 | 103 |
| 104 | 104 |
| 105 // Patch the code at the current PC with a call to the target address. | |
| 106 // Additional guard int3 instructions can be added if required. | |
| 107 void RelocInfo::PatchCodeWithCall(Address target, int guard_bytes) { | |
| 108 // Call instruction takes up 5 bytes and int3 takes up one byte. | |
| 109 static const int kCallCodeSize = 5; | |
| 110 int code_size = kCallCodeSize + guard_bytes; | |
| 111 | |
| 112 // Create a code patcher. | |
| 113 CodePatcher patcher(pc_, code_size); | |
| 114 | |
| 115 // Add a label for checking the size of the code used for returning. | |
| 116 #ifdef DEBUG | |
| 117 Label check_codesize; | |
| 118 patcher.masm()->bind(&check_codesize); | |
| 119 #endif | |
| 120 | |
| 121 // Patch the code. | |
| 122 patcher.masm()->call(target, RelocInfo::NONE32); | |
| 123 | |
| 124 // Check that the size of the code generated is as expected. | |
| 125 DCHECK_EQ(kCallCodeSize, | |
| 126 patcher.masm()->SizeOfCodeGeneratedSince(&check_codesize)); | |
| 127 | |
| 128 // Add the requested number of int3 instructions after the call. | |
| 129 DCHECK_GE(guard_bytes, 0); | |
| 130 for (int i = 0; i < guard_bytes; i++) { | |
| 131 patcher.masm()->int3(); | |
| 132 } | |
| 133 } | |
| 134 | |
| 135 | |
| 136 // ----------------------------------------------------------------------------- | 105 // ----------------------------------------------------------------------------- |
| 137 // Implementation of Operand | 106 // Implementation of Operand |
| 138 | 107 |
| 139 Operand::Operand(Register base, int32_t disp, RelocInfo::Mode rmode) { | 108 Operand::Operand(Register base, int32_t disp, RelocInfo::Mode rmode) { |
| 140 // [base + disp/r] | 109 // [base + disp/r] |
| 141 if (disp == 0 && RelocInfo::IsNone(rmode) && !base.is(ebp)) { | 110 if (disp == 0 && RelocInfo::IsNone(rmode) && !base.is(ebp)) { |
| 142 // [base] | 111 // [base] |
| 143 set_modrm(0, base); | 112 set_modrm(0, base); |
| 144 if (base.is(esp)) set_sib(times_1, esp, base); | 113 if (base.is(esp)) set_sib(times_1, esp, base); |
| 145 } else if (is_int8(disp) && RelocInfo::IsNone(rmode)) { | 114 } else if (is_int8(disp) && RelocInfo::IsNone(rmode)) { |
| (...skipping 1992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2138 fflush(coverage_log); | 2107 fflush(coverage_log); |
| 2139 } | 2108 } |
| 2140 } | 2109 } |
| 2141 | 2110 |
| 2142 #endif | 2111 #endif |
| 2143 | 2112 |
| 2144 } // namespace internal | 2113 } // namespace internal |
| 2145 } // namespace v8 | 2114 } // namespace v8 |
| 2146 | 2115 |
| 2147 #endif // V8_TARGET_ARCH_X87 | 2116 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |