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

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

Issue 967323002: Refactor BreakLocationIterator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: static_cast instead Created 5 years, 9 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/assembler-arm64-inl.h ('k') | src/arm64/full-codegen-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
1 // Copyright 2013 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_ARM64 7 #if V8_TARGET_ARCH_ARM64
8 8
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/debug.h" 10 #include "src/debug.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 14
15 15
16 #define __ ACCESS_MASM(masm) 16 #define __ ACCESS_MASM(masm)
17 17
18 bool BreakLocationIterator::IsDebugBreakAtReturn() {
19 return Debug::IsDebugBreakAtReturn(rinfo());
20 }
21 18
22 19 void BreakLocation::SetDebugBreakAtReturn() {
23 void BreakLocationIterator::SetDebugBreakAtReturn() {
24 // Patch the code emitted by FullCodeGenerator::EmitReturnSequence, changing 20 // Patch the code emitted by FullCodeGenerator::EmitReturnSequence, changing
25 // the return from JS function sequence from 21 // the return from JS function sequence from
26 // mov sp, fp 22 // mov sp, fp
27 // ldp fp, lr, [sp] #16 23 // ldp fp, lr, [sp] #16
28 // lrd ip0, [pc, #(3 * kInstructionSize)] 24 // lrd ip0, [pc, #(3 * kInstructionSize)]
29 // add sp, sp, ip0 25 // add sp, sp, ip0
30 // ret 26 // ret
31 // <number of paramters ... 27 // <number of paramters ...
32 // ... plus one (64 bits)> 28 // ... plus one (64 bits)>
33 // to a call to the debug break return code. 29 // to a call to the debug break return code.
34 // ldr ip0, [pc, #(3 * kInstructionSize)] 30 // ldr ip0, [pc, #(3 * kInstructionSize)]
35 // blr ip0 31 // blr ip0
36 // hlt kHltBadCode @ code should not return, catch if it does. 32 // hlt kHltBadCode @ code should not return, catch if it does.
37 // <debug break return code ... 33 // <debug break return code ...
38 // ... entry point address (64 bits)> 34 // ... entry point address (64 bits)>
39 35
40 // The patching code must not overflow the space occupied by the return 36 // The patching code must not overflow the space occupied by the return
41 // sequence. 37 // sequence.
42 STATIC_ASSERT(Assembler::kJSRetSequenceInstructions >= 5); 38 STATIC_ASSERT(Assembler::kJSReturnSequenceInstructions >= 5);
43 PatchingAssembler patcher(reinterpret_cast<Instruction*>(rinfo()->pc()), 5); 39 PatchingAssembler patcher(reinterpret_cast<Instruction*>(pc()), 5);
44 byte* entry = 40 byte* entry =
45 debug_info_->GetIsolate()->builtins()->Return_DebugBreak()->entry(); 41 debug_info_->GetIsolate()->builtins()->Return_DebugBreak()->entry();
46 42
47 // The first instruction of a patched return sequence must be a load literal 43 // The first instruction of a patched return sequence must be a load literal
48 // loading the address of the debug break return code. 44 // loading the address of the debug break return code.
49 patcher.ldr_pcrel(ip0, (3 * kInstructionSize) >> kLoadLiteralScaleLog2); 45 patcher.ldr_pcrel(ip0, (3 * kInstructionSize) >> kLoadLiteralScaleLog2);
50 // TODO(all): check the following is correct. 46 // TODO(all): check the following is correct.
51 // The debug break return code will push a frame and call statically compiled 47 // The debug break return code will push a frame and call statically compiled
52 // code. By using blr, even though control will not return after the branch, 48 // code. By using blr, even though control will not return after the branch,
53 // this call site will be registered in the frame (lr being saved as the pc 49 // this call site will be registered in the frame (lr being saved as the pc
54 // of the next instruction to execute for this frame). The debugger can now 50 // of the next instruction to execute for this frame). The debugger can now
55 // iterate on the frames to find call to debug break return code. 51 // iterate on the frames to find call to debug break return code.
56 patcher.blr(ip0); 52 patcher.blr(ip0);
57 patcher.hlt(kHltBadCode); 53 patcher.hlt(kHltBadCode);
58 patcher.dc64(reinterpret_cast<int64_t>(entry)); 54 patcher.dc64(reinterpret_cast<int64_t>(entry));
59 } 55 }
60 56
61 57
62 void BreakLocationIterator::ClearDebugBreakAtReturn() { 58 void BreakLocation::SetDebugBreakAtSlot() {
63 // Reset the code emitted by EmitReturnSequence to its original state.
64 rinfo()->PatchCode(original_rinfo()->pc(),
65 Assembler::kJSRetSequenceInstructions);
66 }
67
68
69 bool Debug::IsDebugBreakAtReturn(RelocInfo* rinfo) {
70 DCHECK(RelocInfo::IsJSReturn(rinfo->rmode()));
71 return rinfo->IsPatchedReturnSequence();
72 }
73
74
75 bool BreakLocationIterator::IsDebugBreakAtSlot() {
76 DCHECK(IsDebugBreakSlot());
77 // Check whether the debug break slot instructions have been patched.
78 return rinfo()->IsPatchedDebugBreakSlotSequence();
79 }
80
81
82 void BreakLocationIterator::SetDebugBreakAtSlot() {
83 // Patch the code emitted by DebugCodegen::GenerateSlots, changing the debug 59 // Patch the code emitted by DebugCodegen::GenerateSlots, changing the debug
84 // break slot code from 60 // break slot code from
85 // mov x0, x0 @ nop DEBUG_BREAK_NOP 61 // mov x0, x0 @ nop DEBUG_BREAK_NOP
86 // mov x0, x0 @ nop DEBUG_BREAK_NOP 62 // mov x0, x0 @ nop DEBUG_BREAK_NOP
87 // mov x0, x0 @ nop DEBUG_BREAK_NOP 63 // mov x0, x0 @ nop DEBUG_BREAK_NOP
88 // mov x0, x0 @ nop DEBUG_BREAK_NOP 64 // mov x0, x0 @ nop DEBUG_BREAK_NOP
89 // to a call to the debug slot code. 65 // to a call to the debug slot code.
90 // ldr ip0, [pc, #(2 * kInstructionSize)] 66 // ldr ip0, [pc, #(2 * kInstructionSize)]
91 // blr ip0 67 // blr ip0
92 // <debug break slot code ... 68 // <debug break slot code ...
93 // ... entry point address (64 bits)> 69 // ... entry point address (64 bits)>
94 70
95 // TODO(all): consider adding a hlt instruction after the blr as we don't 71 // TODO(all): consider adding a hlt instruction after the blr as we don't
96 // expect control to return here. This implies increasing 72 // expect control to return here. This implies increasing
97 // kDebugBreakSlotInstructions to 5 instructions. 73 // kDebugBreakSlotInstructions to 5 instructions.
98 74
99 // The patching code must not overflow the space occupied by the return 75 // The patching code must not overflow the space occupied by the return
100 // sequence. 76 // sequence.
101 STATIC_ASSERT(Assembler::kDebugBreakSlotInstructions >= 4); 77 STATIC_ASSERT(Assembler::kDebugBreakSlotInstructions >= 4);
102 PatchingAssembler patcher(reinterpret_cast<Instruction*>(rinfo()->pc()), 4); 78 PatchingAssembler patcher(reinterpret_cast<Instruction*>(pc()), 4);
103 byte* entry = 79 byte* entry =
104 debug_info_->GetIsolate()->builtins()->Slot_DebugBreak()->entry(); 80 debug_info_->GetIsolate()->builtins()->Slot_DebugBreak()->entry();
105 81
106 // The first instruction of a patched debug break slot must be a load literal 82 // The first instruction of a patched debug break slot must be a load literal
107 // loading the address of the debug break slot code. 83 // loading the address of the debug break slot code.
108 patcher.ldr_pcrel(ip0, (2 * kInstructionSize) >> kLoadLiteralScaleLog2); 84 patcher.ldr_pcrel(ip0, (2 * kInstructionSize) >> kLoadLiteralScaleLog2);
109 // TODO(all): check the following is correct. 85 // TODO(all): check the following is correct.
110 // The debug break slot code will push a frame and call statically compiled 86 // The debug break slot code will push a frame and call statically compiled
111 // code. By using blr, event hough control will not return after the branch, 87 // code. By using blr, event hough control will not return after the branch,
112 // this call site will be registered in the frame (lr being saved as the pc 88 // this call site will be registered in the frame (lr being saved as the pc
113 // of the next instruction to execute for this frame). The debugger can now 89 // of the next instruction to execute for this frame). The debugger can now
114 // iterate on the frames to find call to debug break slot code. 90 // iterate on the frames to find call to debug break slot code.
115 patcher.blr(ip0); 91 patcher.blr(ip0);
116 patcher.dc64(reinterpret_cast<int64_t>(entry)); 92 patcher.dc64(reinterpret_cast<int64_t>(entry));
117 } 93 }
118 94
119 95
120 void BreakLocationIterator::ClearDebugBreakAtSlot() {
121 DCHECK(IsDebugBreakSlot());
122 rinfo()->PatchCode(original_rinfo()->pc(),
123 Assembler::kDebugBreakSlotInstructions);
124 }
125
126
127 static void Generate_DebugBreakCallHelper(MacroAssembler* masm, 96 static void Generate_DebugBreakCallHelper(MacroAssembler* masm,
128 RegList object_regs, 97 RegList object_regs,
129 RegList non_object_regs, 98 RegList non_object_regs,
130 Register scratch) { 99 Register scratch) {
131 { 100 {
132 FrameScope scope(masm, StackFrame::INTERNAL); 101 FrameScope scope(masm, StackFrame::INTERNAL);
133 102
134 // Load padding words on stack. 103 // Load padding words on stack.
135 __ Mov(scratch, Smi::FromInt(LiveEdit::kFramePaddingValue)); 104 __ Mov(scratch, Smi::FromInt(LiveEdit::kFramePaddingValue));
136 __ PushMultipleTimes(scratch, LiveEdit::kFramePaddingInitialSize); 105 __ PushMultipleTimes(scratch, LiveEdit::kFramePaddingInitialSize);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 // Re-run JSFunction, x1 is function, cp is context. 342 // Re-run JSFunction, x1 is function, cp is context.
374 __ Br(scratch); 343 __ Br(scratch);
375 } 344 }
376 345
377 346
378 const bool LiveEdit::kFrameDropperSupported = true; 347 const bool LiveEdit::kFrameDropperSupported = true;
379 348
380 } } // namespace v8::internal 349 } } // namespace v8::internal
381 350
382 #endif // V8_TARGET_ARCH_ARM64 351 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « src/arm64/assembler-arm64-inl.h ('k') | src/arm64/full-codegen-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698