jkummerow@chromium.org | 212d964 | 2012-05-11 15:02:09 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #include "v8.h" |
| 29 | |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 30 | #if defined(V8_TARGET_ARCH_IA32) |
| 31 | |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 32 | #include "codegen.h" |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 33 | #include "debug.h" |
| 34 | |
| 35 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 36 | namespace v8 { |
| 37 | namespace internal { |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 38 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 39 | #ifdef ENABLE_DEBUGGER_SUPPORT |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 40 | |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 41 | bool BreakLocationIterator::IsDebugBreakAtReturn() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 42 | return Debug::IsDebugBreakAtReturn(rinfo()); |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | |
| 46 | // Patch the JS frame exit code with a debug break call. See |
| 47 | // CodeGenerator::VisitReturnStatement and VirtualFrame::Exit in codegen-ia32.cc |
| 48 | // for the precise return instructions sequence. |
| 49 | void BreakLocationIterator::SetDebugBreakAtReturn() { |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 50 | ASSERT(Assembler::kJSReturnSequenceLength >= |
| 51 | Assembler::kCallInstructionLength); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 52 | Isolate* isolate = Isolate::Current(); |
| 53 | rinfo()->PatchCodeWithCall(isolate->debug()->debug_break_return()->entry(), |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 54 | Assembler::kJSReturnSequenceLength - Assembler::kCallInstructionLength); |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | |
| 58 | // Restore the JS frame exit code. |
| 59 | void BreakLocationIterator::ClearDebugBreakAtReturn() { |
| 60 | rinfo()->PatchCode(original_rinfo()->pc(), |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 61 | Assembler::kJSReturnSequenceLength); |
iposva@chromium.org | 245aa85 | 2009-02-10 00:49:54 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 65 | // A debug break in the frame exit code is identified by the JS frame exit code |
| 66 | // having been patched with a call instruction. |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 67 | bool Debug::IsDebugBreakAtReturn(RelocInfo* rinfo) { |
| 68 | ASSERT(RelocInfo::IsJSReturn(rinfo->rmode())); |
christian.plesner.hansen@gmail.com | 9d58c2b | 2009-10-16 11:48:38 +0000 | [diff] [blame] | 69 | return rinfo->IsPatchedReturnSequence(); |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 73 | bool BreakLocationIterator::IsDebugBreakAtSlot() { |
| 74 | ASSERT(IsDebugBreakSlot()); |
| 75 | // Check whether the debug break slot instructions have been patched. |
| 76 | return rinfo()->IsPatchedDebugBreakSlotSequence(); |
| 77 | } |
| 78 | |
| 79 | |
| 80 | void BreakLocationIterator::SetDebugBreakAtSlot() { |
| 81 | ASSERT(IsDebugBreakSlot()); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 82 | Isolate* isolate = Isolate::Current(); |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 83 | rinfo()->PatchCodeWithCall( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 84 | isolate->debug()->debug_break_slot()->entry(), |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 85 | Assembler::kDebugBreakSlotLength - Assembler::kCallInstructionLength); |
| 86 | } |
| 87 | |
| 88 | |
| 89 | void BreakLocationIterator::ClearDebugBreakAtSlot() { |
| 90 | ASSERT(IsDebugBreakSlot()); |
| 91 | rinfo()->PatchCode(original_rinfo()->pc(), Assembler::kDebugBreakSlotLength); |
| 92 | } |
| 93 | |
jkummerow@chromium.org | 212d964 | 2012-05-11 15:02:09 +0000 | [diff] [blame] | 94 | // All debug break stubs support padding for LiveEdit. |
| 95 | const bool Debug::FramePaddingLayout::kIsSupported = true; |
| 96 | |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 97 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 98 | #define __ ACCESS_MASM(masm) |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 99 | |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 100 | static void Generate_DebugBreakCallHelper(MacroAssembler* masm, |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 101 | RegList object_regs, |
| 102 | RegList non_object_regs, |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 103 | bool convert_call_to_jmp) { |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 104 | // Enter an internal frame. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 105 | { |
| 106 | FrameScope scope(masm, StackFrame::INTERNAL); |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 107 | |
jkummerow@chromium.org | 212d964 | 2012-05-11 15:02:09 +0000 | [diff] [blame] | 108 | // Load padding words on stack. |
| 109 | for (int i = 0; i < Debug::FramePaddingLayout::kInitialSize; i++) { |
| 110 | __ push(Immediate(Smi::FromInt( |
| 111 | Debug::FramePaddingLayout::kPaddingValue))); |
| 112 | } |
| 113 | __ push(Immediate(Smi::FromInt(Debug::FramePaddingLayout::kInitialSize))); |
| 114 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 115 | // Store the registers containing live values on the expression stack to |
| 116 | // make sure that these are correctly updated during GC. Non object values |
| 117 | // are stored as a smi causing it to be untouched by GC. |
| 118 | ASSERT((object_regs & ~kJSCallerSaved) == 0); |
| 119 | ASSERT((non_object_regs & ~kJSCallerSaved) == 0); |
| 120 | ASSERT((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 ((object_regs & (1 << r)) != 0) { |
| 125 | __ push(reg); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 126 | } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 127 | if ((non_object_regs & (1 << r)) != 0) { |
| 128 | if (FLAG_debug_code) { |
| 129 | __ test(reg, Immediate(0xc0000000)); |
| 130 | __ Assert(zero, "Unable to encode value as smi"); |
| 131 | } |
| 132 | __ SmiTag(reg); |
| 133 | __ push(reg); |
| 134 | } |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 135 | } |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 136 | |
| 137 | #ifdef DEBUG |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 138 | __ RecordComment("// Calling from debug break to runtime - come in - over"); |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 139 | #endif |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 140 | __ Set(eax, Immediate(0)); // No arguments. |
| 141 | __ mov(ebx, Immediate(ExternalReference::debug_break(masm->isolate()))); |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 142 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 143 | CEntryStub ceb(1); |
| 144 | __ CallStub(&ceb); |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 145 | |
jkummerow@chromium.org | 212d964 | 2012-05-11 15:02:09 +0000 | [diff] [blame] | 146 | // Automatically find register that could be used after register restore. |
| 147 | // We need one register for padding skip instructions. |
| 148 | Register unused_reg = { -1 }; |
| 149 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 150 | // Restore the register values containing object pointers from the |
| 151 | // expression stack. |
| 152 | for (int i = kNumJSCallerSaved; --i >= 0;) { |
| 153 | int r = JSCallerSavedCode(i); |
| 154 | Register reg = { r }; |
| 155 | if (FLAG_debug_code) { |
| 156 | __ Set(reg, Immediate(kDebugZapValue)); |
| 157 | } |
jkummerow@chromium.org | 212d964 | 2012-05-11 15:02:09 +0000 | [diff] [blame] | 158 | bool taken = reg.code() == esi.code(); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 159 | if ((object_regs & (1 << r)) != 0) { |
| 160 | __ pop(reg); |
jkummerow@chromium.org | 212d964 | 2012-05-11 15:02:09 +0000 | [diff] [blame] | 161 | taken = true; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 162 | } |
| 163 | if ((non_object_regs & (1 << r)) != 0) { |
| 164 | __ pop(reg); |
| 165 | __ SmiUntag(reg); |
jkummerow@chromium.org | 212d964 | 2012-05-11 15:02:09 +0000 | [diff] [blame] | 166 | taken = true; |
| 167 | } |
| 168 | if (!taken) { |
| 169 | unused_reg = reg; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 170 | } |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 171 | } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 172 | |
jkummerow@chromium.org | 212d964 | 2012-05-11 15:02:09 +0000 | [diff] [blame] | 173 | ASSERT(unused_reg.code() != -1); |
| 174 | |
| 175 | // Read current padding counter and skip corresponding number of words. |
| 176 | __ pop(unused_reg); |
| 177 | // We divide stored value by 2 (untagging) and multiply it by word's size. |
ulan@chromium.org | d6899c3 | 2012-05-18 14:12:25 +0000 | [diff] [blame] | 178 | STATIC_ASSERT(kSmiTagSize == 1 && kSmiShiftSize == 0); |
jkummerow@chromium.org | 212d964 | 2012-05-11 15:02:09 +0000 | [diff] [blame] | 179 | __ lea(esp, Operand(esp, unused_reg, times_half_pointer_size, 0)); |
| 180 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 181 | // Get rid of the internal frame. |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 182 | } |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 183 | |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 184 | // If this call did not replace a call but patched other code then there will |
| 185 | // be an unwanted return address left on the stack. Here we get rid of that. |
| 186 | if (convert_call_to_jmp) { |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 187 | __ add(esp, Immediate(kPointerSize)); |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 188 | } |
| 189 | |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 190 | // Now that the break point has been handled, resume normal execution by |
| 191 | // jumping to the target address intended by the caller and that was |
| 192 | // overwritten by the address of DebugBreakXXX. |
| 193 | ExternalReference after_break_target = |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 194 | ExternalReference(Debug_Address::AfterBreakTarget(), masm->isolate()); |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 195 | __ jmp(Operand::StaticVariable(after_break_target)); |
| 196 | } |
| 197 | |
| 198 | |
| 199 | void Debug::GenerateLoadICDebugBreak(MacroAssembler* masm) { |
| 200 | // Register state for IC load call (from ic-ia32.cc). |
| 201 | // ----------- S t a t e ------------- |
| 202 | // -- ecx : name |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 203 | // -- edx : receiver |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 204 | // ----------------------------------- |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 205 | Generate_DebugBreakCallHelper(masm, ecx.bit() | edx.bit(), 0, false); |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | |
| 209 | void Debug::GenerateStoreICDebugBreak(MacroAssembler* masm) { |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 210 | // Register state for IC store call (from ic-ia32.cc). |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 211 | // ----------- S t a t e ------------- |
| 212 | // -- eax : value |
| 213 | // -- ecx : name |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 214 | // -- edx : receiver |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 215 | // ----------------------------------- |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 216 | Generate_DebugBreakCallHelper( |
| 217 | masm, eax.bit() | ecx.bit() | edx.bit(), 0, false); |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | |
| 221 | void Debug::GenerateKeyedLoadICDebugBreak(MacroAssembler* masm) { |
| 222 | // Register state for keyed IC load call (from ic-ia32.cc). |
| 223 | // ----------- S t a t e ------------- |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 224 | // -- ecx : key |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 225 | // -- edx : receiver |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 226 | // ----------------------------------- |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 227 | Generate_DebugBreakCallHelper(masm, ecx.bit() | edx.bit(), 0, false); |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | |
| 231 | void Debug::GenerateKeyedStoreICDebugBreak(MacroAssembler* masm) { |
| 232 | // Register state for keyed IC load call (from ic-ia32.cc). |
| 233 | // ----------- S t a t e ------------- |
| 234 | // -- eax : value |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 235 | // -- ecx : key |
| 236 | // -- edx : receiver |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 237 | // ----------------------------------- |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 238 | Generate_DebugBreakCallHelper( |
| 239 | masm, eax.bit() | ecx.bit() | edx.bit(), 0, false); |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 243 | void Debug::GenerateCompareNilICDebugBreak(MacroAssembler* masm) { |
| 244 | // Register state for CompareNil IC |
| 245 | // ----------- S t a t e ------------- |
| 246 | // -- eax : value |
| 247 | // ----------------------------------- |
| 248 | Generate_DebugBreakCallHelper(masm, eax.bit(), 0, false); |
| 249 | } |
| 250 | |
| 251 | |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 252 | void Debug::GenerateCallICDebugBreak(MacroAssembler* masm) { |
| 253 | // Register state for keyed IC call call (from ic-ia32.cc) |
| 254 | // ----------- S t a t e ------------- |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 255 | // -- ecx: name |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 256 | // ----------------------------------- |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 257 | Generate_DebugBreakCallHelper(masm, ecx.bit(), 0, false); |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 261 | void Debug::GenerateReturnDebugBreak(MacroAssembler* masm) { |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 262 | // Register state just before return from JS function (from codegen-ia32.cc). |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 263 | // ----------- S t a t e ------------- |
| 264 | // -- eax: return value |
| 265 | // ----------------------------------- |
| 266 | Generate_DebugBreakCallHelper(masm, eax.bit(), 0, true); |
| 267 | } |
| 268 | |
| 269 | |
| 270 | void Debug::GenerateCallFunctionStubDebugBreak(MacroAssembler* masm) { |
| 271 | // Register state for CallFunctionStub (from code-stubs-ia32.cc). |
| 272 | // ----------- S t a t e ------------- |
| 273 | // -- edi: function |
| 274 | // ----------------------------------- |
| 275 | Generate_DebugBreakCallHelper(masm, edi.bit(), 0, false); |
| 276 | } |
| 277 | |
| 278 | |
| 279 | void Debug::GenerateCallFunctionStubRecordDebugBreak(MacroAssembler* masm) { |
| 280 | // Register state for CallFunctionStub (from code-stubs-ia32.cc). |
| 281 | // ----------- S t a t e ------------- |
| 282 | // -- ebx: cache cell for call target |
| 283 | // -- edi: function |
| 284 | // ----------------------------------- |
| 285 | Generate_DebugBreakCallHelper(masm, ebx.bit() | edi.bit(), 0, false); |
| 286 | } |
| 287 | |
| 288 | |
| 289 | void Debug::GenerateCallConstructStubDebugBreak(MacroAssembler* masm) { |
| 290 | // Register state for CallConstructStub (from code-stubs-ia32.cc). |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 291 | // eax is the actual number of arguments not encoded as a smi see comment |
| 292 | // above IC call. |
| 293 | // ----------- S t a t e ------------- |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 294 | // -- eax: number of arguments (not smi) |
| 295 | // -- edi: constructor function |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 296 | // ----------------------------------- |
| 297 | // The number of arguments in eax is not smi encoded. |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 298 | Generate_DebugBreakCallHelper(masm, edi.bit(), eax.bit(), false); |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 302 | void Debug::GenerateCallConstructStubRecordDebugBreak(MacroAssembler* masm) { |
| 303 | // Register state for CallConstructStub (from code-stubs-ia32.cc). |
| 304 | // eax is the actual number of arguments not encoded as a smi see comment |
| 305 | // above IC call. |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 306 | // ----------- S t a t e ------------- |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 307 | // -- eax: number of arguments (not smi) |
| 308 | // -- ebx: cache cell for call target |
| 309 | // -- edi: constructor function |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 310 | // ----------------------------------- |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 311 | // The number of arguments in eax is not smi encoded. |
| 312 | Generate_DebugBreakCallHelper(masm, ebx.bit() | edi.bit(), eax.bit(), false); |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 316 | void Debug::GenerateSlot(MacroAssembler* masm) { |
| 317 | // Generate enough nop's to make space for a call instruction. |
| 318 | Label check_codesize; |
| 319 | __ bind(&check_codesize); |
| 320 | __ RecordDebugBreakSlot(); |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 321 | __ Nop(Assembler::kDebugBreakSlotLength); |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 322 | ASSERT_EQ(Assembler::kDebugBreakSlotLength, |
| 323 | masm->SizeOfCodeGeneratedSince(&check_codesize)); |
| 324 | } |
| 325 | |
| 326 | |
| 327 | void Debug::GenerateSlotDebugBreak(MacroAssembler* masm) { |
| 328 | // In the places where a debug break slot is inserted no registers can contain |
| 329 | // object pointers. |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 330 | Generate_DebugBreakCallHelper(masm, 0, 0, true); |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 334 | void Debug::GeneratePlainReturnLiveEdit(MacroAssembler* masm) { |
| 335 | masm->ret(0); |
| 336 | } |
| 337 | |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 338 | |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 339 | void Debug::GenerateFrameDropperLiveEdit(MacroAssembler* masm) { |
whesse@chromium.org | e90029b | 2010-08-02 11:52:17 +0000 | [diff] [blame] | 340 | ExternalReference restarter_frame_function_slot = |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 341 | ExternalReference(Debug_Address::RestarterFrameFunctionPointer(), |
| 342 | masm->isolate()); |
whesse@chromium.org | e90029b | 2010-08-02 11:52:17 +0000 | [diff] [blame] | 343 | __ mov(Operand::StaticVariable(restarter_frame_function_slot), Immediate(0)); |
| 344 | |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 345 | // We do not know our frame height, but set esp based on ebp. |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 346 | __ lea(esp, Operand(ebp, -1 * kPointerSize)); |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 347 | |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 348 | __ pop(edi); // Function. |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 349 | __ pop(ebp); |
| 350 | |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 351 | // Load context from the function. |
| 352 | __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
| 353 | |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 354 | // Get function code. |
| 355 | __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
| 356 | __ mov(edx, FieldOperand(edx, SharedFunctionInfo::kCodeOffset)); |
| 357 | __ lea(edx, FieldOperand(edx, Code::kHeaderSize)); |
| 358 | |
| 359 | // Re-run JSFunction, edi is function, esi is context. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 360 | __ jmp(edx); |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 361 | } |
| 362 | |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 363 | const bool Debug::kFrameDropperSupported = true; |
| 364 | |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 365 | #undef __ |
| 366 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 367 | #endif // ENABLE_DEBUGGER_SUPPORT |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 368 | |
| 369 | } } // namespace v8::internal |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 370 | |
| 371 | #endif // V8_TARGET_ARCH_IA32 |