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 17 matching lines...) Expand all Loading... |
28 #ifndef V8_X64_ASSEMBLER_X64_INL_H_ | 28 #ifndef V8_X64_ASSEMBLER_X64_INL_H_ |
29 #define V8_X64_ASSEMBLER_X64_INL_H_ | 29 #define V8_X64_ASSEMBLER_X64_INL_H_ |
30 | 30 |
31 namespace v8 { namespace internal { | 31 namespace v8 { namespace internal { |
32 | 32 |
33 Condition NegateCondition(Condition cc) { | 33 Condition NegateCondition(Condition cc) { |
34 return static_cast<Condition>(cc ^ 1); | 34 return static_cast<Condition>(cc ^ 1); |
35 } | 35 } |
36 | 36 |
37 | 37 |
| 38 // The modes possibly affected by apply must be in kApplyMask. |
| 39 void RelocInfo::apply(int delta) { |
| 40 if (rmode_ == RUNTIME_ENTRY || IsCodeTarget(rmode_)) { |
| 41 intptr_t* p = reinterpret_cast<intptr_t*>(pc_); |
| 42 *p -= delta; // relocate entry |
| 43 } else if (rmode_ == JS_RETURN && IsCallInstruction()) { |
| 44 // Special handling of js_return when a break point is set (call |
| 45 // instruction has been inserted). |
| 46 intptr_t* p = reinterpret_cast<intptr_t*>(pc_ + 1); |
| 47 *p -= delta; // relocate entry |
| 48 } else if (IsInternalReference(rmode_)) { |
| 49 // absolute code pointer inside code object moves with the code object. |
| 50 intptr_t* p = reinterpret_cast<intptr_t*>(pc_); |
| 51 *p += delta; // relocate entry |
| 52 } |
| 53 } |
| 54 |
| 55 |
38 Address RelocInfo::target_address() { | 56 Address RelocInfo::target_address() { |
39 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); | 57 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); |
40 return Assembler::target_address_at(pc_); | 58 return Assembler::target_address_at(pc_); |
41 } | 59 } |
42 | 60 |
43 | 61 |
44 Address RelocInfo::target_address_address() { | 62 Address RelocInfo::target_address_address() { |
45 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); | 63 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); |
46 return reinterpret_cast<Address>(pc_); | 64 return reinterpret_cast<Address>(pc_); |
47 } | 65 } |
48 | 66 |
49 | 67 |
50 void RelocInfo::set_target_address(Address target) { | 68 void RelocInfo::set_target_address(Address target) { |
51 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); | 69 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); |
52 Assembler::set_target_address_at(pc_, target); | 70 Assembler::set_target_address_at(pc_, target); |
53 } | 71 } |
54 | 72 |
55 | 73 |
56 void Assembler::set_target_address_at(byte* location, byte* value) { | 74 void Assembler::set_target_address_at(byte* location, byte* value) { |
57 UNIMPLEMENTED(); | 75 UNIMPLEMENTED(); |
58 } | 76 } |
59 | 77 |
60 | 78 |
61 byte* Assembler::target_address_at(byte* location) { | 79 byte* Assembler::target_address_at(byte* location) { |
62 UNIMPLEMENTED(); | 80 UNIMPLEMENTED(); |
63 return NULL; | 81 return NULL; |
64 } | 82 } |
65 | 83 |
| 84 |
| 85 Object* RelocInfo::target_object() { |
| 86 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| 87 return *reinterpret_cast<Object**>(pc_); |
| 88 } |
| 89 |
| 90 |
| 91 Object** RelocInfo::target_object_address() { |
| 92 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| 93 return reinterpret_cast<Object**>(pc_); |
| 94 } |
| 95 |
| 96 |
| 97 Address* RelocInfo::target_reference_address() { |
| 98 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); |
| 99 return reinterpret_cast<Address*>(pc_); |
| 100 } |
| 101 |
| 102 |
| 103 void RelocInfo::set_target_object(Object* target) { |
| 104 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); |
| 105 *reinterpret_cast<Object**>(pc_) = target; |
| 106 } |
| 107 |
| 108 |
| 109 bool RelocInfo::IsCallInstruction() { |
| 110 UNIMPLEMENTED(); // IA32 code below. |
| 111 return *pc_ == 0xE8; |
| 112 } |
| 113 |
| 114 |
| 115 Address RelocInfo::call_address() { |
| 116 UNIMPLEMENTED(); // IA32 code below. |
| 117 ASSERT(IsCallInstruction()); |
| 118 return Assembler::target_address_at(pc_ + 1); |
| 119 } |
| 120 |
| 121 |
| 122 void RelocInfo::set_call_address(Address target) { |
| 123 UNIMPLEMENTED(); // IA32 code below. |
| 124 ASSERT(IsCallInstruction()); |
| 125 Assembler::set_target_address_at(pc_ + 1, target); |
| 126 } |
| 127 |
| 128 |
| 129 Object* RelocInfo::call_object() { |
| 130 UNIMPLEMENTED(); // IA32 code below. |
| 131 ASSERT(IsCallInstruction()); |
| 132 return *call_object_address(); |
| 133 } |
| 134 |
| 135 |
| 136 void RelocInfo::set_call_object(Object* target) { |
| 137 UNIMPLEMENTED(); // IA32 code below. |
| 138 ASSERT(IsCallInstruction()); |
| 139 *call_object_address() = target; |
| 140 } |
| 141 |
| 142 |
| 143 Object** RelocInfo::call_object_address() { |
| 144 UNIMPLEMENTED(); // IA32 code below. |
| 145 ASSERT(IsCallInstruction()); |
| 146 return reinterpret_cast<Object**>(pc_ + 1); |
| 147 } |
| 148 |
66 } } // namespace v8::internal | 149 } } // namespace v8::internal |
67 | 150 |
68 #endif // V8_X64_ASSEMBLER_X64_INL_H_ | 151 #endif // V8_X64_ASSEMBLER_X64_INL_H_ |
OLD | NEW |