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

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

Issue 13657: Moved the code generation for debug break stubs from builtins* to debug*. Fro... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years 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/debug-arm.cc ('k') | src/stub-cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ native
OLDNEW
(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 //#include "runtime.h"
33
34 namespace v8 { namespace internal {
35
36
37 #define __ masm->
38
39
40 static void Generate_DebugBreakCallHelper(MacroAssembler* masm,
41 RegList pointer_regs,
42 bool convert_call_to_jmp) {
43 // Save the content of all general purpose registers in memory. This copy in
44 // memory is later pushed onto the JS expression stack for the fake JS frame
45 // generated and also to the C frame generated on top of that. In the JS
46 // frame ONLY the registers containing pointers will be pushed on the
47 // expression stack. This causes the GC to update these pointers so that
48 // they will have the correct value when returning from the debugger.
49 __ SaveRegistersToMemory(kJSCallerSaved);
50
51 // Enter an internal frame.
52 __ EnterInternalFrame();
53
54 // Store the registers containing object pointers on the expression stack to
55 // make sure that these are correctly updated during GC.
56 __ PushRegistersFromMemory(pointer_regs);
57
58 #ifdef DEBUG
59 __ RecordComment("// Calling from debug break to runtime - come in - over");
60 #endif
61 __ Set(eax, Immediate(0)); // no arguments
62 __ mov(ebx, Immediate(ExternalReference::debug_break()));
63
64 CEntryDebugBreakStub ceb;
65 __ CallStub(&ceb);
66
67 // Restore the register values containing object pointers from the expression
68 // stack in the reverse order as they where pushed.
69 __ PopRegistersToMemory(pointer_regs);
70
71 // Get rid of the internal frame.
72 __ LeaveInternalFrame();
73
74 // If this call did not replace a call but patched other code then there will
75 // be an unwanted return address left on the stack. Here we get rid of that.
76 if (convert_call_to_jmp) {
77 __ pop(eax);
78 }
79
80 // Finally restore all registers.
81 __ RestoreRegistersFromMemory(kJSCallerSaved);
82
83 // Now that the break point has been handled, resume normal execution by
84 // jumping to the target address intended by the caller and that was
85 // overwritten by the address of DebugBreakXXX.
86 ExternalReference after_break_target =
87 ExternalReference(Debug_Address::AfterBreakTarget());
88 __ jmp(Operand::StaticVariable(after_break_target));
89 }
90
91
92 void Debug::GenerateLoadICDebugBreak(MacroAssembler* masm) {
93 // Register state for IC load call (from ic-ia32.cc).
94 // ----------- S t a t e -------------
95 // -- ecx : name
96 // -----------------------------------
97 Generate_DebugBreakCallHelper(masm, ecx.bit(), false);
98 }
99
100
101 void Debug::GenerateStoreICDebugBreak(MacroAssembler* masm) {
102 // REgister state for IC store call (from ic-ia32.cc).
103 // ----------- S t a t e -------------
104 // -- eax : value
105 // -- ecx : name
106 // -----------------------------------
107 Generate_DebugBreakCallHelper(masm, eax.bit() | ecx.bit(), false);
108 }
109
110
111 void Debug::GenerateKeyedLoadICDebugBreak(MacroAssembler* masm) {
112 // Register state for keyed IC load call (from ic-ia32.cc).
113 // ----------- S t a t e -------------
114 // No registers used on entry.
115 // -----------------------------------
116 Generate_DebugBreakCallHelper(masm, 0, false);
117 }
118
119
120 void Debug::GenerateKeyedStoreICDebugBreak(MacroAssembler* masm) {
121 // Register state for keyed IC load call (from ic-ia32.cc).
122 // ----------- S t a t e -------------
123 // -- eax : value
124 // -----------------------------------
125 // Register eax contains an object that needs to be pushed on the
126 // expression stack of the fake JS frame.
127 Generate_DebugBreakCallHelper(masm, eax.bit(), false);
128 }
129
130
131 void Debug::GenerateCallICDebugBreak(MacroAssembler* masm) {
132 // Register state for keyed IC call call (from ic-ia32.cc)
133 // ----------- S t a t e -------------
134 // -- eax: number of arguments
135 // -----------------------------------
136 // The number of arguments in eax is not smi encoded.
137 Generate_DebugBreakCallHelper(masm, 0, false);
138 }
139
140
141 void Debug::GenerateConstructCallDebugBreak(MacroAssembler* masm) {
142 // Register state just before return from JS function (from codegen-ia32.cc).
143 // eax is the actual number of arguments not encoded as a smi see comment
144 // above IC call.
145 // ----------- S t a t e -------------
146 // -- eax: number of arguments
147 // -----------------------------------
148 // The number of arguments in eax is not smi encoded.
149 Generate_DebugBreakCallHelper(masm, 0, false);
150 }
151
152
153 void Debug::GenerateReturnDebugBreak(MacroAssembler* masm) {
154 // Register state just before return from JS function (from codegen-ia32.cc).
155 // ----------- S t a t e -------------
156 // -- eax: return value
157 // -----------------------------------
158 Generate_DebugBreakCallHelper(masm, eax.bit(), true);
159 }
160
161
162 void Debug::GenerateReturnDebugBreakEntry(MacroAssembler* masm) {
163 // OK to clobber ebx as we are returning from a JS function in the code
164 // generated by Ia32CodeGenerator::ExitJSFrame.
165 ExternalReference debug_break_return =
166 ExternalReference(Debug_Address::DebugBreakReturn());
167 __ mov(ebx, Operand::StaticVariable(debug_break_return));
168 __ add(Operand(ebx), Immediate(Code::kHeaderSize - kHeapObjectTag));
169 __ jmp(Operand(ebx));
170 }
171
172
173 void Debug::GenerateStubNoRegistersDebugBreak(MacroAssembler* masm) {
174 // Register state for stub CallFunction (from CallFunctionStub in ic-ia32.cc).
175 // ----------- S t a t e -------------
176 // No registers used on entry.
177 // -----------------------------------
178 Generate_DebugBreakCallHelper(masm, 0, false);
179 }
180
181
182 #undef __
183
184
185 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/debug-arm.cc ('k') | src/stub-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698