| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 void CodePatcher::InsertCallAt(uword start, uword target) { | 224 void CodePatcher::InsertCallAt(uword start, uword target) { |
| 225 // The inserted call should not overlap the lazy deopt jump code. | 225 // The inserted call should not overlap the lazy deopt jump code. |
| 226 ASSERT(start + CallPattern::InstructionLength() <= target); | 226 ASSERT(start + CallPattern::InstructionLength() <= target); |
| 227 *reinterpret_cast<uint8_t*>(start) = 0xE8; | 227 *reinterpret_cast<uint8_t*>(start) = 0xE8; |
| 228 CallPattern call(start); | 228 CallPattern call(start); |
| 229 call.SetTargetAddress(target); | 229 call.SetTargetAddress(target); |
| 230 CPU::FlushICache(start, CallPattern::InstructionLength()); | 230 CPU::FlushICache(start, CallPattern::InstructionLength()); |
| 231 } | 231 } |
| 232 | 232 |
| 233 | 233 |
| 234 uword CodePatcher::GetInstanceCallAt(uword return_address, | 234 uword CodePatcher::GetInstanceCallAt( |
| 235 const Code& code, | 235 uword return_address, const Code& code, ICData* ic_data) { |
| 236 ICData* ic_data) { | |
| 237 ASSERT(code.ContainsInstructionAt(return_address)); | 236 ASSERT(code.ContainsInstructionAt(return_address)); |
| 238 InstanceCall call(return_address); | 237 InstanceCall call(return_address); |
| 239 if (ic_data != NULL) { | 238 if (ic_data != NULL) { |
| 240 *ic_data ^= call.ic_data(); | 239 *ic_data ^= call.ic_data(); |
| 241 } | 240 } |
| 242 return call.target(); | 241 return call.target(); |
| 243 } | 242 } |
| 244 | 243 |
| 245 | 244 |
| 246 RawFunction* CodePatcher::GetUnoptimizedStaticCallTargetAt( | 245 RawFunction* CodePatcher::GetUnoptimizedStaticCallAt( |
| 247 uword return_address, const Code& code) { | 246 uword return_address, const Code& code, ICData* ic_data_result) { |
| 248 ASSERT(code.ContainsInstructionAt(return_address)); | 247 ASSERT(code.ContainsInstructionAt(return_address)); |
| 249 UnoptimizedStaticCall static_call(return_address); | 248 UnoptimizedStaticCall static_call(return_address); |
| 250 ICData& ic_data = ICData::Handle(); | 249 ICData& ic_data = ICData::Handle(); |
| 251 ic_data ^= static_call.ic_data(); | 250 ic_data ^= static_call.ic_data(); |
| 251 if (ic_data_result != NULL) { |
| 252 *ic_data_result = ic_data.raw(); |
| 253 } |
| 252 return ic_data.GetTargetAt(0); | 254 return ic_data.GetTargetAt(0); |
| 253 } | 255 } |
| 254 | 256 |
| 255 | 257 |
| 256 intptr_t CodePatcher::InstanceCallSizeInBytes() { | 258 intptr_t CodePatcher::InstanceCallSizeInBytes() { |
| 257 return InstanceCall::kNumInstructions * InstanceCall::kInstructionSize; | 259 return InstanceCall::kNumInstructions * InstanceCall::kInstructionSize; |
| 258 } | 260 } |
| 259 | 261 |
| 260 } // namespace dart | 262 } // namespace dart |
| 261 | 263 |
| 262 #endif // defined TARGET_ARCH_IA32 | 264 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |