| 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" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 static const int kCallPatternSize = 3 * Instr::kInstrSize; | 37 static const int kCallPatternSize = 3 * Instr::kInstrSize; |
| 38 uword end_; | 38 uword end_; |
| 39 const ObjectPool& object_pool_; | 39 const ObjectPool& object_pool_; |
| 40 Register reg_; | 40 Register reg_; |
| 41 intptr_t index_; | 41 intptr_t index_; |
| 42 DISALLOW_IMPLICIT_CONSTRUCTORS(PoolPointerCall); | 42 DISALLOW_IMPLICIT_CONSTRUCTORS(PoolPointerCall); |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 | |
| 46 RawCode* CodePatcher::GetStaticCallTargetAt(uword return_address, | 45 RawCode* CodePatcher::GetStaticCallTargetAt(uword return_address, |
| 47 const Code& code) { | 46 const Code& code) { |
| 48 ASSERT(code.ContainsInstructionAt(return_address)); | 47 ASSERT(code.ContainsInstructionAt(return_address)); |
| 49 PoolPointerCall call(return_address, code); | 48 PoolPointerCall call(return_address, code); |
| 50 return call.Target(); | 49 return call.Target(); |
| 51 } | 50 } |
| 52 | 51 |
| 53 | |
| 54 void CodePatcher::PatchStaticCallAt(uword return_address, | 52 void CodePatcher::PatchStaticCallAt(uword return_address, |
| 55 const Code& code, | 53 const Code& code, |
| 56 const Code& new_target) { | 54 const Code& new_target) { |
| 57 PatchPoolPointerCallAt(return_address, code, new_target); | 55 PatchPoolPointerCallAt(return_address, code, new_target); |
| 58 } | 56 } |
| 59 | 57 |
| 60 | |
| 61 void CodePatcher::PatchPoolPointerCallAt(uword return_address, | 58 void CodePatcher::PatchPoolPointerCallAt(uword return_address, |
| 62 const Code& code, | 59 const Code& code, |
| 63 const Code& new_target) { | 60 const Code& new_target) { |
| 64 ASSERT(code.ContainsInstructionAt(return_address)); | 61 ASSERT(code.ContainsInstructionAt(return_address)); |
| 65 PoolPointerCall call(return_address, code); | 62 PoolPointerCall call(return_address, code); |
| 66 call.SetTarget(new_target); | 63 call.SetTarget(new_target); |
| 67 } | 64 } |
| 68 | 65 |
| 69 | |
| 70 void CodePatcher::InsertDeoptimizationCallAt(uword start) { | 66 void CodePatcher::InsertDeoptimizationCallAt(uword start) { |
| 71 UNREACHABLE(); | 67 UNREACHABLE(); |
| 72 } | 68 } |
| 73 | 69 |
| 74 | |
| 75 RawCode* CodePatcher::GetInstanceCallAt(uword return_address, | 70 RawCode* CodePatcher::GetInstanceCallAt(uword return_address, |
| 76 const Code& code, | 71 const Code& code, |
| 77 ICData* ic_data) { | 72 ICData* ic_data) { |
| 78 ASSERT(code.ContainsInstructionAt(return_address)); | 73 ASSERT(code.ContainsInstructionAt(return_address)); |
| 79 CallPattern call(return_address, code); | 74 CallPattern call(return_address, code); |
| 80 if (ic_data != NULL) { | 75 if (ic_data != NULL) { |
| 81 *ic_data = call.IcData(); | 76 *ic_data = call.IcData(); |
| 82 } | 77 } |
| 83 return call.TargetCode(); | 78 return call.TargetCode(); |
| 84 } | 79 } |
| 85 | 80 |
| 86 | |
| 87 intptr_t CodePatcher::InstanceCallSizeInBytes() { | 81 intptr_t CodePatcher::InstanceCallSizeInBytes() { |
| 88 // The instance call instruction sequence has a variable size on ARM64. | 82 // The instance call instruction sequence has a variable size on ARM64. |
| 89 UNREACHABLE(); | 83 UNREACHABLE(); |
| 90 return 0; | 84 return 0; |
| 91 } | 85 } |
| 92 | 86 |
| 93 | |
| 94 RawFunction* CodePatcher::GetUnoptimizedStaticCallAt(uword return_address, | 87 RawFunction* CodePatcher::GetUnoptimizedStaticCallAt(uword return_address, |
| 95 const Code& code, | 88 const Code& code, |
| 96 ICData* ic_data_result) { | 89 ICData* ic_data_result) { |
| 97 ASSERT(code.ContainsInstructionAt(return_address)); | 90 ASSERT(code.ContainsInstructionAt(return_address)); |
| 98 CallPattern static_call(return_address, code); | 91 CallPattern static_call(return_address, code); |
| 99 ICData& ic_data = ICData::Handle(); | 92 ICData& ic_data = ICData::Handle(); |
| 100 ic_data ^= static_call.IcData(); | 93 ic_data ^= static_call.IcData(); |
| 101 if (ic_data_result != NULL) { | 94 if (ic_data_result != NULL) { |
| 102 *ic_data_result = ic_data.raw(); | 95 *ic_data_result = ic_data.raw(); |
| 103 } | 96 } |
| 104 return ic_data.GetTargetAt(0); | 97 return ic_data.GetTargetAt(0); |
| 105 } | 98 } |
| 106 | 99 |
| 107 | |
| 108 void CodePatcher::PatchSwitchableCallAt(uword return_address, | 100 void CodePatcher::PatchSwitchableCallAt(uword return_address, |
| 109 const Code& caller_code, | 101 const Code& caller_code, |
| 110 const Object& data, | 102 const Object& data, |
| 111 const Code& target) { | 103 const Code& target) { |
| 112 ASSERT(caller_code.ContainsInstructionAt(return_address)); | 104 ASSERT(caller_code.ContainsInstructionAt(return_address)); |
| 113 SwitchableCallPattern call(return_address, caller_code); | 105 SwitchableCallPattern call(return_address, caller_code); |
| 114 call.SetData(data); | 106 call.SetData(data); |
| 115 call.SetTarget(target); | 107 call.SetTarget(target); |
| 116 } | 108 } |
| 117 | 109 |
| 118 | |
| 119 RawCode* CodePatcher::GetSwitchableCallTargetAt(uword return_address, | 110 RawCode* CodePatcher::GetSwitchableCallTargetAt(uword return_address, |
| 120 const Code& caller_code) { | 111 const Code& caller_code) { |
| 121 ASSERT(caller_code.ContainsInstructionAt(return_address)); | 112 ASSERT(caller_code.ContainsInstructionAt(return_address)); |
| 122 SwitchableCallPattern call(return_address, caller_code); | 113 SwitchableCallPattern call(return_address, caller_code); |
| 123 return call.target(); | 114 return call.target(); |
| 124 } | 115 } |
| 125 | 116 |
| 126 | |
| 127 RawObject* CodePatcher::GetSwitchableCallDataAt(uword return_address, | 117 RawObject* CodePatcher::GetSwitchableCallDataAt(uword return_address, |
| 128 const Code& caller_code) { | 118 const Code& caller_code) { |
| 129 ASSERT(caller_code.ContainsInstructionAt(return_address)); | 119 ASSERT(caller_code.ContainsInstructionAt(return_address)); |
| 130 SwitchableCallPattern call(return_address, caller_code); | 120 SwitchableCallPattern call(return_address, caller_code); |
| 131 return call.data(); | 121 return call.data(); |
| 132 } | 122 } |
| 133 | 123 |
| 134 | |
| 135 void CodePatcher::PatchNativeCallAt(uword return_address, | 124 void CodePatcher::PatchNativeCallAt(uword return_address, |
| 136 const Code& code, | 125 const Code& code, |
| 137 NativeFunction target, | 126 NativeFunction target, |
| 138 const Code& trampoline) { | 127 const Code& trampoline) { |
| 139 ASSERT(code.ContainsInstructionAt(return_address)); | 128 ASSERT(code.ContainsInstructionAt(return_address)); |
| 140 NativeCallPattern call(return_address, code); | 129 NativeCallPattern call(return_address, code); |
| 141 call.set_target(trampoline); | 130 call.set_target(trampoline); |
| 142 call.set_native_function(target); | 131 call.set_native_function(target); |
| 143 } | 132 } |
| 144 | 133 |
| 145 | |
| 146 RawCode* CodePatcher::GetNativeCallAt(uword return_address, | 134 RawCode* CodePatcher::GetNativeCallAt(uword return_address, |
| 147 const Code& code, | 135 const Code& code, |
| 148 NativeFunction* target) { | 136 NativeFunction* target) { |
| 149 ASSERT(code.ContainsInstructionAt(return_address)); | 137 ASSERT(code.ContainsInstructionAt(return_address)); |
| 150 NativeCallPattern call(return_address, code); | 138 NativeCallPattern call(return_address, code); |
| 151 *target = call.native_function(); | 139 *target = call.native_function(); |
| 152 return call.target(); | 140 return call.target(); |
| 153 } | 141 } |
| 154 | 142 |
| 155 } // namespace dart | 143 } // namespace dart |
| 156 | 144 |
| 157 #endif // defined TARGET_ARCH_ARM64 | 145 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |