OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits.h> // For LONG_MIN, LONG_MAX. | 5 #include <limits.h> // For LONG_MIN, LONG_MAX. |
6 | 6 |
7 #if V8_TARGET_ARCH_ARM | 7 #if V8_TARGET_ARCH_ARM |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/division-by-constant.h" | 10 #include "src/base/division-by-constant.h" |
(...skipping 3650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3661 if (reg6.is_valid()) regs |= reg6.bit(); | 3661 if (reg6.is_valid()) regs |= reg6.bit(); |
3662 if (reg7.is_valid()) regs |= reg7.bit(); | 3662 if (reg7.is_valid()) regs |= reg7.bit(); |
3663 if (reg8.is_valid()) regs |= reg8.bit(); | 3663 if (reg8.is_valid()) regs |= reg8.bit(); |
3664 int n_of_non_aliasing_regs = NumRegs(regs); | 3664 int n_of_non_aliasing_regs = NumRegs(regs); |
3665 | 3665 |
3666 return n_of_valid_regs != n_of_non_aliasing_regs; | 3666 return n_of_valid_regs != n_of_non_aliasing_regs; |
3667 } | 3667 } |
3668 #endif | 3668 #endif |
3669 | 3669 |
3670 | 3670 |
3671 CodePatcher::CodePatcher(byte* address, int instructions, | 3671 CodePatcher::CodePatcher(Isolate* isolate, byte* address, int instructions, |
3672 FlushICache flush_cache) | 3672 FlushICache flush_cache) |
3673 : address_(address), | 3673 : address_(address), |
3674 size_(instructions * Assembler::kInstrSize), | 3674 size_(instructions * Assembler::kInstrSize), |
3675 masm_(NULL, address, size_ + Assembler::kGap, CodeObjectRequired::kNo), | 3675 masm_(isolate, address, size_ + Assembler::kGap, CodeObjectRequired::kNo), |
3676 flush_cache_(flush_cache) { | 3676 flush_cache_(flush_cache) { |
3677 // Create a new macro assembler pointing to the address of the code to patch. | 3677 // Create a new macro assembler pointing to the address of the code to patch. |
3678 // The size is adjusted with kGap on order for the assembler to generate size | 3678 // The size is adjusted with kGap on order for the assembler to generate size |
3679 // bytes of instructions without failing with buffer size constraints. | 3679 // bytes of instructions without failing with buffer size constraints. |
3680 DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 3680 DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
3681 } | 3681 } |
3682 | 3682 |
3683 | 3683 |
3684 CodePatcher::~CodePatcher() { | 3684 CodePatcher::~CodePatcher() { |
3685 // Indicate that code has changed. | 3685 // Indicate that code has changed. |
3686 if (flush_cache_ == FLUSH) { | 3686 if (flush_cache_ == FLUSH) { |
3687 Assembler::FlushICacheWithoutIsolate(address_, size_); | 3687 Assembler::FlushICache(masm_.isolate(), address_, size_); |
3688 } | 3688 } |
3689 | 3689 |
3690 // Check that the code was patched as expected. | 3690 // Check that the code was patched as expected. |
3691 DCHECK(masm_.pc_ == address_ + size_); | 3691 DCHECK(masm_.pc_ == address_ + size_); |
3692 DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 3692 DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
3693 } | 3693 } |
3694 | 3694 |
3695 | 3695 |
3696 void CodePatcher::Emit(Instr instr) { | 3696 void CodePatcher::Emit(Instr instr) { |
3697 masm()->emit(instr); | 3697 masm()->emit(instr); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3729 } | 3729 } |
3730 } | 3730 } |
3731 if (mag.shift > 0) mov(result, Operand(result, ASR, mag.shift)); | 3731 if (mag.shift > 0) mov(result, Operand(result, ASR, mag.shift)); |
3732 add(result, result, Operand(dividend, LSR, 31)); | 3732 add(result, result, Operand(dividend, LSR, 31)); |
3733 } | 3733 } |
3734 | 3734 |
3735 } // namespace internal | 3735 } // namespace internal |
3736 } // namespace v8 | 3736 } // namespace v8 |
3737 | 3737 |
3738 #endif // V8_TARGET_ARCH_ARM | 3738 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |