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 #if V8_TARGET_ARCH_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
6 | 6 |
7 #include "src/debug/debug.h" | 7 #include "src/debug/debug.h" |
8 | 8 |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/debug/liveedit.h" | 10 #include "src/debug/liveedit.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 Operand(reinterpret_cast<int64_t>(code->entry())), | 58 Operand(reinterpret_cast<int64_t>(code->entry())), |
59 ADDRESS_LOAD); | 59 ADDRESS_LOAD); |
60 patcher.masm()->Call(v8::internal::t9); | 60 patcher.masm()->Call(v8::internal::t9); |
61 } | 61 } |
62 | 62 |
63 bool DebugCodegen::DebugBreakSlotIsPatched(Address pc) { | 63 bool DebugCodegen::DebugBreakSlotIsPatched(Address pc) { |
64 Instr current_instr = Assembler::instr_at(pc); | 64 Instr current_instr = Assembler::instr_at(pc); |
65 return !Assembler::IsNop(current_instr, Assembler::DEBUG_BREAK_NOP); | 65 return !Assembler::IsNop(current_instr, Assembler::DEBUG_BREAK_NOP); |
66 } | 66 } |
67 | 67 |
| 68 void DebugCodegen::GenerateHandleDebuggerStatement(MacroAssembler* masm) { |
| 69 { |
| 70 FrameScope scope(masm, StackFrame::INTERNAL); |
| 71 __ CallRuntime(Runtime::kHandleDebuggerStatement, 0); |
| 72 } |
| 73 __ MaybeDropFrames(); |
| 74 |
| 75 // Return to caller. |
| 76 __ Ret(); |
| 77 } |
| 78 |
68 void DebugCodegen::GenerateDebugBreakStub(MacroAssembler* masm, | 79 void DebugCodegen::GenerateDebugBreakStub(MacroAssembler* masm, |
69 DebugBreakCallHelperMode mode) { | 80 DebugBreakCallHelperMode mode) { |
70 __ RecordComment("Debug break"); | 81 __ RecordComment("Debug break"); |
71 { | 82 { |
72 FrameScope scope(masm, StackFrame::INTERNAL); | 83 FrameScope scope(masm, StackFrame::INTERNAL); |
73 | 84 |
74 // Load padding words on stack. | |
75 __ li(at, Operand(Smi::FromInt(LiveEdit::kFramePaddingValue))); | |
76 __ Dsubu(sp, sp, | |
77 Operand(kPointerSize * LiveEdit::kFramePaddingInitialSize)); | |
78 for (int i = LiveEdit::kFramePaddingInitialSize - 1; i >= 0; i--) { | |
79 __ sd(at, MemOperand(sp, kPointerSize * i)); | |
80 } | |
81 __ li(at, Operand(Smi::FromInt(LiveEdit::kFramePaddingInitialSize))); | |
82 __ push(at); | |
83 | |
84 // Push arguments for DebugBreak call. | 85 // Push arguments for DebugBreak call. |
85 if (mode == SAVE_RESULT_REGISTER) { | 86 if (mode == SAVE_RESULT_REGISTER) { |
86 // Break on return. | 87 // Break on return. |
87 __ push(v0); | 88 __ push(v0); |
88 } else { | 89 } else { |
89 // Non-return breaks. | 90 // Non-return breaks. |
90 __ Push(masm->isolate()->factory()->the_hole_value()); | 91 __ Push(masm->isolate()->factory()->the_hole_value()); |
91 } | 92 } |
92 __ PrepareCEntryArgs(1); | 93 __ PrepareCEntryArgs(1); |
93 __ PrepareCEntryFunction(ExternalReference( | 94 __ PrepareCEntryFunction(ExternalReference( |
94 Runtime::FunctionForId(Runtime::kDebugBreak), masm->isolate())); | 95 Runtime::FunctionForId(Runtime::kDebugBreak), masm->isolate())); |
95 | 96 |
96 CEntryStub ceb(masm->isolate(), 1); | 97 CEntryStub ceb(masm->isolate(), 1); |
97 __ CallStub(&ceb); | 98 __ CallStub(&ceb); |
98 | 99 |
99 if (FLAG_debug_code) { | 100 if (FLAG_debug_code) { |
100 for (int i = 0; i < kNumJSCallerSaved; i++) { | 101 for (int i = 0; i < kNumJSCallerSaved; i++) { |
101 Register reg = {JSCallerSavedCode(i)}; | 102 Register reg = {JSCallerSavedCode(i)}; |
102 // Do not clobber v0 if mode is SAVE_RESULT_REGISTER. It will | 103 // Do not clobber v0 if mode is SAVE_RESULT_REGISTER. It will |
103 // contain return value of the function returned by DebugBreak. | 104 // contain return value of the function returned by DebugBreak. |
104 if (!(reg.is(v0) && (mode == SAVE_RESULT_REGISTER))) { | 105 if (!(reg.is(v0) && (mode == SAVE_RESULT_REGISTER))) { |
105 __ li(reg, kDebugZapValue); | 106 __ li(reg, kDebugZapValue); |
106 } | 107 } |
107 } | 108 } |
108 } | 109 } |
109 | 110 |
110 // Don't bother removing padding bytes pushed on the stack | |
111 // as the frame is going to be restored right away. | |
112 | |
113 // Leave the internal frame. | 111 // Leave the internal frame. |
114 } | 112 } |
115 | 113 |
116 // Now that the break point has been handled, resume normal execution by | 114 __ MaybeDropFrames(); |
117 // jumping to the target address intended by the caller and that was | 115 |
118 // overwritten by the address of DebugBreakXXX. | 116 // Return to caller. |
119 ExternalReference after_break_target = | 117 __ Ret(); |
120 ExternalReference::debug_after_break_target_address(masm->isolate()); | |
121 __ li(t9, Operand(after_break_target)); | |
122 __ ld(t9, MemOperand(t9)); | |
123 __ Jump(t9); | |
124 } | 118 } |
125 | 119 |
126 | 120 void DebugCodegen::GenerateFrameDropperTrampoline(MacroAssembler* masm) { |
127 void DebugCodegen::GenerateFrameDropperLiveEdit(MacroAssembler* masm) { | 121 // Frame is being dropped: |
128 // We do not know our frame height, but set sp based on fp. | 122 // - Drop to the target frame specified by a1. |
129 __ ld(a1, MemOperand(fp, FrameDropperFrameConstants::kFunctionOffset)); | 123 // - Look up current function on the frame. |
| 124 // - Leave the frame. |
| 125 // - Restart the frame by calling the function. |
| 126 __ mov(fp, a1); |
| 127 __ ld(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
130 | 128 |
131 // Pop return address and frame. | 129 // Pop return address and frame. |
132 __ LeaveFrame(StackFrame::INTERNAL); | 130 __ LeaveFrame(StackFrame::INTERNAL); |
133 | 131 |
134 ParameterCount dummy(0); | 132 __ ld(a0, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
135 __ CheckDebugHook(a1, no_reg, dummy, dummy); | 133 __ ld(a0, |
| 134 FieldMemOperand(a0, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 135 __ mov(a2, a0); |
136 | 136 |
137 // Load context from the function. | 137 ParameterCount dummy1(a2); |
138 __ ld(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); | 138 ParameterCount dummy2(a0); |
139 | 139 __ InvokeFunction(a1, dummy1, dummy2, JUMP_FUNCTION, |
140 // Clear new.target as a safety measure. | 140 CheckDebugStepCallWrapper()); |
141 __ LoadRoot(a3, Heap::kUndefinedValueRootIndex); | |
142 | |
143 // Get function code. | |
144 __ ld(at, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); | |
145 __ ld(at, FieldMemOperand(at, SharedFunctionInfo::kCodeOffset)); | |
146 __ Daddu(t9, at, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
147 | |
148 // Re-run JSFunction, a1 is function, cp is context. | |
149 __ Jump(t9); | |
150 } | 141 } |
151 | 142 |
152 | 143 |
153 const bool LiveEdit::kFrameDropperSupported = true; | 144 const bool LiveEdit::kFrameDropperSupported = true; |
154 | 145 |
155 #undef __ | 146 #undef __ |
156 | 147 |
157 } // namespace internal | 148 } // namespace internal |
158 } // namespace v8 | 149 } // namespace v8 |
159 | 150 |
160 #endif // V8_TARGET_ARCH_MIPS64 | 151 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |