| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
| 6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/constants_arm.h" | 9 #include "vm/constants_arm.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 Register reg; | 59 Register reg; |
| 60 uword native_function_load_end = | 60 uword native_function_load_end = |
| 61 InstructionPattern::DecodeLoadWordFromPool(end_ - 2 * Instr::kInstrSize, | 61 InstructionPattern::DecodeLoadWordFromPool(end_ - 2 * Instr::kInstrSize, |
| 62 ®, | 62 ®, |
| 63 &target_code_pool_index_); | 63 &target_code_pool_index_); |
| 64 ASSERT(reg == CODE_REG); | 64 ASSERT(reg == CODE_REG); |
| 65 InstructionPattern::DecodeLoadWordFromPool(native_function_load_end, | 65 InstructionPattern::DecodeLoadWordFromPool(native_function_load_end, |
| 66 ®, | 66 ®, |
| 67 &native_function_pool_index_); | 67 &native_function_pool_index_); |
| 68 ASSERT(reg == R5); | 68 ASSERT(reg == R9); |
| 69 } | 69 } |
| 70 | 70 |
| 71 | 71 |
| 72 RawCode* NativeCallPattern::target() const { | 72 RawCode* NativeCallPattern::target() const { |
| 73 return reinterpret_cast<RawCode*>( | 73 return reinterpret_cast<RawCode*>( |
| 74 object_pool_.ObjectAt(target_code_pool_index_)); | 74 object_pool_.ObjectAt(target_code_pool_index_)); |
| 75 } | 75 } |
| 76 | 76 |
| 77 | 77 |
| 78 void NativeCallPattern::set_target(const Code& new_target) const { | 78 void NativeCallPattern::set_target(const Code& new_target) const { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // sequence is the instruction before the one at end). Returns a pointer to | 173 // sequence is the instruction before the one at end). Returns a pointer to |
| 174 // the first instruction in the sequence. Returns the register being loaded | 174 // the first instruction in the sequence. Returns the register being loaded |
| 175 // and the index in the pool being read from in the output parameters 'reg' | 175 // and the index in the pool being read from in the output parameters 'reg' |
| 176 // and 'index' respectively. | 176 // and 'index' respectively. |
| 177 uword InstructionPattern::DecodeLoadWordFromPool(uword end, | 177 uword InstructionPattern::DecodeLoadWordFromPool(uword end, |
| 178 Register* reg, | 178 Register* reg, |
| 179 intptr_t* index) { | 179 intptr_t* index) { |
| 180 uword start = end - Instr::kInstrSize; | 180 uword start = end - Instr::kInstrSize; |
| 181 int32_t instr = Instr::At(start)->InstructionBits(); | 181 int32_t instr = Instr::At(start)->InstructionBits(); |
| 182 intptr_t offset = 0; | 182 intptr_t offset = 0; |
| 183 if ((instr & 0xffff0000) == 0xe5990000) { // ldr reg, [pp, #+offset] | 183 if ((instr & 0xffff0000) == (0xe5950000 | (PP << 16))) { |
| 184 // ldr reg, [pp, #+offset] |
| 184 offset = instr & 0xfff; | 185 offset = instr & 0xfff; |
| 185 *reg = static_cast<Register>((instr & 0xf000) >> 12); | 186 *reg = static_cast<Register>((instr & 0xf000) >> 12); |
| 186 } else { | 187 } else { |
| 187 ASSERT((instr & 0xfff00000) == 0xe5900000); // ldr reg, [reg, #+offset] | 188 ASSERT((instr & 0xfff00000) == 0xe5900000); // ldr reg, [reg, #+offset] |
| 188 offset = instr & 0xfff; | 189 offset = instr & 0xfff; |
| 189 start -= Instr::kInstrSize; | 190 start -= Instr::kInstrSize; |
| 190 instr = Instr::At(start)->InstructionBits(); | 191 instr = Instr::At(start)->InstructionBits(); |
| 191 if ((instr & 0xffff0000) == 0xe2890000) { // add reg, pp, operand | 192 if ((instr & 0xffff0000) == (0xe2850000 | (PP << 16))) { |
| 193 // add reg, pp, operand |
| 192 const intptr_t rot = (instr & 0xf00) >> 7; | 194 const intptr_t rot = (instr & 0xf00) >> 7; |
| 193 const intptr_t imm8 = instr & 0xff; | 195 const intptr_t imm8 = instr & 0xff; |
| 194 offset += (imm8 >> rot) | (imm8 << (32 - rot)); | 196 offset += (imm8 >> rot) | (imm8 << (32 - rot)); |
| 195 *reg = static_cast<Register>((instr & 0xf000) >> 12); | 197 *reg = static_cast<Register>((instr & 0xf000) >> 12); |
| 196 } else { | 198 } else { |
| 197 ASSERT((instr & 0xffff0000) == 0xe0890000); // add reg, pp, reg | 199 ASSERT((instr & 0xffff0000) == (0xe0800000 | (PP << 16))); |
| 200 // add reg, pp, reg |
| 198 end = DecodeLoadWordImmediate(end, reg, &offset); | 201 end = DecodeLoadWordImmediate(end, reg, &offset); |
| 199 } | 202 } |
| 200 } | 203 } |
| 201 *index = ObjectPool::IndexFromOffset(offset); | 204 *index = ObjectPool::IndexFromOffset(offset); |
| 202 return start; | 205 return start; |
| 203 } | 206 } |
| 204 | 207 |
| 205 | 208 |
| 206 RawICData* CallPattern::IcData() { | 209 RawICData* CallPattern::IcData() { |
| 207 if (ic_data_.IsNull()) { | 210 if (ic_data_.IsNull()) { |
| 208 Register reg; | 211 Register reg; |
| 209 InstructionPattern::DecodeLoadObject(ic_data_load_end_, | 212 InstructionPattern::DecodeLoadObject(ic_data_load_end_, |
| 210 object_pool_, | 213 object_pool_, |
| 211 ®, | 214 ®, |
| 212 &ic_data_); | 215 &ic_data_); |
| 213 ASSERT(reg == R5); | 216 ASSERT(reg == R9); |
| 214 } | 217 } |
| 215 return ic_data_.raw(); | 218 return ic_data_.raw(); |
| 216 } | 219 } |
| 217 | 220 |
| 218 | 221 |
| 219 RawCode* CallPattern::TargetCode() const { | 222 RawCode* CallPattern::TargetCode() const { |
| 220 return reinterpret_cast<RawCode*>( | 223 return reinterpret_cast<RawCode*>( |
| 221 object_pool_.ObjectAt(target_code_pool_index_)); | 224 object_pool_.ObjectAt(target_code_pool_index_)); |
| 222 } | 225 } |
| 223 | 226 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 } else { | 292 } else { |
| 290 ASSERT(version == ARMv7); | 293 ASSERT(version == ARMv7); |
| 291 return bx_lr->InstructionBits() == instruction; | 294 return bx_lr->InstructionBits() == instruction; |
| 292 } | 295 } |
| 293 return false; | 296 return false; |
| 294 } | 297 } |
| 295 | 298 |
| 296 } // namespace dart | 299 } // namespace dart |
| 297 | 300 |
| 298 #endif // defined TARGET_ARCH_ARM | 301 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |