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 25 matching lines...) Expand all Loading... |
36 const ARMVersion version = TargetCPUFeatures::arm_version(); | 36 const ARMVersion version = TargetCPUFeatures::arm_version(); |
37 if ((version == ARMv5TE) || (version == ARMv6)) { | 37 if ((version == ARMv5TE) || (version == ARMv6)) { |
38 return 5 * Instr::kInstrSize; | 38 return 5 * Instr::kInstrSize; |
39 } else { | 39 } else { |
40 ASSERT(version == ARMv7); | 40 ASSERT(version == ARMv7); |
41 return 3 * Instr::kInstrSize; | 41 return 3 * Instr::kInstrSize; |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
45 | 45 |
| 46 NativeCallPattern::NativeCallPattern(uword pc, const Code& code) |
| 47 : object_pool_(ObjectPool::Handle(code.GetObjectPool())), |
| 48 end_(pc), |
| 49 native_function_pool_index_(-1), |
| 50 target_address_pool_index_(-1) { |
| 51 ASSERT(code.ContainsInstructionAt(pc)); |
| 52 // Last instruction: blx lr. |
| 53 ASSERT(*(reinterpret_cast<uword*>(end_) - 1) == 0xe12fff3e); |
| 54 |
| 55 Register reg; |
| 56 uword native_function_load_end = |
| 57 InstructionPattern::DecodeLoadWordFromPool(end_ - Instr::kInstrSize, |
| 58 ®, |
| 59 &target_address_pool_index_); |
| 60 ASSERT(reg == LR); |
| 61 InstructionPattern::DecodeLoadWordFromPool(native_function_load_end, |
| 62 ®, |
| 63 &native_function_pool_index_); |
| 64 ASSERT(reg == R5); |
| 65 } |
| 66 |
| 67 |
| 68 uword NativeCallPattern::target() const { |
| 69 return object_pool_.RawValueAt(target_address_pool_index_); |
| 70 } |
| 71 |
| 72 |
| 73 void NativeCallPattern::set_target(uword target_address) const { |
| 74 object_pool_.SetRawValueAt(target_address_pool_index_, target_address); |
| 75 // No need to flush the instruction cache, since the code is not modified. |
| 76 } |
| 77 |
| 78 |
| 79 NativeFunction NativeCallPattern::native_function() const { |
| 80 return reinterpret_cast<NativeFunction>( |
| 81 object_pool_.RawValueAt(native_function_pool_index_)); |
| 82 } |
| 83 |
| 84 |
| 85 void NativeCallPattern::set_native_function(NativeFunction func) const { |
| 86 object_pool_.SetRawValueAt(native_function_pool_index_, |
| 87 reinterpret_cast<uword>(func)); |
| 88 } |
| 89 |
| 90 |
46 // Decodes a load sequence ending at 'end' (the last instruction of the load | 91 // Decodes a load sequence ending at 'end' (the last instruction of the load |
47 // sequence is the instruction before the one at end). Returns a pointer to | 92 // sequence is the instruction before the one at end). Returns a pointer to |
48 // the first instruction in the sequence. Returns the register being loaded | 93 // the first instruction in the sequence. Returns the register being loaded |
49 // and the loaded object in the output parameters 'reg' and 'obj' | 94 // and the loaded object in the output parameters 'reg' and 'obj' |
50 // respectively. | 95 // respectively. |
51 uword InstructionPattern::DecodeLoadObject(uword end, | 96 uword InstructionPattern::DecodeLoadObject(uword end, |
52 const ObjectPool& object_pool, | 97 const ObjectPool& object_pool, |
53 Register* reg, | 98 Register* reg, |
54 Object* obj) { | 99 Object* obj) { |
55 uword start = 0; | 100 uword start = 0; |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 } else { | 382 } else { |
338 ASSERT(version == ARMv7); | 383 ASSERT(version == ARMv7); |
339 return bx_lr->InstructionBits() == instruction; | 384 return bx_lr->InstructionBits() == instruction; |
340 } | 385 } |
341 return false; | 386 return false; |
342 } | 387 } |
343 | 388 |
344 } // namespace dart | 389 } // namespace dart |
345 | 390 |
346 #endif // defined TARGET_ARCH_ARM | 391 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |