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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // ----------------------------------------------------------------------------- | 187 // ----------------------------------------------------------------------------- |
188 // Implementation of RelocInfo | 188 // Implementation of RelocInfo |
189 | 189 |
190 // The modes possibly affected by apply must be in kApplyMask. | 190 // The modes possibly affected by apply must be in kApplyMask. |
191 void RelocInfo::apply(intptr_t delta) { | 191 void RelocInfo::apply(intptr_t delta) { |
192 if (IsInternalReference(rmode_)) { | 192 if (IsInternalReference(rmode_)) { |
193 // absolute code pointer inside code object moves with the code object. | 193 // absolute code pointer inside code object moves with the code object. |
194 Memory::Address_at(pc_) += delta; | 194 Memory::Address_at(pc_) += delta; |
195 } else if (IsCodeTarget(rmode_)) { | 195 } else if (IsCodeTarget(rmode_)) { |
196 Memory::int32_at(pc_) -= delta; | 196 Memory::int32_at(pc_) -= delta; |
197 } else if (rmode_ == JS_RETURN && IsCallInstruction()) { | 197 } else if (rmode_ == JS_RETURN && IsPatchedReturnSequence()) { |
198 // Special handling of js_return when a break point is set (call | 198 // Special handling of js_return when a break point is set (call |
199 // instruction has been inserted). | 199 // instruction has been inserted). |
200 Memory::int32_at(pc_ + 1) -= delta; // relocate entry | 200 Memory::int32_at(pc_ + 1) -= delta; // relocate entry |
201 } | 201 } |
202 } | 202 } |
203 | 203 |
204 | 204 |
205 Address RelocInfo::target_address() { | 205 Address RelocInfo::target_address() { |
206 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); | 206 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); |
207 if (IsCodeTarget(rmode_)) { | 207 if (IsCodeTarget(rmode_)) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 return reinterpret_cast<Address*>(pc_); | 255 return reinterpret_cast<Address*>(pc_); |
256 } | 256 } |
257 | 257 |
258 | 258 |
259 void RelocInfo::set_target_object(Object* target) { | 259 void RelocInfo::set_target_object(Object* target) { |
260 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); | 260 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
261 *reinterpret_cast<Object**>(pc_) = target; | 261 *reinterpret_cast<Object**>(pc_) = target; |
262 } | 262 } |
263 | 263 |
264 | 264 |
265 bool RelocInfo::IsCallInstruction() { | 265 bool RelocInfo::IsPatchedReturnSequence() { |
266 // The recognized call sequence is: | 266 // The recognized call sequence is: |
267 // movq(kScratchRegister, immediate64); call(kScratchRegister); | 267 // movq(kScratchRegister, immediate64); call(kScratchRegister); |
268 // It only needs to be distinguished from a return sequence | 268 // It only needs to be distinguished from a return sequence |
269 // movq(rsp, rbp); pop(rbp); ret(n); int3 *6 | 269 // movq(rsp, rbp); pop(rbp); ret(n); int3 *6 |
270 // The 11th byte is int3 (0xCC) in the return sequence and | 270 // The 11th byte is int3 (0xCC) in the return sequence and |
271 // REX.WB (0x48+register bit) for the call sequence. | 271 // REX.WB (0x48+register bit) for the call sequence. |
| 272 #ifdef ENABLE_DEBUGGER_SUPPORT |
272 return pc_[10] != 0xCC; | 273 return pc_[10] != 0xCC; |
| 274 #else |
| 275 return false; |
| 276 #endif |
273 } | 277 } |
274 | 278 |
275 | 279 |
276 Address RelocInfo::call_address() { | 280 Address RelocInfo::call_address() { |
277 ASSERT(IsCallInstruction()); | 281 ASSERT(IsPatchedReturnSequence()); |
278 return Memory::Address_at( | 282 return Memory::Address_at( |
279 pc_ + Assembler::kRealPatchReturnSequenceAddressOffset); | 283 pc_ + Assembler::kRealPatchReturnSequenceAddressOffset); |
280 } | 284 } |
281 | 285 |
282 | 286 |
283 void RelocInfo::set_call_address(Address target) { | 287 void RelocInfo::set_call_address(Address target) { |
284 ASSERT(IsCallInstruction()); | 288 ASSERT(IsPatchedReturnSequence()); |
285 Memory::Address_at(pc_ + Assembler::kRealPatchReturnSequenceAddressOffset) = | 289 Memory::Address_at(pc_ + Assembler::kRealPatchReturnSequenceAddressOffset) = |
286 target; | 290 target; |
287 } | 291 } |
288 | 292 |
289 | 293 |
290 Object* RelocInfo::call_object() { | 294 Object* RelocInfo::call_object() { |
291 ASSERT(IsCallInstruction()); | 295 ASSERT(IsPatchedReturnSequence()); |
292 return *call_object_address(); | 296 return *call_object_address(); |
293 } | 297 } |
294 | 298 |
295 | 299 |
296 void RelocInfo::set_call_object(Object* target) { | 300 void RelocInfo::set_call_object(Object* target) { |
297 ASSERT(IsCallInstruction()); | 301 ASSERT(IsPatchedReturnSequence()); |
298 *call_object_address() = target; | 302 *call_object_address() = target; |
299 } | 303 } |
300 | 304 |
301 | 305 |
302 Object** RelocInfo::call_object_address() { | 306 Object** RelocInfo::call_object_address() { |
303 ASSERT(IsCallInstruction()); | 307 ASSERT(IsPatchedReturnSequence()); |
304 return reinterpret_cast<Object**>( | 308 return reinterpret_cast<Object**>( |
305 pc_ + Assembler::kPatchReturnSequenceAddressOffset); | 309 pc_ + Assembler::kPatchReturnSequenceAddressOffset); |
306 } | 310 } |
307 | 311 |
308 // ----------------------------------------------------------------------------- | 312 // ----------------------------------------------------------------------------- |
309 // Implementation of Operand | 313 // Implementation of Operand |
310 | 314 |
311 void Operand::set_modrm(int mod, Register rm_reg) { | 315 void Operand::set_modrm(int mod, Register rm_reg) { |
312 ASSERT(is_uint2(mod)); | 316 ASSERT(is_uint2(mod)); |
313 buf_[0] = mod << 6 | rm_reg.low_bits(); | 317 buf_[0] = mod << 6 | rm_reg.low_bits(); |
(...skipping 25 matching lines...) Expand all Loading... |
339 ASSERT(len_ == 1 || len_ == 2); | 343 ASSERT(len_ == 1 || len_ == 2); |
340 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); | 344 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); |
341 *p = disp; | 345 *p = disp; |
342 len_ += sizeof(int32_t); | 346 len_ += sizeof(int32_t); |
343 } | 347 } |
344 | 348 |
345 | 349 |
346 } } // namespace v8::internal | 350 } } // namespace v8::internal |
347 | 351 |
348 #endif // V8_X64_ASSEMBLER_X64_INL_H_ | 352 #endif // V8_X64_ASSEMBLER_X64_INL_H_ |
OLD | NEW |