OLD | NEW |
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 | |
30 #include "v8.h" | 28 #include "v8.h" |
31 | 29 |
32 #if defined(V8_TARGET_ARCH_MIPS) | 30 #if defined(V8_TARGET_ARCH_MIPS) |
33 | 31 |
34 #include "codegen-inl.h" | 32 #include "codegen-inl.h" |
35 #include "register-allocator-inl.h" | 33 #include "register-allocator-inl.h" |
36 #include "scopes.h" | 34 #include "scopes.h" |
37 #include "virtual-frame-inl.h" | 35 #include "virtual-frame-inl.h" |
38 | 36 |
39 namespace v8 { | 37 namespace v8 { |
40 namespace internal { | 38 namespace internal { |
41 | 39 |
42 // ------------------------------------------------------------------------- | |
43 // VirtualFrame implementation. | |
44 | |
45 #define __ ACCESS_MASM(masm()) | 40 #define __ ACCESS_MASM(masm()) |
46 | 41 |
47 void VirtualFrame::SyncElementBelowStackPointer(int index) { | 42 void VirtualFrame::PopToA1A0() { |
48 UNREACHABLE(); | 43 UNIMPLEMENTED_MIPS(); |
49 } | 44 } |
50 | 45 |
51 | 46 |
52 void VirtualFrame::SyncElementByPushing(int index) { | 47 void VirtualFrame::PopToA1() { |
53 UNREACHABLE(); | 48 UNIMPLEMENTED_MIPS(); |
54 } | 49 } |
55 | 50 |
56 | 51 |
57 void VirtualFrame::SyncRange(int begin, int end) { | 52 void VirtualFrame::PopToA0() { |
58 // All elements are in memory on MIPS (ie, synced). | 53 UNIMPLEMENTED_MIPS(); |
59 #ifdef DEBUG | |
60 for (int i = begin; i <= end; i++) { | |
61 ASSERT(elements_[i].is_synced()); | |
62 } | |
63 #endif | |
64 } | 54 } |
65 | 55 |
66 | 56 |
67 void VirtualFrame::MergeTo(VirtualFrame* expected) { | 57 void VirtualFrame::MergeTo(const VirtualFrame* expected, |
| 58 Condition cond, |
| 59 Register r1, |
| 60 const Operand& r2) { |
| 61 UNIMPLEMENTED_MIPS(); |
| 62 } |
| 63 |
| 64 |
| 65 void VirtualFrame::MergeTo(VirtualFrame* expected, |
| 66 Condition cond, |
| 67 Register r1, |
| 68 const Operand& r2) { |
| 69 UNIMPLEMENTED_MIPS(); |
| 70 } |
| 71 |
| 72 |
| 73 void VirtualFrame::MergeTOSTo( |
| 74 VirtualFrame::TopOfStack expected_top_of_stack_state, |
| 75 Condition cond, |
| 76 Register r1, |
| 77 const Operand& r2) { |
68 UNIMPLEMENTED_MIPS(); | 78 UNIMPLEMENTED_MIPS(); |
69 } | 79 } |
70 | 80 |
71 | 81 |
72 void VirtualFrame::Enter() { | 82 void VirtualFrame::Enter() { |
73 // TODO(MIPS): Implement DEBUG | 83 UNIMPLEMENTED_MIPS(); |
74 | |
75 // We are about to push four values to the frame. | |
76 Adjust(4); | |
77 __ MultiPush(ra.bit() | fp.bit() | cp.bit() | a1.bit()); | |
78 // Adjust FP to point to saved FP. | |
79 __ addiu(fp, sp, 2 * kPointerSize); | |
80 } | 84 } |
81 | 85 |
82 | 86 |
83 void VirtualFrame::Exit() { | 87 void VirtualFrame::Exit() { |
84 UNIMPLEMENTED_MIPS(); | 88 UNIMPLEMENTED_MIPS(); |
85 } | 89 } |
86 | 90 |
87 | 91 |
88 void VirtualFrame::AllocateStackSlots() { | 92 void VirtualFrame::AllocateStackSlots() { |
89 int count = local_count(); | 93 UNIMPLEMENTED_MIPS(); |
90 if (count > 0) { | 94 } |
91 Comment cmnt(masm(), "[ Allocate space for locals"); | 95 |
92 Adjust(count); | |
93 // Initialize stack slots with 'undefined' value. | |
94 __ LoadRoot(t0, Heap::kUndefinedValueRootIndex); | |
95 __ addiu(sp, sp, -count * kPointerSize); | |
96 for (int i = 0; i < count; i++) { | |
97 __ sw(t0, MemOperand(sp, (count-i-1)*kPointerSize)); | |
98 } | |
99 } | |
100 } | |
101 | |
102 | |
103 void VirtualFrame::SaveContextRegister() { | |
104 UNIMPLEMENTED_MIPS(); | |
105 } | |
106 | |
107 | |
108 void VirtualFrame::RestoreContextRegister() { | |
109 UNIMPLEMENTED_MIPS(); | |
110 } | |
111 | 96 |
112 | 97 |
113 void VirtualFrame::PushReceiverSlotAddress() { | 98 void VirtualFrame::PushReceiverSlotAddress() { |
114 UNIMPLEMENTED_MIPS(); | 99 UNIMPLEMENTED_MIPS(); |
115 } | 100 } |
116 | 101 |
117 | 102 |
118 int VirtualFrame::InvalidateFrameSlotAt(int index) { | |
119 return kIllegalIndex; | |
120 } | |
121 | |
122 | |
123 void VirtualFrame::TakeFrameSlotAt(int index) { | |
124 UNIMPLEMENTED_MIPS(); | |
125 } | |
126 | |
127 | |
128 void VirtualFrame::StoreToFrameSlotAt(int index) { | |
129 UNIMPLEMENTED_MIPS(); | |
130 } | |
131 | |
132 | |
133 void VirtualFrame::PushTryHandler(HandlerType type) { | 103 void VirtualFrame::PushTryHandler(HandlerType type) { |
134 UNIMPLEMENTED_MIPS(); | 104 UNIMPLEMENTED_MIPS(); |
135 } | 105 } |
136 | 106 |
137 | 107 |
138 void VirtualFrame::RawCallStub(CodeStub* stub) { | 108 void VirtualFrame::CallJSFunction(int arg_count) { |
139 UNIMPLEMENTED_MIPS(); | 109 UNIMPLEMENTED_MIPS(); |
140 } | 110 } |
141 | 111 |
142 | 112 |
143 void VirtualFrame::CallStub(CodeStub* stub, Result* arg) { | 113 void VirtualFrame::CallRuntime(const Runtime::Function* f, int arg_count) { |
144 UNIMPLEMENTED_MIPS(); | 114 UNIMPLEMENTED_MIPS(); |
145 } | |
146 | |
147 | |
148 void VirtualFrame::CallStub(CodeStub* stub, Result* arg0, Result* arg1) { | |
149 UNIMPLEMENTED_MIPS(); | |
150 } | |
151 | |
152 | |
153 void VirtualFrame::CallRuntime(Runtime::Function* f, int arg_count) { | |
154 PrepareForCall(arg_count, arg_count); | |
155 ASSERT(cgen()->HasValidEntryRegisters()); | |
156 __ CallRuntime(f, arg_count); | |
157 } | 115 } |
158 | 116 |
159 | 117 |
160 void VirtualFrame::CallRuntime(Runtime::FunctionId id, int arg_count) { | 118 void VirtualFrame::CallRuntime(Runtime::FunctionId id, int arg_count) { |
161 PrepareForCall(arg_count, arg_count); | 119 UNIMPLEMENTED_MIPS(); |
162 ASSERT(cgen()->HasValidEntryRegisters()); | 120 } |
163 __ CallRuntime(id, arg_count); | 121 |
164 } | 122 |
165 | 123 #ifdef ENABLE_DEBUGGER_SUPPORT |
166 | 124 void VirtualFrame::DebugBreak() { |
167 void VirtualFrame::CallAlignedRuntime(Runtime::Function* f, int arg_count) { | 125 UNIMPLEMENTED_MIPS(); |
168 UNIMPLEMENTED_MIPS(); | 126 } |
169 } | 127 #endif |
170 | |
171 | |
172 void VirtualFrame::CallAlignedRuntime(Runtime::FunctionId id, int arg_count) { | |
173 UNIMPLEMENTED_MIPS(); | |
174 } | |
175 | 128 |
176 | 129 |
177 void VirtualFrame::InvokeBuiltin(Builtins::JavaScript id, | 130 void VirtualFrame::InvokeBuiltin(Builtins::JavaScript id, |
178 InvokeJSFlags flags, | 131 InvokeJSFlags flags, |
179 Result* arg_count_register, | |
180 int arg_count) { | 132 int arg_count) { |
181 UNIMPLEMENTED_MIPS(); | 133 UNIMPLEMENTED_MIPS(); |
182 } | 134 } |
183 | 135 |
184 | 136 |
| 137 void VirtualFrame::CallLoadIC(Handle<String> name, RelocInfo::Mode mode) { |
| 138 UNIMPLEMENTED_MIPS(); |
| 139 } |
| 140 |
| 141 |
| 142 void VirtualFrame::CallStoreIC(Handle<String> name, bool is_contextual) { |
| 143 UNIMPLEMENTED_MIPS(); |
| 144 } |
| 145 |
| 146 |
| 147 void VirtualFrame::CallKeyedLoadIC() { |
| 148 UNIMPLEMENTED_MIPS(); |
| 149 } |
| 150 |
| 151 |
| 152 void VirtualFrame::CallKeyedStoreIC() { |
| 153 UNIMPLEMENTED_MIPS(); |
| 154 } |
| 155 |
| 156 |
185 void VirtualFrame::CallCodeObject(Handle<Code> code, | 157 void VirtualFrame::CallCodeObject(Handle<Code> code, |
186 RelocInfo::Mode rmode, | 158 RelocInfo::Mode rmode, |
187 int dropped_args) { | 159 int dropped_args) { |
188 switch (code->kind()) { | 160 UNIMPLEMENTED_MIPS(); |
189 case Code::CALL_IC: | 161 } |
190 break; | 162 |
191 case Code::FUNCTION: | 163 |
192 UNIMPLEMENTED_MIPS(); | 164 // NO_TOS_REGISTERS, A0_TOS, A1_TOS, A1_A0_TOS, A0_A1_TOS. |
193 break; | 165 const bool VirtualFrame::kA0InUse[TOS_STATES] = |
194 case Code::KEYED_LOAD_IC: | 166 { false, true, false, true, true }; |
195 UNIMPLEMENTED_MIPS(); | 167 const bool VirtualFrame::kA1InUse[TOS_STATES] = |
196 break; | 168 { false, false, true, true, true }; |
197 case Code::LOAD_IC: | 169 const int VirtualFrame::kVirtualElements[TOS_STATES] = |
198 UNIMPLEMENTED_MIPS(); | 170 { 0, 1, 1, 2, 2 }; |
199 break; | 171 const Register VirtualFrame::kTopRegister[TOS_STATES] = |
200 case Code::KEYED_STORE_IC: | 172 { a0, a0, a1, a1, a0 }; |
201 UNIMPLEMENTED_MIPS(); | 173 const Register VirtualFrame::kBottomRegister[TOS_STATES] = |
202 break; | 174 { a0, a0, a1, a0, a1 }; |
203 case Code::STORE_IC: | 175 const Register VirtualFrame::kAllocatedRegisters[ |
204 UNIMPLEMENTED_MIPS(); | 176 VirtualFrame::kNumberOfAllocatedRegisters] = { a2, a3, t0, t1, t2 }; |
205 break; | 177 // Popping is done by the transition implied by kStateAfterPop. Of course if |
206 case Code::BUILTIN: | 178 // there were no stack slots allocated to registers then the physical SP must |
207 UNIMPLEMENTED_MIPS(); | 179 // be adjusted. |
208 break; | 180 const VirtualFrame::TopOfStack VirtualFrame::kStateAfterPop[TOS_STATES] = |
209 default: | 181 { NO_TOS_REGISTERS, NO_TOS_REGISTERS, NO_TOS_REGISTERS, A0_TOS, A1_TOS }; |
210 UNREACHABLE(); | 182 // Pushing is done by the transition implied by kStateAfterPush. Of course if |
211 break; | 183 // the maximum number of registers was already allocated to the top of stack |
212 } | 184 // slots then one register must be physically pushed onto the stack. |
213 Forget(dropped_args); | 185 const VirtualFrame::TopOfStack VirtualFrame::kStateAfterPush[TOS_STATES] = |
214 ASSERT(cgen()->HasValidEntryRegisters()); | 186 { A0_TOS, A1_A0_TOS, A0_A1_TOS, A0_A1_TOS, A1_A0_TOS }; |
215 __ Call(code, rmode); | |
216 } | |
217 | |
218 | |
219 void VirtualFrame::CallCodeObject(Handle<Code> code, | |
220 RelocInfo::Mode rmode, | |
221 Result* arg, | |
222 int dropped_args) { | |
223 UNIMPLEMENTED_MIPS(); | |
224 } | |
225 | |
226 | |
227 void VirtualFrame::CallCodeObject(Handle<Code> code, | |
228 RelocInfo::Mode rmode, | |
229 Result* arg0, | |
230 Result* arg1, | |
231 int dropped_args, | |
232 bool set_auto_args_slots) { | |
233 UNIMPLEMENTED_MIPS(); | |
234 } | |
235 | 187 |
236 | 188 |
237 void VirtualFrame::Drop(int count) { | 189 void VirtualFrame::Drop(int count) { |
238 ASSERT(count >= 0); | 190 UNIMPLEMENTED_MIPS(); |
239 ASSERT(height() >= count); | 191 } |
240 int num_virtual_elements = (element_count() - 1) - stack_pointer_; | 192 |
241 | 193 |
242 // Emit code to lower the stack pointer if necessary. | 194 void VirtualFrame::Pop() { |
243 if (num_virtual_elements < count) { | 195 UNIMPLEMENTED_MIPS(); |
244 int num_dropped = count - num_virtual_elements; | |
245 stack_pointer_ -= num_dropped; | |
246 __ addiu(sp, sp, num_dropped * kPointerSize); | |
247 } | |
248 | |
249 // Discard elements from the virtual frame and free any registers. | |
250 for (int i = 0; i < count; i++) { | |
251 FrameElement dropped = elements_.RemoveLast(); | |
252 if (dropped.is_register()) { | |
253 Unuse(dropped.reg()); | |
254 } | |
255 } | |
256 } | |
257 | |
258 | |
259 void VirtualFrame::DropFromVFrameOnly(int count) { | |
260 UNIMPLEMENTED_MIPS(); | |
261 } | |
262 | |
263 | |
264 Result VirtualFrame::Pop() { | |
265 UNIMPLEMENTED_MIPS(); | |
266 Result res = Result(); | |
267 return res; // UNIMPLEMENTED RETURN | |
268 } | 196 } |
269 | 197 |
270 | 198 |
271 void VirtualFrame::EmitPop(Register reg) { | 199 void VirtualFrame::EmitPop(Register reg) { |
272 ASSERT(stack_pointer_ == element_count() - 1); | 200 UNIMPLEMENTED_MIPS(); |
273 stack_pointer_--; | 201 } |
274 elements_.RemoveLast(); | 202 |
275 __ Pop(reg); | 203 |
| 204 void VirtualFrame::SpillAllButCopyTOSToA0() { |
| 205 UNIMPLEMENTED_MIPS(); |
| 206 } |
| 207 |
| 208 |
| 209 void VirtualFrame::SpillAllButCopyTOSToA1() { |
| 210 UNIMPLEMENTED_MIPS(); |
| 211 } |
| 212 |
| 213 |
| 214 void VirtualFrame::SpillAllButCopyTOSToA1A0() { |
| 215 UNIMPLEMENTED_MIPS(); |
| 216 } |
| 217 |
| 218 |
| 219 Register VirtualFrame::Peek() { |
| 220 UNIMPLEMENTED_MIPS(); |
| 221 return no_reg; |
| 222 } |
| 223 |
| 224 |
| 225 Register VirtualFrame::Peek2() { |
| 226 UNIMPLEMENTED_MIPS(); |
| 227 return no_reg; |
| 228 } |
| 229 |
| 230 |
| 231 void VirtualFrame::Dup() { |
| 232 UNIMPLEMENTED_MIPS(); |
| 233 } |
| 234 |
| 235 |
| 236 void VirtualFrame::Dup2() { |
| 237 UNIMPLEMENTED_MIPS(); |
| 238 } |
| 239 |
| 240 |
| 241 Register VirtualFrame::PopToRegister(Register but_not_to_this_one) { |
| 242 UNIMPLEMENTED_MIPS(); |
| 243 return no_reg; |
| 244 } |
| 245 |
| 246 |
| 247 void VirtualFrame::EnsureOneFreeTOSRegister() { |
| 248 UNIMPLEMENTED_MIPS(); |
276 } | 249 } |
277 | 250 |
278 | 251 |
279 void VirtualFrame::EmitMultiPop(RegList regs) { | 252 void VirtualFrame::EmitMultiPop(RegList regs) { |
280 ASSERT(stack_pointer_ == element_count() - 1); | 253 UNIMPLEMENTED_MIPS(); |
281 for (int16_t i = 0; i < kNumRegisters; i++) { | 254 } |
282 if ((regs & (1 << i)) != 0) { | 255 |
283 stack_pointer_--; | 256 |
284 elements_.RemoveLast(); | 257 void VirtualFrame::EmitPush(Register reg, TypeInfo info) { |
285 } | 258 UNIMPLEMENTED_MIPS(); |
286 } | 259 } |
287 __ MultiPop(regs); | 260 |
288 } | 261 |
289 | 262 void VirtualFrame::SetElementAt(Register reg, int this_far_down) { |
290 | 263 UNIMPLEMENTED_MIPS(); |
291 void VirtualFrame::EmitPush(Register reg) { | 264 } |
292 ASSERT(stack_pointer_ == element_count() - 1); | 265 |
293 elements_.Add(FrameElement::MemoryElement(NumberInfo::Unknown())); | 266 |
294 stack_pointer_++; | 267 Register VirtualFrame::GetTOSRegister() { |
295 __ Push(reg); | 268 UNIMPLEMENTED_MIPS(); |
| 269 return no_reg; |
| 270 } |
| 271 |
| 272 |
| 273 void VirtualFrame::EmitPush(Operand operand, TypeInfo info) { |
| 274 UNIMPLEMENTED_MIPS(); |
| 275 } |
| 276 |
| 277 |
| 278 void VirtualFrame::EmitPush(MemOperand operand, TypeInfo info) { |
| 279 UNIMPLEMENTED_MIPS(); |
| 280 } |
| 281 |
| 282 |
| 283 void VirtualFrame::EmitPushRoot(Heap::RootListIndex index) { |
| 284 UNIMPLEMENTED_MIPS(); |
296 } | 285 } |
297 | 286 |
298 | 287 |
299 void VirtualFrame::EmitMultiPush(RegList regs) { | 288 void VirtualFrame::EmitMultiPush(RegList regs) { |
300 ASSERT(stack_pointer_ == element_count() - 1); | 289 UNIMPLEMENTED_MIPS(); |
301 for (int16_t i = kNumRegisters; i > 0; i--) { | 290 } |
302 if ((regs & (1 << i)) != 0) { | 291 |
303 elements_.Add(FrameElement::MemoryElement(NumberInfo::Unknown())); | 292 |
304 stack_pointer_++; | 293 void VirtualFrame::EmitMultiPushReversed(RegList regs) { |
305 } | 294 UNIMPLEMENTED_MIPS(); |
306 } | 295 } |
307 __ MultiPush(regs); | 296 |
308 } | 297 |
309 | 298 void VirtualFrame::SpillAll() { |
310 | 299 UNIMPLEMENTED_MIPS(); |
311 void VirtualFrame::EmitArgumentSlots(RegList reglist) { | 300 } |
312 UNIMPLEMENTED_MIPS(); | 301 |
313 } | |
314 | 302 |
315 #undef __ | 303 #undef __ |
316 | 304 |
317 } } // namespace v8::internal | 305 } } // namespace v8::internal |
318 | 306 |
319 #endif // V8_TARGET_ARCH_MIPS | 307 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |