| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 const Code& code, | 162 const Code& code, |
| 163 uword new_target) { | 163 uword new_target) { |
| 164 ASSERT(code.ContainsInstructionAt(return_address)); | 164 ASSERT(code.ContainsInstructionAt(return_address)); |
| 165 InstanceCall call(return_address); | 165 InstanceCall call(return_address); |
| 166 call.set_target(new_target); | 166 call.set_target(new_target); |
| 167 } | 167 } |
| 168 | 168 |
| 169 | 169 |
| 170 | 170 |
| 171 void CodePatcher::InsertCallAt(uword start, uword target) { | 171 void CodePatcher::InsertCallAt(uword start, uword target) { |
| 172 // The inserted call should not overlap the lazy deopt jump code. |
| 173 ASSERT(start + CallPattern::InstructionLength() <= target); |
| 172 *reinterpret_cast<uint8_t*>(start) = 0xE8; | 174 *reinterpret_cast<uint8_t*>(start) = 0xE8; |
| 173 CallPattern call(start); | 175 CallPattern call(start); |
| 174 call.SetTargetAddress(target); | 176 call.SetTargetAddress(target); |
| 175 CPU::FlushICache(start, CallPattern::InstructionLength()); | 177 CPU::FlushICache(start, CallPattern::InstructionLength()); |
| 176 } | 178 } |
| 177 | 179 |
| 178 | 180 |
| 179 uword CodePatcher::GetInstanceCallAt(uword return_address, | 181 uword CodePatcher::GetInstanceCallAt(uword return_address, |
| 180 const Code& code, | 182 const Code& code, |
| 181 ICData* ic_data, | 183 ICData* ic_data, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 192 } | 194 } |
| 193 | 195 |
| 194 | 196 |
| 195 intptr_t CodePatcher::InstanceCallSizeInBytes() { | 197 intptr_t CodePatcher::InstanceCallSizeInBytes() { |
| 196 return DartCallPattern::kNumInstructions * DartCallPattern::kInstructionSize; | 198 return DartCallPattern::kNumInstructions * DartCallPattern::kInstructionSize; |
| 197 } | 199 } |
| 198 | 200 |
| 199 } // namespace dart | 201 } // namespace dart |
| 200 | 202 |
| 201 #endif // defined TARGET_ARCH_IA32 | 203 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |