OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 <assert.h> // For assert | 5 #include <assert.h> // For assert |
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_PPC | 8 #if V8_TARGET_ARCH_PPC |
9 | 9 |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 4323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4334 if (reg6.is_valid()) regs |= reg6.bit(); | 4334 if (reg6.is_valid()) regs |= reg6.bit(); |
4335 if (reg7.is_valid()) regs |= reg7.bit(); | 4335 if (reg7.is_valid()) regs |= reg7.bit(); |
4336 if (reg8.is_valid()) regs |= reg8.bit(); | 4336 if (reg8.is_valid()) regs |= reg8.bit(); |
4337 int n_of_non_aliasing_regs = NumRegs(regs); | 4337 int n_of_non_aliasing_regs = NumRegs(regs); |
4338 | 4338 |
4339 return n_of_valid_regs != n_of_non_aliasing_regs; | 4339 return n_of_valid_regs != n_of_non_aliasing_regs; |
4340 } | 4340 } |
4341 #endif | 4341 #endif |
4342 | 4342 |
4343 | 4343 |
4344 CodePatcher::CodePatcher(byte* address, int instructions, | 4344 CodePatcher::CodePatcher(Isolate* isolate, byte* address, int instructions, |
4345 FlushICache flush_cache) | 4345 FlushICache flush_cache) |
4346 : address_(address), | 4346 : address_(address), |
4347 size_(instructions * Assembler::kInstrSize), | 4347 size_(instructions * Assembler::kInstrSize), |
4348 masm_(NULL, address, size_ + Assembler::kGap, CodeObjectRequired::kNo), | 4348 masm_(isolate, address, size_ + Assembler::kGap, CodeObjectRequired::kNo), |
4349 flush_cache_(flush_cache) { | 4349 flush_cache_(flush_cache) { |
4350 // Create a new macro assembler pointing to the address of the code to patch. | 4350 // Create a new macro assembler pointing to the address of the code to patch. |
4351 // The size is adjusted with kGap on order for the assembler to generate size | 4351 // The size is adjusted with kGap on order for the assembler to generate size |
4352 // bytes of instructions without failing with buffer size constraints. | 4352 // bytes of instructions without failing with buffer size constraints. |
4353 DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 4353 DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
4354 } | 4354 } |
4355 | 4355 |
4356 | 4356 |
4357 CodePatcher::~CodePatcher() { | 4357 CodePatcher::~CodePatcher() { |
4358 // Indicate that code has changed. | 4358 // Indicate that code has changed. |
4359 if (flush_cache_ == FLUSH) { | 4359 if (flush_cache_ == FLUSH) { |
4360 Assembler::FlushICacheWithoutIsolate(address_, size_); | 4360 Assembler::FlushICache(masm_.isolate(), address_, size_); |
4361 } | 4361 } |
4362 | 4362 |
4363 // Check that the code was patched as expected. | 4363 // Check that the code was patched as expected. |
4364 DCHECK(masm_.pc_ == address_ + size_); | 4364 DCHECK(masm_.pc_ == address_ + size_); |
4365 DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 4365 DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
4366 } | 4366 } |
4367 | 4367 |
4368 | 4368 |
4369 void CodePatcher::Emit(Instr instr) { masm()->emit(instr); } | 4369 void CodePatcher::Emit(Instr instr) { masm()->emit(instr); } |
4370 | 4370 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4403 } | 4403 } |
4404 if (mag.shift > 0) srawi(result, result, mag.shift); | 4404 if (mag.shift > 0) srawi(result, result, mag.shift); |
4405 ExtractBit(r0, dividend, 31); | 4405 ExtractBit(r0, dividend, 31); |
4406 add(result, result, r0); | 4406 add(result, result, r0); |
4407 } | 4407 } |
4408 | 4408 |
4409 } // namespace internal | 4409 } // namespace internal |
4410 } // namespace v8 | 4410 } // namespace v8 |
4411 | 4411 |
4412 #endif // V8_TARGET_ARCH_PPC | 4412 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |