Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: src/x64/debug-x64.cc

Issue 6020012: Cleanup of x64 code. Rearrange functions in ic-x64.cc to match order in ic-i... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/assembler-x64.h ('k') | src/x64/ic-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28
29 #include "v8.h" 28 #include "v8.h"
30 29
31 #if defined(V8_TARGET_ARCH_X64) 30 #if defined(V8_TARGET_ARCH_X64)
32 31
33 #include "codegen-inl.h" 32 #include "codegen-inl.h"
34 #include "debug.h" 33 #include "debug.h"
35 34
36 35
37 namespace v8 { 36 namespace v8 {
38 namespace internal { 37 namespace internal {
39 38
40 #ifdef ENABLE_DEBUGGER_SUPPORT 39 #ifdef ENABLE_DEBUGGER_SUPPORT
41 40
41 bool BreakLocationIterator::IsDebugBreakAtReturn() {
42 return Debug::IsDebugBreakAtReturn(rinfo());
43 }
44
45
46 // Patch the JS frame exit code with a debug break call. See
47 // CodeGenerator::VisitReturnStatement and VirtualFrame::Exit in codegen-x64.cc
48 // for the precise return instructions sequence.
49 void BreakLocationIterator::SetDebugBreakAtReturn() {
50 ASSERT(Assembler::kJSReturnSequenceLength >=
51 Assembler::kCallInstructionLength);
52 rinfo()->PatchCodeWithCall(Debug::debug_break_return()->entry(),
53 Assembler::kJSReturnSequenceLength - Assembler::kCallInstructionLength);
54 }
55
56
57 // Restore the JS frame exit code.
58 void BreakLocationIterator::ClearDebugBreakAtReturn() {
59 rinfo()->PatchCode(original_rinfo()->pc(),
60 Assembler::kJSReturnSequenceLength);
61 }
62
63
64 // A debug break in the frame exit code is identified by the JS frame exit code
65 // having been patched with a call instruction.
42 bool Debug::IsDebugBreakAtReturn(v8::internal::RelocInfo* rinfo) { 66 bool Debug::IsDebugBreakAtReturn(v8::internal::RelocInfo* rinfo) {
43 ASSERT(RelocInfo::IsJSReturn(rinfo->rmode())); 67 ASSERT(RelocInfo::IsJSReturn(rinfo->rmode()));
44 return rinfo->IsPatchedReturnSequence(); 68 return rinfo->IsPatchedReturnSequence();
45 } 69 }
46 70
71
72 bool BreakLocationIterator::IsDebugBreakAtSlot() {
73 ASSERT(IsDebugBreakSlot());
74 // Check whether the debug break slot instructions have been patched.
75 return !Assembler::IsNop(rinfo()->pc());
76 }
77
78
79 void BreakLocationIterator::SetDebugBreakAtSlot() {
80 ASSERT(IsDebugBreakSlot());
81 rinfo()->PatchCodeWithCall(
82 Debug::debug_break_slot()->entry(),
83 Assembler::kDebugBreakSlotLength - Assembler::kCallInstructionLength);
84 }
85
86
87 void BreakLocationIterator::ClearDebugBreakAtSlot() {
88 ASSERT(IsDebugBreakSlot());
89 rinfo()->PatchCode(original_rinfo()->pc(), Assembler::kDebugBreakSlotLength);
90 }
91
92
47 #define __ ACCESS_MASM(masm) 93 #define __ ACCESS_MASM(masm)
48 94
95
49 static void Generate_DebugBreakCallHelper(MacroAssembler* masm, 96 static void Generate_DebugBreakCallHelper(MacroAssembler* masm,
50 RegList object_regs, 97 RegList object_regs,
51 RegList non_object_regs, 98 RegList non_object_regs,
52 bool convert_call_to_jmp) { 99 bool convert_call_to_jmp) {
53 // Enter an internal frame. 100 // Enter an internal frame.
54 __ EnterInternalFrame(); 101 __ EnterInternalFrame();
55 102
56 // Store the registers containing live values on the expression stack to 103 // Store the registers containing live values on the expression stack to
57 // make sure that these are correctly updated during GC. Non object values 104 // make sure that these are correctly updated during GC. Non object values
58 // are stored as as two smi causing it to be untouched by GC. 105 // are stored as as two smis causing it to be untouched by GC.
59 ASSERT((object_regs & ~kJSCallerSaved) == 0); 106 ASSERT((object_regs & ~kJSCallerSaved) == 0);
60 ASSERT((non_object_regs & ~kJSCallerSaved) == 0); 107 ASSERT((non_object_regs & ~kJSCallerSaved) == 0);
61 ASSERT((object_regs & non_object_regs) == 0); 108 ASSERT((object_regs & non_object_regs) == 0);
62 for (int i = 0; i < kNumJSCallerSaved; i++) { 109 for (int i = 0; i < kNumJSCallerSaved; i++) {
63 int r = JSCallerSavedCode(i); 110 int r = JSCallerSavedCode(i);
64 Register reg = { r }; 111 Register reg = { r };
65 ASSERT(!reg.is(kScratchRegister)); 112 ASSERT(!reg.is(kScratchRegister));
66 if ((object_regs & (1 << r)) != 0) { 113 if ((object_regs & (1 << r)) != 0) {
67 __ push(reg); 114 __ push(reg);
68 } 115 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // Now that the break point has been handled, resume normal execution by 166 // Now that the break point has been handled, resume normal execution by
120 // jumping to the target address intended by the caller and that was 167 // jumping to the target address intended by the caller and that was
121 // overwritten by the address of DebugBreakXXX. 168 // overwritten by the address of DebugBreakXXX.
122 ExternalReference after_break_target = 169 ExternalReference after_break_target =
123 ExternalReference(Debug_Address::AfterBreakTarget()); 170 ExternalReference(Debug_Address::AfterBreakTarget());
124 __ movq(kScratchRegister, after_break_target); 171 __ movq(kScratchRegister, after_break_target);
125 __ jmp(Operand(kScratchRegister, 0)); 172 __ jmp(Operand(kScratchRegister, 0));
126 } 173 }
127 174
128 175
129 void Debug::GenerateCallICDebugBreak(MacroAssembler* masm) { 176 void Debug::GenerateLoadICDebugBreak(MacroAssembler* masm) {
130 // Register state for IC call call (from ic-x64.cc) 177 // Register state for IC load call (from ic-x64.cc).
131 // ----------- S t a t e ------------- 178 // ----------- S t a t e -------------
132 // -- rcx: function name 179 // -- rax : receiver
180 // -- rcx : name
133 // ----------------------------------- 181 // -----------------------------------
134 Generate_DebugBreakCallHelper(masm, rcx.bit(), 0, false); 182 Generate_DebugBreakCallHelper(masm, rax.bit() | rcx.bit(), 0, false);
135 } 183 }
136 184
137 185
138 void Debug::GenerateConstructCallDebugBreak(MacroAssembler* masm) { 186 void Debug::GenerateStoreICDebugBreak(MacroAssembler* masm) {
139 // Register state just before return from JS function (from codegen-x64.cc). 187 // Register state for IC store call (from ic-x64.cc).
140 // rax is the actual number of arguments not encoded as a smi, see comment
141 // above IC call.
142 // ----------- S t a t e ------------- 188 // ----------- S t a t e -------------
143 // -- rax: number of arguments 189 // -- rax : value
190 // -- rcx : name
191 // -- rdx : receiver
144 // ----------------------------------- 192 // -----------------------------------
145 // The number of arguments in rax is not smi encoded. 193 Generate_DebugBreakCallHelper(
146 Generate_DebugBreakCallHelper(masm, rdi.bit(), rax.bit(), false); 194 masm, rax.bit() | rcx.bit() | rdx.bit(), 0, false);
147 } 195 }
148 196
149 197
150 void Debug::GenerateKeyedLoadICDebugBreak(MacroAssembler* masm) { 198 void Debug::GenerateKeyedLoadICDebugBreak(MacroAssembler* masm) {
151 // Register state for keyed IC load call (from ic-x64.cc). 199 // Register state for keyed IC load call (from ic-x64.cc).
152 // ----------- S t a t e ------------- 200 // ----------- S t a t e -------------
153 // -- rax : key 201 // -- rax : key
154 // -- rdx : receiver 202 // -- rdx : receiver
155 // ----------------------------------- 203 // -----------------------------------
156 Generate_DebugBreakCallHelper(masm, rax.bit() | rdx.bit(), 0, false); 204 Generate_DebugBreakCallHelper(masm, rax.bit() | rdx.bit(), 0, false);
157 } 205 }
158 206
159 207
160 void Debug::GenerateKeyedStoreICDebugBreak(MacroAssembler* masm) { 208 void Debug::GenerateKeyedStoreICDebugBreak(MacroAssembler* masm) {
161 // Register state for keyed IC load call (from ic-x64.cc). 209 // Register state for keyed IC load call (from ic-x64.cc).
162 // ----------- S t a t e ------------- 210 // ----------- S t a t e -------------
163 // -- rax : value 211 // -- rax : value
164 // -- rcx : key 212 // -- rcx : key
165 // -- rdx : receiver 213 // -- rdx : receiver
166 // ----------------------------------- 214 // -----------------------------------
167 Generate_DebugBreakCallHelper( 215 Generate_DebugBreakCallHelper(
168 masm, rax.bit() | rcx.bit() | rdx.bit(), 0, false); 216 masm, rax.bit() | rcx.bit() | rdx.bit(), 0, false);
169 } 217 }
170 218
171 219
172 void Debug::GenerateLoadICDebugBreak(MacroAssembler* masm) { 220 void Debug::GenerateCallICDebugBreak(MacroAssembler* masm) {
173 // Register state for IC load call (from ic-x64.cc). 221 // Register state for IC call call (from ic-x64.cc)
174 // ----------- S t a t e ------------- 222 // ----------- S t a t e -------------
175 // -- rax : receiver 223 // -- rcx: function name
176 // -- rcx : name
177 // ----------------------------------- 224 // -----------------------------------
178 Generate_DebugBreakCallHelper(masm, rax.bit() | rcx.bit(), 0, false); 225 Generate_DebugBreakCallHelper(masm, rcx.bit(), 0, false);
226 }
227
228
229 void Debug::GenerateConstructCallDebugBreak(MacroAssembler* masm) {
230 // Register state just before return from JS function (from codegen-x64.cc).
231 // rax is the actual number of arguments not encoded as a smi, see comment
232 // above IC call.
233 // ----------- S t a t e -------------
234 // -- rax: number of arguments
235 // -----------------------------------
236 // The number of arguments in rax is not smi encoded.
237 Generate_DebugBreakCallHelper(masm, rdi.bit(), rax.bit(), false);
179 } 238 }
180 239
181 240
182 void Debug::GenerateReturnDebugBreak(MacroAssembler* masm) { 241 void Debug::GenerateReturnDebugBreak(MacroAssembler* masm) {
183 // Register state just before return from JS function (from codegen-x64.cc). 242 // Register state just before return from JS function (from codegen-x64.cc).
184 // ----------- S t a t e ------------- 243 // ----------- S t a t e -------------
185 // -- rax: return value 244 // -- rax: return value
186 // ----------------------------------- 245 // -----------------------------------
187 Generate_DebugBreakCallHelper(masm, rax.bit(), 0, true); 246 Generate_DebugBreakCallHelper(masm, rax.bit(), 0, true);
188 } 247 }
189 248
190 249
191 void Debug::GenerateStoreICDebugBreak(MacroAssembler* masm) {
192 // Register state for IC store call (from ic-x64.cc).
193 // ----------- S t a t e -------------
194 // -- rax : value
195 // -- rcx : name
196 // -- rdx : receiver
197 // -----------------------------------
198 Generate_DebugBreakCallHelper(
199 masm, rax.bit() | rcx.bit() | rdx.bit(), 0, false);
200 }
201
202
203 void Debug::GenerateStubNoRegistersDebugBreak(MacroAssembler* masm) { 250 void Debug::GenerateStubNoRegistersDebugBreak(MacroAssembler* masm) {
204 // Register state for stub CallFunction (from CallFunctionStub in ic-x64.cc). 251 // Register state for stub CallFunction (from CallFunctionStub in ic-x64.cc).
205 // ----------- S t a t e ------------- 252 // ----------- S t a t e -------------
206 // No registers used on entry. 253 // No registers used on entry.
207 // ----------------------------------- 254 // -----------------------------------
208 Generate_DebugBreakCallHelper(masm, 0, 0, false); 255 Generate_DebugBreakCallHelper(masm, 0, 0, false);
209 } 256 }
210 257
211 258
212 void Debug::GenerateSlot(MacroAssembler* masm) { 259 void Debug::GenerateSlot(MacroAssembler* masm) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 __ lea(rdx, FieldOperand(rdx, Code::kHeaderSize)); 302 __ lea(rdx, FieldOperand(rdx, Code::kHeaderSize));
256 303
257 // Re-run JSFunction, rdi is function, rsi is context. 304 // Re-run JSFunction, rdi is function, rsi is context.
258 __ jmp(rdx); 305 __ jmp(rdx);
259 } 306 }
260 307
261 const bool Debug::kFrameDropperSupported = true; 308 const bool Debug::kFrameDropperSupported = true;
262 309
263 #undef __ 310 #undef __
264 311
265
266
267
268 void BreakLocationIterator::ClearDebugBreakAtReturn() {
269 rinfo()->PatchCode(original_rinfo()->pc(),
270 Assembler::kJSReturnSequenceLength);
271 }
272
273
274 bool BreakLocationIterator::IsDebugBreakAtReturn() {
275 return Debug::IsDebugBreakAtReturn(rinfo());
276 }
277
278
279 void BreakLocationIterator::SetDebugBreakAtReturn() {
280 ASSERT(Assembler::kJSReturnSequenceLength >=
281 Assembler::kCallInstructionLength);
282 rinfo()->PatchCodeWithCall(Debug::debug_break_return()->entry(),
283 Assembler::kJSReturnSequenceLength - Assembler::kCallInstructionLength);
284 }
285
286
287 bool BreakLocationIterator::IsDebugBreakAtSlot() {
288 ASSERT(IsDebugBreakSlot());
289 // Check whether the debug break slot instructions have been patched.
290 return !Assembler::IsNop(rinfo()->pc());
291 }
292
293
294 void BreakLocationIterator::SetDebugBreakAtSlot() {
295 ASSERT(IsDebugBreakSlot());
296 rinfo()->PatchCodeWithCall(
297 Debug::debug_break_slot()->entry(),
298 Assembler::kDebugBreakSlotLength - Assembler::kCallInstructionLength);
299 }
300
301
302 void BreakLocationIterator::ClearDebugBreakAtSlot() {
303 ASSERT(IsDebugBreakSlot());
304 rinfo()->PatchCode(original_rinfo()->pc(), Assembler::kDebugBreakSlotLength);
305 }
306
307
308 #endif // ENABLE_DEBUGGER_SUPPORT 312 #endif // ENABLE_DEBUGGER_SUPPORT
309 313
310 } } // namespace v8::internal 314 } } // namespace v8::internal
311 315
312 #endif // V8_TARGET_ARCH_X64 316 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/assembler-x64.h ('k') | src/x64/ic-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698