| 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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 } | 207 } |
| 208 return call.target(); | 208 return call.target(); |
| 209 } | 209 } |
| 210 | 210 |
| 211 | 211 |
| 212 intptr_t CodePatcher::InstanceCallSizeInBytes() { | 212 intptr_t CodePatcher::InstanceCallSizeInBytes() { |
| 213 return InstanceCall::kCallPatternSize; | 213 return InstanceCall::kCallPatternSize; |
| 214 } | 214 } |
| 215 | 215 |
| 216 | 216 |
| 217 RawFunction* CodePatcher::GetUnoptimizedStaticCallTargetAt( | |
| 218 uword return_address, const Code& code) { | |
| 219 ASSERT(code.ContainsInstructionAt(return_address)); | |
| 220 UnoptimizedStaticCall static_call(return_address); | |
| 221 ICData& ic_data = ICData::Handle(); | |
| 222 ic_data ^= static_call.ic_data(); | |
| 223 return ic_data.GetTargetAt(0); | |
| 224 } | |
| 225 | |
| 226 | |
| 227 void CodePatcher::InsertCallAt(uword start, uword target) { | 217 void CodePatcher::InsertCallAt(uword start, uword target) { |
| 228 // The inserted call should not overlap the lazy deopt jump code. | 218 // The inserted call should not overlap the lazy deopt jump code. |
| 229 ASSERT(start + ShortCallPattern::InstructionLength() <= target); | 219 ASSERT(start + ShortCallPattern::InstructionLength() <= target); |
| 230 *reinterpret_cast<uint8_t*>(start) = 0xE8; | 220 *reinterpret_cast<uint8_t*>(start) = 0xE8; |
| 231 ShortCallPattern call(start); | 221 ShortCallPattern call(start); |
| 232 call.SetTargetAddress(target); | 222 call.SetTargetAddress(target); |
| 233 CPU::FlushICache(start, ShortCallPattern::InstructionLength()); | 223 CPU::FlushICache(start, ShortCallPattern::InstructionLength()); |
| 234 } | 224 } |
| 235 | 225 |
| 236 | 226 |
| 227 RawFunction* CodePatcher::GetUnoptimizedStaticCallAt( |
| 228 uword return_address, const Code& code, ICData* ic_data_result) { |
| 229 ASSERT(code.ContainsInstructionAt(return_address)); |
| 230 UnoptimizedStaticCall static_call(return_address); |
| 231 ICData& ic_data = ICData::Handle(); |
| 232 ic_data ^= static_call.ic_data(); |
| 233 if (ic_data_result != NULL) { |
| 234 *ic_data_result = ic_data.raw(); |
| 235 } |
| 236 return ic_data.GetTargetAt(0); |
| 237 } |
| 238 |
| 237 } // namespace dart | 239 } // namespace dart |
| 238 | 240 |
| 239 #endif // defined TARGET_ARCH_X64 | 241 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |