blob: c2116de77a79ca24c9c62273b0284e373e283a88 [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
32#include "codegen-inl.h"
33#include "register-allocator-inl.h"
34#include "scopes.h"
Steve Block6ded16b2010-05-10 14:33:55 +010035#include "virtual-frame-inl.h"
Andrei Popescu31002712010-02-23 13:46:05 +000036
37namespace v8 {
38namespace internal {
39
40// -------------------------------------------------------------------------
41// VirtualFrame implementation.
42
43#define __ ACCESS_MASM(masm())
44
Andrei Popescu31002712010-02-23 13:46:05 +000045void VirtualFrame::SyncElementBelowStackPointer(int index) {
46 UNREACHABLE();
47}
48
49
50void VirtualFrame::SyncElementByPushing(int index) {
51 UNREACHABLE();
52}
53
54
55void VirtualFrame::SyncRange(int begin, int end) {
Steve Block6ded16b2010-05-10 14:33:55 +010056 // All elements are in memory on MIPS (ie, synced).
57#ifdef DEBUG
58 for (int i = begin; i <= end; i++) {
59 ASSERT(elements_[i].is_synced());
60 }
61#endif
Andrei Popescu31002712010-02-23 13:46:05 +000062}
63
64
65void VirtualFrame::MergeTo(VirtualFrame* expected) {
66 UNIMPLEMENTED_MIPS();
67}
68
69
70void VirtualFrame::Enter() {
Steve Block6ded16b2010-05-10 14:33:55 +010071 // TODO(MIPS): Implement DEBUG
72
73 // We are about to push four values to the frame.
74 Adjust(4);
75 __ MultiPush(ra.bit() | fp.bit() | cp.bit() | a1.bit());
76 // Adjust FP to point to saved FP.
77 __ addiu(fp, sp, 2 * kPointerSize);
Andrei Popescu31002712010-02-23 13:46:05 +000078}
79
80
81void VirtualFrame::Exit() {
82 UNIMPLEMENTED_MIPS();
83}
84
85
86void VirtualFrame::AllocateStackSlots() {
Steve Block6ded16b2010-05-10 14:33:55 +010087 int count = local_count();
88 if (count > 0) {
89 Comment cmnt(masm(), "[ Allocate space for locals");
90 Adjust(count);
91 // Initialize stack slots with 'undefined' value.
92 __ LoadRoot(t0, Heap::kUndefinedValueRootIndex);
93 __ addiu(sp, sp, -count * kPointerSize);
94 for (int i = 0; i < count; i++) {
95 __ sw(t0, MemOperand(sp, (count-i-1)*kPointerSize));
96 }
97 }
Andrei Popescu31002712010-02-23 13:46:05 +000098}
99
100
101void VirtualFrame::SaveContextRegister() {
102 UNIMPLEMENTED_MIPS();
103}
104
105
106void VirtualFrame::RestoreContextRegister() {
107 UNIMPLEMENTED_MIPS();
108}
109
110
111void VirtualFrame::PushReceiverSlotAddress() {
112 UNIMPLEMENTED_MIPS();
113}
114
115
116int VirtualFrame::InvalidateFrameSlotAt(int index) {
117 return kIllegalIndex;
118}
119
120
121void VirtualFrame::TakeFrameSlotAt(int index) {
122 UNIMPLEMENTED_MIPS();
123}
124
125
126void VirtualFrame::StoreToFrameSlotAt(int index) {
127 UNIMPLEMENTED_MIPS();
128}
129
130
131void VirtualFrame::PushTryHandler(HandlerType type) {
132 UNIMPLEMENTED_MIPS();
133}
134
135
136void VirtualFrame::RawCallStub(CodeStub* stub) {
137 UNIMPLEMENTED_MIPS();
138}
139
140
141void VirtualFrame::CallStub(CodeStub* stub, Result* arg) {
142 UNIMPLEMENTED_MIPS();
143}
144
145
146void VirtualFrame::CallStub(CodeStub* stub, Result* arg0, Result* arg1) {
147 UNIMPLEMENTED_MIPS();
148}
149
150
151void VirtualFrame::CallRuntime(Runtime::Function* f, int arg_count) {
Steve Block6ded16b2010-05-10 14:33:55 +0100152 PrepareForCall(arg_count, arg_count);
153 ASSERT(cgen()->HasValidEntryRegisters());
154 __ CallRuntime(f, arg_count);
Andrei Popescu31002712010-02-23 13:46:05 +0000155}
156
157
158void VirtualFrame::CallRuntime(Runtime::FunctionId id, int arg_count) {
Steve Block6ded16b2010-05-10 14:33:55 +0100159 PrepareForCall(arg_count, arg_count);
160 ASSERT(cgen()->HasValidEntryRegisters());
161 __ CallRuntime(id, arg_count);
Andrei Popescu31002712010-02-23 13:46:05 +0000162}
163
164
165void VirtualFrame::CallAlignedRuntime(Runtime::Function* f, int arg_count) {
166 UNIMPLEMENTED_MIPS();
167}
168
169
170void VirtualFrame::CallAlignedRuntime(Runtime::FunctionId id, int arg_count) {
171 UNIMPLEMENTED_MIPS();
172}
173
174
175void VirtualFrame::InvokeBuiltin(Builtins::JavaScript id,
176 InvokeJSFlags flags,
177 Result* arg_count_register,
178 int arg_count) {
179 UNIMPLEMENTED_MIPS();
180}
181
182
Andrei Popescu31002712010-02-23 13:46:05 +0000183void VirtualFrame::CallCodeObject(Handle<Code> code,
184 RelocInfo::Mode rmode,
185 int dropped_args) {
Steve Block6ded16b2010-05-10 14:33:55 +0100186 switch (code->kind()) {
187 case Code::CALL_IC:
188 break;
189 case Code::FUNCTION:
190 UNIMPLEMENTED_MIPS();
191 break;
192 case Code::KEYED_LOAD_IC:
193 UNIMPLEMENTED_MIPS();
194 break;
195 case Code::LOAD_IC:
196 UNIMPLEMENTED_MIPS();
197 break;
198 case Code::KEYED_STORE_IC:
199 UNIMPLEMENTED_MIPS();
200 break;
201 case Code::STORE_IC:
202 UNIMPLEMENTED_MIPS();
203 break;
204 case Code::BUILTIN:
205 UNIMPLEMENTED_MIPS();
206 break;
207 default:
208 UNREACHABLE();
209 break;
210 }
211 Forget(dropped_args);
212 ASSERT(cgen()->HasValidEntryRegisters());
213 __ Call(code, rmode);
Andrei Popescu31002712010-02-23 13:46:05 +0000214}
215
216
217void VirtualFrame::CallCodeObject(Handle<Code> code,
218 RelocInfo::Mode rmode,
219 Result* arg,
220 int dropped_args) {
221 UNIMPLEMENTED_MIPS();
222}
223
224
225void VirtualFrame::CallCodeObject(Handle<Code> code,
226 RelocInfo::Mode rmode,
227 Result* arg0,
228 Result* arg1,
229 int dropped_args,
230 bool set_auto_args_slots) {
231 UNIMPLEMENTED_MIPS();
232}
233
234
235void VirtualFrame::Drop(int count) {
Steve Block6ded16b2010-05-10 14:33:55 +0100236 ASSERT(count >= 0);
237 ASSERT(height() >= count);
238 int num_virtual_elements = (element_count() - 1) - stack_pointer_;
239
240 // Emit code to lower the stack pointer if necessary.
241 if (num_virtual_elements < count) {
242 int num_dropped = count - num_virtual_elements;
243 stack_pointer_ -= num_dropped;
244 __ addiu(sp, sp, num_dropped * kPointerSize);
245 }
246
247 // Discard elements from the virtual frame and free any registers.
248 for (int i = 0; i < count; i++) {
249 FrameElement dropped = elements_.RemoveLast();
250 if (dropped.is_register()) {
251 Unuse(dropped.reg());
252 }
253 }
Andrei Popescu31002712010-02-23 13:46:05 +0000254}
255
256
257void VirtualFrame::DropFromVFrameOnly(int count) {
258 UNIMPLEMENTED_MIPS();
259}
260
261
262Result VirtualFrame::Pop() {
263 UNIMPLEMENTED_MIPS();
264 Result res = Result();
Steve Block6ded16b2010-05-10 14:33:55 +0100265 return res; // UNIMPLEMENTED RETURN
Andrei Popescu31002712010-02-23 13:46:05 +0000266}
267
268
269void VirtualFrame::EmitPop(Register reg) {
Steve Block6ded16b2010-05-10 14:33:55 +0100270 ASSERT(stack_pointer_ == element_count() - 1);
271 stack_pointer_--;
272 elements_.RemoveLast();
273 __ Pop(reg);
Andrei Popescu31002712010-02-23 13:46:05 +0000274}
275
Steve Block6ded16b2010-05-10 14:33:55 +0100276
Andrei Popescu31002712010-02-23 13:46:05 +0000277void VirtualFrame::EmitMultiPop(RegList regs) {
Steve Block6ded16b2010-05-10 14:33:55 +0100278 ASSERT(stack_pointer_ == element_count() - 1);
279 for (int16_t i = 0; i < kNumRegisters; i++) {
280 if ((regs & (1 << i)) != 0) {
281 stack_pointer_--;
282 elements_.RemoveLast();
283 }
284 }
285 __ MultiPop(regs);
Andrei Popescu31002712010-02-23 13:46:05 +0000286}
287
288
289void VirtualFrame::EmitPush(Register reg) {
Steve Block6ded16b2010-05-10 14:33:55 +0100290 ASSERT(stack_pointer_ == element_count() - 1);
291 elements_.Add(FrameElement::MemoryElement(NumberInfo::Unknown()));
292 stack_pointer_++;
293 __ Push(reg);
Andrei Popescu31002712010-02-23 13:46:05 +0000294}
295
Steve Block6ded16b2010-05-10 14:33:55 +0100296
Andrei Popescu31002712010-02-23 13:46:05 +0000297void VirtualFrame::EmitMultiPush(RegList regs) {
Steve Block6ded16b2010-05-10 14:33:55 +0100298 ASSERT(stack_pointer_ == element_count() - 1);
299 for (int16_t i = kNumRegisters; i > 0; i--) {
300 if ((regs & (1 << i)) != 0) {
301 elements_.Add(FrameElement::MemoryElement(NumberInfo::Unknown()));
302 stack_pointer_++;
303 }
304 }
305 __ MultiPush(regs);
Andrei Popescu31002712010-02-23 13:46:05 +0000306}
307
Steve Block6ded16b2010-05-10 14:33:55 +0100308
Andrei Popescu31002712010-02-23 13:46:05 +0000309void VirtualFrame::EmitArgumentSlots(RegList reglist) {
310 UNIMPLEMENTED_MIPS();
311}
312
313#undef __
314
315} } // namespace v8::internal
316