Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 4 | |
| 5 | |
| 6 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 7 | #include "src/v8.h" |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 8 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 9 | #if V8_TARGET_ARCH_MIPS |
Leon Clarke | f7060e2 | 2010-06-03 12:02:55 +0100 | [diff] [blame] | 10 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 11 | #include "src/codegen.h" |
| 12 | #include "src/debug.h" |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 13 | |
| 14 | namespace v8 { |
| 15 | namespace internal { |
| 16 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 17 | bool BreakLocationIterator::IsDebugBreakAtReturn() { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 18 | return Debug::IsDebugBreakAtReturn(rinfo()); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | |
| 22 | void BreakLocationIterator::SetDebugBreakAtReturn() { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 23 | // Mips return sequence: |
| 24 | // mov sp, fp |
| 25 | // lw fp, sp(0) |
| 26 | // lw ra, sp(4) |
| 27 | // addiu sp, sp, 8 |
| 28 | // addiu sp, sp, N |
| 29 | // jr ra |
| 30 | // nop (in branch delay slot) |
| 31 | |
| 32 | // Make sure this constant matches the number if instrucntions we emit. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 33 | DCHECK(Assembler::kJSReturnSequenceInstructions == 7); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 34 | CodePatcher patcher(rinfo()->pc(), Assembler::kJSReturnSequenceInstructions); |
| 35 | // li and Call pseudo-instructions emit two instructions each. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 36 | patcher.masm()->li(v8::internal::t9, Operand(reinterpret_cast<int32_t>( |
| 37 | debug_info_->GetIsolate()->builtins()->Return_DebugBreak()->entry()))); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 38 | patcher.masm()->Call(v8::internal::t9); |
| 39 | patcher.masm()->nop(); |
| 40 | patcher.masm()->nop(); |
| 41 | patcher.masm()->nop(); |
| 42 | |
| 43 | // TODO(mips): Open issue about using breakpoint instruction instead of nops. |
| 44 | // patcher.masm()->bkpt(0); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | |
| 48 | // Restore the JS frame exit code. |
| 49 | void BreakLocationIterator::ClearDebugBreakAtReturn() { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 50 | rinfo()->PatchCode(original_rinfo()->pc(), |
| 51 | Assembler::kJSReturnSequenceInstructions); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 55 | // A debug break in the exit code is identified by the JS frame exit code |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 56 | // having been patched with li/call psuedo-instrunction (liu/ori/jalr). |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 57 | bool Debug::IsDebugBreakAtReturn(RelocInfo* rinfo) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 58 | DCHECK(RelocInfo::IsJSReturn(rinfo->rmode())); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 59 | return rinfo->IsPatchedReturnSequence(); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | |
| 63 | bool BreakLocationIterator::IsDebugBreakAtSlot() { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 64 | DCHECK(IsDebugBreakSlot()); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 65 | // Check whether the debug break slot instructions have been patched. |
| 66 | return rinfo()->IsPatchedDebugBreakSlotSequence(); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | |
| 70 | void BreakLocationIterator::SetDebugBreakAtSlot() { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 71 | DCHECK(IsDebugBreakSlot()); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 72 | // Patch the code changing the debug break slot code from: |
| 73 | // nop(DEBUG_BREAK_NOP) - nop(1) is sll(zero_reg, zero_reg, 1) |
| 74 | // nop(DEBUG_BREAK_NOP) |
| 75 | // nop(DEBUG_BREAK_NOP) |
| 76 | // nop(DEBUG_BREAK_NOP) |
| 77 | // to a call to the debug break slot code. |
| 78 | // li t9, address (lui t9 / ori t9 instruction pair) |
| 79 | // call t9 (jalr t9 / nop instruction pair) |
| 80 | CodePatcher patcher(rinfo()->pc(), Assembler::kDebugBreakSlotInstructions); |
| 81 | patcher.masm()->li(v8::internal::t9, Operand(reinterpret_cast<int32_t>( |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 82 | debug_info_->GetIsolate()->builtins()->Slot_DebugBreak()->entry()))); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 83 | patcher.masm()->Call(v8::internal::t9); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | |
| 87 | void BreakLocationIterator::ClearDebugBreakAtSlot() { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 88 | DCHECK(IsDebugBreakSlot()); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 89 | rinfo()->PatchCode(original_rinfo()->pc(), |
| 90 | Assembler::kDebugBreakSlotInstructions); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | |
| 94 | #define __ ACCESS_MASM(masm) |
| 95 | |
| 96 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 97 | |
| 98 | static void Generate_DebugBreakCallHelper(MacroAssembler* masm, |
| 99 | RegList object_regs, |
| 100 | RegList non_object_regs) { |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 101 | { |
| 102 | FrameScope scope(masm, StackFrame::INTERNAL); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 103 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 104 | // Load padding words on stack. |
| 105 | __ li(at, Operand(Smi::FromInt(LiveEdit::kFramePaddingValue))); |
| 106 | __ Subu(sp, sp, |
| 107 | Operand(kPointerSize * LiveEdit::kFramePaddingInitialSize)); |
| 108 | for (int i = LiveEdit::kFramePaddingInitialSize - 1; i >= 0; i--) { |
| 109 | __ sw(at, MemOperand(sp, kPointerSize * i)); |
| 110 | } |
| 111 | __ li(at, Operand(Smi::FromInt(LiveEdit::kFramePaddingInitialSize))); |
| 112 | __ push(at); |
| 113 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 114 | // Store the registers containing live values on the expression stack to |
| 115 | // make sure that these are correctly updated during GC. Non object values |
| 116 | // are stored as a smi causing it to be untouched by GC. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 117 | DCHECK((object_regs & ~kJSCallerSaved) == 0); |
| 118 | DCHECK((non_object_regs & ~kJSCallerSaved) == 0); |
| 119 | DCHECK((object_regs & non_object_regs) == 0); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 120 | if ((object_regs | non_object_regs) != 0) { |
| 121 | for (int i = 0; i < kNumJSCallerSaved; i++) { |
| 122 | int r = JSCallerSavedCode(i); |
| 123 | Register reg = { r }; |
| 124 | if ((non_object_regs & (1 << r)) != 0) { |
| 125 | if (FLAG_debug_code) { |
| 126 | __ And(at, reg, 0xc0000000); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 127 | __ Assert(eq, kUnableToEncodeValueAsSmi, at, Operand(zero_reg)); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 128 | } |
| 129 | __ sll(reg, reg, kSmiTagSize); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 130 | } |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 131 | } |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 132 | __ MultiPush(object_regs | non_object_regs); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 133 | } |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 134 | |
| 135 | #ifdef DEBUG |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 136 | __ RecordComment("// Calling from debug break to runtime - come in - over"); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 137 | #endif |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 138 | __ PrepareCEntryArgs(0); // No arguments. |
| 139 | __ PrepareCEntryFunction(ExternalReference::debug_break(masm->isolate())); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 140 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 141 | CEntryStub ceb(masm->isolate(), 1); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 142 | __ CallStub(&ceb); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 143 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 144 | // Restore the register values from the expression stack. |
| 145 | if ((object_regs | non_object_regs) != 0) { |
| 146 | __ MultiPop(object_regs | non_object_regs); |
| 147 | for (int i = 0; i < kNumJSCallerSaved; i++) { |
| 148 | int r = JSCallerSavedCode(i); |
| 149 | Register reg = { r }; |
| 150 | if ((non_object_regs & (1 << r)) != 0) { |
| 151 | __ srl(reg, reg, kSmiTagSize); |
| 152 | } |
| 153 | if (FLAG_debug_code && |
| 154 | (((object_regs |non_object_regs) & (1 << r)) == 0)) { |
| 155 | __ li(reg, kDebugZapValue); |
| 156 | } |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 157 | } |
| 158 | } |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 159 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 160 | // Don't bother removing padding bytes pushed on the stack |
| 161 | // as the frame is going to be restored right away. |
| 162 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 163 | // Leave the internal frame. |
| 164 | } |
Ben Murdoch | 85b7179 | 2012-04-11 18:30:58 +0100 | [diff] [blame] | 165 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 166 | // Now that the break point has been handled, resume normal execution by |
| 167 | // jumping to the target address intended by the caller and that was |
| 168 | // overwritten by the address of DebugBreakXXX. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 169 | ExternalReference after_break_target = |
| 170 | ExternalReference::debug_after_break_target_address(masm->isolate()); |
| 171 | __ li(t9, Operand(after_break_target)); |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 172 | __ lw(t9, MemOperand(t9)); |
| 173 | __ Jump(t9); |
| 174 | } |
| 175 | |
| 176 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 177 | void DebugCodegen::GenerateCallICStubDebugBreak(MacroAssembler* masm) { |
| 178 | // Register state for CallICStub |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 179 | // ----------- S t a t e ------------- |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 180 | // -- a1 : function |
| 181 | // -- a3 : slot in feedback array (smi) |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 182 | // ----------------------------------- |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 183 | Generate_DebugBreakCallHelper(masm, a1.bit() | a3.bit(), 0); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 187 | void DebugCodegen::GenerateLoadICDebugBreak(MacroAssembler* masm) { |
| 188 | Register receiver = LoadDescriptor::ReceiverRegister(); |
| 189 | Register name = LoadDescriptor::NameRegister(); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 190 | RegList regs = receiver.bit() | name.bit(); |
| 191 | if (FLAG_vector_ics) { |
| 192 | regs |= VectorLoadICTrampolineDescriptor::SlotRegister().bit(); |
| 193 | } |
| 194 | Generate_DebugBreakCallHelper(masm, regs, 0); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | |
| 198 | void DebugCodegen::GenerateStoreICDebugBreak(MacroAssembler* masm) { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 199 | // Calling convention for IC store (from ic-mips.cc). |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 200 | Register receiver = StoreDescriptor::ReceiverRegister(); |
| 201 | Register name = StoreDescriptor::NameRegister(); |
| 202 | Register value = StoreDescriptor::ValueRegister(); |
| 203 | Generate_DebugBreakCallHelper( |
| 204 | masm, receiver.bit() | name.bit() | value.bit(), 0); |
| 205 | } |
| 206 | |
| 207 | |
| 208 | void DebugCodegen::GenerateKeyedLoadICDebugBreak(MacroAssembler* masm) { |
| 209 | // Calling convention for keyed IC load (from ic-mips.cc). |
| 210 | GenerateLoadICDebugBreak(masm); |
| 211 | } |
| 212 | |
| 213 | |
| 214 | void DebugCodegen::GenerateKeyedStoreICDebugBreak(MacroAssembler* masm) { |
| 215 | // Calling convention for IC keyed store call (from ic-mips.cc). |
| 216 | Register receiver = StoreDescriptor::ReceiverRegister(); |
| 217 | Register name = StoreDescriptor::NameRegister(); |
| 218 | Register value = StoreDescriptor::ValueRegister(); |
| 219 | Generate_DebugBreakCallHelper( |
| 220 | masm, receiver.bit() | name.bit() | value.bit(), 0); |
| 221 | } |
| 222 | |
| 223 | |
| 224 | void DebugCodegen::GenerateCompareNilICDebugBreak(MacroAssembler* masm) { |
| 225 | // Register state for CompareNil IC |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 226 | // ----------- S t a t e ------------- |
| 227 | // -- a0 : value |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 228 | // ----------------------------------- |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 229 | Generate_DebugBreakCallHelper(masm, a0.bit(), 0); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 233 | void DebugCodegen::GenerateReturnDebugBreak(MacroAssembler* masm) { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 234 | // In places other than IC call sites it is expected that v0 is TOS which |
| 235 | // is an object - this is not generally the case so this should be used with |
| 236 | // care. |
| 237 | Generate_DebugBreakCallHelper(masm, v0.bit(), 0); |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 241 | void DebugCodegen::GenerateCallFunctionStubDebugBreak(MacroAssembler* masm) { |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 242 | // Register state for CallFunctionStub (from code-stubs-mips.cc). |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 243 | // ----------- S t a t e ------------- |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 244 | // -- a1 : function |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 245 | // ----------------------------------- |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 246 | Generate_DebugBreakCallHelper(masm, a1.bit(), 0); |
| 247 | } |
| 248 | |
| 249 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 250 | void DebugCodegen::GenerateCallConstructStubDebugBreak(MacroAssembler* masm) { |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 251 | // Calling convention for CallConstructStub (from code-stubs-mips.cc). |
| 252 | // ----------- S t a t e ------------- |
| 253 | // -- a0 : number of arguments (not smi) |
| 254 | // -- a1 : constructor function |
| 255 | // ----------------------------------- |
| 256 | Generate_DebugBreakCallHelper(masm, a1.bit() , a0.bit()); |
| 257 | } |
| 258 | |
| 259 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 260 | void DebugCodegen::GenerateCallConstructStubRecordDebugBreak( |
| 261 | MacroAssembler* masm) { |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 262 | // Calling convention for CallConstructStub (from code-stubs-mips.cc). |
| 263 | // ----------- S t a t e ------------- |
| 264 | // -- a0 : number of arguments (not smi) |
| 265 | // -- a1 : constructor function |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 266 | // -- a2 : feedback array |
| 267 | // -- a3 : feedback slot (smi) |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 268 | // ----------------------------------- |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 269 | Generate_DebugBreakCallHelper(masm, a1.bit() | a2.bit() | a3.bit(), a0.bit()); |
Ben Murdoch | 5d4cdbf | 2012-04-11 10:23:59 +0100 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 273 | void DebugCodegen::GenerateSlot(MacroAssembler* masm) { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 274 | // Generate enough nop's to make space for a call instruction. Avoid emitting |
| 275 | // the trampoline pool in the debug break slot code. |
| 276 | Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm); |
| 277 | Label check_codesize; |
| 278 | __ bind(&check_codesize); |
| 279 | __ RecordDebugBreakSlot(); |
| 280 | for (int i = 0; i < Assembler::kDebugBreakSlotInstructions; i++) { |
| 281 | __ nop(MacroAssembler::DEBUG_BREAK_NOP); |
| 282 | } |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 283 | DCHECK_EQ(Assembler::kDebugBreakSlotInstructions, |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 284 | masm->InstructionsGeneratedSince(&check_codesize)); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 285 | } |
| 286 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 287 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 288 | void DebugCodegen::GenerateSlotDebugBreak(MacroAssembler* masm) { |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 289 | // In the places where a debug break slot is inserted no registers can contain |
| 290 | // object pointers. |
| 291 | Generate_DebugBreakCallHelper(masm, 0, 0); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 295 | void DebugCodegen::GeneratePlainReturnLiveEdit(MacroAssembler* masm) { |
| 296 | __ Ret(); |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 300 | void DebugCodegen::GenerateFrameDropperLiveEdit(MacroAssembler* masm) { |
| 301 | ExternalReference restarter_frame_function_slot = |
| 302 | ExternalReference::debug_restarter_frame_function_pointer_address( |
| 303 | masm->isolate()); |
| 304 | __ li(at, Operand(restarter_frame_function_slot)); |
| 305 | __ sw(zero_reg, MemOperand(at, 0)); |
| 306 | |
| 307 | // We do not know our frame height, but set sp based on fp. |
| 308 | __ Subu(sp, fp, Operand(kPointerSize)); |
| 309 | |
| 310 | __ Pop(ra, fp, a1); // Return address, Frame, Function. |
| 311 | |
| 312 | // Load context from the function. |
| 313 | __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
| 314 | |
| 315 | // Get function code. |
| 316 | __ lw(at, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
| 317 | __ lw(at, FieldMemOperand(at, SharedFunctionInfo::kCodeOffset)); |
| 318 | __ Addu(t9, at, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 319 | |
| 320 | // Re-run JSFunction, a1 is function, cp is context. |
| 321 | __ Jump(t9); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 322 | } |
| 323 | |
Iain Merrick | 7568138 | 2010-08-19 15:07:18 +0100 | [diff] [blame] | 324 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 325 | const bool LiveEdit::kFrameDropperSupported = true; |
Iain Merrick | 7568138 | 2010-08-19 15:07:18 +0100 | [diff] [blame] | 326 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 327 | #undef __ |
| 328 | |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 329 | } } // namespace v8::internal |
| 330 | |
Leon Clarke | f7060e2 | 2010-06-03 12:02:55 +0100 | [diff] [blame] | 331 | #endif // V8_TARGET_ARCH_MIPS |