OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 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 | 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 | 5 |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #if V8_TARGET_ARCH_MIPS | 9 #if V8_TARGET_ARCH_MIPS |
10 | 10 |
11 #include "src/codegen.h" | 11 #include "src/codegen.h" |
12 #include "src/debug.h" | 12 #include "src/debug.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 bool BreakLocationIterator::IsDebugBreakAtReturn() { | 17 void BreakLocation::SetDebugBreakAtReturn() { |
18 return Debug::IsDebugBreakAtReturn(rinfo()); | |
19 } | |
20 | |
21 | |
22 void BreakLocationIterator::SetDebugBreakAtReturn() { | |
23 // Mips return sequence: | 18 // Mips return sequence: |
24 // mov sp, fp | 19 // mov sp, fp |
25 // lw fp, sp(0) | 20 // lw fp, sp(0) |
26 // lw ra, sp(4) | 21 // lw ra, sp(4) |
27 // addiu sp, sp, 8 | 22 // addiu sp, sp, 8 |
28 // addiu sp, sp, N | 23 // addiu sp, sp, N |
29 // jr ra | 24 // jr ra |
30 // nop (in branch delay slot) | 25 // nop (in branch delay slot) |
31 | 26 |
32 // Make sure this constant matches the number if instrucntions we emit. | 27 // Make sure this constant matches the number if instrucntions we emit. |
33 DCHECK(Assembler::kJSReturnSequenceInstructions == 7); | 28 DCHECK(Assembler::kJSReturnSequenceInstructions == 7); |
34 CodePatcher patcher(rinfo()->pc(), Assembler::kJSReturnSequenceInstructions); | 29 CodePatcher patcher(pc(), Assembler::kJSReturnSequenceInstructions); |
35 // li and Call pseudo-instructions emit two instructions each. | 30 // li and Call pseudo-instructions emit two instructions each. |
36 patcher.masm()->li(v8::internal::t9, Operand(reinterpret_cast<int32_t>( | 31 patcher.masm()->li(v8::internal::t9, Operand(reinterpret_cast<int32_t>( |
37 debug_info_->GetIsolate()->builtins()->Return_DebugBreak()->entry()))); | 32 debug_info_->GetIsolate()->builtins()->Return_DebugBreak()->entry()))); |
38 patcher.masm()->Call(v8::internal::t9); | 33 patcher.masm()->Call(v8::internal::t9); |
39 patcher.masm()->nop(); | 34 patcher.masm()->nop(); |
40 patcher.masm()->nop(); | 35 patcher.masm()->nop(); |
41 patcher.masm()->nop(); | 36 patcher.masm()->nop(); |
42 | 37 |
43 // TODO(mips): Open issue about using breakpoint instruction instead of nops. | 38 // TODO(mips): Open issue about using breakpoint instruction instead of nops. |
44 // patcher.masm()->bkpt(0); | 39 // patcher.masm()->bkpt(0); |
45 } | 40 } |
46 | 41 |
47 | 42 |
48 // Restore the JS frame exit code. | 43 void BreakLocation::SetDebugBreakAtSlot() { |
49 void BreakLocationIterator::ClearDebugBreakAtReturn() { | |
50 rinfo()->PatchCode(original_rinfo()->pc(), | |
51 Assembler::kJSReturnSequenceInstructions); | |
52 } | |
53 | |
54 | |
55 // A debug break in the exit code is identified by the JS frame exit code | |
56 // having been patched with li/call psuedo-instrunction (liu/ori/jalr). | |
57 bool Debug::IsDebugBreakAtReturn(RelocInfo* rinfo) { | |
58 DCHECK(RelocInfo::IsJSReturn(rinfo->rmode())); | |
59 return rinfo->IsPatchedReturnSequence(); | |
60 } | |
61 | |
62 | |
63 bool BreakLocationIterator::IsDebugBreakAtSlot() { | |
64 DCHECK(IsDebugBreakSlot()); | |
65 // Check whether the debug break slot instructions have been patched. | |
66 return rinfo()->IsPatchedDebugBreakSlotSequence(); | |
67 } | |
68 | |
69 | |
70 void BreakLocationIterator::SetDebugBreakAtSlot() { | |
71 DCHECK(IsDebugBreakSlot()); | 44 DCHECK(IsDebugBreakSlot()); |
72 // Patch the code changing the debug break slot code from: | 45 // Patch the code changing the debug break slot code from: |
73 // nop(DEBUG_BREAK_NOP) - nop(1) is sll(zero_reg, zero_reg, 1) | 46 // nop(DEBUG_BREAK_NOP) - nop(1) is sll(zero_reg, zero_reg, 1) |
74 // nop(DEBUG_BREAK_NOP) | 47 // nop(DEBUG_BREAK_NOP) |
75 // nop(DEBUG_BREAK_NOP) | 48 // nop(DEBUG_BREAK_NOP) |
76 // nop(DEBUG_BREAK_NOP) | 49 // nop(DEBUG_BREAK_NOP) |
77 // to a call to the debug break slot code. | 50 // to a call to the debug break slot code. |
78 // li t9, address (lui t9 / ori t9 instruction pair) | 51 // li t9, address (lui t9 / ori t9 instruction pair) |
79 // call t9 (jalr t9 / nop instruction pair) | 52 // call t9 (jalr t9 / nop instruction pair) |
80 CodePatcher patcher(rinfo()->pc(), Assembler::kDebugBreakSlotInstructions); | 53 CodePatcher patcher(pc(), Assembler::kDebugBreakSlotInstructions); |
81 patcher.masm()->li(v8::internal::t9, Operand(reinterpret_cast<int32_t>( | 54 patcher.masm()->li(v8::internal::t9, Operand(reinterpret_cast<int32_t>( |
82 debug_info_->GetIsolate()->builtins()->Slot_DebugBreak()->entry()))); | 55 debug_info_->GetIsolate()->builtins()->Slot_DebugBreak()->entry()))); |
83 patcher.masm()->Call(v8::internal::t9); | 56 patcher.masm()->Call(v8::internal::t9); |
84 } | 57 } |
85 | 58 |
86 | 59 |
87 void BreakLocationIterator::ClearDebugBreakAtSlot() { | |
88 DCHECK(IsDebugBreakSlot()); | |
89 rinfo()->PatchCode(original_rinfo()->pc(), | |
90 Assembler::kDebugBreakSlotInstructions); | |
91 } | |
92 | |
93 | |
94 #define __ ACCESS_MASM(masm) | 60 #define __ ACCESS_MASM(masm) |
95 | 61 |
96 | 62 |
97 | 63 |
98 static void Generate_DebugBreakCallHelper(MacroAssembler* masm, | 64 static void Generate_DebugBreakCallHelper(MacroAssembler* masm, |
99 RegList object_regs, | 65 RegList object_regs, |
100 RegList non_object_regs) { | 66 RegList non_object_regs) { |
101 { | 67 { |
102 FrameScope scope(masm, StackFrame::INTERNAL); | 68 FrameScope scope(masm, StackFrame::INTERNAL); |
103 | 69 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 } | 288 } |
323 | 289 |
324 | 290 |
325 const bool LiveEdit::kFrameDropperSupported = true; | 291 const bool LiveEdit::kFrameDropperSupported = true; |
326 | 292 |
327 #undef __ | 293 #undef __ |
328 | 294 |
329 } } // namespace v8::internal | 295 } } // namespace v8::internal |
330 | 296 |
331 #endif // V8_TARGET_ARCH_MIPS | 297 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |