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

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

Issue 144963003: A64: add missing files. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « src/a64/cpu-a64.cc ('k') | src/a64/debugger-a64.h » ('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 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 #include "v8.h"
29
30 #if defined(V8_TARGET_ARCH_A64)
31
32 #include "codegen.h"
33 #include "debug.h"
34
35 namespace v8 {
36 namespace internal {
37
38
39 #define __ ACCESS_MASM(masm)
40
41
42 #ifdef ENABLE_DEBUGGER_SUPPORT
43 bool BreakLocationIterator::IsDebugBreakAtReturn() {
44 return Debug::IsDebugBreakAtReturn(rinfo());
45 }
46
47
48 void BreakLocationIterator::SetDebugBreakAtReturn() {
49 // Patch the code emitted by FullCodeGenerator::EmitReturnSequence, changing
50 // the return from JS function sequence from
51 // mov sp, fp
52 // ldp fp, lr, [sp] #16
53 // lrd ip0, [pc, #(3 * kInstructionSize)]
54 // add sp, sp, ip0
55 // ret
56 // <number of paramters ...
57 // ... plus one (64 bits)>
58 // to a call to the debug break return code.
59 // ldr ip0, [pc, #(3 * kInstructionSize)]
60 // blr ip0
61 // hlt kHltBadCode @ code should not return, catch if it does.
62 // <debug break return code ...
63 // ... entry point address (64 bits)>
64
65 // The patching code must not overflow the space occupied by the return
66 // sequence.
67 STATIC_ASSERT(Assembler::kJSRetSequenceInstructions >= 5);
68 PatchingAssembler patcher(reinterpret_cast<Instruction*>(rinfo()->pc()), 5);
69 byte* entry = Isolate::Current()->debug()->debug_break_return()->entry();
70
71 // The first instruction of a patched return sequence must be a load literal
72 // loading the address of the debug break return code.
73 patcher.LoadLiteral(ip0, 3 * kInstructionSize);
74 // TODO(all): check the following is correct.
75 // The debug break return code will push a frame and call statically compiled
76 // code. By using blr, even though control will not return after the branch,
77 // this call site will be registered in the frame (lr being saved as the pc
78 // of the next instruction to execute for this frame). The debugger can now
79 // iterate on the frames to find call to debug break return code.
80 patcher.blr(ip0);
81 patcher.hlt(kHltBadCode);
82 patcher.dc64(reinterpret_cast<int64_t>(entry));
83 }
84
85
86 void BreakLocationIterator::ClearDebugBreakAtReturn() {
87 // Reset the code emitted by EmitReturnSequence to its original state.
88 rinfo()->PatchCode(original_rinfo()->pc(),
89 Assembler::kJSRetSequenceInstructions);
90 }
91
92
93 bool Debug::IsDebugBreakAtReturn(RelocInfo* rinfo) {
94 ASSERT(RelocInfo::IsJSReturn(rinfo->rmode()));
95 return rinfo->IsPatchedReturnSequence();
96 }
97
98
99 bool BreakLocationIterator::IsDebugBreakAtSlot() {
100 ASSERT(IsDebugBreakSlot());
101 // Check whether the debug break slot instructions have been patched.
102 return rinfo()->IsPatchedDebugBreakSlotSequence();
103 }
104
105
106 void BreakLocationIterator::SetDebugBreakAtSlot() {
107 // Patch the code emitted by Debug::GenerateSlots, changing the debug break
108 // slot code from
109 // mov x0, x0 @ nop DEBUG_BREAK_NOP
110 // mov x0, x0 @ nop DEBUG_BREAK_NOP
111 // mov x0, x0 @ nop DEBUG_BREAK_NOP
112 // mov x0, x0 @ nop DEBUG_BREAK_NOP
113 // to a call to the debug slot code.
114 // ldr ip0, [pc, #(2 * kInstructionSize)]
115 // blr ip0
116 // <debug break slot code ...
117 // ... entry point address (64 bits)>
118
119 // TODO(all): consider adding a hlt instruction after the blr as we don't
120 // expect control to return here. This implies increasing
121 // kDebugBreakSlotInstructions to 5 instructions.
122
123 // The patching code must not overflow the space occupied by the return
124 // sequence.
125 STATIC_ASSERT(Assembler::kDebugBreakSlotInstructions >= 4);
126 PatchingAssembler patcher(reinterpret_cast<Instruction*>(rinfo()->pc()), 4);
127 byte* entry = Isolate::Current()->debug()->debug_break_slot()->entry();
128
129 // The first instruction of a patched debug break slot must be a load literal
130 // loading the address of the debug break slot code.
131 patcher.LoadLiteral(ip0, 2 * kInstructionSize);
132 // TODO(all): check the following is correct.
133 // The debug break slot code will push a frame and call statically compiled
134 // code. By using blr, event hough control will not return after the branch,
135 // this call site will be registered in the frame (lr being saved as the pc
136 // of the next instruction to execute for this frame). The debugger can now
137 // iterate on the frames to find call to debug break slot code.
138 patcher.blr(ip0);
139 patcher.dc64(reinterpret_cast<int64_t>(entry));
140 }
141
142
143 void BreakLocationIterator::ClearDebugBreakAtSlot() {
144 ASSERT(IsDebugBreakSlot());
145 rinfo()->PatchCode(original_rinfo()->pc(),
146 Assembler::kDebugBreakSlotInstructions);
147 }
148
149 const bool Debug::FramePaddingLayout::kIsSupported = false;
150
151 static void Generate_DebugBreakCallHelper(MacroAssembler* masm,
152 RegList object_regs,
153 RegList non_object_regs,
154 Register scratch) {
155 {
156 FrameScope scope(masm, StackFrame::INTERNAL);
157
158 // Any live values (object_regs and non_object_regs) in caller-saved
159 // registers (or lr) need to be stored on the stack so that their values are
160 // safely preserved for a call into C code.
161 //
162 // Also:
163 // * object_regs may be modified during the C code by the garbage
164 // collector. Every object register must be a valid tagged pointer or
165 // SMI.
166 //
167 // * non_object_regs will be converted to SMIs so that the garbage
168 // collector doesn't try to interpret them as pointers.
169 //
170 // TODO(jbramley): Why can't this handle callee-saved registers?
171 ASSERT((~kCallerSaved.list() & object_regs) == 0);
172 ASSERT((~kCallerSaved.list() & non_object_regs) == 0);
173 ASSERT((object_regs & non_object_regs) == 0);
174 ASSERT((scratch.Bit() & object_regs) == 0);
175 ASSERT((scratch.Bit() & non_object_regs) == 0);
176 ASSERT((ip0.Bit() & (object_regs | non_object_regs)) == 0);
177 ASSERT((ip1.Bit() & (object_regs | non_object_regs)) == 0);
178 STATIC_ASSERT(kSmiValueSize == 32);
179
180 CPURegList non_object_list =
181 CPURegList(CPURegister::kRegister, kXRegSize, non_object_regs);
182 while (!non_object_list.IsEmpty()) {
183 // Store each non-object register as two SMIs.
184 Register reg(non_object_list.PopLowestIndex());
185 __ Push(reg);
186 __ Poke(wzr, 0);
187 __ Push(reg.W(), wzr);
188 // Stack:
189 // jssp[12]: reg[63:32]
190 // jssp[8]: 0x00000000 (SMI tag & padding)
191 // jssp[4]: reg[31:0]
192 // jssp[0]: 0x00000000 (SMI tag & padding)
193 STATIC_ASSERT((kSmiTag == 0) && (kSmiShift == 32));
194 }
195
196 if (object_regs != 0) {
197 __ PushXRegList(object_regs);
198 }
199
200 #ifdef DEBUG
201 __ RecordComment("// Calling from debug break to runtime - come in - over");
202 #endif
203 __ Mov(x0, 0); // No arguments.
204 __ Mov(x1, Operand(ExternalReference::debug_break(masm->isolate())));
205
206 CEntryStub stub(1);
207 __ CallStub(&stub);
208
209 // Restore the register values from the expression stack.
210 if (object_regs != 0) {
211 __ PopXRegList(object_regs);
212 }
213
214 non_object_list =
215 CPURegList(CPURegister::kRegister, kXRegSize, non_object_regs);
216 while (!non_object_list.IsEmpty()) {
217 // Load each non-object register from two SMIs.
218 // Stack:
219 // jssp[12]: reg[63:32]
220 // jssp[8]: 0x00000000 (SMI tag & padding)
221 // jssp[4]: reg[31:0]
222 // jssp[0]: 0x00000000 (SMI tag & padding)
223 Register reg(non_object_list.PopHighestIndex());
224 __ Pop(scratch, reg);
225 __ Bfxil(reg, scratch, 32, 32);
226 }
227
228 // Leave the internal frame.
229 }
230
231 // Now that the break point has been handled, resume normal execution by
232 // jumping to the target address intended by the caller and that was
233 // overwritten by the address of DebugBreakXXX.
234 ExternalReference after_break_target(Debug_Address::AfterBreakTarget(),
235 masm->isolate());
236 __ Mov(scratch, Operand(after_break_target));
237 __ Ldr(scratch, MemOperand(scratch));
238 __ Br(scratch);
239 }
240
241
242 void Debug::GenerateLoadICDebugBreak(MacroAssembler* masm) {
243 // Calling convention for IC load (from ic-arm.cc).
244 // ----------- S t a t e -------------
245 // -- x2 : name
246 // -- lr : return address
247 // -- x0 : receiver
248 // -- [sp] : receiver
249 // -----------------------------------
250 // Registers x0 and x2 contain objects that need to be pushed on the
251 // expression stack of the fake JS frame.
252 Generate_DebugBreakCallHelper(masm, x0.Bit() | x2.Bit(), 0, x10);
253 }
254
255
256 void Debug::GenerateStoreICDebugBreak(MacroAssembler* masm) {
257 // Calling convention for IC store (from ic-arm.cc).
258 // ----------- S t a t e -------------
259 // -- x0 : value
260 // -- x1 : receiver
261 // -- x2 : name
262 // -- lr : return address
263 // -----------------------------------
264 // Registers x0, x1, and x2 contain objects that need to be pushed on the
265 // expression stack of the fake JS frame.
266 Generate_DebugBreakCallHelper(masm, x0.Bit() | x1.Bit() | x2.Bit(), 0, x10);
267 }
268
269
270 void Debug::GenerateKeyedLoadICDebugBreak(MacroAssembler* masm) {
271 // ---------- S t a t e --------------
272 // -- lr : return address
273 // -- x0 : key
274 // -- x1 : receiver
275 Generate_DebugBreakCallHelper(masm, x0.Bit() | x1.Bit(), 0, x10);
276 }
277
278
279 void Debug::GenerateKeyedStoreICDebugBreak(MacroAssembler* masm) {
280 // ---------- S t a t e --------------
281 // -- x0 : value
282 // -- x1 : key
283 // -- x2 : receiver
284 // -- lr : return address
285 Generate_DebugBreakCallHelper(masm, x0.Bit() | x1.Bit() | x2.Bit(), 0, x10);
286 }
287
288
289 void Debug::GenerateCompareNilICDebugBreak(MacroAssembler* masm) {
290 // Register state for CompareNil IC
291 // ----------- S t a t e -------------
292 // -- r0 : value
293 // -----------------------------------
294 Generate_DebugBreakCallHelper(masm, x0.Bit(), 0, x10);
295 }
296
297
298 void Debug::GenerateCallICDebugBreak(MacroAssembler* masm) {
299 // Calling convention for IC call (from ic-arm.cc)
300 // ----------- S t a t e -------------
301 // -- x2 : name
302 // -----------------------------------
303 Generate_DebugBreakCallHelper(masm, x2.Bit(), 0, x10);
304 }
305
306
307 void Debug::GenerateReturnDebugBreak(MacroAssembler* masm) {
308 // In places other than IC call sites it is expected that r0 is TOS which
309 // is an object - this is not generally the case so this should be used with
310 // care.
311 Generate_DebugBreakCallHelper(masm, x0.Bit(), 0, x10);
312 }
313
314
315 void Debug::GenerateCallFunctionStubDebugBreak(MacroAssembler* masm) {
316 // Register state for CallFunctionStub (from code-stubs-a64.cc).
317 // ----------- S t a t e -------------
318 // -- x1 : function
319 // -----------------------------------
320 Generate_DebugBreakCallHelper(masm, x1.Bit(), 0, x10);
321 }
322
323
324 void Debug::GenerateCallFunctionStubRecordDebugBreak(MacroAssembler* masm) {
325 // Register state for CallFunctionStub (from code-stubs-a64.cc).
326 // ----------- S t a t e -------------
327 // -- x1 : function
328 // -- x2 : cache cell for call target
329 // -----------------------------------
330 Generate_DebugBreakCallHelper(masm, x1.Bit() | x2.Bit(), 0, x10);
331 }
332
333
334 void Debug::GenerateCallConstructStubDebugBreak(MacroAssembler* masm) {
335 // Calling convention for CallConstructStub (from code-stubs-a64.cc).
336 // ----------- S t a t e -------------
337 // -- x0 : number of arguments (not smi)
338 // -- x1 : constructor function
339 // -----------------------------------
340 Generate_DebugBreakCallHelper(masm, x1.Bit(), x0.Bit(), x10);
341 }
342
343
344 void Debug::GenerateCallConstructStubRecordDebugBreak(MacroAssembler* masm) {
345 // Calling convention for CallConstructStub (from code-stubs-a64.cc).
346 // ----------- S t a t e -------------
347 // -- x0 : number of arguments (not smi)
348 // -- x1 : constructor function
349 // -- x2 : cache cell for call target
350 // -----------------------------------
351 Generate_DebugBreakCallHelper(masm, x1.Bit() | x2.Bit(), x0.Bit(), x10);
352 }
353
354
355 void Debug::GenerateSlot(MacroAssembler* masm) {
356 // Generate enough nop's to make space for a call instruction. Avoid emitting
357 // the constant pool in the debug break slot code.
358 InstructionAccurateScope scope(masm, Assembler::kDebugBreakSlotInstructions);
359
360 __ RecordDebugBreakSlot();
361 for (int i = 0; i < Assembler::kDebugBreakSlotInstructions; i++) {
362 __ nop(Assembler::DEBUG_BREAK_NOP);
363 }
364 }
365
366
367 void Debug::GenerateSlotDebugBreak(MacroAssembler* masm) {
368 // In the places where a debug break slot is inserted no registers can contain
369 // object pointers.
370 Generate_DebugBreakCallHelper(masm, 0, 0, x10);
371 }
372
373
374 void Debug::GeneratePlainReturnLiveEdit(MacroAssembler* masm) {
375 masm->Abort("LiveEdit frame dropping is not supported on a64.");
376 }
377
378
379 void Debug::GenerateFrameDropperLiveEdit(MacroAssembler* masm) {
380 masm->Abort("LiveEdit frame dropping is not supported on a64.");
381 }
382
383 const bool Debug::kFrameDropperSupported = false;
384
385 #endif // ENABLE_DEBUGGER_SUPPORT
386
387 } } // namespace v8::internal
388
389 #endif // V8_TARGET_ARCH_A64
OLDNEW
« no previous file with comments | « src/a64/cpu-a64.cc ('k') | src/a64/debugger-a64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698