OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 | 52 |
53 // We do not support thumb inter-working with an arm architecture not supporting | 53 // We do not support thumb inter-working with an arm architecture not supporting |
54 // the blx instruction (below v5t). If you know what CPU you are compiling for | 54 // the blx instruction (below v5t). If you know what CPU you are compiling for |
55 // you can use -march=armv7 or similar. | 55 // you can use -march=armv7 or similar. |
56 #if defined(USE_THUMB_INTERWORK) && !defined(CAN_USE_THUMB_INSTRUCTIONS) | 56 #if defined(USE_THUMB_INTERWORK) && !defined(CAN_USE_THUMB_INSTRUCTIONS) |
57 # error "For thumb inter-working we require an architecture which supports blx" | 57 # error "For thumb inter-working we require an architecture which supports blx" |
58 #endif | 58 #endif |
59 | 59 |
60 | 60 |
61 // Using blx may yield better code, so use it when required or when available | |
62 #if defined(USE_THUMB_INTERWORK) || defined(CAN_USE_ARMV5_INSTRUCTIONS) | |
63 #define USE_BLX 1 | |
64 #endif | |
65 | |
66 // Using bx does not yield better code, so use it only when required | 61 // Using bx does not yield better code, so use it only when required |
67 #if defined(USE_THUMB_INTERWORK) | 62 #if defined(USE_THUMB_INTERWORK) |
68 #define USE_BX 1 | 63 #define USE_BX 1 |
69 #endif | 64 #endif |
70 | 65 |
71 | 66 |
72 void MacroAssembler::Jump(Register target, Condition cond) { | 67 void MacroAssembler::Jump(Register target, Condition cond) { |
73 #if USE_BX | 68 #if USE_BX |
74 bx(target, cond); | 69 bx(target, cond); |
75 #else | 70 #else |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 #else | 105 #else |
111 // set lr for return at current pc + 8 | 106 // set lr for return at current pc + 8 |
112 mov(lr, Operand(pc), LeaveCC, cond); | 107 mov(lr, Operand(pc), LeaveCC, cond); |
113 mov(pc, Operand(target), LeaveCC, cond); | 108 mov(pc, Operand(target), LeaveCC, cond); |
114 #endif | 109 #endif |
115 } | 110 } |
116 | 111 |
117 | 112 |
118 void MacroAssembler::Call(intptr_t target, RelocInfo::Mode rmode, | 113 void MacroAssembler::Call(intptr_t target, RelocInfo::Mode rmode, |
119 Condition cond) { | 114 Condition cond) { |
| 115 #if USE_BLX |
| 116 // On ARMv5 and after the recommended call sequence is: |
| 117 // ldr ip, [pc, #...] |
| 118 // blx ip |
| 119 |
| 120 // The two instructions (ldr and blx) could be separated by a literal |
| 121 // pool and the code would still work. The issue comes from the |
| 122 // patching code which expect the ldr to be just above the blx. |
| 123 BlockConstPoolFor(2); |
| 124 // Statement positions are expected to be recorded when the target |
| 125 // address is loaded. The mov method will automatically record |
| 126 // positions when pc is the target, since this is not the case here |
| 127 // we have to do it explicitly. |
| 128 WriteRecordedPositions(); |
| 129 |
| 130 mov(ip, Operand(target, rmode), LeaveCC, cond); |
| 131 blx(ip, cond); |
| 132 |
| 133 ASSERT(kCallTargetAddressOffset == 2 * kInstrSize); |
| 134 #else |
120 // Set lr for return at current pc + 8. | 135 // Set lr for return at current pc + 8. |
121 mov(lr, Operand(pc), LeaveCC, cond); | 136 mov(lr, Operand(pc), LeaveCC, cond); |
122 // Emit a ldr<cond> pc, [pc + offset of target in constant pool]. | 137 // Emit a ldr<cond> pc, [pc + offset of target in constant pool]. |
123 mov(pc, Operand(target, rmode), LeaveCC, cond); | 138 mov(pc, Operand(target, rmode), LeaveCC, cond); |
124 // If USE_BLX is defined, we could emit a 'mov ip, target', followed by a | 139 |
125 // 'blx ip'; however, the code would not be shorter than the above sequence | |
126 // and the target address of the call would be referenced by the first | |
127 // instruction rather than the second one, which would make it harder to patch | |
128 // (two instructions before the return address, instead of one). | |
129 ASSERT(kCallTargetAddressOffset == kInstrSize); | 140 ASSERT(kCallTargetAddressOffset == kInstrSize); |
| 141 #endif |
130 } | 142 } |
131 | 143 |
132 | 144 |
133 void MacroAssembler::Call(byte* target, RelocInfo::Mode rmode, | 145 void MacroAssembler::Call(byte* target, RelocInfo::Mode rmode, |
134 Condition cond) { | 146 Condition cond) { |
135 ASSERT(!RelocInfo::IsCodeTarget(rmode)); | 147 ASSERT(!RelocInfo::IsCodeTarget(rmode)); |
136 Call(reinterpret_cast<intptr_t>(target), rmode, cond); | 148 Call(reinterpret_cast<intptr_t>(target), rmode, cond); |
137 } | 149 } |
138 | 150 |
139 | 151 |
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 } | 1513 } |
1502 | 1514 |
1503 | 1515 |
1504 void CodePatcher::Emit(Address addr) { | 1516 void CodePatcher::Emit(Address addr) { |
1505 masm()->emit(reinterpret_cast<Instr>(addr)); | 1517 masm()->emit(reinterpret_cast<Instr>(addr)); |
1506 } | 1518 } |
1507 #endif // ENABLE_DEBUGGER_SUPPORT | 1519 #endif // ENABLE_DEBUGGER_SUPPORT |
1508 | 1520 |
1509 | 1521 |
1510 } } // namespace v8::internal | 1522 } } // namespace v8::internal |
OLD | NEW |