| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_ARM64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64. |
| 6 #if defined(TARGET_ARCH_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
| 7 | 7 |
| 8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
| 9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/instructions.h" | 10 #include "vm/instructions.h" |
| 11 #include "vm/object.h" | 11 #include "vm/object.h" |
| 12 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 class PoolPointerCall : public ValueObject { | 15 class PoolPointerCall : public ValueObject { |
| 16 public: | 16 public: |
| 17 PoolPointerCall(uword pc, const Code& code) | 17 PoolPointerCall(uword pc, const Code& code) |
| 18 : end_(pc), | 18 : end_(pc), object_pool_(ObjectPool::Handle(code.GetObjectPool())) { |
| 19 object_pool_(ObjectPool::Handle(code.GetObjectPool())) { | |
| 20 // Last instruction: blr ip0. | 19 // Last instruction: blr ip0. |
| 21 ASSERT(*(reinterpret_cast<uint32_t*>(end_) - 1) == 0xd63f0200); | 20 ASSERT(*(reinterpret_cast<uint32_t*>(end_) - 1) == 0xd63f0200); |
| 22 InstructionPattern::DecodeLoadWordFromPool( | 21 InstructionPattern::DecodeLoadWordFromPool(end_ - 2 * Instr::kInstrSize, |
| 23 end_ - 2 * Instr::kInstrSize, ®_, &index_); | 22 ®_, &index_); |
| 24 } | 23 } |
| 25 | 24 |
| 26 intptr_t pp_index() const { | 25 intptr_t pp_index() const { return index_; } |
| 27 return index_; | |
| 28 } | |
| 29 | 26 |
| 30 RawCode* Target() const { | 27 RawCode* Target() const { |
| 31 return reinterpret_cast<RawCode*>(object_pool_.ObjectAt(pp_index())); | 28 return reinterpret_cast<RawCode*>(object_pool_.ObjectAt(pp_index())); |
| 32 } | 29 } |
| 33 | 30 |
| 34 void SetTarget(const Code& target) const { | 31 void SetTarget(const Code& target) const { |
| 35 object_pool_.SetObjectAt(pp_index(), target); | 32 object_pool_.SetObjectAt(pp_index(), target); |
| 36 // No need to flush the instruction cache, since the code is not modified. | 33 // No need to flush the instruction cache, since the code is not modified. |
| 37 } | 34 } |
| 38 | 35 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 84 } |
| 88 | 85 |
| 89 | 86 |
| 90 intptr_t CodePatcher::InstanceCallSizeInBytes() { | 87 intptr_t CodePatcher::InstanceCallSizeInBytes() { |
| 91 // The instance call instruction sequence has a variable size on ARM64. | 88 // The instance call instruction sequence has a variable size on ARM64. |
| 92 UNREACHABLE(); | 89 UNREACHABLE(); |
| 93 return 0; | 90 return 0; |
| 94 } | 91 } |
| 95 | 92 |
| 96 | 93 |
| 97 RawFunction* CodePatcher::GetUnoptimizedStaticCallAt( | 94 RawFunction* CodePatcher::GetUnoptimizedStaticCallAt(uword return_address, |
| 98 uword return_address, const Code& code, ICData* ic_data_result) { | 95 const Code& code, |
| 96 ICData* ic_data_result) { |
| 99 ASSERT(code.ContainsInstructionAt(return_address)); | 97 ASSERT(code.ContainsInstructionAt(return_address)); |
| 100 CallPattern static_call(return_address, code); | 98 CallPattern static_call(return_address, code); |
| 101 ICData& ic_data = ICData::Handle(); | 99 ICData& ic_data = ICData::Handle(); |
| 102 ic_data ^= static_call.IcData(); | 100 ic_data ^= static_call.IcData(); |
| 103 if (ic_data_result != NULL) { | 101 if (ic_data_result != NULL) { |
| 104 *ic_data_result = ic_data.raw(); | 102 *ic_data_result = ic_data.raw(); |
| 105 } | 103 } |
| 106 return ic_data.GetTargetAt(0); | 104 return ic_data.GetTargetAt(0); |
| 107 } | 105 } |
| 108 | 106 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 NativeFunction* target) { | 148 NativeFunction* target) { |
| 151 ASSERT(code.ContainsInstructionAt(return_address)); | 149 ASSERT(code.ContainsInstructionAt(return_address)); |
| 152 NativeCallPattern call(return_address, code); | 150 NativeCallPattern call(return_address, code); |
| 153 *target = call.native_function(); | 151 *target = call.native_function(); |
| 154 return call.target(); | 152 return call.target(); |
| 155 } | 153 } |
| 156 | 154 |
| 157 } // namespace dart | 155 } // namespace dart |
| 158 | 156 |
| 159 #endif // defined TARGET_ARCH_ARM64 | 157 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |