OLD | NEW |
1 | 1 |
2 // Copyright 2012 the V8 project authors. All rights reserved. | 2 // Copyright 2012 the V8 project authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 #include <limits.h> // For LONG_MIN, LONG_MAX. | 6 #include <limits.h> // For LONG_MIN, LONG_MAX. |
7 | 7 |
8 #if V8_TARGET_ARCH_MIPS | 8 #if V8_TARGET_ARCH_MIPS |
9 | 9 |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 5784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5795 if (reg5.is_valid()) regs |= reg5.bit(); | 5795 if (reg5.is_valid()) regs |= reg5.bit(); |
5796 if (reg6.is_valid()) regs |= reg6.bit(); | 5796 if (reg6.is_valid()) regs |= reg6.bit(); |
5797 if (reg7.is_valid()) regs |= reg7.bit(); | 5797 if (reg7.is_valid()) regs |= reg7.bit(); |
5798 if (reg8.is_valid()) regs |= reg8.bit(); | 5798 if (reg8.is_valid()) regs |= reg8.bit(); |
5799 int n_of_non_aliasing_regs = NumRegs(regs); | 5799 int n_of_non_aliasing_regs = NumRegs(regs); |
5800 | 5800 |
5801 return n_of_valid_regs != n_of_non_aliasing_regs; | 5801 return n_of_valid_regs != n_of_non_aliasing_regs; |
5802 } | 5802 } |
5803 | 5803 |
5804 | 5804 |
5805 CodePatcher::CodePatcher(byte* address, int instructions, | 5805 CodePatcher::CodePatcher(Isolate* isolate, byte* address, int instructions, |
5806 FlushICache flush_cache) | 5806 FlushICache flush_cache) |
5807 : address_(address), | 5807 : address_(address), |
5808 size_(instructions * Assembler::kInstrSize), | 5808 size_(instructions * Assembler::kInstrSize), |
5809 masm_(NULL, address, size_ + Assembler::kGap, CodeObjectRequired::kNo), | 5809 masm_(isolate, address, size_ + Assembler::kGap, CodeObjectRequired::kNo), |
5810 flush_cache_(flush_cache) { | 5810 flush_cache_(flush_cache) { |
5811 // Create a new macro assembler pointing to the address of the code to patch. | 5811 // Create a new macro assembler pointing to the address of the code to patch. |
5812 // The size is adjusted with kGap on order for the assembler to generate size | 5812 // The size is adjusted with kGap on order for the assembler to generate size |
5813 // bytes of instructions without failing with buffer size constraints. | 5813 // bytes of instructions without failing with buffer size constraints. |
5814 DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 5814 DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
5815 } | 5815 } |
5816 | 5816 |
5817 | 5817 |
5818 CodePatcher::~CodePatcher() { | 5818 CodePatcher::~CodePatcher() { |
5819 // Indicate that code has changed. | 5819 // Indicate that code has changed. |
5820 if (flush_cache_ == FLUSH) { | 5820 if (flush_cache_ == FLUSH) { |
5821 Assembler::FlushICacheWithoutIsolate(address_, size_); | 5821 Assembler::FlushICache(masm_.isolate(), address_, size_); |
5822 } | 5822 } |
5823 | 5823 |
5824 // Check that the code was patched as expected. | 5824 // Check that the code was patched as expected. |
5825 DCHECK(masm_.pc_ == address_ + size_); | 5825 DCHECK(masm_.pc_ == address_ + size_); |
5826 DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 5826 DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
5827 } | 5827 } |
5828 | 5828 |
5829 | 5829 |
5830 void CodePatcher::Emit(Instr instr) { | 5830 void CodePatcher::Emit(Instr instr) { |
5831 masm()->emit(instr); | 5831 masm()->emit(instr); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5864 if (mag.shift > 0) sra(result, result, mag.shift); | 5864 if (mag.shift > 0) sra(result, result, mag.shift); |
5865 srl(at, dividend, 31); | 5865 srl(at, dividend, 31); |
5866 Addu(result, result, Operand(at)); | 5866 Addu(result, result, Operand(at)); |
5867 } | 5867 } |
5868 | 5868 |
5869 | 5869 |
5870 } // namespace internal | 5870 } // namespace internal |
5871 } // namespace v8 | 5871 } // namespace v8 |
5872 | 5872 |
5873 #endif // V8_TARGET_ARCH_MIPS | 5873 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |