| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 Instr current_instr = Assembler::instr_at(pc); | 70 Instr current_instr = Assembler::instr_at(pc); |
| 71 return !Assembler::IsNop(current_instr, Assembler::DEBUG_BREAK_NOP); | 71 return !Assembler::IsNop(current_instr, Assembler::DEBUG_BREAK_NOP); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void DebugCodegen::GenerateDebugBreakStub(MacroAssembler* masm, | 74 void DebugCodegen::GenerateDebugBreakStub(MacroAssembler* masm, |
| 75 DebugBreakCallHelperMode mode) { | 75 DebugBreakCallHelperMode mode) { |
| 76 __ RecordComment("Debug break"); | 76 __ RecordComment("Debug break"); |
| 77 { | 77 { |
| 78 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 78 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 79 | 79 |
| 80 // Load padding words on stack. | |
| 81 __ LoadSmiLiteral(ip, Smi::FromInt(LiveEdit::kFramePaddingValue)); | |
| 82 for (int i = 0; i < LiveEdit::kFramePaddingInitialSize; i++) { | |
| 83 __ push(ip); | |
| 84 } | |
| 85 __ LoadSmiLiteral(ip, Smi::FromInt(LiveEdit::kFramePaddingInitialSize)); | |
| 86 __ push(ip); | |
| 87 | |
| 88 // Push arguments for DebugBreak call. | 80 // Push arguments for DebugBreak call. |
| 89 if (mode == SAVE_RESULT_REGISTER) { | 81 if (mode == SAVE_RESULT_REGISTER) { |
| 90 // Break on return. | 82 // Break on return. |
| 91 __ push(r3); | 83 __ push(r3); |
| 92 } else { | 84 } else { |
| 93 // Non-return breaks. | 85 // Non-return breaks. |
| 94 __ Push(masm->isolate()->factory()->the_hole_value()); | 86 __ Push(masm->isolate()->factory()->the_hole_value()); |
| 95 } | 87 } |
| 96 __ mov(r3, Operand(1)); | 88 __ mov(r3, Operand(1)); |
| 97 __ mov(r4, | 89 __ mov(r4, |
| 98 Operand(ExternalReference( | 90 Operand(ExternalReference( |
| 99 Runtime::FunctionForId(Runtime::kDebugBreak), masm->isolate()))); | 91 Runtime::FunctionForId(Runtime::kDebugBreak), masm->isolate()))); |
| 100 | 92 |
| 101 CEntryStub ceb(masm->isolate(), 1); | 93 CEntryStub ceb(masm->isolate(), 1); |
| 102 __ CallStub(&ceb); | 94 __ CallStub(&ceb); |
| 103 | 95 |
| 104 if (FLAG_debug_code) { | 96 if (FLAG_debug_code) { |
| 105 for (int i = 0; i < kNumJSCallerSaved; i++) { | 97 for (int i = 0; i < kNumJSCallerSaved; i++) { |
| 106 Register reg = {JSCallerSavedCode(i)}; | 98 Register reg = {JSCallerSavedCode(i)}; |
| 107 // Do not clobber r3 if mode is SAVE_RESULT_REGISTER. It will | 99 // Do not clobber r3 if mode is SAVE_RESULT_REGISTER. It will |
| 108 // contain return value of the function. | 100 // contain return value of the function. |
| 109 if (!(reg.is(r3) && (mode == SAVE_RESULT_REGISTER))) { | 101 if (!(reg.is(r3) && (mode == SAVE_RESULT_REGISTER))) { |
| 110 __ mov(reg, Operand(kDebugZapValue)); | 102 __ mov(reg, Operand(kDebugZapValue)); |
| 111 } | 103 } |
| 112 } | 104 } |
| 113 } | 105 } |
| 114 | |
| 115 // Don't bother removing padding bytes pushed on the stack | |
| 116 // as the frame is going to be restored right away. | |
| 117 | |
| 118 // Leave the internal frame. | 106 // Leave the internal frame. |
| 119 } | 107 } |
| 120 | 108 |
| 121 // Now that the break point has been handled, resume normal execution by | 109 __ MaybeDropFrames(); |
| 122 // jumping to the target address intended by the caller and that was | 110 |
| 123 // overwritten by the address of DebugBreakXXX. | 111 // Return to caller. |
| 124 ExternalReference after_break_target = | 112 __ Ret(); |
| 125 ExternalReference::debug_after_break_target_address(masm->isolate()); | |
| 126 __ mov(ip, Operand(after_break_target)); | |
| 127 __ LoadP(ip, MemOperand(ip)); | |
| 128 __ JumpToJSEntry(ip); | |
| 129 } | 113 } |
| 130 | 114 |
| 115 void DebugCodegen::GenerateHandleDebuggerStatement(MacroAssembler* masm) { |
| 116 { |
| 117 FrameScope scope(masm, StackFrame::INTERNAL); |
| 118 __ CallRuntime(Runtime::kHandleDebuggerStatement, 0); |
| 119 } |
| 120 __ MaybeDropFrames(); |
| 131 | 121 |
| 132 void DebugCodegen::GenerateFrameDropperLiveEdit(MacroAssembler* masm) { | 122 // Return to caller. |
| 133 // Load the function pointer off of our current stack frame. | 123 __ Ret(); |
| 134 __ LoadP(r4, MemOperand(fp, FrameDropperFrameConstants::kFunctionOffset)); | |
| 135 | |
| 136 // Pop return address and frame | |
| 137 __ LeaveFrame(StackFrame::INTERNAL); | |
| 138 | |
| 139 ParameterCount dummy(0); | |
| 140 __ CheckDebugHook(r4, no_reg, dummy, dummy); | |
| 141 | |
| 142 // Load context from the function. | |
| 143 __ LoadP(cp, FieldMemOperand(r4, JSFunction::kContextOffset)); | |
| 144 | |
| 145 // Clear new.target as a safety measure. | |
| 146 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex); | |
| 147 | |
| 148 // Get function code. | |
| 149 __ LoadP(ip, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); | |
| 150 __ LoadP(ip, FieldMemOperand(ip, SharedFunctionInfo::kCodeOffset)); | |
| 151 __ addi(ip, ip, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
| 152 | |
| 153 // Re-run JSFunction, r4 is function, cp is context. | |
| 154 __ Jump(ip); | |
| 155 } | 124 } |
| 156 | 125 |
| 126 void DebugCodegen::GenerateFrameDropperTrampoline(MacroAssembler* masm) { |
| 127 // Frame is being dropped: |
| 128 // - Drop to the target frame specified by r4. |
| 129 // - Look up current function on the frame. |
| 130 // - Leave the frame. |
| 131 // - Restart the frame by calling the function. |
| 132 |
| 133 __ mr(fp, r4); |
| 134 __ LoadP(r4, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 135 __ LeaveFrame(StackFrame::INTERNAL); |
| 136 __ LoadP(r3, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); |
| 137 __ LoadP( |
| 138 r3, FieldMemOperand(r3, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 139 __ mr(r5, r3); |
| 140 |
| 141 ParameterCount dummy1(r5); |
| 142 ParameterCount dummy2(r3); |
| 143 __ InvokeFunction(r4, dummy1, dummy2, JUMP_FUNCTION, |
| 144 CheckDebugStepCallWrapper()); |
| 145 } |
| 157 | 146 |
| 158 const bool LiveEdit::kFrameDropperSupported = true; | 147 const bool LiveEdit::kFrameDropperSupported = true; |
| 159 | 148 |
| 160 #undef __ | 149 #undef __ |
| 161 } // namespace internal | 150 } // namespace internal |
| 162 } // namespace v8 | 151 } // namespace v8 |
| 163 | 152 |
| 164 #endif // V8_TARGET_ARCH_PPC | 153 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |