OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #include "codegen-inl.h" | 30 #include "codegen-inl.h" |
31 #include "debug.h" | 31 #include "debug.h" |
32 | 32 |
33 namespace v8 { | 33 namespace v8 { |
34 namespace internal { | 34 namespace internal { |
35 | 35 |
36 #ifdef ENABLE_DEBUGGER_SUPPORT | 36 #ifdef ENABLE_DEBUGGER_SUPPORT |
37 // Currently debug break is not supported in frame exit code on ARM. | |
38 bool BreakLocationIterator::IsDebugBreakAtReturn() { | 37 bool BreakLocationIterator::IsDebugBreakAtReturn() { |
39 return false; | 38 return Debug::IsDebugBreakAtReturn(rinfo()); |
40 } | 39 } |
41 | 40 |
42 | 41 |
43 // Currently debug break is not supported in frame exit code on ARM. | |
44 void BreakLocationIterator::SetDebugBreakAtReturn() { | 42 void BreakLocationIterator::SetDebugBreakAtReturn() { |
45 UNIMPLEMENTED(); | 43 // Patch the code changing the return from JS function sequence from |
| 44 // mov sp, fp |
| 45 // ldmia sp!, {fp, lr} |
| 46 // add sp, sp, #4 |
| 47 // bx lr |
| 48 // to a call to the debug break return code. |
| 49 // mov lr, pc |
| 50 // ldr pc, [pc, #-4] |
| 51 // <debug break return code entry point address> |
| 52 // bktp 0 |
| 53 CodePatcher patcher(rinfo()->pc(), 4); |
| 54 patcher.masm()->mov(v8::internal::lr, v8::internal::pc); |
| 55 patcher.masm()->ldr(v8::internal::pc, MemOperand(v8::internal::pc, -4)); |
| 56 patcher.Emit(Debug::debug_break_return()->entry()); |
| 57 patcher.masm()->bkpt(0); |
46 } | 58 } |
47 | 59 |
48 | 60 |
49 // Currently debug break is not supported in frame exit code on ARM. | 61 // Restore the JS frame exit code. |
50 void BreakLocationIterator::ClearDebugBreakAtReturn() { | 62 void BreakLocationIterator::ClearDebugBreakAtReturn() { |
51 UNIMPLEMENTED(); | 63 rinfo()->PatchCode(original_rinfo()->pc(), |
| 64 CodeGenerator::kJSReturnSequenceLength); |
52 } | 65 } |
53 | 66 |
54 | 67 |
| 68 // A debug break in the exit code is identified by a call. |
55 bool Debug::IsDebugBreakAtReturn(RelocInfo* rinfo) { | 69 bool Debug::IsDebugBreakAtReturn(RelocInfo* rinfo) { |
56 ASSERT(RelocInfo::IsJSReturn(rinfo->rmode())); | 70 ASSERT(RelocInfo::IsJSReturn(rinfo->rmode())); |
57 // Currently debug break is not supported in frame exit code on ARM. | 71 return rinfo->IsCallInstruction(); |
58 return false; | |
59 } | 72 } |
60 | 73 |
61 | 74 |
62 #define __ ACCESS_MASM(masm) | 75 #define __ ACCESS_MASM(masm) |
63 | 76 |
64 | 77 |
65 static void Generate_DebugBreakCallHelper(MacroAssembler* masm, | 78 static void Generate_DebugBreakCallHelper(MacroAssembler* masm, |
66 RegList pointer_regs) { | 79 RegList pointer_regs) { |
67 // Save the content of all general purpose registers in memory. This copy in | 80 // Save the content of all general purpose registers in memory. This copy in |
68 // memory is later pushed onto the JS expression stack for the fake JS frame | 81 // memory is later pushed onto the JS expression stack for the fake JS frame |
(...skipping 19 matching lines...) Expand all Loading... |
88 CEntryDebugBreakStub ceb; | 101 CEntryDebugBreakStub ceb; |
89 __ CallStub(&ceb); | 102 __ CallStub(&ceb); |
90 | 103 |
91 // Restore the register values containing object pointers from the expression | 104 // Restore the register values containing object pointers from the expression |
92 // stack in the reverse order as they where pushed. | 105 // stack in the reverse order as they where pushed. |
93 // Use sp as base to pop. | 106 // Use sp as base to pop. |
94 __ CopyRegistersFromStackToMemory(sp, r3, pointer_regs); | 107 __ CopyRegistersFromStackToMemory(sp, r3, pointer_regs); |
95 | 108 |
96 __ LeaveInternalFrame(); | 109 __ LeaveInternalFrame(); |
97 | 110 |
98 // Inlined ExitJSFrame ends here. | |
99 | |
100 // Finally restore all registers. | 111 // Finally restore all registers. |
101 __ RestoreRegistersFromMemory(kJSCallerSaved); | 112 __ RestoreRegistersFromMemory(kJSCallerSaved); |
102 | 113 |
103 // Now that the break point has been handled, resume normal execution by | 114 // Now that the break point has been handled, resume normal execution by |
104 // jumping to the target address intended by the caller and that was | 115 // jumping to the target address intended by the caller and that was |
105 // overwritten by the address of DebugBreakXXX. | 116 // overwritten by the address of DebugBreakXXX. |
106 __ mov(ip, Operand(ExternalReference(Debug_Address::AfterBreakTarget()))); | 117 __ mov(ip, Operand(ExternalReference(Debug_Address::AfterBreakTarget()))); |
107 __ ldr(ip, MemOperand(ip)); | 118 __ ldr(ip, MemOperand(ip)); |
108 __ Jump(ip); | 119 __ Jump(ip); |
109 } | 120 } |
(...skipping 21 matching lines...) Expand all Loading... |
131 // -- lr : return address | 142 // -- lr : return address |
132 // -- [sp] : receiver | 143 // -- [sp] : receiver |
133 // ----------------------------------- | 144 // ----------------------------------- |
134 // Registers r0 and r2 contain objects that needs to be pushed on the | 145 // Registers r0 and r2 contain objects that needs to be pushed on the |
135 // expression stack of the fake JS frame. | 146 // expression stack of the fake JS frame. |
136 Generate_DebugBreakCallHelper(masm, r0.bit() | r2.bit()); | 147 Generate_DebugBreakCallHelper(masm, r0.bit() | r2.bit()); |
137 } | 148 } |
138 | 149 |
139 | 150 |
140 void Debug::GenerateKeyedLoadICDebugBreak(MacroAssembler* masm) { | 151 void Debug::GenerateKeyedLoadICDebugBreak(MacroAssembler* masm) { |
141 // Keyed load IC not implemented on ARM. | 152 // ---------- S t a t e -------------- |
| 153 // -- lr : return address |
| 154 // -- sp[0] : key |
| 155 // -- sp[4] : receiver |
| 156 Generate_DebugBreakCallHelper(masm, 0); |
142 } | 157 } |
143 | 158 |
144 | 159 |
145 void Debug::GenerateKeyedStoreICDebugBreak(MacroAssembler* masm) { | 160 void Debug::GenerateKeyedStoreICDebugBreak(MacroAssembler* masm) { |
146 // Keyed store IC not implemented on ARM. | 161 // ---------- S t a t e -------------- |
| 162 // -- lr : return address |
| 163 // -- sp[0] : key |
| 164 // -- sp[4] : receiver |
| 165 Generate_DebugBreakCallHelper(masm, 0); |
147 } | 166 } |
148 | 167 |
149 | 168 |
150 void Debug::GenerateCallICDebugBreak(MacroAssembler* masm) { | 169 void Debug::GenerateCallICDebugBreak(MacroAssembler* masm) { |
151 // Calling convention for IC call (from ic-arm.cc) | 170 // Calling convention for IC call (from ic-arm.cc) |
152 // ----------- S t a t e ------------- | 171 // ----------- S t a t e ------------- |
153 // -- r0: number of arguments | 172 // -- r0: number of arguments |
154 // -- r1: receiver | 173 // -- r1: receiver |
155 // -- lr: return address | 174 // -- lr: return address |
156 // ----------------------------------- | 175 // ----------------------------------- |
(...skipping 16 matching lines...) Expand all Loading... |
173 | 192 |
174 void Debug::GenerateReturnDebugBreak(MacroAssembler* masm) { | 193 void Debug::GenerateReturnDebugBreak(MacroAssembler* masm) { |
175 // In places other than IC call sites it is expected that r0 is TOS which | 194 // In places other than IC call sites it is expected that r0 is TOS which |
176 // is an object - this is not generally the case so this should be used with | 195 // is an object - this is not generally the case so this should be used with |
177 // care. | 196 // care. |
178 Generate_DebugBreakCallHelper(masm, r0.bit()); | 197 Generate_DebugBreakCallHelper(masm, r0.bit()); |
179 } | 198 } |
180 | 199 |
181 | 200 |
182 void Debug::GenerateStubNoRegistersDebugBreak(MacroAssembler* masm) { | 201 void Debug::GenerateStubNoRegistersDebugBreak(MacroAssembler* masm) { |
183 // Generate nothing as CodeStub CallFunction is not used on ARM. | 202 // ----------- S t a t e ------------- |
| 203 // No registers used on entry. |
| 204 // ----------------------------------- |
| 205 Generate_DebugBreakCallHelper(masm, 0); |
184 } | 206 } |
185 | 207 |
186 | 208 |
187 #undef __ | 209 #undef __ |
188 | 210 |
189 #endif // ENABLE_DEBUGGER_SUPPORT | 211 #endif // ENABLE_DEBUGGER_SUPPORT |
190 | 212 |
191 } } // namespace v8::internal | 213 } } // namespace v8::internal |
OLD | NEW |