OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 int MacroAssembler::CallSize(Register target, Condition cond) { | 106 int MacroAssembler::CallSize(Register target, Condition cond) { |
107 #if USE_BLX | 107 #if USE_BLX |
108 return kInstrSize; | 108 return kInstrSize; |
109 #else | 109 #else |
110 return 2 * kInstrSize; | 110 return 2 * kInstrSize; |
111 #endif | 111 #endif |
112 } | 112 } |
113 | 113 |
114 | 114 |
115 void MacroAssembler::Call(Register target, Condition cond) { | 115 void MacroAssembler::Call(Register target, Condition cond) { |
| 116 // Block constant pool for the call instruction sequence. |
| 117 BlockConstPoolScope block_const_pool(this); |
116 #ifdef DEBUG | 118 #ifdef DEBUG |
117 int pre_position = pc_offset(); | 119 int pre_position = pc_offset(); |
118 #endif | 120 #endif |
119 | 121 |
120 #if USE_BLX | 122 #if USE_BLX |
121 blx(target, cond); | 123 blx(target, cond); |
122 #else | 124 #else |
123 // set lr for return at current pc + 8 | 125 // set lr for return at current pc + 8 |
124 { BlockConstPoolScope block_const_pool(this); | 126 mov(lr, Operand(pc), LeaveCC, cond); |
125 mov(lr, Operand(pc), LeaveCC, cond); | 127 mov(pc, Operand(target), LeaveCC, cond); |
126 mov(pc, Operand(target), LeaveCC, cond); | |
127 } | |
128 #endif | 128 #endif |
129 | 129 |
130 #ifdef DEBUG | 130 #ifdef DEBUG |
131 int post_position = pc_offset(); | 131 int post_position = pc_offset(); |
132 CHECK_EQ(pre_position + CallSize(target, cond), post_position); | 132 CHECK_EQ(pre_position + CallSize(target, cond), post_position); |
133 #endif | 133 #endif |
134 } | 134 } |
135 | 135 |
136 | 136 |
137 int MacroAssembler::CallSize( | 137 int MacroAssembler::CallSize( |
138 intptr_t target, RelocInfo::Mode rmode, Condition cond) { | 138 intptr_t target, RelocInfo::Mode rmode, Condition cond) { |
139 int size = 2 * kInstrSize; | 139 int size = 2 * kInstrSize; |
140 Instr mov_instr = cond | MOV | LeaveCC; | 140 Instr mov_instr = cond | MOV | LeaveCC; |
141 if (!Operand(target, rmode).is_single_instruction(mov_instr)) { | 141 if (!Operand(target, rmode).is_single_instruction(mov_instr)) { |
142 size += kInstrSize; | 142 size += kInstrSize; |
143 } | 143 } |
144 return size; | 144 return size; |
145 } | 145 } |
146 | 146 |
147 | 147 |
148 void MacroAssembler::Call( | 148 void MacroAssembler::Call( |
149 intptr_t target, RelocInfo::Mode rmode, Condition cond) { | 149 intptr_t target, RelocInfo::Mode rmode, Condition cond) { |
| 150 // Block constant pool for the call instruction sequence. |
| 151 BlockConstPoolScope block_const_pool(this); |
150 #ifdef DEBUG | 152 #ifdef DEBUG |
151 int pre_position = pc_offset(); | 153 int pre_position = pc_offset(); |
152 #endif | 154 #endif |
153 | 155 |
154 #if USE_BLX | 156 #if USE_BLX |
155 // On ARMv5 and after the recommended call sequence is: | 157 // On ARMv5 and after the recommended call sequence is: |
156 // ldr ip, [pc, #...] | 158 // ldr ip, [pc, #...] |
157 // blx ip | 159 // blx ip |
158 | 160 |
159 // The two instructions (ldr and blx) could be separated by a constant | 161 // Statement positions are expected to be recorded when the target |
160 // pool and the code would still work. The issue comes from the | 162 // address is loaded. The mov method will automatically record |
161 // patching code which expect the ldr to be just above the blx. | 163 // positions when pc is the target, since this is not the case here |
162 { BlockConstPoolScope block_const_pool(this); | 164 // we have to do it explicitly. |
163 // Statement positions are expected to be recorded when the target | 165 positions_recorder()->WriteRecordedPositions(); |
164 // address is loaded. The mov method will automatically record | |
165 // positions when pc is the target, since this is not the case here | |
166 // we have to do it explicitly. | |
167 positions_recorder()->WriteRecordedPositions(); | |
168 | 166 |
169 mov(ip, Operand(target, rmode), LeaveCC, cond); | 167 mov(ip, Operand(target, rmode), LeaveCC, cond); |
170 blx(ip, cond); | 168 blx(ip, cond); |
171 } | |
172 | 169 |
173 ASSERT(kCallTargetAddressOffset == 2 * kInstrSize); | 170 ASSERT(kCallTargetAddressOffset == 2 * kInstrSize); |
174 #else | 171 #else |
175 { BlockConstPoolScope block_const_pool(this); | 172 // Set lr for return at current pc + 8. |
176 // Set lr for return at current pc + 8. | 173 mov(lr, Operand(pc), LeaveCC, cond); |
177 mov(lr, Operand(pc), LeaveCC, cond); | 174 // Emit a ldr<cond> pc, [pc + offset of target in constant pool]. |
178 // Emit a ldr<cond> pc, [pc + offset of target in constant pool]. | 175 mov(pc, Operand(target, rmode), LeaveCC, cond); |
179 mov(pc, Operand(target, rmode), LeaveCC, cond); | |
180 } | |
181 ASSERT(kCallTargetAddressOffset == kInstrSize); | 176 ASSERT(kCallTargetAddressOffset == kInstrSize); |
182 #endif | 177 #endif |
183 | 178 |
184 #ifdef DEBUG | 179 #ifdef DEBUG |
185 int post_position = pc_offset(); | 180 int post_position = pc_offset(); |
186 CHECK_EQ(pre_position + CallSize(target, rmode, cond), post_position); | 181 CHECK_EQ(pre_position + CallSize(target, rmode, cond), post_position); |
187 #endif | 182 #endif |
188 } | 183 } |
189 | 184 |
190 | 185 |
(...skipping 2585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2776 void CodePatcher::EmitCondition(Condition cond) { | 2771 void CodePatcher::EmitCondition(Condition cond) { |
2777 Instr instr = Assembler::instr_at(masm_.pc_); | 2772 Instr instr = Assembler::instr_at(masm_.pc_); |
2778 instr = (instr & ~kCondMask) | cond; | 2773 instr = (instr & ~kCondMask) | cond; |
2779 masm_.emit(instr); | 2774 masm_.emit(instr); |
2780 } | 2775 } |
2781 | 2776 |
2782 | 2777 |
2783 } } // namespace v8::internal | 2778 } } // namespace v8::internal |
2784 | 2779 |
2785 #endif // V8_TARGET_ARCH_ARM | 2780 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |