blob: b61ce75bd9edca4f7ac6652256f7e9370c6260e6 [file] [log] [blame]
Andrei Popescu31002712010-02-23 13:46:05 +00001// Copyright 2010 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
29
30#include "v8.h"
31
Leon Clarkef7060e22010-06-03 12:02:55 +010032#if defined(V8_TARGET_ARCH_MIPS)
33
Andrei Popescu31002712010-02-23 13:46:05 +000034#include "codegen-inl.h"
35#include "register-allocator-inl.h"
36#include "scopes.h"
Steve Block6ded16b2010-05-10 14:33:55 +010037#include "virtual-frame-inl.h"
Andrei Popescu31002712010-02-23 13:46:05 +000038
39namespace v8 {
40namespace internal {
41
42// -------------------------------------------------------------------------
43// VirtualFrame implementation.
44
45#define __ ACCESS_MASM(masm())
46
Andrei Popescu31002712010-02-23 13:46:05 +000047void VirtualFrame::SyncElementBelowStackPointer(int index) {
48 UNREACHABLE();
49}
50
51
52void VirtualFrame::SyncElementByPushing(int index) {
53 UNREACHABLE();
54}
55
56
57void VirtualFrame::SyncRange(int begin, int end) {
Steve Block6ded16b2010-05-10 14:33:55 +010058 // All elements are in memory on MIPS (ie, synced).
59#ifdef DEBUG
60 for (int i = begin; i <= end; i++) {
61 ASSERT(elements_[i].is_synced());
62 }
63#endif
Andrei Popescu31002712010-02-23 13:46:05 +000064}
65
66
67void VirtualFrame::MergeTo(VirtualFrame* expected) {
68 UNIMPLEMENTED_MIPS();
69}
70
71
72void VirtualFrame::Enter() {
Steve Block6ded16b2010-05-10 14:33:55 +010073 // TODO(MIPS): Implement DEBUG
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);
Andrei Popescu31002712010-02-23 13:46:05 +000080}
81
82
83void VirtualFrame::Exit() {
84 UNIMPLEMENTED_MIPS();
85}
86
87
88void VirtualFrame::AllocateStackSlots() {
Steve Block6ded16b2010-05-10 14:33:55 +010089 int count = local_count();
90 if (count > 0) {
91 Comment cmnt(masm(), "[ Allocate space for locals");
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 }
Andrei Popescu31002712010-02-23 13:46:05 +0000100}
101
102
103void VirtualFrame::SaveContextRegister() {
104 UNIMPLEMENTED_MIPS();
105}
106
107
108void VirtualFrame::RestoreContextRegister() {
109 UNIMPLEMENTED_MIPS();
110}
111
112
113void VirtualFrame::PushReceiverSlotAddress() {
114 UNIMPLEMENTED_MIPS();
115}
116
117
118int VirtualFrame::InvalidateFrameSlotAt(int index) {
119 return kIllegalIndex;
120}
121
122
123void VirtualFrame::TakeFrameSlotAt(int index) {
124 UNIMPLEMENTED_MIPS();
125}
126
127
128void VirtualFrame::StoreToFrameSlotAt(int index) {
129 UNIMPLEMENTED_MIPS();
130}
131
132
133void VirtualFrame::PushTryHandler(HandlerType type) {
134 UNIMPLEMENTED_MIPS();
135}
136
137
138void VirtualFrame::RawCallStub(CodeStub* stub) {
139 UNIMPLEMENTED_MIPS();
140}
141
142
143void VirtualFrame::CallStub(CodeStub* stub, Result* arg) {
144 UNIMPLEMENTED_MIPS();
145}
146
147
148void VirtualFrame::CallStub(CodeStub* stub, Result* arg0, Result* arg1) {
149 UNIMPLEMENTED_MIPS();
150}
151
152
153void VirtualFrame::CallRuntime(Runtime::Function* f, int arg_count) {
Steve Block6ded16b2010-05-10 14:33:55 +0100154 PrepareForCall(arg_count, arg_count);
155 ASSERT(cgen()->HasValidEntryRegisters());
156 __ CallRuntime(f, arg_count);
Andrei Popescu31002712010-02-23 13:46:05 +0000157}
158
159
160void VirtualFrame::CallRuntime(Runtime::FunctionId id, int arg_count) {
Steve Block6ded16b2010-05-10 14:33:55 +0100161 PrepareForCall(arg_count, arg_count);
162 ASSERT(cgen()->HasValidEntryRegisters());
163 __ CallRuntime(id, arg_count);
Andrei Popescu31002712010-02-23 13:46:05 +0000164}
165
166
167void VirtualFrame::CallAlignedRuntime(Runtime::Function* f, int arg_count) {
168 UNIMPLEMENTED_MIPS();
169}
170
171
172void VirtualFrame::CallAlignedRuntime(Runtime::FunctionId id, int arg_count) {
173 UNIMPLEMENTED_MIPS();
174}
175
176
177void VirtualFrame::InvokeBuiltin(Builtins::JavaScript id,
178 InvokeJSFlags flags,
179 Result* arg_count_register,
180 int arg_count) {
181 UNIMPLEMENTED_MIPS();
182}
183
184
Andrei Popescu31002712010-02-23 13:46:05 +0000185void VirtualFrame::CallCodeObject(Handle<Code> code,
186 RelocInfo::Mode rmode,
187 int dropped_args) {
Steve Block6ded16b2010-05-10 14:33:55 +0100188 switch (code->kind()) {
189 case Code::CALL_IC:
190 break;
191 case Code::FUNCTION:
192 UNIMPLEMENTED_MIPS();
193 break;
194 case Code::KEYED_LOAD_IC:
195 UNIMPLEMENTED_MIPS();
196 break;
197 case Code::LOAD_IC:
198 UNIMPLEMENTED_MIPS();
199 break;
200 case Code::KEYED_STORE_IC:
201 UNIMPLEMENTED_MIPS();
202 break;
203 case Code::STORE_IC:
204 UNIMPLEMENTED_MIPS();
205 break;
206 case Code::BUILTIN:
207 UNIMPLEMENTED_MIPS();
208 break;
209 default:
210 UNREACHABLE();
211 break;
212 }
213 Forget(dropped_args);
214 ASSERT(cgen()->HasValidEntryRegisters());
215 __ Call(code, rmode);
Andrei Popescu31002712010-02-23 13:46:05 +0000216}
217
218
219void VirtualFrame::CallCodeObject(Handle<Code> code,
220 RelocInfo::Mode rmode,
221 Result* arg,
222 int dropped_args) {
223 UNIMPLEMENTED_MIPS();
224}
225
226
227void 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
236
237void VirtualFrame::Drop(int count) {
Steve Block6ded16b2010-05-10 14:33:55 +0100238 ASSERT(count >= 0);
239 ASSERT(height() >= count);
240 int num_virtual_elements = (element_count() - 1) - stack_pointer_;
241
242 // Emit code to lower the stack pointer if necessary.
243 if (num_virtual_elements < count) {
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 }
Andrei Popescu31002712010-02-23 13:46:05 +0000256}
257
258
259void VirtualFrame::DropFromVFrameOnly(int count) {
260 UNIMPLEMENTED_MIPS();
261}
262
263
264Result VirtualFrame::Pop() {
265 UNIMPLEMENTED_MIPS();
266 Result res = Result();
Steve Block6ded16b2010-05-10 14:33:55 +0100267 return res; // UNIMPLEMENTED RETURN
Andrei Popescu31002712010-02-23 13:46:05 +0000268}
269
270
271void VirtualFrame::EmitPop(Register reg) {
Steve Block6ded16b2010-05-10 14:33:55 +0100272 ASSERT(stack_pointer_ == element_count() - 1);
273 stack_pointer_--;
274 elements_.RemoveLast();
275 __ Pop(reg);
Andrei Popescu31002712010-02-23 13:46:05 +0000276}
277
Steve Block6ded16b2010-05-10 14:33:55 +0100278
Andrei Popescu31002712010-02-23 13:46:05 +0000279void VirtualFrame::EmitMultiPop(RegList regs) {
Steve Block6ded16b2010-05-10 14:33:55 +0100280 ASSERT(stack_pointer_ == element_count() - 1);
281 for (int16_t i = 0; i < kNumRegisters; i++) {
282 if ((regs & (1 << i)) != 0) {
283 stack_pointer_--;
284 elements_.RemoveLast();
285 }
286 }
287 __ MultiPop(regs);
Andrei Popescu31002712010-02-23 13:46:05 +0000288}
289
290
291void VirtualFrame::EmitPush(Register reg) {
Steve Block6ded16b2010-05-10 14:33:55 +0100292 ASSERT(stack_pointer_ == element_count() - 1);
293 elements_.Add(FrameElement::MemoryElement(NumberInfo::Unknown()));
294 stack_pointer_++;
295 __ Push(reg);
Andrei Popescu31002712010-02-23 13:46:05 +0000296}
297
Steve Block6ded16b2010-05-10 14:33:55 +0100298
Andrei Popescu31002712010-02-23 13:46:05 +0000299void VirtualFrame::EmitMultiPush(RegList regs) {
Steve Block6ded16b2010-05-10 14:33:55 +0100300 ASSERT(stack_pointer_ == element_count() - 1);
301 for (int16_t i = kNumRegisters; i > 0; i--) {
302 if ((regs & (1 << i)) != 0) {
303 elements_.Add(FrameElement::MemoryElement(NumberInfo::Unknown()));
304 stack_pointer_++;
305 }
306 }
307 __ MultiPush(regs);
Andrei Popescu31002712010-02-23 13:46:05 +0000308}
309
Steve Block6ded16b2010-05-10 14:33:55 +0100310
Andrei Popescu31002712010-02-23 13:46:05 +0000311void VirtualFrame::EmitArgumentSlots(RegList reglist) {
312 UNIMPLEMENTED_MIPS();
313}
314
315#undef __
316
317} } // namespace v8::internal
318
Leon Clarkef7060e22010-06-03 12:02:55 +0100319#endif // V8_TARGET_ARCH_MIPS