Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/code_patcher.h" | 9 #include "vm/code_patcher.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 uword call_address() const { | 135 uword call_address() const { |
| 136 return start_ + 1 * kInstructionSize; | 136 return start_ + 1 * kInstructionSize; |
| 137 } | 137 } |
| 138 | 138 |
| 139 uword start_; | 139 uword start_; |
| 140 | 140 |
| 141 DISALLOW_IMPLICIT_CONSTRUCTORS(StaticCall); | 141 DISALLOW_IMPLICIT_CONSTRUCTORS(StaticCall); |
| 142 }; | 142 }; |
| 143 | 143 |
| 144 | 144 |
| 145 uword CodePatcher::GetStaticCallTargetAt(uword return_address) { | 145 uword CodePatcher::GetStaticCallTargetAt(uword return_address, |
| 146 const Code& code) { | |
|
srdjan
2013/02/15 21:24:27
Here and below, you could assert that return addre
regis
2013/02/15 22:51:31
LookupCode would be too slow, but I can assert tha
| |
| 146 StaticCall call(return_address); | 147 StaticCall call(return_address); |
| 147 return call.target(); | 148 return call.target(); |
| 148 } | 149 } |
| 149 | 150 |
| 150 | 151 |
| 151 void CodePatcher::PatchStaticCallAt(uword return_address, uword new_target) { | 152 void CodePatcher::PatchStaticCallAt(uword return_address, |
| 153 const Code& code, | |
| 154 uword new_target) { | |
| 152 StaticCall call(return_address); | 155 StaticCall call(return_address); |
| 153 call.set_target(new_target); | 156 call.set_target(new_target); |
| 154 } | 157 } |
| 155 | 158 |
| 156 | 159 |
| 157 void CodePatcher::PatchInstanceCallAt(uword return_address, uword new_target) { | 160 void CodePatcher::PatchInstanceCallAt(uword return_address, |
| 161 const Code& code, | |
| 162 uword new_target) { | |
| 158 InstanceCall call(return_address); | 163 InstanceCall call(return_address); |
| 159 call.set_target(new_target); | 164 call.set_target(new_target); |
| 160 } | 165 } |
| 161 | 166 |
| 162 | 167 |
| 163 | 168 |
| 164 void CodePatcher::InsertCallAt(uword start, uword target) { | 169 void CodePatcher::InsertCallAt(uword start, uword target) { |
| 165 *reinterpret_cast<uint8_t*>(start) = 0xE8; | 170 *reinterpret_cast<uint8_t*>(start) = 0xE8; |
| 166 CallPattern call(start); | 171 CallPattern call(start); |
| 167 call.SetTargetAddress(target); | 172 call.SetTargetAddress(target); |
| 168 CPU::FlushICache(start, CallPattern::InstructionLength()); | 173 CPU::FlushICache(start, CallPattern::InstructionLength()); |
| 169 } | 174 } |
| 170 | 175 |
| 171 | 176 |
| 172 bool CodePatcher::IsDartCall(uword return_address) { | |
| 173 return DartCallPattern::IsValid(return_address); | |
| 174 } | |
| 175 | |
| 176 | |
| 177 uword CodePatcher::GetInstanceCallAt(uword return_address, | 177 uword CodePatcher::GetInstanceCallAt(uword return_address, |
| 178 const Code& code, | |
| 178 ICData* ic_data, | 179 ICData* ic_data, |
| 179 Array* arguments_descriptor) { | 180 Array* arguments_descriptor) { |
| 180 InstanceCall call(return_address); | 181 InstanceCall call(return_address); |
| 181 if (ic_data != NULL) { | 182 if (ic_data != NULL) { |
| 182 *ic_data ^= call.ic_data(); | 183 *ic_data ^= call.ic_data(); |
| 183 } | 184 } |
| 184 if (arguments_descriptor != NULL) { | 185 if (arguments_descriptor != NULL) { |
| 185 *arguments_descriptor ^= call.arguments_descriptor(); | 186 *arguments_descriptor ^= call.arguments_descriptor(); |
| 186 } | 187 } |
| 187 return call.target(); | 188 return call.target(); |
| 188 } | 189 } |
| 189 | 190 |
| 190 | 191 |
| 191 intptr_t CodePatcher::InstanceCallSizeInBytes() { | 192 intptr_t CodePatcher::InstanceCallSizeInBytes() { |
| 192 return DartCallPattern::kNumInstructions * DartCallPattern::kInstructionSize; | 193 return DartCallPattern::kNumInstructions * DartCallPattern::kInstructionSize; |
| 193 } | 194 } |
| 194 | 195 |
| 195 } // namespace dart | 196 } // namespace dart |
| 196 | 197 |
| 197 #endif // defined TARGET_ARCH_IA32 | 198 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |