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

Side by Side Diff: src/x64/virtual-frame-x64.cc

Issue 123018: X64 implementation starts using virtual frame and register allocators. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 6 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/virtual-frame-x64.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 #include "v8.h"
29
30 #include "codegen-inl.h"
31 #include "register-allocator-inl.h"
32 #include "scopes.h"
33
34 namespace v8 {
35 namespace internal {
36
37 #define __ ACCESS_MASM(masm())
38
39 // -------------------------------------------------------------------------
40 // VirtualFrame implementation.
41
42 // On entry to a function, the virtual frame already contains the receiver,
43 // the parameters, and a return address. All frame elements are in memory.
44 VirtualFrame::VirtualFrame()
45 : elements_(parameter_count() + local_count() + kPreallocatedElements),
46 stack_pointer_(parameter_count() + 1) { // 0-based index of TOS.
47 for (int i = 0; i <= stack_pointer_; i++) {
48 elements_.Add(FrameElement::MemoryElement());
49 }
50 for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) {
51 register_locations_[i] = kIllegalIndex;
52 }
53 }
54
55
56 void VirtualFrame::Enter() {
57 // Registers live on entry to a JS frame:
58 // rsp: stack pointer, points to return address from this function.
59 // rbp: base pointer, points to previous JS, ArgumentsAdaptor, or
60 // Trampoline frame.
61 // rsi: context of this function call.
62 // rdi: pointer to this function object.
63 Comment cmnt(masm(), "[ Enter JS frame");
64
65 #ifdef DEBUG
66 // Verify that rdi contains a JS function. The following code
67 // relies on rax being available for use.
68 __ testq(rdi, Immediate(kSmiTagMask));
69 __ Check(not_zero,
70 "VirtualFrame::Enter - rdi is not a function (smi check).");
71 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rax);
72 __ Check(equal,
73 "VirtualFrame::Enter - rdi is not a function (map check).");
74 #endif
75
76 EmitPush(rbp);
77
78 __ movq(rbp, rsp);
79
80 // Store the context in the frame. The context is kept in rsi and a
81 // copy is stored in the frame. The external reference to rsi
82 // remains.
83 EmitPush(rsi);
84
85 // Store the function in the frame. The frame owns the register
86 // reference now (ie, it can keep it in rdi or spill it later).
87 Push(rdi);
88 // SyncElementAt(element_count() - 1);
89 cgen()->allocator()->Unuse(rdi);
90 }
91
92
93 void VirtualFrame::Exit() {
94 Comment cmnt(masm(), "[ Exit JS frame");
95 // Record the location of the JS exit code for patching when setting
96 // break point.
97 __ RecordJSReturn();
98
99 // Avoid using the leave instruction here, because it is too
100 // short. We need the return sequence to be a least the size of a
101 // call instruction to support patching the exit code in the
102 // debugger. See VisitReturnStatement for the full return sequence.
103 __ movq(rsp, rbp);
104 stack_pointer_ = frame_pointer();
105 for (int i = element_count() - 1; i > stack_pointer_; i--) {
106 FrameElement last = elements_.RemoveLast();
107 if (last.is_register()) {
108 Unuse(last.reg());
109 }
110 }
111
112 EmitPop(rbp);
113 }
114
115
116 void VirtualFrame::EmitPop(Register reg) {
117 ASSERT(stack_pointer_ == element_count() - 1);
118 stack_pointer_--;
119 elements_.RemoveLast();
120 __ pop(reg);
121 }
122
123
124 void VirtualFrame::EmitPop(const Operand& operand) {
125 ASSERT(stack_pointer_ == element_count() - 1);
126 stack_pointer_--;
127 elements_.RemoveLast();
128 __ pop(operand);
129 }
130
131
132 void VirtualFrame::EmitPush(Register reg) {
133 ASSERT(stack_pointer_ == element_count() - 1);
134 elements_.Add(FrameElement::MemoryElement());
135 stack_pointer_++;
136 __ push(reg);
137 }
138
139
140 void VirtualFrame::EmitPush(const Operand& operand) {
141 ASSERT(stack_pointer_ == element_count() - 1);
142 elements_.Add(FrameElement::MemoryElement());
143 stack_pointer_++;
144 __ push(operand);
145 }
146
147
148 void VirtualFrame::EmitPush(Immediate immediate) {
149 ASSERT(stack_pointer_ == element_count() - 1);
150 elements_.Add(FrameElement::MemoryElement());
151 stack_pointer_++;
152 __ push(immediate);
153 }
154
155
156 void VirtualFrame::Drop(int a) {
157 UNIMPLEMENTED();
158 }
159
160 int VirtualFrame::InvalidateFrameSlotAt(int a) {
161 UNIMPLEMENTED();
162 return -1;
163 }
164
165 void VirtualFrame::MergeTo(VirtualFrame* a) {
166 UNIMPLEMENTED();
167 }
168
169 Result VirtualFrame::Pop() {
170 UNIMPLEMENTED();
171 return Result(NULL);
172 }
173
174 Result VirtualFrame::RawCallStub(CodeStub* a) {
175 UNIMPLEMENTED();
176 return Result(NULL);
177 }
178
179 void VirtualFrame::SyncElementBelowStackPointer(int a) {
180 UNIMPLEMENTED();
181 }
182
183 void VirtualFrame::SyncElementByPushing(int a) {
184 UNIMPLEMENTED();
185 }
186
187 void VirtualFrame::SyncRange(int a, int b) {
188 UNIMPLEMENTED();
189 }
190
191
192 #undef __
193
194 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/x64/virtual-frame-x64.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698