[macro-assembler] Delete unused CodePatcher
Bug: v8:6921 Change-Id: I82e0d29aba237dff22dd8dfa80ddecd7fd724df3 Reviewed-on: https://chromium-review.googlesource.com/718421 Reviewed-by: Camillo Bruni <cbruni@chromium.org> Commit-Queue: Toon Verwaest <verwaest@chromium.org> Cr-Commit-Position: refs/heads/master@{#48539}
This commit is contained in:
parent
bc70017d21
commit
5766962964
@ -1724,7 +1724,6 @@ class Assembler : public AssemblerBase {
|
||||
void ConstantPoolAddEntry(int position, Double value);
|
||||
|
||||
friend class RelocInfo;
|
||||
friend class CodePatcher;
|
||||
friend class BlockConstPoolScope;
|
||||
friend class BlockCodeTargetSharingScope;
|
||||
friend class EnsureSpace;
|
||||
|
@ -2482,51 +2482,6 @@ bool AreAliased(Register reg1,
|
||||
}
|
||||
#endif
|
||||
|
||||
CodePatcher::CodePatcher(Isolate* isolate, byte* address, int instructions,
|
||||
FlushICache flush_cache)
|
||||
: address_(address),
|
||||
size_(instructions * Assembler::kInstrSize),
|
||||
masm_(isolate, address, size_ + Assembler::kGap, CodeObjectRequired::kNo),
|
||||
flush_cache_(flush_cache) {
|
||||
// Create a new macro assembler pointing to the address of the code to patch.
|
||||
// The size is adjusted with kGap on order for the assembler to generate size
|
||||
// bytes of instructions without failing with buffer size constraints.
|
||||
DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
|
||||
}
|
||||
|
||||
|
||||
CodePatcher::~CodePatcher() {
|
||||
// Indicate that code has changed.
|
||||
if (flush_cache_ == FLUSH) {
|
||||
Assembler::FlushICache(masm_.isolate(), address_, size_);
|
||||
}
|
||||
|
||||
// Check that we don't have any pending constant pools.
|
||||
DCHECK(masm_.pending_32_bit_constants_.empty());
|
||||
DCHECK(masm_.pending_64_bit_constants_.empty());
|
||||
|
||||
// Check that the code was patched as expected.
|
||||
DCHECK(masm_.pc_ == address_ + size_);
|
||||
DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
|
||||
}
|
||||
|
||||
|
||||
void CodePatcher::Emit(Instr instr) {
|
||||
masm()->emit(instr);
|
||||
}
|
||||
|
||||
|
||||
void CodePatcher::Emit(Address addr) {
|
||||
masm()->emit(reinterpret_cast<Instr>(addr));
|
||||
}
|
||||
|
||||
|
||||
void CodePatcher::EmitCondition(Condition cond) {
|
||||
Instr instr = Assembler::instr_at(masm_.pc_);
|
||||
instr = (instr & ~kCondMask) | cond;
|
||||
masm_.emit(instr);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
|
@ -913,43 +913,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
friend class StandardFrame;
|
||||
};
|
||||
|
||||
// The code patcher is used to patch (typically) small parts of code e.g. for
|
||||
// debugging and other types of instrumentation. When using the code patcher
|
||||
// the exact number of bytes specified must be emitted. It is not legal to emit
|
||||
// relocation information. If any of these constraints are violated it causes
|
||||
// an assertion to fail.
|
||||
class CodePatcher {
|
||||
public:
|
||||
enum FlushICache {
|
||||
FLUSH,
|
||||
DONT_FLUSH
|
||||
};
|
||||
|
||||
CodePatcher(Isolate* isolate, byte* address, int instructions,
|
||||
FlushICache flush_cache = FLUSH);
|
||||
~CodePatcher();
|
||||
|
||||
// Macro assembler to emit code.
|
||||
MacroAssembler* masm() { return &masm_; }
|
||||
|
||||
// Emit an instruction directly.
|
||||
void Emit(Instr instr);
|
||||
|
||||
// Emit an address directly.
|
||||
void Emit(Address addr);
|
||||
|
||||
// Emit the condition part of an instruction leaving the rest of the current
|
||||
// instruction unchanged.
|
||||
void EmitCondition(Condition cond);
|
||||
|
||||
private:
|
||||
byte* address_; // The address of the code being patched.
|
||||
int size_; // Number of bytes of the expected patch size.
|
||||
MacroAssembler masm_; // Macro assembler used to generate the code.
|
||||
FlushICache flush_cache_; // Whether to flush the I cache after patching.
|
||||
};
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Static helper functions.
|
||||
|
||||
|
@ -328,7 +328,7 @@ Assembler::Assembler(IsolateData isolate_data, void* buffer, int buffer_size)
|
||||
: AssemblerBase(isolate_data, buffer, buffer_size) {
|
||||
// Clear the buffer in debug mode unless it was provided by the
|
||||
// caller in which case we can't be sure it's okay to overwrite
|
||||
// existing code in it; see CodePatcher::CodePatcher(...).
|
||||
// existing code in it.
|
||||
#ifdef DEBUG
|
||||
if (own_buffer_) {
|
||||
memset(buffer_, 0xCC, buffer_size_); // int3
|
||||
|
@ -1788,7 +1788,6 @@ class Assembler : public AssemblerBase {
|
||||
|
||||
bool is_optimizable_farjmp(int idx);
|
||||
|
||||
friend class CodePatcher;
|
||||
friend class EnsureSpace;
|
||||
|
||||
// Internal reference positions, required for (potential) patching in
|
||||
|
@ -1640,26 +1640,6 @@ bool AreAliased(Register reg1,
|
||||
#endif
|
||||
|
||||
|
||||
CodePatcher::CodePatcher(Isolate* isolate, byte* address, int size)
|
||||
: address_(address),
|
||||
size_(size),
|
||||
masm_(isolate, address, size + Assembler::kGap, CodeObjectRequired::kNo) {
|
||||
// Create a new macro assembler pointing to the address of the code to patch.
|
||||
// The size is adjusted with kGap on order for the assembler to generate size
|
||||
// bytes of instructions without failing with buffer size constraints.
|
||||
DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
|
||||
}
|
||||
|
||||
|
||||
CodePatcher::~CodePatcher() {
|
||||
// Indicate that code has changed.
|
||||
Assembler::FlushICache(masm_.isolate(), address_, size_);
|
||||
|
||||
// Check that the code was patched as expected.
|
||||
DCHECK(masm_.pc_ == address_ + size_);
|
||||
DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
|
||||
}
|
||||
|
||||
void TurboAssembler::CheckPageFlag(Register object, Register scratch, int mask,
|
||||
Condition cc, Label* condition_met,
|
||||
Label::Distance condition_met_distance) {
|
||||
|
@ -708,25 +708,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
friend class StandardFrame;
|
||||
};
|
||||
|
||||
// The code patcher is used to patch (typically) small parts of code e.g. for
|
||||
// debugging and other types of instrumentation. When using the code patcher
|
||||
// the exact number of bytes specified must be emitted. Is not legal to emit
|
||||
// relocation information. If any of these constraints are violated it causes
|
||||
// an assertion.
|
||||
class CodePatcher {
|
||||
public:
|
||||
CodePatcher(Isolate* isolate, byte* address, int size);
|
||||
~CodePatcher();
|
||||
|
||||
// Macro assembler to emit code.
|
||||
MacroAssembler* masm() { return &masm_; }
|
||||
|
||||
private:
|
||||
byte* address_; // The address of the code being patched.
|
||||
int size_; // Number of bytes of the expected patch size.
|
||||
MacroAssembler masm_; // Macro assembler used to generate the code.
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Static helper functions.
|
||||
|
||||
|
@ -2226,7 +2226,6 @@ class Assembler : public AssemblerBase {
|
||||
|
||||
friend class RegExpMacroAssemblerMIPS;
|
||||
friend class RelocInfo;
|
||||
friend class CodePatcher;
|
||||
friend class BlockTrampolinePoolScope;
|
||||
friend class EnsureSpace;
|
||||
};
|
||||
|
@ -5435,49 +5435,6 @@ bool AreAliased(Register reg1, Register reg2, Register reg3, Register reg4,
|
||||
return n_of_valid_regs != n_of_non_aliasing_regs;
|
||||
}
|
||||
|
||||
|
||||
CodePatcher::CodePatcher(Isolate* isolate, byte* address, int instructions,
|
||||
FlushICache flush_cache)
|
||||
: address_(address),
|
||||
size_(instructions * Assembler::kInstrSize),
|
||||
masm_(isolate, address, size_ + Assembler::kGap, CodeObjectRequired::kNo),
|
||||
flush_cache_(flush_cache) {
|
||||
// Create a new macro assembler pointing to the address of the code to patch.
|
||||
// The size is adjusted with kGap on order for the assembler to generate size
|
||||
// bytes of instructions without failing with buffer size constraints.
|
||||
DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
|
||||
}
|
||||
|
||||
|
||||
CodePatcher::~CodePatcher() {
|
||||
// Indicate that code has changed.
|
||||
if (flush_cache_ == FLUSH) {
|
||||
Assembler::FlushICache(masm_.isolate(), address_, size_);
|
||||
}
|
||||
|
||||
// Check that the code was patched as expected.
|
||||
|
||||
DCHECK(masm_.pc_ == address_ + size_);
|
||||
DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
|
||||
}
|
||||
|
||||
|
||||
void CodePatcher::Emit(Instr instr) {
|
||||
masm()->emit(instr);
|
||||
}
|
||||
|
||||
|
||||
void CodePatcher::Emit(Address addr) {
|
||||
masm()->emit(reinterpret_cast<Instr>(addr));
|
||||
}
|
||||
|
||||
|
||||
void CodePatcher::ChangeBranchCondition(Instr current_instr,
|
||||
uint32_t new_opcode) {
|
||||
current_instr = (current_instr & ~kOpcodeMask) | new_opcode;
|
||||
masm_.emit(current_instr);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
|
@ -1248,42 +1248,6 @@ const Operand& rt = Operand(zero_reg), BranchDelaySlot bd = PROTECT
|
||||
friend class StandardFrame;
|
||||
};
|
||||
|
||||
// The code patcher is used to patch (typically) small parts of code e.g. for
|
||||
// debugging and other types of instrumentation. When using the code patcher
|
||||
// the exact number of bytes specified must be emitted. It is not legal to emit
|
||||
// relocation information. If any of these constraints are violated it causes
|
||||
// an assertion to fail.
|
||||
class CodePatcher {
|
||||
public:
|
||||
enum FlushICache {
|
||||
FLUSH,
|
||||
DONT_FLUSH
|
||||
};
|
||||
|
||||
CodePatcher(Isolate* isolate, byte* address, int instructions,
|
||||
FlushICache flush_cache = FLUSH);
|
||||
~CodePatcher();
|
||||
|
||||
// Macro assembler to emit code.
|
||||
MacroAssembler* masm() { return &masm_; }
|
||||
|
||||
// Emit an instruction directly.
|
||||
void Emit(Instr instr);
|
||||
|
||||
// Emit an address directly.
|
||||
void Emit(Address addr);
|
||||
|
||||
// Change the condition part of an instruction leaving the rest of the current
|
||||
// instruction unchanged.
|
||||
void ChangeBranchCondition(Instr current_instr, uint32_t new_opcode);
|
||||
|
||||
private:
|
||||
byte* address_; // The address of the code being patched.
|
||||
int size_; // Number of bytes of the expected patch size.
|
||||
MacroAssembler masm_; // Macro assembler used to generate the code.
|
||||
FlushICache flush_cache_; // Whether to flush the I cache after patching.
|
||||
};
|
||||
|
||||
template <typename Func>
|
||||
void TurboAssembler::GenerateSwitchTable(Register index, size_t case_count,
|
||||
Func GetLabelFunction) {
|
||||
|
@ -2292,7 +2292,6 @@ class Assembler : public AssemblerBase {
|
||||
|
||||
friend class RegExpMacroAssemblerMIPS;
|
||||
friend class RelocInfo;
|
||||
friend class CodePatcher;
|
||||
friend class BlockTrampolinePoolScope;
|
||||
friend class EnsureSpace;
|
||||
};
|
||||
|
@ -5703,48 +5703,6 @@ bool AreAliased(Register reg1, Register reg2, Register reg3, Register reg4,
|
||||
return n_of_valid_regs != n_of_non_aliasing_regs;
|
||||
}
|
||||
|
||||
|
||||
CodePatcher::CodePatcher(Isolate* isolate, byte* address, int instructions,
|
||||
FlushICache flush_cache)
|
||||
: address_(address),
|
||||
size_(instructions * Assembler::kInstrSize),
|
||||
masm_(isolate, address, size_ + Assembler::kGap, CodeObjectRequired::kNo),
|
||||
flush_cache_(flush_cache) {
|
||||
// Create a new macro assembler pointing to the address of the code to patch.
|
||||
// The size is adjusted with kGap on order for the assembler to generate size
|
||||
// bytes of instructions without failing with buffer size constraints.
|
||||
DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
|
||||
}
|
||||
|
||||
|
||||
CodePatcher::~CodePatcher() {
|
||||
// Indicate that code has changed.
|
||||
if (flush_cache_ == FLUSH) {
|
||||
Assembler::FlushICache(masm_.isolate(), address_, size_);
|
||||
}
|
||||
// Check that the code was patched as expected.
|
||||
DCHECK(masm_.pc_ == address_ + size_);
|
||||
DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
|
||||
}
|
||||
|
||||
|
||||
void CodePatcher::Emit(Instr instr) {
|
||||
masm()->emit(instr);
|
||||
}
|
||||
|
||||
|
||||
void CodePatcher::Emit(Address addr) {
|
||||
// masm()->emit(reinterpret_cast<Instr>(addr));
|
||||
}
|
||||
|
||||
|
||||
void CodePatcher::ChangeBranchCondition(Instr current_instr,
|
||||
uint32_t new_opcode) {
|
||||
current_instr = (current_instr & ~kOpcodeMask) | new_opcode;
|
||||
masm_.emit(current_instr);
|
||||
}
|
||||
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
|
@ -1346,43 +1346,6 @@ const Operand& rt = Operand(zero_reg), BranchDelaySlot bd = PROTECT
|
||||
friend class StandardFrame;
|
||||
};
|
||||
|
||||
|
||||
// The code patcher is used to patch (typically) small parts of code e.g. for
|
||||
// debugging and other types of instrumentation. When using the code patcher
|
||||
// the exact number of bytes specified must be emitted. It is not legal to emit
|
||||
// relocation information. If any of these constraints are violated it causes
|
||||
// an assertion to fail.
|
||||
class CodePatcher {
|
||||
public:
|
||||
enum FlushICache {
|
||||
FLUSH,
|
||||
DONT_FLUSH
|
||||
};
|
||||
|
||||
CodePatcher(Isolate* isolate, byte* address, int instructions,
|
||||
FlushICache flush_cache = FLUSH);
|
||||
~CodePatcher();
|
||||
|
||||
// Macro assembler to emit code.
|
||||
MacroAssembler* masm() { return &masm_; }
|
||||
|
||||
// Emit an instruction directly.
|
||||
void Emit(Instr instr);
|
||||
|
||||
// Emit an address directly.
|
||||
void Emit(Address addr);
|
||||
|
||||
// Change the condition part of an instruction leaving the rest of the current
|
||||
// instruction unchanged.
|
||||
void ChangeBranchCondition(Instr current_instr, uint32_t new_opcode);
|
||||
|
||||
private:
|
||||
byte* address_; // The address of the code being patched.
|
||||
int size_; // Number of bytes of the expected patch size.
|
||||
MacroAssembler masm_; // Macro assembler used to generate the code.
|
||||
FlushICache flush_cache_; // Whether to flush the I cache after patching.
|
||||
};
|
||||
|
||||
template <typename Func>
|
||||
void TurboAssembler::GenerateSwitchTable(Register index, size_t case_count,
|
||||
Func GetLabelFunction) {
|
||||
|
@ -1641,7 +1641,6 @@ class Assembler : public AssemblerBase {
|
||||
|
||||
friend class RegExpMacroAssemblerPPC;
|
||||
friend class RelocInfo;
|
||||
friend class CodePatcher;
|
||||
friend class BlockTrampolinePoolScope;
|
||||
friend class EnsureSpace;
|
||||
|
||||
|
@ -2973,49 +2973,6 @@ bool AreAliased(Register reg1, Register reg2, Register reg3, Register reg4,
|
||||
#endif
|
||||
|
||||
|
||||
CodePatcher::CodePatcher(Isolate* isolate, byte* address, int instructions,
|
||||
FlushICache flush_cache)
|
||||
: address_(address),
|
||||
size_(instructions * Assembler::kInstrSize),
|
||||
masm_(isolate, address, size_ + Assembler::kGap, CodeObjectRequired::kNo),
|
||||
flush_cache_(flush_cache) {
|
||||
// Create a new macro assembler pointing to the address of the code to patch.
|
||||
// The size is adjusted with kGap on order for the assembler to generate size
|
||||
// bytes of instructions without failing with buffer size constraints.
|
||||
DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
|
||||
}
|
||||
|
||||
|
||||
CodePatcher::~CodePatcher() {
|
||||
// Indicate that code has changed.
|
||||
if (flush_cache_ == FLUSH) {
|
||||
Assembler::FlushICache(masm_.isolate(), address_, size_);
|
||||
}
|
||||
|
||||
// Check that the code was patched as expected.
|
||||
DCHECK(masm_.pc_ == address_ + size_);
|
||||
DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
|
||||
}
|
||||
|
||||
|
||||
void CodePatcher::Emit(Instr instr) { masm()->emit(instr); }
|
||||
|
||||
|
||||
void CodePatcher::EmitCondition(Condition cond) {
|
||||
Instr instr = Assembler::instr_at(masm_.pc_);
|
||||
switch (cond) {
|
||||
case eq:
|
||||
instr = (instr & ~kCondMask) | BT;
|
||||
break;
|
||||
case ne:
|
||||
instr = (instr & ~kCondMask) | BF;
|
||||
break;
|
||||
default:
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
masm_.emit(instr);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
|
@ -1056,37 +1056,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
friend class StandardFrame;
|
||||
};
|
||||
|
||||
// The code patcher is used to patch (typically) small parts of code e.g. for
|
||||
// debugging and other types of instrumentation. When using the code patcher
|
||||
// the exact number of bytes specified must be emitted. It is not legal to emit
|
||||
// relocation information. If any of these constraints are violated it causes
|
||||
// an assertion to fail.
|
||||
class CodePatcher {
|
||||
public:
|
||||
enum FlushICache { FLUSH, DONT_FLUSH };
|
||||
|
||||
CodePatcher(Isolate* isolate, byte* address, int instructions,
|
||||
FlushICache flush_cache = FLUSH);
|
||||
~CodePatcher();
|
||||
|
||||
// Macro assembler to emit code.
|
||||
MacroAssembler* masm() { return &masm_; }
|
||||
|
||||
// Emit an instruction directly.
|
||||
void Emit(Instr instr);
|
||||
|
||||
// Emit the condition part of an instruction leaving the rest of the current
|
||||
// instruction unchanged.
|
||||
void EmitCondition(Condition cond);
|
||||
|
||||
private:
|
||||
byte* address_; // The address of the code being patched.
|
||||
int size_; // Number of bytes of the expected patch size.
|
||||
MacroAssembler masm_; // Macro assembler used to generate the code.
|
||||
FlushICache flush_cache_; // Whether to flush the I cache after patching.
|
||||
};
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Static helper functions.
|
||||
|
||||
|
@ -1592,7 +1592,6 @@ class Assembler : public AssemblerBase {
|
||||
|
||||
friend class RegExpMacroAssemblerS390;
|
||||
friend class RelocInfo;
|
||||
friend class CodePatcher;
|
||||
|
||||
std::vector<Handle<Code>> code_targets_;
|
||||
friend class EnsureSpace;
|
||||
|
@ -4314,29 +4314,6 @@ bool AreAliased(Register reg1, Register reg2, Register reg3, Register reg4,
|
||||
}
|
||||
#endif
|
||||
|
||||
CodePatcher::CodePatcher(Isolate* isolate, byte* address, int size,
|
||||
FlushICache flush_cache)
|
||||
: address_(address),
|
||||
size_(size),
|
||||
masm_(isolate, address, size_ + Assembler::kGap, CodeObjectRequired::kNo),
|
||||
flush_cache_(flush_cache) {
|
||||
// Create a new macro assembler pointing to the address of the code to patch.
|
||||
// The size is adjusted with kGap on order for the assembler to generate size
|
||||
// bytes of instructions without failing with buffer size constraints.
|
||||
DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
|
||||
}
|
||||
|
||||
CodePatcher::~CodePatcher() {
|
||||
// Indicate that code has changed.
|
||||
if (flush_cache_ == FLUSH) {
|
||||
Assembler::FlushICache(masm_.isolate(), address_, size_);
|
||||
}
|
||||
|
||||
// Check that the code was patched as expected.
|
||||
DCHECK(masm_.pc_ == address_ + size_);
|
||||
DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
|
@ -1354,29 +1354,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
friend class StandardFrame;
|
||||
};
|
||||
|
||||
// The code patcher is used to patch (typically) small parts of code e.g. for
|
||||
// debugging and other types of instrumentation. When using the code patcher
|
||||
// the exact number of bytes specified must be emitted. It is not legal to emit
|
||||
// relocation information. If any of these constraints are violated it causes
|
||||
// an assertion to fail.
|
||||
class CodePatcher {
|
||||
public:
|
||||
enum FlushICache { FLUSH, DONT_FLUSH };
|
||||
|
||||
CodePatcher(Isolate* isolate, byte* address, int instructions,
|
||||
FlushICache flush_cache = FLUSH);
|
||||
~CodePatcher();
|
||||
|
||||
// Macro assembler to emit code.
|
||||
MacroAssembler* masm() { return &masm_; }
|
||||
|
||||
private:
|
||||
byte* address_; // The address of the code being patched.
|
||||
int size_; // Number of bytes of the expected patch size.
|
||||
MacroAssembler masm_; // Macro assembler used to generate the code.
|
||||
FlushICache flush_cache_; // Whether to flush the I cache after patching.
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Static helper functions.
|
||||
|
||||
|
@ -2411,7 +2411,6 @@ class Assembler : public AssemblerBase {
|
||||
|
||||
bool is_optimizable_farjmp(int idx);
|
||||
|
||||
friend class CodePatcher;
|
||||
friend class EnsureSpace;
|
||||
friend class RegExpMacroAssemblerX64;
|
||||
|
||||
|
@ -2751,27 +2751,6 @@ bool AreAliased(Register reg1,
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
CodePatcher::CodePatcher(Isolate* isolate, byte* address, int size)
|
||||
: address_(address),
|
||||
size_(size),
|
||||
masm_(isolate, address, size + Assembler::kGap, CodeObjectRequired::kNo) {
|
||||
// Create a new macro assembler pointing to the address of the code to patch.
|
||||
// The size is adjusted with kGap on order for the assembler to generate size
|
||||
// bytes of instructions without failing with buffer size constraints.
|
||||
DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
|
||||
}
|
||||
|
||||
|
||||
CodePatcher::~CodePatcher() {
|
||||
// Indicate that code has changed.
|
||||
Assembler::FlushICache(masm_.isolate(), address_, size_);
|
||||
|
||||
// Check that the code was patched as expected.
|
||||
DCHECK(masm_.pc_ == address_ + size_);
|
||||
DCHECK(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
|
||||
}
|
||||
|
||||
void TurboAssembler::CheckPageFlag(Register object, Register scratch, int mask,
|
||||
Condition cc, Label* condition_met,
|
||||
Label::Distance condition_met_distance) {
|
||||
|
@ -978,27 +978,6 @@ class MacroAssembler : public TurboAssembler {
|
||||
friend class StandardFrame;
|
||||
};
|
||||
|
||||
|
||||
// The code patcher is used to patch (typically) small parts of code e.g. for
|
||||
// debugging and other types of instrumentation. When using the code patcher
|
||||
// the exact number of bytes specified must be emitted. Is not legal to emit
|
||||
// relocation information. If any of these constraints are violated it causes
|
||||
// an assertion.
|
||||
class CodePatcher {
|
||||
public:
|
||||
CodePatcher(Isolate* isolate, byte* address, int size);
|
||||
~CodePatcher();
|
||||
|
||||
// Macro assembler to emit code.
|
||||
MacroAssembler* masm() { return &masm_; }
|
||||
|
||||
private:
|
||||
byte* address_; // The address of the code being patched.
|
||||
int size_; // Number of bytes of the expected patch size.
|
||||
MacroAssembler masm_; // Macro assembler used to generate the code.
|
||||
};
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Static helper functions.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user