OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 3827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3838 if (reg4.is_valid()) regs |= reg4.bit(); | 3838 if (reg4.is_valid()) regs |= reg4.bit(); |
3839 if (reg5.is_valid()) regs |= reg5.bit(); | 3839 if (reg5.is_valid()) regs |= reg5.bit(); |
3840 if (reg6.is_valid()) regs |= reg6.bit(); | 3840 if (reg6.is_valid()) regs |= reg6.bit(); |
3841 int n_of_non_aliasing_regs = NumRegs(regs); | 3841 int n_of_non_aliasing_regs = NumRegs(regs); |
3842 | 3842 |
3843 return n_of_valid_regs != n_of_non_aliasing_regs; | 3843 return n_of_valid_regs != n_of_non_aliasing_regs; |
3844 } | 3844 } |
3845 #endif | 3845 #endif |
3846 | 3846 |
3847 | 3847 |
3848 CodePatcher::CodePatcher(byte* address, int instructions) | 3848 CodePatcher::CodePatcher(byte* address, |
| 3849 int instructions, |
| 3850 FlushICache flush_cache) |
3849 : address_(address), | 3851 : address_(address), |
3850 size_(instructions * Assembler::kInstrSize), | 3852 size_(instructions * Assembler::kInstrSize), |
3851 masm_(NULL, address, size_ + Assembler::kGap) { | 3853 masm_(NULL, address, size_ + Assembler::kGap), |
| 3854 flush_cache_(flush_cache) { |
3852 // Create a new macro assembler pointing to the address of the code to patch. | 3855 // Create a new macro assembler pointing to the address of the code to patch. |
3853 // The size is adjusted with kGap on order for the assembler to generate size | 3856 // The size is adjusted with kGap on order for the assembler to generate size |
3854 // bytes of instructions without failing with buffer size constraints. | 3857 // bytes of instructions without failing with buffer size constraints. |
3855 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 3858 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
3856 } | 3859 } |
3857 | 3860 |
3858 | 3861 |
3859 CodePatcher::~CodePatcher() { | 3862 CodePatcher::~CodePatcher() { |
3860 // Indicate that code has changed. | 3863 // Indicate that code has changed. |
3861 CPU::FlushICache(address_, size_); | 3864 if (flush_cache_ == FLUSH) { |
| 3865 CPU::FlushICache(address_, size_); |
| 3866 } |
3862 | 3867 |
3863 // Check that the code was patched as expected. | 3868 // Check that the code was patched as expected. |
3864 ASSERT(masm_.pc_ == address_ + size_); | 3869 ASSERT(masm_.pc_ == address_ + size_); |
3865 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 3870 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
3866 } | 3871 } |
3867 | 3872 |
3868 | 3873 |
3869 void CodePatcher::Emit(Instr instr) { | 3874 void CodePatcher::Emit(Instr instr) { |
3870 masm()->emit(instr); | 3875 masm()->emit(instr); |
3871 } | 3876 } |
3872 | 3877 |
3873 | 3878 |
3874 void CodePatcher::Emit(Address addr) { | 3879 void CodePatcher::Emit(Address addr) { |
3875 masm()->emit(reinterpret_cast<Instr>(addr)); | 3880 masm()->emit(reinterpret_cast<Instr>(addr)); |
3876 } | 3881 } |
3877 | 3882 |
3878 | 3883 |
3879 void CodePatcher::EmitCondition(Condition cond) { | 3884 void CodePatcher::EmitCondition(Condition cond) { |
3880 Instr instr = Assembler::instr_at(masm_.pc_); | 3885 Instr instr = Assembler::instr_at(masm_.pc_); |
3881 instr = (instr & ~kCondMask) | cond; | 3886 instr = (instr & ~kCondMask) | cond; |
3882 masm_.emit(instr); | 3887 masm_.emit(instr); |
3883 } | 3888 } |
3884 | 3889 |
3885 | 3890 |
3886 } } // namespace v8::internal | 3891 } } // namespace v8::internal |
3887 | 3892 |
3888 #endif // V8_TARGET_ARCH_ARM | 3893 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |