OLD | NEW |
(Empty) | |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 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 |
| 30 #include "codegen-inl.h" |
| 31 #include "debug.h" |
| 32 |
| 33 namespace v8 { namespace internal { |
| 34 |
| 35 |
| 36 #define __ masm-> |
| 37 |
| 38 |
| 39 static void Generate_DebugBreakCallHelper(MacroAssembler* masm, |
| 40 RegList pointer_regs) { |
| 41 // Save the content of all general purpose registers in memory. This copy in |
| 42 // memory is later pushed onto the JS expression stack for the fake JS frame |
| 43 // generated and also to the C frame generated on top of that. In the JS |
| 44 // frame ONLY the registers containing pointers will be pushed on the |
| 45 // expression stack. This causes the GC to update these pointers so that |
| 46 // they will have the correct value when returning from the debugger. |
| 47 __ SaveRegistersToMemory(kJSCallerSaved); |
| 48 |
| 49 __ EnterInternalFrame(); |
| 50 |
| 51 // Store the registers containing object pointers on the expression stack to |
| 52 // make sure that these are correctly updated during GC. |
| 53 // Use sp as base to push. |
| 54 __ CopyRegistersFromMemoryToStack(sp, pointer_regs); |
| 55 |
| 56 #ifdef DEBUG |
| 57 __ RecordComment("// Calling from debug break to runtime - come in - over"); |
| 58 #endif |
| 59 __ mov(r0, Operand(0)); // no arguments |
| 60 __ mov(r1, Operand(ExternalReference::debug_break())); |
| 61 |
| 62 CEntryDebugBreakStub ceb; |
| 63 __ CallStub(&ceb); |
| 64 |
| 65 // Restore the register values containing object pointers from the expression |
| 66 // stack in the reverse order as they where pushed. |
| 67 // Use sp as base to pop. |
| 68 __ CopyRegistersFromStackToMemory(sp, r3, pointer_regs); |
| 69 |
| 70 __ LeaveInternalFrame(); |
| 71 |
| 72 // Inlined ExitJSFrame ends here. |
| 73 |
| 74 // Finally restore all registers. |
| 75 __ RestoreRegistersFromMemory(kJSCallerSaved); |
| 76 |
| 77 // Now that the break point has been handled, resume normal execution by |
| 78 // jumping to the target address intended by the caller and that was |
| 79 // overwritten by the address of DebugBreakXXX. |
| 80 __ mov(ip, Operand(ExternalReference(Debug_Address::AfterBreakTarget()))); |
| 81 __ ldr(ip, MemOperand(ip)); |
| 82 __ Jump(ip); |
| 83 } |
| 84 |
| 85 |
| 86 void Debug::GenerateLoadICDebugBreak(MacroAssembler* masm) { |
| 87 // Calling convention for IC load (from ic-arm.cc). |
| 88 // ----------- S t a t e ------------- |
| 89 // -- r0 : receiver |
| 90 // -- r2 : name |
| 91 // -- lr : return address |
| 92 // -- [sp] : receiver |
| 93 // ----------------------------------- |
| 94 // Registers r0 and r2 contain objects that needs to be pushed on the |
| 95 // expression stack of the fake JS frame. |
| 96 Generate_DebugBreakCallHelper(masm, r0.bit() | r2.bit()); |
| 97 } |
| 98 |
| 99 |
| 100 void Debug::GenerateStoreICDebugBreak(MacroAssembler* masm) { |
| 101 // Calling convention for IC store (from ic-arm.cc). |
| 102 // ----------- S t a t e ------------- |
| 103 // -- r0 : receiver |
| 104 // -- r2 : name |
| 105 // -- lr : return address |
| 106 // -- [sp] : receiver |
| 107 // ----------------------------------- |
| 108 // Registers r0 and r2 contain objects that needs to be pushed on the |
| 109 // expression stack of the fake JS frame. |
| 110 Generate_DebugBreakCallHelper(masm, r0.bit() | r2.bit()); |
| 111 } |
| 112 |
| 113 |
| 114 void Debug::GenerateKeyedLoadICDebugBreak(MacroAssembler* masm) { |
| 115 // Keyed load IC not implemented on ARM. |
| 116 } |
| 117 |
| 118 |
| 119 void Debug::GenerateKeyedStoreICDebugBreak(MacroAssembler* masm) { |
| 120 // Keyed store IC not implemented on ARM. |
| 121 } |
| 122 |
| 123 |
| 124 void Debug::GenerateCallICDebugBreak(MacroAssembler* masm) { |
| 125 // Calling convention for IC call (from ic-arm.cc) |
| 126 // ----------- S t a t e ------------- |
| 127 // -- r0: number of arguments |
| 128 // -- r1: receiver |
| 129 // -- lr: return address |
| 130 // ----------------------------------- |
| 131 // Register r1 contains an object that needs to be pushed on the expression |
| 132 // stack of the fake JS frame. r0 is the actual number of arguments not |
| 133 // encoded as a smi, therefore it cannot be on the expression stack of the |
| 134 // fake JS frame as it can easily be an invalid pointer (e.g. 1). r0 will be |
| 135 // pushed on the stack of the C frame and restored from there. |
| 136 Generate_DebugBreakCallHelper(masm, r1.bit()); |
| 137 } |
| 138 |
| 139 |
| 140 void Debug::GenerateConstructCallDebugBreak(MacroAssembler* masm) { |
| 141 // In places other than IC call sites it is expected that r0 is TOS which |
| 142 // is an object - this is not generally the case so this should be used with |
| 143 // care. |
| 144 Generate_DebugBreakCallHelper(masm, r0.bit()); |
| 145 } |
| 146 |
| 147 |
| 148 void Debug::GenerateReturnDebugBreak(MacroAssembler* masm) { |
| 149 // In places other than IC call sites it is expected that r0 is TOS which |
| 150 // is an object - this is not generally the case so this should be used with |
| 151 // care. |
| 152 Generate_DebugBreakCallHelper(masm, r0.bit()); |
| 153 } |
| 154 |
| 155 |
| 156 void Debug::GenerateReturnDebugBreakEntry(MacroAssembler* masm) { |
| 157 // Generate nothing as this handling of debug break return is not done this |
| 158 // way on ARM - yet. |
| 159 } |
| 160 |
| 161 |
| 162 void Debug::GenerateStubNoRegistersDebugBreak(MacroAssembler* masm) { |
| 163 // Generate nothing as CodeStub CallFunction is not used on ARM. |
| 164 } |
| 165 |
| 166 |
| 167 #undef __ |
| 168 |
| 169 |
| 170 } } // namespace v8::internal |
OLD | NEW |