Commit 7f78e7b3 authored by chunyang.dai's avatar chunyang.dai Committed by Commit bot

X87: Refactor BreakLocationIterator

port 1a608493 (r26983)

original commit message:

   Refactor BreakLocationIterator.

   We now have BreakLocation::Iterator to iterate via RelocIterator, and
   create a BreakLocation when we are done iterating. The reloc info is
   stored in BreakLocation in a GC-safe way and instantiated on demand.

BUG=

Review URL: https://codereview.chromium.org/978183002

Cr-Commit-Position: refs/heads/master@{#27003}
parent 256d5d4d
......@@ -102,6 +102,37 @@ bool RelocInfo::IsInConstantPool() {
}
// Patch the code at the current PC with a call to the target address.
// Additional guard int3 instructions can be added if required.
void RelocInfo::PatchCodeWithCall(Address target, int guard_bytes) {
// Call instruction takes up 5 bytes and int3 takes up one byte.
static const int kCallCodeSize = 5;
int code_size = kCallCodeSize + guard_bytes;
// Create a code patcher.
CodePatcher patcher(pc_, code_size);
// Add a label for checking the size of the code used for returning.
#ifdef DEBUG
Label check_codesize;
patcher.masm()->bind(&check_codesize);
#endif
// Patch the code.
patcher.masm()->call(target, RelocInfo::NONE32);
// Check that the size of the code generated is as expected.
DCHECK_EQ(kCallCodeSize,
patcher.masm()->SizeOfCodeGeneratedSince(&check_codesize));
// Add the requested number of int3 instructions after the call.
DCHECK_GE(guard_bytes, 0);
for (int i = 0; i < guard_bytes; i++) {
patcher.masm()->int3();
}
}
// -----------------------------------------------------------------------------
// Implementation of Operand
......
......@@ -15,7 +15,7 @@ namespace internal {
// Patch the code at the current PC with a call to the target address.
// Additional guard int3 instructions can be added if required.
void RelocInfo::PatchCodeWithCall(Address pc, Address target, int guard_bytes) {
void PatchCodeWithCall(Address pc, Address target, int guard_bytes) {
// Call instruction takes up 5 bytes and int3 takes up one byte.
static const int kCallCodeSize = 5;
int code_size = kCallCodeSize + guard_bytes;
......@@ -58,10 +58,10 @@ void BreakLocation::SetDebugBreakAtReturn() {
}
void BreakLocationIterator::SetDebugBreakAtSlot() {
void BreakLocation::SetDebugBreakAtSlot() {
DCHECK(IsDebugBreakSlot());
Isolate* isolate = debug_info_->GetIsolate();
rinfo().PatchCodeWithCall(
PatchCodeWithCall(
pc(), isolate->builtins()->Slot_DebugBreak()->entry(),
Assembler::kDebugBreakSlotLength - Assembler::kCallInstructionLength);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment