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

Side by Side Diff: src/arm64/debug-arm64.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/arm64/builtins-arm64.cc ('k') | src/arm64/macro-assembler-arm64.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 2013 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_ARM64
8
9 #include "src/codegen.h"
10 #include "src/debug.h"
11
12 namespace v8 {
13 namespace internal {
14
15 #define __ ACCESS_MASM(masm)
16
17
18 void EmitDebugBreakSlot(Assembler* masm) {
19 Label check_size;
20 __ bind(&check_size);
21 for (int i = 0; i < Assembler::kDebugBreakSlotInstructions; i++) {
22 __ nop(Assembler::DEBUG_BREAK_NOP);
23 }
24 DCHECK_EQ(Assembler::kDebugBreakSlotInstructions,
25 static_cast<int>(masm->InstructionsGeneratedSince(&check_size)));
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. Avoid emitting
32 // the constant pool in the debug break slot code.
33 InstructionAccurateScope scope(masm, Assembler::kDebugBreakSlotInstructions);
34 masm->RecordDebugBreakSlot(mode, call_argc);
35 EmitDebugBreakSlot(masm);
36 }
37
38
39 void DebugCodegen::ClearDebugBreakSlot(Address pc) {
40 PatchingAssembler patcher(reinterpret_cast<Instruction*>(pc),
41 Assembler::kDebugBreakSlotInstructions);
42 EmitDebugBreakSlot(&patcher);
43 }
44
45
46 void DebugCodegen::PatchDebugBreakSlot(Address pc, Handle<Code> code) {
47 DCHECK_EQ(Code::BUILTIN, code->kind());
48 PatchingAssembler patcher(reinterpret_cast<Instruction*>(pc),
49 Assembler::kDebugBreakSlotInstructions);
50 // Patch the code emitted by DebugCodegen::GenerateSlots, changing the debug
51 // break slot code from
52 // mov x0, x0 @ nop DEBUG_BREAK_NOP
53 // mov x0, x0 @ nop DEBUG_BREAK_NOP
54 // mov x0, x0 @ nop DEBUG_BREAK_NOP
55 // mov x0, x0 @ nop DEBUG_BREAK_NOP
56 // mov x0, x0 @ nop DEBUG_BREAK_NOP
57 // to a call to the debug slot code.
58 // ldr ip0, [pc, #(2 * kInstructionSize)]
59 // blr ip0
60 // b skip
61 // <debug break slot code entry point address (64 bits)>
62 // skip:
63
64 Label skip_constant;
65 // The first instruction of a patched debug break slot must be a load literal
66 // loading the address of the debug break slot code.
67 patcher.ldr_pcrel(ip0, (2 * kInstructionSize) >> kLoadLiteralScaleLog2);
68 patcher.b(&skip_constant);
69 patcher.dc64(reinterpret_cast<int64_t>(code->entry()));
70 patcher.bind(&skip_constant);
71 // TODO(all): check the following is correct.
72 // The debug break slot code will push a frame and call statically compiled
73 // code. By using blr, this call site will be registered in the frame.
74 // The debugger can now iterate on the frames to find this call.
75 patcher.blr(ip0);
76 }
77
78
79 void DebugCodegen::GenerateDebugBreakStub(MacroAssembler* masm,
80 DebugBreakCallHelperMode mode) {
81 __ RecordComment("Debug break");
82 Register scratch = x10;
83 {
84 FrameScope scope(masm, StackFrame::INTERNAL);
85
86 // Load padding words on stack.
87 __ Mov(scratch, Smi::FromInt(LiveEdit::kFramePaddingValue));
88 __ PushMultipleTimes(scratch, LiveEdit::kFramePaddingInitialSize);
89 __ Mov(scratch, Smi::FromInt(LiveEdit::kFramePaddingInitialSize));
90 __ Push(scratch);
91
92 if (mode == SAVE_RESULT_REGISTER) __ Push(x0);
93
94 __ Mov(x0, 0); // No arguments.
95 __ Mov(x1, ExternalReference(Runtime::FunctionForId(Runtime::kDebugBreak),
96 masm->isolate()));
97
98 CEntryStub stub(masm->isolate(), 1);
99 __ CallStub(&stub);
100
101 if (FLAG_debug_code) {
102 for (int i = 0; i < kNumJSCallerSaved; i++) {
103 Register reg = Register::XRegFromCode(JSCallerSavedCode(i));
104 __ Mov(reg, Operand(kDebugZapValue));
105 }
106 }
107
108 // Restore the register values from the expression stack.
109 if (mode == SAVE_RESULT_REGISTER) __ Pop(x0);
110
111 // Don't bother removing padding bytes pushed on the stack
112 // as the frame is going to be restored right away.
113
114 // Leave the internal frame.
115 }
116
117 // Now that the break point has been handled, resume normal execution by
118 // jumping to the target address intended by the caller and that was
119 // overwritten by the address of DebugBreakXXX.
120 ExternalReference after_break_target =
121 ExternalReference::debug_after_break_target_address(masm->isolate());
122 __ Mov(scratch, after_break_target);
123 __ Ldr(scratch, MemOperand(scratch));
124 __ Br(scratch);
125 }
126
127
128 void DebugCodegen::GeneratePlainReturnLiveEdit(MacroAssembler* masm) {
129 __ Ret();
130 }
131
132
133 void DebugCodegen::GenerateFrameDropperLiveEdit(MacroAssembler* masm) {
134 ExternalReference restarter_frame_function_slot =
135 ExternalReference::debug_restarter_frame_function_pointer_address(
136 masm->isolate());
137 UseScratchRegisterScope temps(masm);
138 Register scratch = temps.AcquireX();
139
140 __ Mov(scratch, restarter_frame_function_slot);
141 __ Str(xzr, MemOperand(scratch));
142
143 // We do not know our frame height, but set sp based on fp.
144 __ Sub(masm->StackPointer(), fp, kPointerSize);
145 __ AssertStackConsistency();
146
147 __ Pop(x1, fp, lr); // Function, Frame, Return address.
148
149 // Load context from the function.
150 __ Ldr(cp, FieldMemOperand(x1, JSFunction::kContextOffset));
151
152 // Get function code.
153 __ Ldr(scratch, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset));
154 __ Ldr(scratch, FieldMemOperand(scratch, SharedFunctionInfo::kCodeOffset));
155 __ Add(scratch, scratch, Code::kHeaderSize - kHeapObjectTag);
156
157 // Re-run JSFunction, x1 is function, cp is context.
158 __ Br(scratch);
159 }
160
161
162 const bool LiveEdit::kFrameDropperSupported = true;
163
164 } // namespace internal
165 } // namespace v8
166
167 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « src/arm64/builtins-arm64.cc ('k') | src/arm64/macro-assembler-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698