Index: src/x64/debug-x64.cc |
diff --git a/src/x64/debug-x64.cc b/src/x64/debug-x64.cc |
index d14588f1be9aa1fe5155af84a764db7925730c44..804dcd68835a8589adc114aa8f1e6b1d5d651d4f 100644 |
--- a/src/x64/debug-x64.cc |
+++ b/src/x64/debug-x64.cc |
@@ -14,62 +14,50 @@ |
namespace v8 { |
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 PatchCodeWithCall(Address pc, Address target, int guard_bytes) { |
- int code_size = Assembler::kCallSequenceLength + guard_bytes; |
+#define __ ACCESS_MASM(masm) |
- // Create a code patcher. |
- CodePatcher patcher(pc, code_size); |
-// Add a label for checking the size of the code used for returning. |
-#ifdef DEBUG |
+void EmitDebugBreakSlot(MacroAssembler* masm) { |
Label check_codesize; |
- patcher.masm()->bind(&check_codesize); |
-#endif |
- |
- // Patch the code. |
- patcher.masm()->movp(kScratchRegister, reinterpret_cast<void*>(target), |
- Assembler::RelocInfoNone()); |
- patcher.masm()->call(kScratchRegister); |
- |
- // Check that the size of the code generated is as expected. |
- DCHECK_EQ(Assembler::kCallSequenceLength, |
- patcher.masm()->SizeOfCodeGeneratedSince(&check_codesize)); |
+ __ bind(&check_codesize); |
+ __ Nop(Assembler::kDebugBreakSlotLength); |
+ DCHECK_EQ(Assembler::kDebugBreakSlotLength, |
+ masm->SizeOfCodeGeneratedSince(&check_codesize)); |
+} |
- // Add the requested number of int3 instructions after the call. |
- for (int i = 0; i < guard_bytes; i++) { |
- patcher.masm()->int3(); |
- } |
- CpuFeatures::FlushICache(pc, code_size); |
+void DebugCodegen::GenerateSlot(MacroAssembler* masm, RelocInfo::Mode mode, |
+ int call_argc) { |
+ // Generate enough nop's to make space for a call instruction. |
+ masm->RecordDebugBreakSlot(mode, call_argc); |
+ EmitDebugBreakSlot(masm); |
} |
-// Patch the JS frame exit code with a debug break call. See |
-// CodeGenerator::VisitReturnStatement and VirtualFrame::Exit in codegen-x64.cc |
-// for the precise return instructions sequence. |
-void BreakLocation::SetDebugBreakAtReturn() { |
- DCHECK(Assembler::kJSReturnSequenceLength >= Assembler::kCallSequenceLength); |
- PatchCodeWithCall( |
- pc(), debug_info_->GetIsolate()->builtins()->Return_DebugBreak()->entry(), |
- Assembler::kJSReturnSequenceLength - Assembler::kCallSequenceLength); |
+void DebugCodegen::ClearDebugBreakSlot(Address pc) { |
+ CodePatcher patcher(pc, Assembler::kDebugBreakSlotLength); |
+ EmitDebugBreakSlot(patcher.masm()); |
} |
-void BreakLocation::SetDebugBreakAtSlot() { |
- DCHECK(IsDebugBreakSlot()); |
- PatchCodeWithCall( |
- pc(), debug_info_->GetIsolate()->builtins()->Slot_DebugBreak()->entry(), |
- Assembler::kDebugBreakSlotLength - Assembler::kCallSequenceLength); |
+void DebugCodegen::PatchDebugBreakSlot(Address pc, Handle<Code> code) { |
+ DCHECK_EQ(Code::BUILTIN, code->kind()); |
+ static const int kSize = Assembler::kDebugBreakSlotLength; |
+ CodePatcher patcher(pc, kSize); |
+ Label check_codesize; |
+ patcher.masm()->bind(&check_codesize); |
+ patcher.masm()->movp(kScratchRegister, reinterpret_cast<void*>(code->entry()), |
+ Assembler::RelocInfoNone()); |
+ patcher.masm()->call(kScratchRegister); |
+ // Check that the size of the code generated is as expected. |
+ DCHECK_EQ(kSize, patcher.masm()->SizeOfCodeGeneratedSince(&check_codesize)); |
} |
-#define __ ACCESS_MASM(masm) |
- |
+void DebugCodegen::GenerateDebugBreakStub(MacroAssembler* masm, |
+ DebugBreakCallHelperMode mode) { |
+ __ RecordComment("Debug break"); |
-static void Generate_DebugBreakCallHelper(MacroAssembler* masm, |
- RegList object_regs) { |
// Enter an internal frame. |
{ |
FrameScope scope(masm, StackFrame::INTERNAL); |
@@ -80,40 +68,23 @@ static void Generate_DebugBreakCallHelper(MacroAssembler* masm, |
} |
__ Push(Smi::FromInt(LiveEdit::kFramePaddingInitialSize)); |
- // Store the registers containing live values on the expression stack to |
- // make sure that these are correctly updated during GC. Non object values |
- // are stored as as two smis causing it to be untouched by GC. |
- DCHECK((object_regs & ~kJSCallerSaved) == 0); |
- for (int i = 0; i < kNumJSCallerSaved; i++) { |
- int r = JSCallerSavedCode(i); |
- Register reg = { r }; |
- DCHECK(!reg.is(kScratchRegister)); |
- if ((object_regs & (1 << r)) != 0) { |
- __ Push(reg); |
- } |
- } |
+ if (mode == SAVE_RESULT_REGISTER) __ Push(rax); |
-#ifdef DEBUG |
- __ RecordComment("// Calling from debug break to runtime - come in - over"); |
-#endif |
__ Set(rax, 0); // No arguments (argc == 0). |
__ Move(rbx, ExternalReference::debug_break(masm->isolate())); |
CEntryStub ceb(masm->isolate(), 1); |
__ CallStub(&ceb); |
- // Restore the register values from the expression stack. |
- for (int i = kNumJSCallerSaved - 1; i >= 0; i--) { |
- int r = JSCallerSavedCode(i); |
- Register reg = { r }; |
- if (FLAG_debug_code) { |
+ if (FLAG_debug_code) { |
+ for (int i = 0; i < kNumJSCallerSaved; ++i) { |
+ Register reg = {JSCallerSavedCode(i)}; |
__ Set(reg, kDebugZapValue); |
} |
- if ((object_regs & (1 << r)) != 0) { |
- __ Pop(reg); |
- } |
} |
+ if (mode == SAVE_RESULT_REGISTER) __ Pop(rax); |
+ |
// Read current padding counter and skip corresponding number of words. |
__ Pop(kScratchRegister); |
__ SmiToInteger32(kScratchRegister, kScratchRegister); |
@@ -136,35 +107,6 @@ static void Generate_DebugBreakCallHelper(MacroAssembler* masm, |
} |
-void DebugCodegen::GenerateReturnDebugBreak(MacroAssembler* masm) { |
- // Register state just before return from JS function (from codegen-x64.cc). |
- // ----------- S t a t e ------------- |
- // -- rax: return value |
- // ----------------------------------- |
- Generate_DebugBreakCallHelper(masm, rax.bit()); |
-} |
- |
- |
-void DebugCodegen::GenerateSlot(MacroAssembler* masm, |
- DebugCodegen::SlotLocation location, |
- int call_argc) { |
- // Generate enough nop's to make space for a call instruction. |
- Label check_codesize; |
- __ bind(&check_codesize); |
- RecordRelocInfo(masm, location, call_argc); |
- __ Nop(Assembler::kDebugBreakSlotLength); |
- DCHECK_EQ(Assembler::kDebugBreakSlotLength, |
- masm->SizeOfCodeGeneratedSince(&check_codesize)); |
-} |
- |
- |
-void DebugCodegen::GenerateSlotDebugBreak(MacroAssembler* masm) { |
- // In the places where a debug break slot is inserted no registers can contain |
- // object pointers. |
- Generate_DebugBreakCallHelper(masm, 0); |
-} |
- |
- |
void DebugCodegen::GeneratePlainReturnLiveEdit(MacroAssembler* masm) { |
masm->ret(0); |
} |