blob: 26fea2515369337415dda74cf25c79cc8ddc9e22 [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 "debug.h"
36#include "runtime.h"
37
38namespace v8 {
39namespace internal {
40
41
42#define __ ACCESS_MASM(masm)
43
44
45void Builtins::Generate_Adaptor(MacroAssembler* masm,
46 CFunctionId id,
47 BuiltinExtraArguments extra_args) {
48 UNIMPLEMENTED_MIPS();
49}
50
51
52void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
53 UNIMPLEMENTED_MIPS();
54}
55
56
57void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) {
58 UNIMPLEMENTED_MIPS();
59}
60
61
62void Builtins::Generate_JSConstructCall(MacroAssembler* masm) {
63 UNIMPLEMENTED_MIPS();
64}
65
66
67void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
68 UNIMPLEMENTED_MIPS();
69}
70
71
72void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) {
73 UNIMPLEMENTED_MIPS();
74}
75
76
77static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
78 bool is_construct) {
Steve Block6ded16b2010-05-10 14:33:55 +010079 // Called from JSEntryStub::GenerateBody
80
81 // Registers:
82 // a0: entry_address
83 // a1: function
84 // a2: reveiver_pointer
85 // a3: argc
86 // s0: argv
87 //
88 // Stack:
89 // arguments slots
90 // handler frame
91 // entry frame
92 // callee saved registers + ra
93 // 4 args slots
94 // args
95
96 // Clear the context before we push it when entering the JS frame.
97 __ li(cp, Operand(0));
98
99 // Enter an internal frame.
100 __ EnterInternalFrame();
101
102 // Set up the context from the function argument.
103 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset));
104
105 // Set up the roots register.
106 ExternalReference roots_address = ExternalReference::roots_address();
107 __ li(s6, Operand(roots_address));
108
109 // Push the function and the receiver onto the stack.
110 __ MultiPushReversed(a1.bit() | a2.bit());
111
112 // Copy arguments to the stack in a loop.
113 // a3: argc
114 // s0: argv, ie points to first arg
115 Label loop, entry;
116 __ sll(t0, a3, kPointerSizeLog2);
117 __ add(t2, s0, t0);
118 __ b(&entry);
119 __ nop(); // Branch delay slot nop.
120 // t2 points past last arg.
121 __ bind(&loop);
122 __ lw(t0, MemOperand(s0)); // Read next parameter.
123 __ addiu(s0, s0, kPointerSize);
124 __ lw(t0, MemOperand(t0)); // Dereference handle.
125 __ Push(t0); // Push parameter.
126 __ bind(&entry);
127 __ Branch(ne, &loop, s0, Operand(t2));
128
129 // Registers:
130 // a0: entry_address
131 // a1: function
132 // a2: reveiver_pointer
133 // a3: argc
134 // s0: argv
135 // s6: roots_address
136 //
137 // Stack:
138 // arguments
139 // receiver
140 // function
141 // arguments slots
142 // handler frame
143 // entry frame
144 // callee saved registers + ra
145 // 4 args slots
146 // args
147
148 // Initialize all JavaScript callee-saved registers, since they will be seen
149 // by the garbage collector as part of handlers.
150 __ LoadRoot(t4, Heap::kUndefinedValueRootIndex);
151 __ mov(s1, t4);
152 __ mov(s2, t4);
153 __ mov(s3, t4);
154 __ mov(s4, s4);
155 __ mov(s5, t4);
156 // s6 holds the root address. Do not clobber.
157 // s7 is cp. Do not init.
158
159 // Invoke the code and pass argc as a0.
160 __ mov(a0, a3);
161 if (is_construct) {
162 UNIMPLEMENTED_MIPS();
163 __ break_(0x164);
164 } else {
165 ParameterCount actual(a0);
166 __ InvokeFunction(a1, actual, CALL_FUNCTION);
167 }
168
169 __ LeaveInternalFrame();
170
171 __ Jump(ra);
Andrei Popescu31002712010-02-23 13:46:05 +0000172}
173
174
175void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) {
176 Generate_JSEntryTrampolineHelper(masm, false);
177}
178
179
180void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
181 Generate_JSEntryTrampolineHelper(masm, true);
182}
183
184
185void Builtins::Generate_FunctionCall(MacroAssembler* masm) {
186 UNIMPLEMENTED_MIPS();
187}
188
189
190void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
191 UNIMPLEMENTED_MIPS();
192}
193
194
195void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
196 UNIMPLEMENTED_MIPS();
Steve Block6ded16b2010-05-10 14:33:55 +0100197 __ break_(0x201);
Andrei Popescu31002712010-02-23 13:46:05 +0000198}
199
200
201#undef __
202
203} } // namespace v8::internal
204
Leon Clarkef7060e22010-06-03 12:02:55 +0100205#endif // V8_TARGET_ARCH_MIPS