Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(776)

Side by Side Diff: src/x64/debug-x64.cc

Issue 1265923002: Debugger: move implementation to a separate folder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/x64/assembler-x64-inl.h ('k') | src/x64/macro-assembler-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/v8.h"
6
7 #if V8_TARGET_ARCH_X64
8
9 #include "src/assembler.h"
10 #include "src/codegen.h"
11 #include "src/debug.h"
12
13
14 namespace v8 {
15 namespace internal {
16
17 #define __ ACCESS_MASM(masm)
18
19
20 void EmitDebugBreakSlot(MacroAssembler* masm) {
21 Label check_codesize;
22 __ bind(&check_codesize);
23 __ Nop(Assembler::kDebugBreakSlotLength);
24 DCHECK_EQ(Assembler::kDebugBreakSlotLength,
25 masm->SizeOfCodeGeneratedSince(&check_codesize));
26 }
27
28
29 void DebugCodegen::GenerateSlot(MacroAssembler* masm, RelocInfo::Mode mode,
30 int call_argc) {
31 // Generate enough nop's to make space for a call instruction.
32 masm->RecordDebugBreakSlot(mode, call_argc);
33 EmitDebugBreakSlot(masm);
34 }
35
36
37 void DebugCodegen::ClearDebugBreakSlot(Address pc) {
38 CodePatcher patcher(pc, Assembler::kDebugBreakSlotLength);
39 EmitDebugBreakSlot(patcher.masm());
40 }
41
42
43 void DebugCodegen::PatchDebugBreakSlot(Address pc, Handle<Code> code) {
44 DCHECK_EQ(Code::BUILTIN, code->kind());
45 static const int kSize = Assembler::kDebugBreakSlotLength;
46 CodePatcher patcher(pc, kSize);
47 Label check_codesize;
48 patcher.masm()->bind(&check_codesize);
49 patcher.masm()->movp(kScratchRegister, reinterpret_cast<void*>(code->entry()),
50 Assembler::RelocInfoNone());
51 patcher.masm()->call(kScratchRegister);
52 // Check that the size of the code generated is as expected.
53 DCHECK_EQ(kSize, patcher.masm()->SizeOfCodeGeneratedSince(&check_codesize));
54 }
55
56
57 void DebugCodegen::GenerateDebugBreakStub(MacroAssembler* masm,
58 DebugBreakCallHelperMode mode) {
59 __ RecordComment("Debug break");
60
61 // Enter an internal frame.
62 {
63 FrameScope scope(masm, StackFrame::INTERNAL);
64
65 // Load padding words on stack.
66 for (int i = 0; i < LiveEdit::kFramePaddingInitialSize; i++) {
67 __ Push(Smi::FromInt(LiveEdit::kFramePaddingValue));
68 }
69 __ Push(Smi::FromInt(LiveEdit::kFramePaddingInitialSize));
70
71 if (mode == SAVE_RESULT_REGISTER) __ Push(rax);
72
73 __ Set(rax, 0); // No arguments (argc == 0).
74 __ Move(rbx, ExternalReference(Runtime::FunctionForId(Runtime::kDebugBreak),
75 masm->isolate()));
76
77 CEntryStub ceb(masm->isolate(), 1);
78 __ CallStub(&ceb);
79
80 if (FLAG_debug_code) {
81 for (int i = 0; i < kNumJSCallerSaved; ++i) {
82 Register reg = {JSCallerSavedCode(i)};
83 __ Set(reg, kDebugZapValue);
84 }
85 }
86
87 if (mode == SAVE_RESULT_REGISTER) __ Pop(rax);
88
89 // Read current padding counter and skip corresponding number of words.
90 __ Pop(kScratchRegister);
91 __ SmiToInteger32(kScratchRegister, kScratchRegister);
92 __ leap(rsp, Operand(rsp, kScratchRegister, times_pointer_size, 0));
93
94 // Get rid of the internal frame.
95 }
96
97 // This call did not replace a call , so there will be an unwanted
98 // return address left on the stack. Here we get rid of that.
99 __ addp(rsp, Immediate(kPCOnStackSize));
100
101 // Now that the break point has been handled, resume normal execution by
102 // jumping to the target address intended by the caller and that was
103 // overwritten by the address of DebugBreakXXX.
104 ExternalReference after_break_target =
105 ExternalReference::debug_after_break_target_address(masm->isolate());
106 __ Move(kScratchRegister, after_break_target);
107 __ Jump(Operand(kScratchRegister, 0));
108 }
109
110
111 void DebugCodegen::GeneratePlainReturnLiveEdit(MacroAssembler* masm) {
112 masm->ret(0);
113 }
114
115
116 void DebugCodegen::GenerateFrameDropperLiveEdit(MacroAssembler* masm) {
117 ExternalReference restarter_frame_function_slot =
118 ExternalReference::debug_restarter_frame_function_pointer_address(
119 masm->isolate());
120 __ Move(rax, restarter_frame_function_slot);
121 __ movp(Operand(rax, 0), Immediate(0));
122
123 // We do not know our frame height, but set rsp based on rbp.
124 __ leap(rsp, Operand(rbp, -1 * kPointerSize));
125
126 __ Pop(rdi); // Function.
127 __ popq(rbp);
128
129 // Load context from the function.
130 __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
131
132 // Get function code.
133 __ movp(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
134 __ movp(rdx, FieldOperand(rdx, SharedFunctionInfo::kCodeOffset));
135 __ leap(rdx, FieldOperand(rdx, Code::kHeaderSize));
136
137 // Re-run JSFunction, rdi is function, rsi is context.
138 __ jmp(rdx);
139 }
140
141 const bool LiveEdit::kFrameDropperSupported = true;
142
143 #undef __
144
145 } // namespace internal
146 } // namespace v8
147
148 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/assembler-x64-inl.h ('k') | src/x64/macro-assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698