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